fix(help): show the settings help on the admin Security and Services tabs

Both tabs fell back to the admin overview without guides, and the guides for API keys, providers and file types opened the Security tab instead of Services.
This commit is contained in:
Maurice
2026-11-23 15:01:44 +01:00
parent e459ec6e60
commit dec3058777
7 changed files with 44 additions and 10 deletions
@@ -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(<HelpGuideView guide={getHelpGuide('instance-keys')!} />)
expect(screen.getByRole('link', { name: /^Go to/ })).toHaveAttribute('href', '/admin?tab=services')
unmount()
render(<HelpGuideView guide={getHelpGuide('auth-methods')!} />)
expect(screen.getByRole('link', { name: /^Go to/ })).toHaveAttribute('href', '/admin?tab=settings')
})
})
+1 -1
View File
@@ -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 (
<div className="trek-help-view flex flex-col gap-6">
+13 -5
View File
@@ -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<Record<string, string>> = { 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']),
+2
View File
@@ -162,6 +162,8 @@ export interface HelpGuide {
docs?: HelpDocLink
/** An in-app route the guide can take the reader to; label is `help.guide.<id>.link`. */
link?: string
/** Where "go there" opens when the guide's part of its screen sits elsewhere, under another tab. */
route?: string
related?: string[]
}
+2 -3
View File
@@ -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 (
<PageShell background="var(--bg-primary)">
<HelpAnchor id={helpId} />
+10 -1
View File
@@ -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');
});
});
+8
View File
@@ -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'
}