Replace admin Back button with UserMenu
Remove the Back button and its sessionStorage return-URL stash logic. Add UserMenu to the right side of the admin topbar, providing consistent navigation to all surfaces and eliminating the infinite-loop problem (Back → / → admin → Back → ...). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ const { render } = preact;
|
|||||||
|
|
||||||
import { ToastContainer } from '../../primitives/toast.js';
|
import { ToastContainer } from '../../primitives/toast.js';
|
||||||
import { DialogStack } from '../../shell/dialog-stack.js';
|
import { DialogStack } from '../../shell/dialog-stack.js';
|
||||||
|
import { UserMenu } from '../../shell/user-menu.js';
|
||||||
|
|
||||||
// ── Category → Section mapping ──────────────
|
// ── Category → Section mapping ──────────────
|
||||||
const ADMIN_SECTIONS = {
|
const ADMIN_SECTIONS = {
|
||||||
@@ -121,26 +122,6 @@ function AdminSurface() {
|
|||||||
}
|
}
|
||||||
}, [section]);
|
}, [section]);
|
||||||
|
|
||||||
// Back button with return URL stash
|
|
||||||
useEffect(() => {
|
|
||||||
const RETURN_KEY = 'sb_admin_return';
|
|
||||||
if (!sessionStorage.getItem(RETURN_KEY)) {
|
|
||||||
const ref = document.referrer;
|
|
||||||
if (ref && ref.startsWith(location.origin) && !ref.includes('/admin')) {
|
|
||||||
sessionStorage.setItem(RETURN_KEY, ref);
|
|
||||||
} else {
|
|
||||||
sessionStorage.setItem(RETURN_KEY, location.origin + BASE + '/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const backClick = useCallback((e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const RETURN_KEY = 'sb_admin_return';
|
|
||||||
const returnURL = sessionStorage.getItem(RETURN_KEY);
|
|
||||||
sessionStorage.removeItem(RETURN_KEY);
|
|
||||||
location.href = returnURL || BASE + '/';
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const navClick = useCallback((e) => {
|
const navClick = useCallback((e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -155,15 +136,6 @@ function AdminSurface() {
|
|||||||
<div class="surface-admin">
|
<div class="surface-admin">
|
||||||
${/* Top Bar */``}
|
${/* Top Bar */``}
|
||||||
<div class="admin-topbar">
|
<div class="admin-topbar">
|
||||||
<a href="${BASE}/" class="admin-topbar-back" onClick=${backClick}>
|
|
||||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
||||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
||||||
<line x1="19" y1="12" x2="5" y2="12"/>
|
|
||||||
<polyline points="12 19 5 12 12 5"/>
|
|
||||||
</svg>
|
|
||||||
Back
|
|
||||||
</a>
|
|
||||||
<div class="admin-topbar-sep"></div>
|
|
||||||
<span class="admin-topbar-title">
|
<span class="admin-topbar-title">
|
||||||
<img src="${BASE}/favicon.svg" alt="" width="18" height="18" style="vertical-align:-3px;" />
|
<img src="${BASE}/favicon.svg" alt="" width="18" height="18" style="vertical-align:-3px;" />
|
||||||
Administration
|
Administration
|
||||||
@@ -179,6 +151,10 @@ function AdminSurface() {
|
|||||||
</a>
|
</a>
|
||||||
`)}
|
`)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-left:auto;">
|
||||||
|
<${UserMenu} placement="down-right" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="admin-body">
|
<div class="admin-body">
|
||||||
|
|||||||
Reference in New Issue
Block a user