feat(client): let a managed surface attach as an admin tab

The nav-entry seam was the wrong shape for what actually attaches here. A
subscription surface is about the install, not about a trip: /admin is already
behind an admin check, already grouped, and already where somebody looks to
change how their instance works. A top-level nav entry put it beside My Trips
for a screen opened once a month by one person.

Two lines in AdminPage rather than an overlay replacing the file: the tab list
gets the extra entries appended per group, and the body renders whichever one is
active. Appended rather than inserted because PageSidebar needs a group's tabs
contiguous.

The route and nav-entry seams stay. They are the right answer for a surface that
genuinely is a page, and both remain empty here.
This commit is contained in:
Maurice
2026-08-15 17:23:35 +02:00
committed by Maurice
parent 887e6c5026
commit f2329c9a63
3 changed files with 51 additions and 2 deletions
+8 -1
View File
@@ -8,12 +8,19 @@
*/
import { describe, it, expect } from 'vitest'
import { Briefcase } from 'lucide-react'
import { managedNavItems, managedRoutes, visibleManagedNavItems, type ManagedNavItem } from './index'
import {
managedAdminTabs,
managedNavItems,
managedRoutes,
visibleManagedNavItems,
type ManagedNavItem,
} from './index'
describe('managed attachment point', () => {
it('FE-MANAGED-001: ships empty, so the public build registers nothing', () => {
expect(managedRoutes).toEqual([])
expect(managedNavItems).toEqual([])
expect(managedAdminTabs).toEqual([])
})
it('FE-MANAGED-002: an empty list stays empty for either kind of user', () => {
+27
View File
@@ -64,8 +64,35 @@ export function visibleManagedNavItems(isAdmin: boolean): ManagedNavItem[] {
return managedNavItems.filter((item) => !item.adminOnly || isAdmin)
}
export interface ManagedAdminTab {
/** Tab id, also the deep-link value of ?tab= on /admin. Keep it bare. */
id: string
label: string
/** lucide-react, like every other icon in the app. */
Icon: LucideIcon
/**
* Which group heading the tab sits under. The admin sidebar groups tabs and
* requires a group's tabs to be contiguous, so this is appended to the end of
* whichever group it names rather than inserted mid-list.
*/
group?: 'users' | 'config' | 'integration' | 'maintenance'
/** Rendered in the tab body. /admin already requires an admin to get here. */
element: ReactElement
}
/** Extra protected routes. Spread into the router next to the built-in ones. */
export const managedRoutes: ManagedRoute[] = []
/**
* Extra tabs in Admin → the left sidebar.
*
* This is where a surface belongs when it is about the install rather than about
* a trip: /admin is already behind an admin check, already grouped, and already
* the place somebody looks when they want to change how their instance works.
* A top-level nav entry would put it next to My Trips for a screen opened once
* a month by one person.
*/
export const managedAdminTabs: ManagedAdminTab[] = []
/** Extra entries for the desktop navbar and the mobile tab bar. */
export const managedNavItems: ManagedNavItem[] = []
+16 -1
View File
@@ -1,4 +1,4 @@
import React from 'react'
import React, { Fragment } from 'react'
import { adminApi } from '../api/client'
import DevNotificationsPanel from '../components/Admin/DevNotificationsPanel'
import DefaultUserSettingsTab from '../components/Admin/DefaultUserSettingsTab'
@@ -21,6 +21,7 @@ import AdminUsersTab from './admin/AdminUsersTab'
import AdminSettingsTab from './admin/AdminSettingsTab'
import AdminNotificationsTab from './admin/AdminNotificationsTab'
import AdminUserModals from './admin/AdminUserModals'
import { managedAdminTabs } from '../managed'
export default function AdminPage(): React.ReactElement {
// ViewportRoute in App.tsx picks the branch now, so the phone screen is a
@@ -46,6 +47,7 @@ function AdminPageDesktop(): React.ReactElement {
const gConfig = t('admin.group.config')
const gIntegration = t('admin.group.integration')
const gMaintenance = t('admin.group.maintenance')
const GROUP_LABELS = { users: gUsers, config: gConfig, integration: gIntegration, maintenance: gMaintenance }
const TABS: PageSidebarTab[] = [
{ id: 'users', label: t('admin.tabs.users'), icon: Users, group: gUsers },
{ id: 'defaults', label: t('admin.tabs.defaults'), icon: UserCog, group: gUsers },
@@ -62,6 +64,14 @@ function AdminPageDesktop(): React.ReactElement {
...(managed ? [] : [{ id: 'backup', label: t('admin.tabs.backup'), icon: Database, group: gMaintenance }]),
{ id: 'audit', label: t('admin.tabs.audit'), icon: ScrollText, group: gMaintenance },
...(devMode ? [{ id: 'dev-notifications', label: 'Dev: Notifications', icon: Bug, group: gMaintenance }] : []),
// Empty in this repository — see client/src/managed. Appended per group
// rather than inserted, because the sidebar needs a group's tabs contiguous.
...managedAdminTabs.map(tab => ({
id: tab.id,
label: tab.label,
icon: tab.Icon,
group: GROUP_LABELS[tab.group ?? 'config'],
})),
]
return (
@@ -175,6 +185,11 @@ function AdminPageDesktop(): React.ReactElement {
{activeTab === 'defaults' && <DefaultUserSettingsTab />}
{activeTab === 'dev-notifications' && <DevNotificationsPanel />}
{/* Empty in this repository — see client/src/managed. */}
{managedAdminTabs.map(tab => (
activeTab === tab.id ? <Fragment key={tab.id}>{tab.element}</Fragment> : null
))}
</PageSidebar>
</div>