diff --git a/src/lib/commandCenter/commands.ts b/src/lib/commandCenter/commands.ts index 470a61012..959542e46 100644 --- a/src/lib/commandCenter/commands.ts +++ b/src/lib/commandCenter/commands.ts @@ -5,6 +5,7 @@ import { onMount } from 'svelte'; import { derived, writable } from 'svelte/store'; import { nanoid } from 'nanoid/non-secure'; import { trackEvent } from '$lib/actions/analytics'; +import { omit } from '$lib/helpers/omit'; const groups = [ 'ungrouped', @@ -18,6 +19,9 @@ const groups = [ 'databases', 'functions', 'messaging', + 'messages', + 'providers', + 'topics', 'storage', 'domains', 'webhooks', @@ -45,6 +49,7 @@ type BaseCommand = { forceEnable?: boolean; group?: CommandGroup; icon?: string; + image?: string; rank?: number; nested?: boolean; keepOpen?: boolean; @@ -70,7 +75,23 @@ export const disabledMap = writable>(new Map()); // Derived stores export const commands = derived(commandMap, ($commandMap) => { - return Array.from($commandMap.values()).flat(); + const res: Command[] = []; + const keys = new Set(); + + const allCommands = Array.from($commandMap.values()).flat().toReversed(); + + for (const command of allCommands) { + if (isKeyedCommand(command) && !command.disabled) { + const keysString = command.keys.join('+'); + if (keys.has(keysString)) { + res.push(omit(command, 'keys')); + continue; + } + keys.add(keysString); + } + res.push(command); + } + return res; }); const commandsEnabled = derived(disabledMap, ($disabledMap) => { @@ -110,9 +131,9 @@ function hasDisputing(command: KeyedCommand, allCommands: Command[]) { } export const commandCenterKeyDownHandler = derived( - [commandMap, commandsEnabled, wizard], - ([$commandMap, enabled, $wizard]) => { - const commandsArr = Array.from($commandMap.values()).flat(); + [commands, commandsEnabled, wizard], + ([$commands, enabled, $wizard]) => { + const commandsArr = $commands; let recentKeyCodes: number[] = []; let validCommands: KeyedCommand[] = []; diff --git a/src/lib/commandCenter/panels/createMessage.svelte b/src/lib/commandCenter/panels/createMessage.svelte new file mode 100644 index 000000000..db1cd5437 --- /dev/null +++ b/src/lib/commandCenter/panels/createMessage.svelte @@ -0,0 +1,73 @@ + + + diff --git a/src/lib/commandCenter/panels/index.ts b/src/lib/commandCenter/panels/index.ts index c1d8a59f1..a3a139fb3 100644 --- a/src/lib/commandCenter/panels/index.ts +++ b/src/lib/commandCenter/panels/index.ts @@ -78,3 +78,9 @@ export const FilesPanel: SubPanel = { name: 'Files', component: Files }; + +import CreateMessage from './createMessage.svelte'; +export const CreateMessagePanel: SubPanel = { + name: 'Create Message', + component: CreateMessage +}; diff --git a/src/lib/commandCenter/panels/root.svelte b/src/lib/commandCenter/panels/root.svelte index 66850914f..3aca62151 100644 --- a/src/lib/commandCenter/panels/root.svelte +++ b/src/lib/commandCenter/panels/root.svelte @@ -2,6 +2,8 @@ This is the root command panel. It precedes all other command panels. --> diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index dccfe71a4..fad67ef9b 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -56,7 +56,7 @@ $: $registerCommands([ { - label: 'Go to projects', + label: 'Go to Projects', callback: () => { goto('/console'); }, @@ -77,15 +77,6 @@ icon: 'sparkles', disabled: !isAssistantEnabled }, - { - label: 'Go to account', - callback: () => { - goto('/console/account'); - }, - keys: ['i'], - group: 'navigation', - rank: -2 - }, { label: 'Create new organization', callback: () => { diff --git a/src/routes/console/project-[project]/+layout.svelte b/src/routes/console/project-[project]/+layout.svelte index d8f26f01b..a2cdf33f5 100644 --- a/src/routes/console/project-[project]/+layout.svelte +++ b/src/routes/console/project-[project]/+layout.svelte @@ -15,6 +15,7 @@ userSearcher } from '$lib/commandCenter/searchers'; import { MigrationBox } from '$lib/components'; + import { page } from '$app/stores'; onMount(() => { return sdk.forConsole.client.subscribe(['project', 'console'], (response) => { @@ -27,20 +28,20 @@ }); $: $registerCommands([ - { - label: 'Go to Databases', - callback: () => { - goto(`/console/project-${$project.$id}/databases`); - }, - keys: ['d'], - group: 'navigation' - }, { label: 'Go to Auth', callback: () => { goto(`/console/project-${$project.$id}/auth`); }, - keys: ['a'], + keys: ['g', 'a'], + group: 'navigation' + }, + { + label: 'Go to Databases', + callback: () => { + goto(`/console/project-${$project.$id}/databases`); + }, + keys: ['g', 'd'], group: 'navigation' }, { @@ -48,7 +49,16 @@ callback: () => { goto(`/console/project-${$project.$id}/functions`); }, - keys: ['f'], + keys: ['g', 'f'], + group: 'navigation' + }, + { + label: 'Go to Messaging', + callback: () => { + goto(`/console/project-${$project.$id}/messaging`); + }, + keys: ['g', 'm'], + disabled: $page.url.pathname.endsWith('messaging'), group: 'navigation' }, { @@ -56,23 +66,23 @@ callback: () => { goto(`/console/project-${$project.$id}/storage`); }, - keys: ['s'], + keys: ['g', 's'], group: 'navigation' }, { - label: 'Go to settings', + label: 'Go to Settings', callback: () => { goto(`/console/project-${$project.$id}/settings`); }, - keys: ['p'], + keys: ['g', 'e'], group: 'navigation' }, { - label: 'Go to overview', + label: 'Go to Overview', callback: () => { goto(`/console/project-${$project.$id}`); }, - keys: ['o'], + keys: ['g', 'o'], group: 'navigation' } ]); diff --git a/src/routes/console/project-[project]/auth/+layout.svelte b/src/routes/console/project-[project]/auth/+layout.svelte index cfb6a198b..ca114d653 100644 --- a/src/routes/console/project-[project]/auth/+layout.svelte +++ b/src/routes/console/project-[project]/auth/+layout.svelte @@ -1,7 +1,8 @@ - Permissions + Permissions

Choose who can access your collection and documents. For more about - Document security + Document security import { goto } from '$app/navigation'; import { page } from '$app/stores'; - import { registerCommands, updateCommandGroupRanks } from '$lib/commandCenter'; + import { + addSubPanel, + registerCommands, + registerSearchers, + updateCommandGroupRanks + } from '$lib/commandCenter'; + import { CreateMessagePanel } from '$lib/commandCenter/panels'; + import { messagesSearcher } from '$lib/commandCenter/searchers/messages'; + import { providersSearcher } from '$lib/commandCenter/searchers/providers'; + import { topicsSearcher } from '$lib/commandCenter/searchers/topics'; import { project } from '../store'; - import { showCreate } from './store'; - - // TODO: finalize the commands $: $registerCommands([ { label: 'Create message', - callback: () => { - if (!$page.url.pathname.endsWith('messaging')) { - goto(`/console/project-${$project.$id}/messaging`); - } - $showCreate = true; - }, keys: $page.url.pathname.endsWith('messaging') ? ['c'] : ['c', 'm'], + callback() { + addSubPanel(CreateMessagePanel); + }, icon: 'plus', group: 'messaging' }, { - label: 'Go to topics', + label: 'Go to Topics', + keys: ['g', 't'], callback() { goto(`/console/project-${$project.$id}/messaging/topics`); }, - keys: ['g', 't'], disabled: $page.url.pathname.endsWith('topics') || $page.url.pathname.includes('message-'), - group: 'navigation', - rank: 10 + group: 'messaging', + rank: 1 }, { - label: 'Go to providers', + label: 'Go to Providers', + keys: ['g', 'p'], callback() { goto(`/console/project-${$project.$id}/messaging/providers`); }, - keys: ['g', 'p'], disabled: - $page.url.pathname.endsWith('topics') || $page.url.pathname.includes('message-'), - group: 'navigation', - rank: 10 + $page.url.pathname.endsWith('providers') || $page.url.pathname.includes('message-'), + group: 'messaging', + rank: 2 } - // { - // label: 'Find messages', - // callback: () => { - // addSubPanel(BucketsPanel); - // }, - // group: 'messaging', - // rank: -1 - // } ]); - $: $updateCommandGroupRanks({ messaging: 200, navigation: 100 }); + $registerSearchers(messagesSearcher, providersSearcher, topicsSearcher); + + $: $updateCommandGroupRanks({ messaging: 400, providers: 300, topics: 200, navigation: 100 }); diff --git a/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+layout.svelte b/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+layout.svelte index 525eedb90..6ec507e4f 100644 --- a/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+layout.svelte +++ b/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+layout.svelte @@ -1,3 +1,47 @@ + + Topic - Appwrite