High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
refactor(web): admin page layout (#25281)
Jason Rasmussen843d563178ac
diff --git a/web/src/lib/components/AdminSidebar.svelte b/web/src/lib/components/AdminSidebar.sveltedeleted file mode 100644index fa660d7e2f..0000000000--- a/web/src/lib/components/AdminSidebar.svelte+++ /dev/null@@ -1,21 +0,0 @@-<script lang="ts">- import BottomInfo from '$lib/components/shared-components/side-bar/bottom-info.svelte';- import { AppRoute } from '$lib/constants';- import { NavbarItem } from '@immich/ui';- import { mdiAccountMultipleOutline, mdiBookshelf, mdiCog, mdiServer, mdiTrayFull } from '@mdi/js';- import { t } from 'svelte-i18n';-</script>--<div class="h-full flex flex-col justify-between gap-2">- <div class="flex flex-col pt-8 pe-4 gap-1">- <NavbarItem title={$t('users')} href={AppRoute.ADMIN_USERS} icon={mdiAccountMultipleOutline} />- <NavbarItem title={$t('external_libraries')} href={AppRoute.ADMIN_LIBRARIES} icon={mdiBookshelf} />- <NavbarItem title={$t('admin.queues')} href={AppRoute.ADMIN_QUEUES} icon={mdiTrayFull} />- <NavbarItem title={$t('settings')} href={AppRoute.ADMIN_SETTINGS} icon={mdiCog} />- <NavbarItem title={$t('server_stats')} href={AppRoute.ADMIN_STATS} icon={mdiServer} />- </div>-- <div class="mb-2 me-4">- <BottomInfo />- </div>-</div>diff --git a/web/src/lib/components/BreadcrumbActionPage.svelte b/web/src/lib/components/BreadcrumbActionPage.sveltenew file mode 100644index 0000000000..cdde67b725--- /dev/null+++ b/web/src/lib/components/BreadcrumbActionPage.svelte@@ -0,0 +1,61 @@+<script lang="ts">+ import type { HeaderButtonActionItem } from '$lib/types';+ import {+ Breadcrumbs,+ Button,+ Container,+ ContextMenuButton,+ HStack,+ MenuItemType,+ Scrollable,+ isMenuItemType,+ type BreadcrumbItem,+ } from '@immich/ui';+ import { mdiSlashForward } from '@mdi/js';+ import type { Snippet } from 'svelte';+ import { t } from 'svelte-i18n';++ type Props = {+ breadcrumbs?: BreadcrumbItem[];+ actions?: Array<HeaderButtonActionItem | MenuItemType>;+ children?: Snippet;+ };++ let { breadcrumbs = [], actions = [], children }: Props = $props();++ const enabledActions = $derived(+ actions+ .filter((action): action is HeaderButtonActionItem => !isMenuItemType(action))+ .filter((action) => action.$if?.() ?? true),+ );+</script>++<div class="h-full flex flex-col">+ <div class="flex h-16 w-full justify-between items-center border-b py-2 px-4 md:px-2">+ <Breadcrumbs items={breadcrumbs} separator={mdiSlashForward} />++ {#if enabledActions.length > 0}+ <div class="hidden md:block">+ <HStack gap={0}>+ {#each enabledActions as action, i (i)}+ <Button+ variant="ghost"+ size="small"+ color={action.color ?? 'secondary'}+ leadingIcon={action.icon}+ onclick={() => action.onAction(action)}+ title={action.data?.title}+ >+ {action.title}+ </Button>+ {/each}+ </HStack>+ </div>++ <ContextMenuButton aria-label={$t('open')} items={actions} class="md:hidden" />+ {/if}+ </div>+ <Scrollable class="grow">+ <Container class="p-2 pb-16" {children} />+ </Scrollable>+</div>diff --git a/web/src/lib/components/layouts/AdminPageLayout.svelte b/web/src/lib/components/layouts/AdminPageLayout.svelteindex 6ec982d132..712932a68d 100644--- a/web/src/lib/components/layouts/AdminPageLayout.svelte+++ b/web/src/lib/components/layouts/AdminPageLayout.svelte@@ -1,23 +1,12 @@<script lang="ts">- import AdminSidebar from '$lib/components/AdminSidebar.svelte';- import PageContent from '$lib/components/layouts/PageContent.svelte';+ import BreadcrumbActionPage from '$lib/components/BreadcrumbActionPage.svelte';import NavigationBar from '$lib/components/shared-components/navigation-bar/navigation-bar.svelte';+ import BottomInfo from '$lib/components/shared-components/side-bar/bottom-info.svelte';+ import { AppRoute } from '$lib/constants';import { sidebarStore } from '$lib/stores/sidebar.svelte';import type { HeaderButtonActionItem } from '$lib/types';- import {- AppShell,- AppShellHeader,- AppShellSidebar,- Breadcrumbs,- Button,- ContextMenuButton,- HStack,- MenuItemType,- Scrollable,- isMenuItemType,- type BreadcrumbItem,- } from '@immich/ui';- import { mdiSlashForward } from '@mdi/js';+ import { AppShell, AppShellHeader, AppShellSidebar, MenuItemType, NavbarItem, type BreadcrumbItem } from '@immich/ui';+ import { mdiAccountMultipleOutline, mdiBookshelf, mdiCog, mdiServer, mdiTrayFull } from '@mdi/js';import type { Snippet } from 'svelte';import { t } from 'svelte-i18n';@@ -27,52 +16,31 @@children?: Snippet;};- let { breadcrumbs, actions = [], children }: Props = $props();-- const enabledActions = $derived(- actions- .filter((action): action is HeaderButtonActionItem => !isMenuItemType(action))- .filter((action) => action.$if?.() ?? true),- );+ let { breadcrumbs, actions, children }: Props = $props();</script><AppShell><AppShellHeader>- <NavigationBar showUploadButton={false} noBorder />+ <NavigationBar noBorder /></AppShellHeader>- <AppShellSidebar bind:open={sidebarStore.isOpen} class="border-none shadow-none">- <AdminSidebar />- </AppShellSidebar>-- <div class="h-full flex flex-col">- <div class="flex h-16 w-full justify-between items-center border-b py-2 px-4 md:px-2">- <Breadcrumbs items={breadcrumbs} separator={mdiSlashForward} />-- {#if enabledActions.length > 0}- <div class="hidden md:block">- <HStack gap={0}>- {#each enabledActions as action, i (i)}- <Button- variant="ghost"- size="small"- color={action.color ?? 'secondary'}- leadingIcon={action.icon}- onclick={() => action.onAction(action)}- title={action.data?.title}- >- {action.title}- </Button>- {/each}- </HStack>- </div>+ <AppShellSidebar+ bind:open={sidebarStore.isOpen}+ class="border-none shadow-none h-full flex flex-col justify-between gap-2"+ >+ <div class="flex flex-col pt-8 pe-4 gap-1">+ <NavbarItem title={$t('users')} href={AppRoute.ADMIN_USERS} icon={mdiAccountMultipleOutline} />+ <NavbarItem title={$t('external_libraries')} href={AppRoute.ADMIN_LIBRARIES} icon={mdiBookshelf} />+ <NavbarItem title={$t('admin.queues')} href={AppRoute.ADMIN_QUEUES} icon={mdiTrayFull} />+ <NavbarItem title={$t('settings')} href={AppRoute.ADMIN_SETTINGS} icon={mdiCog} />+ <NavbarItem title={$t('server_stats')} href={AppRoute.ADMIN_STATS} icon={mdiServer} />+ </div>- <ContextMenuButton aria-label={$t('open')} items={actions} class="md:hidden" />- {/if}+ <div class="mb-2 me-4">+ <BottomInfo /></div>- <Scrollable class="grow">- <PageContent>- {@render children?.()}- </PageContent>- </Scrollable>- </div>+ </AppShellSidebar>++ <BreadcrumbActionPage {breadcrumbs} {actions}>+ {@render children?.()}+ </BreadcrumbActionPage></AppShell>diff --git a/web/src/lib/components/layouts/PageContent.svelte b/web/src/lib/components/layouts/PageContent.sveltedeleted file mode 100644index 150aaecf43..0000000000--- a/web/src/lib/components/layouts/PageContent.svelte+++ /dev/null@@ -1,12 +0,0 @@-<script lang="ts">- import { Container } from '@immich/ui';- import type { Snippet } from 'svelte';-- type Props = {- children?: Snippet;- };-- const { children }: Props = $props();-</script>--<Container class="p-2 pb-16" {children} />diff --git a/web/src/lib/components/layouts/user-page-layout.svelte b/web/src/lib/components/layouts/user-page-layout.svelteindex 500e66c8da..614b1377fb 100644--- a/web/src/lib/components/layouts/user-page-layout.svelte+++ b/web/src/lib/components/layouts/user-page-layout.svelte@@ -14,13 +14,11 @@interface Props {hideNavbar?: boolean;- showUploadButton?: boolean;title?: string | undefined;description?: string | undefined;scrollbar?: boolean;use?: ActionArray;actions?: Array<HeaderButtonActionItem | MenuItemType>;- header?: Snippet;sidebar?: Snippet;buttons?: Snippet;children?: Snippet;@@ -28,13 +26,11 @@let {hideNavbar = false,- showUploadButton = false,title = undefined,description = undefined,scrollbar = true,use = [],actions = [],- header,sidebar,buttons,children,@@ -52,10 +48,8 @@<header>{#if !hideNavbar}- <NavigationBar {showUploadButton} onUploadClick={() => openFileUploadDialog()} />+ <NavigationBar onUploadClick={() => openFileUploadDialog()} />{/if}-- {@render header?.()}</header><divtabindex="-1"diff --git a/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte b/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelteindex 0fd96630eb..6224d6222f 100644--- a/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte+++ b/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte@@ -25,14 +25,13 @@import UserAvatar from '../user-avatar.svelte';import AccountInfoPanel from './account-info-panel.svelte';- interface Props {- showUploadButton?: boolean;+ type Props = {onUploadClick?: () => void;// TODO: remove once this is only used in <AppShellHeader>noBorder?: boolean;- }+ };- let { showUploadButton = true, onUploadClick, noBorder = false }: Props = $props();+ let { onUploadClick, noBorder = false }: Props = $props();let shouldShowAccountInfoPanel = $state(false);let shouldShowNotificationPanel = $state(false);@@ -105,7 +104,7 @@/>{/if}- {#if !page.url.pathname.includes('/admin') && showUploadButton && onUploadClick}+ {#if !page.url.pathname.includes('/admin') && onUploadClick}<ButtonleadingIcon={mdiTrayArrowUp}onclick={onUploadClick}diff --git a/web/src/routes/(user)/photos/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/photos/[[assetId=id]]/+page.svelteindex 65adfcbe9e..de14774ff1 100644--- a/web/src/routes/(user)/photos/[[assetId=id]]/+page.svelte+++ b/web/src/routes/(user)/photos/[[assetId=id]]/+page.svelte@@ -102,7 +102,7 @@);</script>-<UserPageLayout hideNavbar={assetInteraction.selectionActive} showUploadButton scrollbar={false}>+<UserPageLayout hideNavbar={assetInteraction.selectionActive} scrollbar={false}><TimelineenableRouting={true}bind:timelineManager