- {#each filteredGroups as group, groupIndex}
-
-
{group.name}
-
- {#each group.actions as action, actionIndex}
- {@const globalIndex =
- filteredGroups
- .slice(0, groupIndex)
- .reduce((sum, g) => sum + g.actions.length, 0) + actionIndex}
- -
-
-
- {/each}
-
-
+
+
+ {#if breadcrumbs.length > 0}
+
+
+ {#each breadcrumbs as crumb, index}
+ /
+
+ {crumb.name}
+
{/each}
- {#if search != ''}
-
-
- {$t('nav.commands.search', { default: '' })}
-
-
- {/if}
+ {/if}
+
+ {#each filteredGroups as group, groupIndex}
+
+
{group.name}
+
+ {#each group.actions as action, actionIndex}
+ {@const globalIndex =
+ filteredGroups
+ .slice(0, groupIndex)
+ .reduce((sum, g) => sum + g.actions.length, 0) + actionIndex}
+ -
+ {
+ e.stopPropagation()
+ handleSelect(action)
+ }}
+ class="{globalIndex == selectedIndex
+ ? '!bg-slate-100 dark:!bg-zinc-800 text-inherit'
+ : 'text-slate-600 dark:text-zinc-400'} block"
+ />
+
+ {/each}
+
+
+ {/each}
+ {#if search != ''}
+
+
+ {$t('nav.commands.search', { default: '' })}
+
+
+ {/if}
-
+
diff --git a/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte b/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte
new file mode 100644
index 00000000..8b24d866
--- /dev/null
+++ b/src/lib/components/ui/navbar/commands/CommandsWrapper.svelte
@@ -0,0 +1,32 @@
+
+
+
+
+{#if open}
+
+ {#await import('./Commands.svelte')}
+
+
+ Downloading actions...
+
+ {:then { default: Commands }}
+
+ {/await}
+
+{/if}
diff --git a/src/lib/components/ui/navbar/commands/actions.ts b/src/lib/components/ui/navbar/commands/actions.ts
index 321c73fa..cf558ac1 100644
--- a/src/lib/components/ui/navbar/commands/actions.ts
+++ b/src/lib/components/ui/navbar/commands/actions.ts
@@ -1,5 +1,10 @@
import type { Profile } from '$lib/auth'
+import {
+ amModOfAny,
+ isAdmin,
+} from '$lib/components/lemmy/moderation/moderation'
import { resumables, type ResumableItem } from '$lib/lemmy/item'
+import { userSettings } from '$lib/settings'
import { t } from '$lib/translations'
import { fullCommunityName } from '$lib/util'
import {
@@ -12,10 +17,29 @@ import {
Inbox,
Newspaper,
PencilSquare,
+ ServerStack,
+ ShieldCheck,
UserCircle,
UserGroup,
+ ViewColumns,
+ type IconSource,
} from 'svelte-hero-icons'
+export interface Group {
+ name: string
+ actions: Action[]
+}
+
+export interface Action {
+ name: string
+ desc?: string
+ handle?: () => any
+ href?: string
+ shortcut?: string
+ icon: string | IconSource
+ subActions?: Action[]
+}
+
export function getGroups(resumables: ResumableItem[], profile: Profile) {
return [
{
@@ -35,6 +59,24 @@ export function getGroups(resumables: ResumableItem[], profile: Profile) {
name: t.get('nav.communities'),
icon: GlobeAlt,
},
+ ...(amModOfAny(profile.user)
+ ? [
+ {
+ href: '/moderation',
+ name: t.get('nav.moderation'),
+ icon: ShieldCheck,
+ },
+ ]
+ : []),
+ ...(profile.user && isAdmin(profile.user)
+ ? [
+ {
+ href: '/admin',
+ name: t.get('nav.admin'),
+ icon: ServerStack,
+ },
+ ]
+ : []),
],
},
{
@@ -89,6 +131,56 @@ export function getGroups(resumables: ResumableItem[], profile: Profile) {
name: t.get('nav.menu.settings'),
icon: Cog6Tooth,
},
+ {
+ name: t.get('nav.commands.setView'),
+ icon: ViewColumns,
+ subActions: [
+ {
+ name: t.get('nav.commands.setViewTo', {
+ default: t.get('filter.view.compact'),
+ }),
+ icon: ViewColumns,
+ handle: () =>
+ userSettings.update((s) => ({
+ ...s,
+ view: 'compact',
+ })),
+ },
+ {
+ name: t.get('nav.commands.setViewTo', {
+ default: t.get('filter.view.cozy'),
+ }),
+ icon: ViewColumns,
+ handle: () =>
+ userSettings.update((s) => ({
+ ...s,
+ view: 'cozy',
+ })),
+ },
+ {
+ name: t.get('nav.commands.setViewTo', {
+ default: t.get('filter.view.list'),
+ }),
+ icon: ViewColumns,
+ handle: () =>
+ userSettings.update((s) => ({
+ ...s,
+ view: 'list',
+ })),
+ },
+ {
+ name: t.get('nav.commands.setViewTo', {
+ default: t.get('filter.view.legacy'),
+ }),
+ icon: ViewColumns,
+ handle: () =>
+ userSettings.update((s) => ({
+ ...s,
+ view: 'card',
+ })),
+ },
+ ],
+ },
],
},
{
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 7cdf934b..aa8dacca 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -38,7 +38,9 @@
"recents": "Recents",
"content": "Content",
"search": "Search for {{default}}",
- "main": "Main"
+ "main": "Main",
+ "setView": "Set view",
+ "setViewTo": "Set view to {{default}}"
}
},
"account": {