diff --git a/client/src/components/Help/HelpGuideView.test.tsx b/client/src/components/Help/HelpGuideView.test.tsx index 4e05be63d..da274fd04 100644 --- a/client/src/components/Help/HelpGuideView.test.tsx +++ b/client/src/components/Help/HelpGuideView.test.tsx @@ -27,4 +27,12 @@ describe('HelpGuideView: links', () => { expect(screen.queryByRole('link', { name: /Open Appearance settings/ })).toBeNull() expect(screen.getByRole('link', { name: /Open in Help & Docs/ })).toHaveAttribute('href', '/help/My-Trips-Dashboard#per-trip-actions') }) + + it('takes an admin guide to the tab its settings sit under', () => { + const { unmount } = render() + expect(screen.getByRole('link', { name: /^Go to/ })).toHaveAttribute('href', '/admin?tab=services') + unmount() + render() + expect(screen.getByRole('link', { name: /^Go to/ })).toHaveAttribute('href', '/admin?tab=settings') + }) }) diff --git a/client/src/components/Help/HelpGuideView.tsx b/client/src/components/Help/HelpGuideView.tsx index e290a0a07..a4f542c2c 100644 --- a/client/src/components/Help/HelpGuideView.tsx +++ b/client/src/components/Help/HelpGuideView.tsx @@ -38,7 +38,7 @@ export default function HelpGuideView({ guide }: { guide: HelpGuide }): React.Re const related = (guide.related ?? []).map(getHelpGuide).filter((g): g is HelpGuide => g !== null) const Icon = helpIcon(guide.icon) const ScreenIcon = screen ? helpIcon(screen.icon) : Icon - const screenRoute = useScreenRoute(screen?.route) + const screenRoute = useScreenRoute(guide.route ?? screen?.route) return (
diff --git a/client/src/help/contexts/admin.ts b/client/src/help/contexts/admin.ts index abcc07dfb..f3d6cad26 100644 --- a/client/src/help/contexts/admin.ts +++ b/client/src/help/contexts/admin.ts @@ -23,8 +23,16 @@ const GITHUB = 'Admin-GitHub-Releases' const guide = ( id: string, context: string, icon: HelpGuide['icon'], size: HelpGuide['size'], steps: number, tips: number, - docs: HelpGuide['docs'], related: string[], result = false, -): HelpGuide => ({ id, context, icon, size, steps, tips, media: { steps: true, result }, docs, related }) + docs: HelpGuide['docs'], related: string[], result = false, route?: string, +): HelpGuide => ({ id, context, icon, size, steps, tips, media: { steps: true, result }, docs, related, route }) + +/** + * The settings screen is two tabs now, Security and Services, and both show its + * help. Its guides go to the Security tab, the ones about outside services to + * Services. + */ +export const ADMIN_TAB_HELP: Readonly> = { security: 'admin-settings', services: 'admin-settings' } +const SERVICES_TAB = '/admin?tab=services' export const adminGuides: HelpGuide[] = [ // Users @@ -46,9 +54,9 @@ export const adminGuides: HelpGuide[] = [ guide('auth-methods', 'admin-settings', 'lock', 'guide', 3, 2, { slug: SETTINGS, anchor: 'authentication-methods' }, ['oidc', 'admin-passkeys']), guide('admin-passkeys', 'admin-settings', 'fingerprint', 'quick', 2, 3, { slug: SETTINGS, anchor: 'passkey-login' }, ['auth-methods', 'passkeys']), guide('oidc', 'admin-settings', 'shield', 'guide', 2, 2, { slug: 'OIDC-SSO' }, ['auth-methods']), - guide('instance-keys', 'admin-settings', 'key', 'guide', 3, 4, { slug: SETTINGS, anchor: 'api-keys' }, ['places-transit', 'default-map']), - guide('places-transit', 'admin-settings', 'search', 'quick', 2, 2, { slug: SETTINGS, anchor: 'transit-provider' }, ['instance-keys']), - guide('file-types', 'admin-settings', 'fileInput', 'quick', 1, 1, { slug: SETTINGS, anchor: 'allowed-file-types' }, ['storage-backends']), + guide('instance-keys', 'admin-settings', 'key', 'guide', 3, 4, { slug: SETTINGS, anchor: 'api-keys' }, ['places-transit', 'default-map'], false, SERVICES_TAB), + guide('places-transit', 'admin-settings', 'search', 'quick', 2, 2, { slug: SETTINGS, anchor: 'transit-provider' }, ['instance-keys'], false, SERVICES_TAB), + guide('file-types', 'admin-settings', 'fileInput', 'quick', 1, 1, { slug: SETTINGS, anchor: 'allowed-file-types' }, ['storage-backends'], false, SERVICES_TAB), guide('rotate-jwt-secret', 'admin-settings', 'shield', 'quick', 2, 2, { slug: SETTINGS, anchor: 'danger-zone' }, ['edit-user', 'auth-methods']), // Addons guide('toggle-addon', 'admin-addons', 'sliders', 'quick', 2, 2, { slug: ADDONS }, ['install-plugin', 'document-providers']), diff --git a/client/src/help/types.ts b/client/src/help/types.ts index e96632493..ce35eb344 100644 --- a/client/src/help/types.ts +++ b/client/src/help/types.ts @@ -162,6 +162,8 @@ export interface HelpGuide { docs?: HelpDocLink /** An in-app route the guide can take the reader to; label is `help.guide..link`. */ link?: string + /** Where "go there" opens when the guide's part of its screen sits elsewhere, under another tab. */ + route?: string related?: string[] } diff --git a/client/src/pages/AdminPage.tsx b/client/src/pages/AdminPage.tsx index bcb7bd0fe..e3fc3861f 100644 --- a/client/src/pages/AdminPage.tsx +++ b/client/src/pages/AdminPage.tsx @@ -10,7 +10,6 @@ import GitHubPanel from '../components/Admin/GitHubPanel' import AddonManager from '../components/Admin/AddonManager' import PackingTemplateManager from '../components/Admin/PackingTemplateManager' import HelpAnchor from '../components/Help/HelpAnchor' -import { getHelpContext } from '../help/registry' import AuditLogPanel from '../components/Admin/AuditLogPanel' import AdminMcpTokensPanel from '../components/Admin/AdminMcpTokensPanel' import AdminPluginsPanel from '../components/Admin/AdminPluginsPanel' @@ -18,6 +17,7 @@ import AdminStoragePanel from '../components/Admin/storage/AdminStoragePanel' import { Users, Map, Briefcase, Shield, FileText, RotateCcw, Save, SlidersHorizontal, UserCog, Puzzle, Blocks, ShieldCheck, Compass, Bell, Database, ScrollText, KeyRound, GitBranch, Bug, HardDrive } from 'lucide-react' import PageSidebar, { type PageSidebarTab } from '../components/Layout/PageSidebar' import { useAdmin } from './admin/useAdmin' +import { adminHelpId } from './admin/adminModel' import AdminUpdateBanner from './admin/AdminUpdateBanner' import AdminStatCard from './admin/AdminStatCard' import AdminUsersTab from './admin/AdminUsersTab' @@ -88,8 +88,7 @@ function AdminPageDesktop(): React.ReactElement { })), ] - // Every tab is its own help screen; a tab without one falls back to the admin overview. - const helpId = getHelpContext(`admin-${activeTab}`) ? `admin-${activeTab}` : 'admin' + const helpId = adminHelpId(activeTab) return ( diff --git a/client/src/pages/admin/adminModel.test.ts b/client/src/pages/admin/adminModel.test.ts index 8295d0221..328882e82 100644 --- a/client/src/pages/admin/adminModel.test.ts +++ b/client/src/pages/admin/adminModel.test.ts @@ -1,7 +1,7 @@ // FE-ADMMODEL-001 to -005: the invite status both admin user views show; -010 to -012 the users list. import { describe, expect, it } from 'vitest'; -import { formatLastActive, inviteMeta, inviteStatus, mergeSavedUser, type AdminUser } from './adminModel'; +import { adminHelpId, formatLastActive, inviteMeta, inviteStatus, mergeSavedUser, type AdminUser } from './adminModel'; const NOW = new Date('2026-10-09T12:00:00Z'); @@ -106,3 +106,12 @@ describe('inviteMeta', () => { ); }); }); + +describe('adminHelpId', () => { + it('gives the Security and Services tabs the help of the settings they split, and an unknown tab the overview', () => { + expect(adminHelpId('security')).toBe('admin-settings'); + expect(adminHelpId('services')).toBe('admin-settings'); + expect(adminHelpId('users')).toBe('admin-users'); + expect(adminHelpId('no-such-tab')).toBe('admin'); + }); +}); diff --git a/client/src/pages/admin/adminModel.ts b/client/src/pages/admin/adminModel.ts index 25be9f052..043f30892 100644 --- a/client/src/pages/admin/adminModel.ts +++ b/client/src/pages/admin/adminModel.ts @@ -1,4 +1,6 @@ /** Shared types and pure helpers for the admin page + its data hook. No React, no side effects. */ +import { ADMIN_TAB_HELP } from '../../help/contexts/admin' +import { getHelpContext } from '../../help/registry' import { readDateFormat } from '../../hooks/useDateFormat' import { formatDisplayDate } from '../../utils/dateFormat' @@ -106,3 +108,9 @@ export function inviteStatus( const labelKey = isUsedUp ? 'admin.invite.usedUp' : isExpired ? 'admin.invite.expired' : 'admin.invite.active' return { isExpired, isUsedUp, isActive, labelKey } } + +/** The help screen for an admin tab; a tab without one falls back to the admin overview. */ +export function adminHelpId(tab: string): string { + const id = ADMIN_TAB_HELP[tab] ?? `admin-${tab}` + return getHelpContext(id) ? id : 'admin' +}