diff --git a/src/lib/helpers/commandCenter.ts b/src/lib/helpers/commandCenter.ts index 1289b6f57..f1da960f5 100644 --- a/src/lib/helpers/commandCenter.ts +++ b/src/lib/helpers/commandCenter.ts @@ -78,11 +78,11 @@ export const commandCenterKeyDownHandler = derived( [commandCenter, commandsEnabled], ([{ commandMap }, enabled]) => { const commandsArr = Array.from(commandMap.values()).flat(); - const recentKeyCodes = new Set(); + let recentKeyCodes: number[] = []; return (event: KeyboardEvent) => { - recentKeyCodes.add(event.keyCode); - debounce(() => recentKeyCodes.clear(), 1000)(); + recentKeyCodes.push(event.keyCode); + debounce(() => (recentKeyCodes = []), 1000)(); for (const command of commandsArr) { if (command.disabled || (!enabled && !command.forceEnable)) continue; @@ -94,9 +94,7 @@ export const commandCenterKeyDownHandler = derived( const isAltPressed = alt ? event.altKey : true; const commandKeyCodes = keys.map((key) => key.toUpperCase().charCodeAt(0)); - const allKeysPressed = commandKeyCodes.every((keyCode) => - recentKeyCodes.has(keyCode) - ); + const allKeysPressed = recentKeyCodes.join('').includes(commandKeyCodes.join('')); if (allKeysPressed && isMetaPressed && isShiftPressed && isAltPressed) { event.preventDefault(); diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index f2f21e417..f8511ad3f 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -34,8 +34,7 @@ callback: () => { goto('/console'); }, - keys: ['h'], - alt: true + keys: ['g', 'h'] } ]); diff --git a/src/routes/console/commandCenter.svelte b/src/routes/console/commandCenter.svelte index e1857455d..bbdf7c95f 100644 --- a/src/routes/console/commandCenter.svelte +++ b/src/routes/console/commandCenter.svelte @@ -65,7 +65,7 @@ {command.label} -
+
{#if command.ctrl} {isMac() ? '⌘' : 'ctrl'} {/if} @@ -75,10 +75,15 @@ {#if command.alt} {isMac() ? '⌥' : 'alt'} {/if} - {#each command.keys as key} + {#each command.keys as key, i} + {@const hasNext = command.keys.length - 1 !== i} + {key.toUpperCase()} + {#if hasNext} + then + {/if} {/each}
diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte index fecfaae90..ddf821e93 100644 --- a/src/routes/console/organization-[organization]/+page.svelte +++ b/src/routes/console/organization-[organization]/+page.svelte @@ -5,7 +5,7 @@ import { CardContainer, Empty, GridItem1, Heading, PaginationWithLimit } from '$lib/components'; import { Pill } from '$lib/elements'; import { Button } from '$lib/elements/forms'; - import { registerCommand } from '$lib/helpers/commandCenter'; + import { disableCommands, registerCommand } from '$lib/helpers/commandCenter'; import { Container } from '$lib/layout'; import CreateOrganization from '../createOrganization.svelte'; import type { PageData } from './$types'; @@ -63,6 +63,8 @@ disabled: showCreate } ]); + + $: $disableCommands(showCreate); diff --git a/src/routes/console/project-[project]/store.ts b/src/routes/console/project-[project]/store.ts index d932b663f..ed5e12960 100644 --- a/src/routes/console/project-[project]/store.ts +++ b/src/routes/console/project-[project]/store.ts @@ -7,51 +7,53 @@ import { derived, writable, type Readable } from 'svelte/store'; export const project = derived(page, ($page) => $page.data.project as Models.Project); -export const registerProjectCommand = derived([project, registerCommand], ([$project, $register]) => { - return (c: Command[] = []) => - $register([ - ...[ - { - label: 'Go to Overview', - keys: ['o'], - callback: () => { - goto(`/console/project-${$project.$id}`); - } - }, +export const registerProjectCommand = derived( + [project, registerCommand], + ([$project, $register]) => { + return (c: Command[] = []) => { + const projectCommands: Command[] = [ + { + label: 'Go to Overview', + keys: ['g', 'o'], - { - label: 'Go to Auth', - callback: () => { - goto(`/console/project-${$project.$id}/auth`); - }, - keys: ['a'] - }, - { - label: 'Go to Databases', - callback: () => { - goto(`/console/project-${$project.$id}/databases`); - }, - keys: ['d'] - }, - { - label: 'Go to Functions', - callback: () => { - goto(`/console/project-${$project.$id}/functions`); - }, - keys: ['f'] - }, - { - label: 'Go to Storage', - callback: () => { - goto(`/console/project-${$project.$id}/storage`); - }, - keys: ['s'] + callback: () => { + goto(`/console/project-${$project.$id}`); } - ], - ...(c ?? []) - ]) - -}) as Readable<(c?: Command[]) => void>; + }, + + { + label: 'Go to Auth', + callback: () => { + goto(`/console/project-${$project.$id}/auth`); + }, + keys: ['g', 'a'] + }, + { + label: 'Go to Databases', + callback: () => { + goto(`/console/project-${$project.$id}/databases`); + }, + keys: ['g', 'd'] + }, + { + label: 'Go to Functions', + callback: () => { + goto(`/console/project-${$project.$id}/functions`); + }, + keys: ['g', 'f'] + }, + { + label: 'Go to Storage', + callback: () => { + goto(`/console/project-${$project.$id}/storage`); + }, + keys: ['g', 's'] + } + ]; + return $register([...projectCommands, ...(c ?? [])]); + }; + } +) as Readable<(c?: Command[]) => void>; export const onboarding = derived( project,