feat(nav): give admins a mobile entry point to the admin area
The admin area was reachable only from the desktop header's is_admin link; on mobile there was no tab or row, so admins had to type the URL and no tab highlighted. Add a conditional Admin row to the mobile Account hub and `/admin` to the Account tab's match prefixes, so the tab stays highlighted while an admin is in the admin area. e2e: an admin session shows an Admin row linking to /admin; a non-admin never sees it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,9 @@
|
||||
label: 'Account',
|
||||
href: '/profile/account',
|
||||
icon: User,
|
||||
match: ['/profile', '/profile/preferences']
|
||||
// `/admin` keeps the Account tab highlighted while an admin is in
|
||||
// the admin area — its only mobile entry point is the Account hub.
|
||||
match: ['/profile', '/profile/preferences', '/admin']
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import SlidersHorizontal from '@lucide/svelte/icons/sliders-horizontal';
|
||||
import KeyRound from '@lucide/svelte/icons/key-round';
|
||||
import LogOut from '@lucide/svelte/icons/log-out';
|
||||
import Shield from '@lucide/svelte/icons/shield';
|
||||
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||
|
||||
let currentPassword = $state('');
|
||||
@@ -193,6 +194,18 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if session.user.is_admin}
|
||||
<!-- Admin is reachable from the desktop header; the mobile chrome
|
||||
has no Admin tab, so the Account hub is its entry point. -->
|
||||
<div class="row-group">
|
||||
<a class="row" href="/admin" data-testid="account-row-admin">
|
||||
<Shield size={18} aria-hidden="true" />
|
||||
<span class="row-label">Admin</span>
|
||||
<ChevronRight size={16} aria-hidden="true" class="row-chev" />
|
||||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="row-group">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user