mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
feat(settings): one look for every user and admin settings page
The settings pages had grown into a mix of styles: folds, dialogs behind rows, full-width rows next to boxed ones, pills for every figure and buttons in four sizes. Every page now uses the same kit. - Cards keep their tinted head band; every part of a card is a rounded block with its own small head (SettingsBlock), and rows sit in rounded boxes. - Nothing folds and nothing hides behind a dialog: the MCP config, OAuth scopes, mail how-to, AI privacy note and addon sub-options are all shown. - Each page is split into two columns balanced by length (SettingsColumns). - Long explanations moved into an info mark next to the label (HintMark). - One button size everywhere (text-control); tab names are one word. - Admin: the old Settings tab is split into Security and Services (?tab=settings still opens Security, and the phone keeps its single Settings section for both); the Integration group is gone, live flights and mail import sit next to the addons they configure. - Addons: one card per type with rows, no search, filter or fold. - Quota, TREK API facts, mail import status and Google's daily limit are compact lines and strips instead of tiles and pills. - Language is a select; routing has its own card under the defaults; storage saves from the foot of its categories card. - Unused keys, FoldSummary and the page-width wrapper are removed.
This commit is contained in:
@@ -11,10 +11,15 @@ const EYEBROW = 'text-center font-geist font-bold uppercase tracking-[.08em] tex
|
||||
|
||||
// Per-event × per-channel admin notification preference matrix.
|
||||
// Loads its own data and auto-saves each toggle.
|
||||
export default function AdminNotificationsPanel({ t, toast }: { t: (k: string) => string; toast: ReturnType<typeof useToast> }) {
|
||||
export default function AdminNotificationsPanel({ t, toast, bare = false }: {
|
||||
t: (k: string) => string
|
||||
toast: ReturnType<typeof useToast>
|
||||
/** Inside the admin notifications card, which carries the title: the matrix alone. */
|
||||
bare?: boolean
|
||||
}) {
|
||||
const { matrix, saving, visibleChannels, toggle } = useAdminNotificationMatrix(t, toast)
|
||||
|
||||
const card = (children: React.ReactNode) => (
|
||||
const card = (children: React.ReactNode) => bare ? <>{children}</> : (
|
||||
<SettingsCard icon={BellRing} title={t('admin.tabs.notifications')} hint={t('admin.notifications.adminNotificationsHint')}>
|
||||
{children}
|
||||
</SettingsCard>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useId } from 'react'
|
||||
import { Bell, BellRing, CalendarClock, Mail, Save, Send, Smartphone, Webhook } from 'lucide-react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
import { Bell, BellRing, Mail, Save, Send, Webhook } from 'lucide-react'
|
||||
import type { TranslationFn } from '../../types'
|
||||
import type { useAdmin } from './useAdmin'
|
||||
import AdminNotificationsPanel from './AdminNotificationsPanel'
|
||||
@@ -9,7 +8,7 @@ import { SWITCH_ONLY_CHANNELS, useNotificationChannels } from '../../components/
|
||||
import { MASK, useAdminNotificationSettings } from '../../components/Admin/useAdminNotificationSettings'
|
||||
import ToggleSwitch from '../../components/Settings/ToggleSwitch'
|
||||
import {
|
||||
SETTINGS_BUTTON, SETTINGS_BUTTON_DANGER, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, SettingsCard,
|
||||
SETTINGS_BUTTON, SETTINGS_BUTTON_DANGER, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, SettingsCard, SettingsColumns,
|
||||
} from '../../components/Settings/settingsKit'
|
||||
import { EditorField, GRID_2, INPUT } from '../../components/shared/dialogParts'
|
||||
import { fs } from '../../components/shared/DialogShell'
|
||||
@@ -19,9 +18,6 @@ interface AdminNotificationsTabProps {
|
||||
t: TranslationFn
|
||||
}
|
||||
|
||||
/** The glyph on each switch-only channel's card; anything else is the push channel. */
|
||||
const CHANNEL_ICONS: Record<string, LucideIcon> = { webhook: Webhook, ntfy: BellRing }
|
||||
|
||||
/** The save and test buttons under a card's fields, on a hairline of their own. */
|
||||
function CardActions({ children }: { children: React.ReactNode }): React.ReactElement {
|
||||
return <div className="flex flex-wrap items-center gap-2 border-t border-edge-faint pt-4" style={fs(13, 'body')}>{children}</div>
|
||||
@@ -78,115 +74,102 @@ export default function AdminNotificationsTab({ admin, t }: AdminNotificationsTa
|
||||
</EditorField>
|
||||
)
|
||||
|
||||
const tripRemindersCard = (
|
||||
<SettingsCard
|
||||
icon={CalendarClock}
|
||||
title={t('admin.notifications.tripReminders.title')}
|
||||
hint={t('admin.notifications.tripReminders.hint')}
|
||||
action={
|
||||
<ToggleSwitch
|
||||
on={tripRemindersActive}
|
||||
label={t('admin.notifications.tripReminders.title')}
|
||||
onToggle={toggleTripReminders}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
return (<>
|
||||
{/* Two columns from xl up, the same shape as the Settings tab. Most of these
|
||||
cards are a title with a switch on the far right, so on a wide screen the
|
||||
middle stayed empty while the page still scrolled past the three tall ones.
|
||||
Two explicit columns rather than a grid over the flat list: a plain grid
|
||||
pairs cards row by row and leaves a hole under the shorter one, and the SMTP
|
||||
card is taller than all the toggle rows together. Grouped by audience, not by
|
||||
height — the channels a user can receive on the left, everything the operator
|
||||
sends or receives themselves on the right. The channel switches stay
|
||||
together because they all write the same notification_channels list.
|
||||
On a managed install the two admin-target cards are gone and the right column
|
||||
is the matrix alone — still a column, so the grid keeps working. Each card
|
||||
brings its own bottom margin, so the columns only need the gap between them. */}
|
||||
<div className="grid grid-cols-1 gap-x-5 xl:grid-cols-2 xl:items-start">
|
||||
<div className="min-w-0">
|
||||
{/* The relay is the operator's: their host, their credential, their sending
|
||||
reputation. An instance that could point it elsewhere would send under a
|
||||
domain it does not own. */}
|
||||
{!managed && (
|
||||
<SettingsCard
|
||||
icon={Mail}
|
||||
title={t('admin.notifications.emailPanel.title')}
|
||||
hint={t('admin.smtp.hint')}
|
||||
action={<ToggleSwitch on={emailActive} label={t('admin.notifications.emailPanel.title')} onToggle={() => channels.toggle('email')} />}
|
||||
>
|
||||
{/* Greyed and out of reach while the channel is off, never hidden. */}
|
||||
<div data-testid="smtp-fields" className={`flex flex-col gap-4 transition-opacity ${!emailActive ? 'opacity-50 pointer-events-none' : ''}`}>
|
||||
{smtpLoaded && (<>
|
||||
<div className={GRID_2}>
|
||||
{smtpField(SMTP_FIELDS[0])}
|
||||
{smtpField(SMTP_FIELDS[1])}
|
||||
</div>
|
||||
<div className={GRID_2}>
|
||||
{smtpField(SMTP_FIELDS[2])}
|
||||
{smtpField(SMTP_FIELDS[3])}
|
||||
</div>
|
||||
{smtpField(SMTP_FIELDS[4])}
|
||||
</>)}
|
||||
<SettingRows>
|
||||
<SettingRow
|
||||
label={t('admin.smtp.skipTls')}
|
||||
hint={t('admin.smtp.skipTlsHint')}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={smtpValues.smtp_skip_tls_verify === 'true'}
|
||||
label={t('admin.smtp.skipTls')}
|
||||
onToggle={() => {
|
||||
const newVal = smtpValues.smtp_skip_tls_verify === 'true' ? 'false' : 'true'
|
||||
setSmtpValues(prev => ({ ...prev, smtp_skip_tls_verify: newVal }))
|
||||
}}
|
||||
/>
|
||||
}
|
||||
{/* Every channel users can receive on is one switch in one card, the SMTP
|
||||
relay's fields a section under them; the operator's own targets and the
|
||||
admin-only matrix on the right. */}
|
||||
<SettingsColumns
|
||||
left={
|
||||
<SettingsCard icon={Bell} title={t('admin.notifications.channels')}>
|
||||
<SettingRows>
|
||||
{/* The relay is the operator's on a managed install: their host, their
|
||||
credential, their sending reputation. */}
|
||||
{!managed && (
|
||||
<SettingRow
|
||||
label={t('admin.notifications.emailPanel.title')}
|
||||
hint={t('admin.smtp.hint')}
|
||||
control={<ToggleSwitch on={emailActive} label={t('admin.notifications.emailPanel.title')} onToggle={() => channels.toggle('email')} />}
|
||||
/>
|
||||
)}
|
||||
{SWITCH_ONLY_CHANNELS.map(ch => (
|
||||
<SettingRow
|
||||
key={ch.id}
|
||||
label={t(ch.titleKey)}
|
||||
hint={t(ch.hintKey)}
|
||||
control={<ToggleSwitch on={channels.isActive(ch.id)} label={t(ch.titleKey)} onToggle={() => channels.toggle(ch.id)} />}
|
||||
/>
|
||||
))}
|
||||
<SettingRow
|
||||
label={t('admin.notifications.inappPanel.title')}
|
||||
hint={t('admin.notifications.inappPanel.hint')}
|
||||
control={<LockedSwitch />}
|
||||
/>
|
||||
<SettingRow
|
||||
label={t('admin.notifications.tripReminders.title')}
|
||||
hint={t('admin.notifications.tripReminders.hint')}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={tripRemindersActive}
|
||||
label={t('admin.notifications.tripReminders.title')}
|
||||
onToggle={toggleTripReminders}
|
||||
/>
|
||||
</SettingRows>
|
||||
</div>
|
||||
<CardActions>
|
||||
<button type="button" onClick={saveNotifications} className={SETTINGS_BUTTON_PRIMARY}>
|
||||
<Save size={14} strokeWidth={2.2} />{t('common.save')}
|
||||
</button>
|
||||
<button type="button"
|
||||
onClick={testSmtp}
|
||||
disabled={!smtpConfigured}
|
||||
className={SETTINGS_BUTTON}
|
||||
>
|
||||
<Send size={14} strokeWidth={2.2} />{t('admin.smtp.testButton')}
|
||||
</button>
|
||||
</CardActions>
|
||||
</SettingsCard>
|
||||
)}
|
||||
}
|
||||
/>
|
||||
</SettingRows>
|
||||
|
||||
{/* Webhook, Ntfy and Web Push: a title, a hint and the switch each. Nothing
|
||||
to set below them, so the card is its head band alone. */}
|
||||
{SWITCH_ONLY_CHANNELS.map(ch => (
|
||||
<SettingsCard
|
||||
key={ch.id}
|
||||
icon={CHANNEL_ICONS[ch.id] ?? Smartphone}
|
||||
title={t(ch.titleKey)}
|
||||
hint={t(ch.hintKey)}
|
||||
action={<ToggleSwitch on={channels.isActive(ch.id)} label={t(ch.titleKey)} onToggle={() => channels.toggle(ch.id)} />}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* In-App Panel */}
|
||||
<SettingsCard
|
||||
icon={Bell}
|
||||
title={t('admin.notifications.inappPanel.title')}
|
||||
hint={t('admin.notifications.inappPanel.hint')}
|
||||
action={<LockedSwitch />}
|
||||
/>
|
||||
|
||||
{!managed && tripRemindersCard}
|
||||
</div>
|
||||
|
||||
<div className="min-w-0">
|
||||
{/* The SMTP relay, a section of this card: greyed and out of reach while
|
||||
the email channel is off, never hidden. */}
|
||||
{!managed && (
|
||||
<SettingsCard icon={Mail} title={t('admin.notifications.emailPanel.title')}>
|
||||
<div data-testid="smtp-fields" className={`flex flex-col gap-4 transition-opacity ${!emailActive ? 'opacity-50 pointer-events-none' : ''}`}>
|
||||
{smtpLoaded && (<>
|
||||
<div className={GRID_2}>
|
||||
{smtpField(SMTP_FIELDS[0])}
|
||||
{smtpField(SMTP_FIELDS[1])}
|
||||
</div>
|
||||
<div className={GRID_2}>
|
||||
{smtpField(SMTP_FIELDS[2])}
|
||||
{smtpField(SMTP_FIELDS[3])}
|
||||
</div>
|
||||
{smtpField(SMTP_FIELDS[4])}
|
||||
</>)}
|
||||
<SettingRows>
|
||||
<SettingRow
|
||||
label={t('admin.smtp.skipTls')}
|
||||
hint={t('admin.smtp.skipTlsHint')}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={smtpValues.smtp_skip_tls_verify === 'true'}
|
||||
label={t('admin.smtp.skipTls')}
|
||||
onToggle={() => {
|
||||
const newVal = smtpValues.smtp_skip_tls_verify === 'true' ? 'false' : 'true'
|
||||
setSmtpValues(prev => ({ ...prev, smtp_skip_tls_verify: newVal }))
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SettingRows>
|
||||
</div>
|
||||
<CardActions>
|
||||
<button type="button" onClick={saveNotifications} className={SETTINGS_BUTTON_PRIMARY}>
|
||||
<Save size={14} strokeWidth={2.2} />{t('common.save')}
|
||||
</button>
|
||||
<button type="button"
|
||||
onClick={testSmtp}
|
||||
disabled={!smtpConfigured}
|
||||
className={SETTINGS_BUTTON}
|
||||
>
|
||||
<Send size={14} strokeWidth={2.2} />{t('admin.smtp.testButton')}
|
||||
</button>
|
||||
</CardActions>
|
||||
</SettingsCard>
|
||||
)}
|
||||
</SettingsCard>
|
||||
}
|
||||
right={
|
||||
// What the operator receives about running the instance: one card, the
|
||||
// two targets as its blocks, then which event goes out over which channel.
|
||||
<SettingsCard icon={BellRing} title={t('admin.notifications.adminAlerts')} hint={t('admin.notifications.adminNotificationsHint')}>
|
||||
{/* Admin alerts are about running the instance (version notices, and what else
|
||||
lands there later). On a managed install those go to whoever runs it. */}
|
||||
{!managed && (<>
|
||||
@@ -258,7 +241,6 @@ export default function AdminNotificationsTab({ admin, t }: AdminNotificationsTa
|
||||
<button type="button"
|
||||
onClick={clearNtfyToken}
|
||||
className={`${SETTINGS_BUTTON_DANGER} flex-none`}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{t('common.clear')}
|
||||
</button>
|
||||
@@ -286,12 +268,10 @@ export default function AdminNotificationsTab({ admin, t }: AdminNotificationsTa
|
||||
{/* The matrix decides which of those channels each admin-only event goes out
|
||||
over, so it belongs under the targets it routes to rather than across the
|
||||
full width below both columns. */}
|
||||
<AdminNotificationsPanel t={t} toast={toast} />
|
||||
{/* Without the admin alert cards the right column is short, so the
|
||||
reminder switch moves over on a managed install. */}
|
||||
{managed && tripRemindersCard}
|
||||
</div>
|
||||
</div>
|
||||
<AdminNotificationsPanel t={t} toast={toast} bare />
|
||||
</SettingsCard>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* What users' own notifications start as, across the full width: one row per
|
||||
user event, one column per channel users can pick (#1536). */}
|
||||
|
||||
@@ -13,9 +13,20 @@ import AdminSettingsTab from './AdminSettingsTab';
|
||||
type Spy = ReturnType<typeof vi.fn>;
|
||||
type Spies = Record<string, Spy> & { toast: Record<string, Spy> };
|
||||
|
||||
/** The three tabs the settings are split into (security, services, features), on one page. */
|
||||
function AllParts({ admin, t }: { admin: AdminHook; t: ReturnType<typeof useTranslation>['t'] }) {
|
||||
return (
|
||||
<>
|
||||
<AdminSettingsTab admin={admin} t={t} part="security" />
|
||||
<AdminSettingsTab admin={admin} t={t} part="services" />
|
||||
<AdminSettingsTab admin={admin} t={t} part="features" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Harness({ admin }: { admin: AdminHook }) {
|
||||
const { t } = useTranslation();
|
||||
return <AdminSettingsTab admin={admin} t={t} />;
|
||||
return <AllParts admin={admin} t={t} />;
|
||||
}
|
||||
|
||||
function renderTab(overrides: Record<string, unknown> = {}) {
|
||||
@@ -71,7 +82,7 @@ function OidcHarness() {
|
||||
const { t } = useTranslation();
|
||||
const [oidcConfig, setOidcConfig] = React.useState<OidcConfig>(EMPTY_OIDC);
|
||||
const admin = buildAdminHook({ oidcConfig, setOidcConfig });
|
||||
return <AdminSettingsTab admin={admin} t={t} />;
|
||||
return <AllParts admin={admin} t={t} />;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -88,7 +99,8 @@ describe('AdminSettingsTab', () => {
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'Authentication Methods' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Passkey login' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /require two-factor/i })).toBeInTheDocument();
|
||||
// Requiring two-factor is a switch of the sign-in card now, not a card of its own.
|
||||
expect(screen.getByText(/require two-factor/i)).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Allowed File Types' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'API Keys' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: /single sign-on/i })).toBeInTheDocument();
|
||||
@@ -340,13 +352,11 @@ describe('AdminSettingsTab', () => {
|
||||
expect(screen.queryByRole('button', { name: 'Automatic' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-ADMSET-022f: a managed install moves file types to the right column', () => {
|
||||
// With place search and the keys gone the right column would stand empty.
|
||||
it('FE-ADMSET-022f: a managed install keeps the file types card on the services tab', () => {
|
||||
// Place search and the keys are the operator's there; the file types stay the admin's.
|
||||
renderTab({ managed: true });
|
||||
|
||||
const right = screen.getByRole('heading', { name: 'Allowed File Types' }).closest('.min-w-0');
|
||||
expect(right).not.toBeNull();
|
||||
expect(within(right as HTMLElement).queryByRole('heading', { name: /two-factor/i })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Allowed File Types' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-ADMSET-023: the maps Test button is disabled without a key', () => {
|
||||
|
||||
@@ -10,7 +10,7 @@ import CustomSelect from '../../components/shared/CustomSelect'
|
||||
import { fs } from '../../components/shared/DialogShell'
|
||||
import { EditorField, GRID_2, INPUT } from '../../components/shared/dialogParts'
|
||||
import {
|
||||
SETTINGS_BUTTON, SETTINGS_BUTTON_DANGER, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, SettingsCard, SettingsHint, StatusPill,
|
||||
SETTINGS_BUTTON, SETTINGS_BUTTON_DANGER, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, SettingsCard, SettingsColumns, SettingsHint, StatusPill,
|
||||
} from '../../components/Settings/settingsKit'
|
||||
import GoogleOptions from './GoogleOptions'
|
||||
import GoogleDailyLimitRow from '../../components/Admin/GoogleDailyLimitRow'
|
||||
@@ -26,6 +26,12 @@ import type { useAdmin } from './useAdmin'
|
||||
interface AdminSettingsTabProps {
|
||||
admin: ReturnType<typeof useAdmin>
|
||||
t: TranslationFn
|
||||
/**
|
||||
* Which tab this renders: sign-in and its safety (security), what the
|
||||
* install talks to outside (services), or the setup of the features the
|
||||
* addons tab switches on (features).
|
||||
*/
|
||||
part: 'security' | 'services' | 'features'
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +108,7 @@ function KeyField({ shown, value, onChange, inputProps, label, onToggle }: {
|
||||
function SaveBar({ onClick, saving, label }: { onClick: () => void; saving: boolean; label: string }) {
|
||||
return (
|
||||
<div className="flex justify-end">
|
||||
<button type="button" onClick={onClick} disabled={saving} className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
|
||||
<button type="button" onClick={onClick} disabled={saving} className={SETTINGS_BUTTON_PRIMARY}>
|
||||
{saving ? <Loader2 size={14} className="animate-spin" /> : <Save size={14} />}
|
||||
{label}
|
||||
</button>
|
||||
@@ -110,9 +116,9 @@ function SaveBar({ onClick, saving, label }: { onClick: () => void; saving: bool
|
||||
)
|
||||
}
|
||||
|
||||
// "Settings" admin tab: auth methods, require-MFA, allowed file types, API keys,
|
||||
// OIDC config and the danger zone. Pure layout around the useAdmin hook.
|
||||
export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): React.ReactElement {
|
||||
// The admin's security, services and feature setup tabs, cut from what was one
|
||||
// "Settings" tab. Pure layout around the useAdmin hook.
|
||||
export default function AdminSettingsTab({ admin, t, part }: AdminSettingsTabProps): React.ReactElement {
|
||||
const {
|
||||
toast,
|
||||
placesPhotosEnabled, placesAutocompleteEnabled, placesDetailsEnabled, placesEnrichEnabled,
|
||||
@@ -143,8 +149,6 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
const passwordLoginLocked = !passwordLogin && !oidcLogin
|
||||
const oidcLoginLocked = !passwordLogin && oidcLogin
|
||||
|
||||
// On a managed install the right column loses place search, routing and the
|
||||
// keys to the operator, so file types move over and the columns stay even.
|
||||
const fileTypesCard = (
|
||||
<SettingsCard icon={FileType} title={t('admin.fileTypes')} hint={t('admin.fileTypesHint')}>
|
||||
<div>
|
||||
@@ -166,18 +170,9 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
</SettingsCard>
|
||||
)
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Two columns from xl up. Nearly every card here is "label left,
|
||||
switch right", so on a wide screen the middle stayed empty while the
|
||||
page scrolled for ages. Two explicit columns rather than a grid over
|
||||
the flat list: a plain grid pairs cards row by row and leaves a hole
|
||||
under whichever of the pair is shorter, and these differ by hundreds
|
||||
of pixels. Grouped by subject, not by height — access and identity
|
||||
left, integrations and data right. The cards carry their own bottom
|
||||
margin, so only the column gap is set here. */}
|
||||
<div className="grid grid-cols-1 gap-x-5 xl:grid-cols-2 xl:items-start">
|
||||
<div className="min-w-0">
|
||||
// Each card is built once; the parts below pick theirs.
|
||||
const authCard = (
|
||||
<>
|
||||
{/* Authentication Methods */}
|
||||
<SettingsCard icon={LockKeyhole} title={t('admin.authMethods')}>
|
||||
{envOverrideOidcOnly && <Callout>{t('admin.envOverrideHint')}</Callout>}
|
||||
@@ -251,12 +246,7 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</SettingRows>
|
||||
</SettingsCard>
|
||||
|
||||
{/* Passkey (WebAuthn) login */}
|
||||
<SettingsCard icon={Fingerprint} title={t('admin.passkey.title')} hint={t('admin.passkey.cardHint')}>
|
||||
<SettingRows>
|
||||
{/* Passkeys and the 2FA rule are ways in too, so they sit with the others. */}
|
||||
<SettingRow
|
||||
label={t('admin.passkey.login')}
|
||||
hint={t('admin.passkey.loginHint')}
|
||||
@@ -268,17 +258,38 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SettingRow
|
||||
label={t('admin.requireMfa')}
|
||||
hint={t('admin.requireMfaHint')}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={requireMfa}
|
||||
label={t('admin.requireMfa')}
|
||||
onToggle={() => handleToggleRequireMfa(!requireMfa)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SettingRows>
|
||||
|
||||
{passkeyLogin && !passkeyConfigured && <Callout>{t('admin.passkey.notConfigured')}</Callout>}
|
||||
|
||||
</SettingsCard>
|
||||
</>
|
||||
)
|
||||
// Where passkeys bind: an expert setting, a row of the setup list. The switch
|
||||
// to offer passkeys at all is in the sign-in card.
|
||||
const passkeyCard = (
|
||||
<>
|
||||
{/* The domain passkeys bind to and the origins that may present them
|
||||
follow from the address the instance is served on, which the operator
|
||||
owns. Getting either wrong invalidates every enrolled passkey, and on
|
||||
a shared parent domain a wrong RP ID reaches past this instance
|
||||
entirely — so they are pinned per container, not offered here. The
|
||||
switch above stays: whether to offer passkeys at all is a house rule. */}
|
||||
{!managed && (<>
|
||||
entirely — so they are pinned per container, not offered here. */}
|
||||
{!managed && (
|
||||
<SettingsCard
|
||||
icon={Fingerprint}
|
||||
title={t('admin.passkey.title')}
|
||||
hint={t('admin.passkey.cardHint')}
|
||||
badge={webauthnRpId ? <StatusPill>{webauthnRpId}</StatusPill> : undefined}
|
||||
>
|
||||
<EditorField label={t('admin.passkey.rpId')} htmlFor="admin-webauthn-rp-id" hint={t('admin.passkey.rpIdHint')}>
|
||||
<input
|
||||
id="admin-webauthn-rp-id"
|
||||
@@ -300,32 +311,27 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
/>
|
||||
</EditorField>
|
||||
<SaveBar onClick={handleSaveWebauthn} saving={savingWebauthn} label={t('common.save')} />
|
||||
</>)}
|
||||
</SettingsCard>
|
||||
|
||||
{/* Require 2FA for all users */}
|
||||
<SettingsCard icon={ShieldCheck} title={t('admin.requireMfa')}>
|
||||
<SettingRows>
|
||||
<SettingRow
|
||||
label={t('admin.requireMfa')}
|
||||
hint={t('admin.requireMfaHint')}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={requireMfa}
|
||||
label={t('admin.requireMfa')}
|
||||
onToggle={() => handleToggleRequireMfa(!requireMfa)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SettingRows>
|
||||
</SettingsCard>
|
||||
|
||||
</SettingsCard>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
const oidcCard = (
|
||||
<>
|
||||
{/* An issuer the instance names can assert any address as verified, and the
|
||||
discovery calls leave from inside the operator’s network. Sign-on is theirs
|
||||
to wire, so the fields are not offered. */}
|
||||
{!managed && (
|
||||
/* OIDC / SSO Configuration */
|
||||
<SettingsCard icon={LogIn} title={t('admin.oidcTitle')} hint={t('admin.oidcSubtitle')}>
|
||||
<SettingsCard
|
||||
icon={LogIn}
|
||||
title={t('admin.oidcTitle')}
|
||||
hint={t('admin.oidcSubtitle')}
|
||||
badge={
|
||||
oidcConfigured
|
||||
? <StatusPill tone="success" icon={<span className="h-1.5 w-1.5 rounded-full bg-current" />}>{t('settings.configured')}</StatusPill>
|
||||
: <StatusPill icon={<span className="h-1.5 w-1.5 rounded-full bg-current" />}>{t('settings.notSetUp')}</StatusPill>
|
||||
}
|
||||
>
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('admin.oidcDisplayName')} htmlFor="oidc-display-name">
|
||||
<input
|
||||
@@ -390,9 +396,10 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
/>
|
||||
</SettingsCard>
|
||||
)}
|
||||
|
||||
{!managed && fileTypesCard}
|
||||
|
||||
</>
|
||||
)
|
||||
const flightCard = (
|
||||
<>
|
||||
{/* Live flight status: open ADS-B data, no key, on by default; the admin may keep it off. */}
|
||||
<SettingsCard icon={Plane} title={t('flightLive.adminTitle')} hint={managed ? t('flightLive.adminHintManaged') : t('flightLive.adminHint')}>
|
||||
<SettingRows>
|
||||
@@ -410,19 +417,17 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
/>
|
||||
</SettingRows>
|
||||
</SettingsCard>
|
||||
|
||||
</>
|
||||
)
|
||||
const mailCard = (
|
||||
<>
|
||||
{/* Booking mail import: how forwarded booking mails reach this install. On a managed
|
||||
install the operator runs the TREK Cloud relay, so the card is not shown there. */}
|
||||
{!managed && <MailIngestAdminCard />}
|
||||
</div>
|
||||
|
||||
<div className="min-w-0">
|
||||
{managed && fileTypesCard}
|
||||
{/* Inside the place search card elsewhere; that card is the operator's here,
|
||||
sharing place details is still the admin's decision. */}
|
||||
{managed && <PlaceContribPanel hideWhenSwitchedOff />}
|
||||
|
||||
|
||||
</>
|
||||
)
|
||||
const servicesCard = (
|
||||
<>
|
||||
{/* Place search and routing: TREK's own services first, then which provider
|
||||
answers search and transit, and the search log. Apart from the keys, so a
|
||||
keyless install reads its whole setup in one card. Everything here saves
|
||||
@@ -539,7 +544,10 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
|
||||
</SettingsCard>
|
||||
)}
|
||||
|
||||
</>
|
||||
)
|
||||
const apiKeysCard = (
|
||||
<>
|
||||
{/* API Keys: only the keyed providers, Google, Unsplash and Amap. They are
|
||||
the operator's on a managed install, so the card is not shown there
|
||||
(server managed.ts), and neither is the provider pick in the card
|
||||
@@ -570,7 +578,6 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
onClick={() => handleValidateKey('maps')}
|
||||
disabled={!mapsKeyTestable || validating.maps}
|
||||
className={`${SETTINGS_BUTTON} flex-none whitespace-nowrap`}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
{validating.maps ? (
|
||||
<Loader2 size={14} className="animate-spin" />
|
||||
@@ -695,9 +702,10 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
<SaveBar onClick={handleSaveApiKeys} saving={savingKeys} label={t('common.save')} />
|
||||
</SettingsCard>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</>
|
||||
)
|
||||
const dangerCard = (
|
||||
<>
|
||||
{/* Full width, and last. A destructive action should not sit beside a
|
||||
harmless toggle where a mis-aimed click can reach it. */}
|
||||
{/* Rotating the secret signs every user out and fixes nothing an instance admin
|
||||
@@ -713,7 +721,6 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
<button type="button"
|
||||
onClick={() => setShowRotateJwtModal(true)}
|
||||
className={SETTINGS_BUTTON_DANGER}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
<RefreshCw size={14} />
|
||||
{t('admin.rotateJwt.button')}
|
||||
@@ -723,6 +730,55 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
|
||||
</SettingRows>
|
||||
</SettingsCard>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
// What used to be one "Settings" tab, split by what an admin comes for:
|
||||
// who may sign in and how (security), what the install talks to outside
|
||||
// (services), and how the features in the addons tab are set up there.
|
||||
if (part === 'features') {
|
||||
return (
|
||||
<>
|
||||
{flightCard}
|
||||
{mailCard}
|
||||
</>
|
||||
)
|
||||
}
|
||||
if (part === 'services') {
|
||||
// Place search and the services on the left, the keys and file types on the right.
|
||||
return (
|
||||
<SettingsColumns
|
||||
left={<>
|
||||
{/* Inside the place search card elsewhere; that card is the operator's here,
|
||||
sharing place details is still the admin's decision. */}
|
||||
{managed && <PlaceContribPanel hideWhenSwitchedOff />}
|
||||
{servicesCard}
|
||||
</>}
|
||||
right={<>
|
||||
{apiKeysCard}
|
||||
{fileTypesCard}
|
||||
</>}
|
||||
/>
|
||||
)
|
||||
}
|
||||
// Who may sign in and what it takes (the passkey domain, single sign-on),
|
||||
// with the one destructive action in its own card.
|
||||
return (
|
||||
// Split by length, not by kind: single sign-on is the one long form, so the
|
||||
// right column holds it and the short danger zone under it.
|
||||
<SettingsColumns
|
||||
left={
|
||||
<>
|
||||
{authCard}
|
||||
{passkeyCard}
|
||||
</>
|
||||
}
|
||||
right={
|
||||
<>
|
||||
{oidcCard}
|
||||
{dangerCard}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -297,7 +297,6 @@ export default function AdminUserModals({ admin, t }: AdminUserModalsProps): Rea
|
||||
if (editingUser) setPasskeyResetUser(editingUser);
|
||||
}}
|
||||
className={`${SETTINGS_BUTTON_DANGER} flex-none`}
|
||||
style={fs(12.5, 'body')}
|
||||
>
|
||||
<Fingerprint size={14} /> {t('admin.passkey.reset')}
|
||||
</button>
|
||||
@@ -313,7 +312,6 @@ export default function AdminUserModals({ admin, t }: AdminUserModalsProps): Rea
|
||||
type="button"
|
||||
onClick={() => setMfaResetUser(editingUser)}
|
||||
className={`${SETTINGS_BUTTON_DANGER} flex-none`}
|
||||
style={fs(12.5, 'body')}
|
||||
>
|
||||
<ShieldOff size={14} /> {t('admin.mfa.reset')}
|
||||
</button>
|
||||
@@ -359,7 +357,6 @@ export default function AdminUserModals({ admin, t }: AdminUserModalsProps): Rea
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={SETTINGS_BUTTON}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
<ExternalLink size={14} strokeWidth={2.1} className="flex-none" />
|
||||
{t('admin.update.button')}
|
||||
@@ -525,7 +522,6 @@ function SsoUnlinkSection({
|
||||
type="button"
|
||||
onClick={() => setAsking(true)}
|
||||
className={`${SETTINGS_BUTTON_DANGER} flex-none`}
|
||||
style={fs(12.5, 'body')}
|
||||
>
|
||||
<Unlink size={14} /> {t('admin.sso.unlink')}
|
||||
</button>
|
||||
|
||||
@@ -58,7 +58,7 @@ export default function AdminUsersTab({ admin, t, locale }: AdminUsersTabProps):
|
||||
title={t('admin.tabs.users')}
|
||||
hint={<>{users.length} {t('admin.stats.users', { count: users.length })}</>}
|
||||
action={
|
||||
<button type="button" onClick={() => setShowCreateUser(true)} className={SETTINGS_BUTTON_PRIMARY} style={fs(12.5, 'body')}>
|
||||
<button type="button" onClick={() => setShowCreateUser(true)} className={SETTINGS_BUTTON_PRIMARY}>
|
||||
<UserPlus size={14} strokeWidth={2.1} />
|
||||
{t('admin.createUser')}
|
||||
</button>
|
||||
@@ -146,7 +146,7 @@ export default function AdminUsersTab({ admin, t, locale }: AdminUsersTabProps):
|
||||
title={t('admin.invite.title')}
|
||||
hint={t('admin.invite.subtitle')}
|
||||
action={
|
||||
<button type="button" onClick={() => setShowCreateInvite(true)} className={SETTINGS_BUTTON} style={fs(12.5, 'body')}>
|
||||
<button type="button" onClick={() => setShowCreateInvite(true)} className={SETTINGS_BUTTON}>
|
||||
<Plus size={14} strokeWidth={2.2} />
|
||||
{t('admin.invite.create')}
|
||||
</button>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { fireEvent, render, screen } from '../../../tests/helpers/render';
|
||||
import FoldSummary from './FoldSummary';
|
||||
|
||||
describe('FoldSummary', () => {
|
||||
it('heads the fold with a turning chevron and its own label', () => {
|
||||
const { container } = render(
|
||||
<details className="group">
|
||||
<FoldSummary>
|
||||
<span>More</span>
|
||||
</FoldSummary>
|
||||
<p>inside</p>
|
||||
</details>
|
||||
);
|
||||
const summary = container.querySelector('summary') as HTMLElement;
|
||||
expect(summary).toContainElement(screen.getByText('More'));
|
||||
const chevron = summary.querySelector('svg') as SVGElement;
|
||||
expect(chevron).toHaveAttribute('aria-hidden', 'true');
|
||||
expect(chevron.getAttribute('class')).toContain('group-open:rotate-90');
|
||||
expect(summary.firstElementChild).toBe(chevron);
|
||||
});
|
||||
|
||||
it('opens and closes the fold it heads', () => {
|
||||
const { container } = render(
|
||||
<details className="group">
|
||||
<FoldSummary>More</FoldSummary>
|
||||
<p>inside</p>
|
||||
</details>
|
||||
);
|
||||
const details = container.querySelector('details') as HTMLDetailsElement;
|
||||
expect(details.open).toBe(false);
|
||||
fireEvent.click(container.querySelector('summary') as HTMLElement);
|
||||
expect(details.open).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,21 +0,0 @@
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
* The clickable head of a native <details> fold on the admin settings page: a
|
||||
* chevron that turns when the fold opens, then whatever the fold calls itself.
|
||||
* The surrounding <details> needs the `group` class for the chevron to turn.
|
||||
*/
|
||||
export default function FoldSummary({ children }: { children: React.ReactNode }): React.ReactElement {
|
||||
return (
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2.5 px-3.5 py-2.5 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[color:var(--text-primary)] [&::-webkit-details-marker]:hidden">
|
||||
<ChevronRight
|
||||
size={15}
|
||||
strokeWidth={2}
|
||||
className="flex-none text-content-faint transition-transform group-open:rotate-90"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
{children}
|
||||
</summary>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import React from 'react'
|
||||
import { fs } from '../../components/shared/DialogShell'
|
||||
import { StatusPill } from '../../components/Settings/settingsKit'
|
||||
import FoldSummary from './FoldSummary'
|
||||
import { SettingsBlock, StatusPill } from '../../components/Settings/settingsKit'
|
||||
|
||||
interface GoogleOptionsProps {
|
||||
/** "Google options" — the heading of the fold. */
|
||||
@@ -19,19 +17,14 @@ interface GoogleOptionsProps {
|
||||
* an admin opens this card at all. The switches are the opposite — set once,
|
||||
* then never touched, and there are five of them.
|
||||
*
|
||||
* A native <details> rather than a state hook: keyboard operable and announced
|
||||
* to screen readers without writing any of that, and it survives a re-render
|
||||
* without state. Drawn as a box of rows (settingsKit's SettingRows), the
|
||||
* summary being its first row.
|
||||
* Shown open: the settings pages fold nothing away.
|
||||
*/
|
||||
export default function GoogleOptions({ title, summary, children }: GoogleOptionsProps): React.ReactElement {
|
||||
return (
|
||||
<details className="group overflow-hidden rounded-[12px] border border-edge-faint bg-surface-secondary">
|
||||
<FoldSummary>
|
||||
<span className="min-w-0 flex-1 truncate font-medium text-content" style={fs(13, 'body')}>{title}</span>
|
||||
<StatusPill>{summary}</StatusPill>
|
||||
</FoldSummary>
|
||||
<div className="divide-y divide-edge-faint border-t border-edge-faint bg-surface-card">{children}</div>
|
||||
</details>
|
||||
// A block of the card: its title and the count of switches on as the block's
|
||||
// head, its rows inside.
|
||||
<SettingsBlock title={title} badge={<StatusPill>{summary}</StatusPill>} flush>
|
||||
{children}
|
||||
</SettingsBlock>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react'
|
||||
import { fs } from '../../components/shared/DialogShell'
|
||||
import { StatusPill } from '../../components/Settings/settingsKit'
|
||||
import { SettingsBlock, StatusPill } from '../../components/Settings/settingsKit'
|
||||
|
||||
interface ProviderBlockProps {
|
||||
title: string
|
||||
@@ -17,21 +16,16 @@ interface ProviderBlockProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* One provider inside the API card, in the same shape as the TREK block above
|
||||
* it, so the page reads as a list of comparable options rather than one
|
||||
* highlighted thing and some loose fields underneath. A white box on the
|
||||
* card's grey body, its name in a head row, like a bag in the packing sidebar.
|
||||
* One provider inside the API card: its name in a head row, a pill beside it,
|
||||
* its fields below, as one rounded block of the card (SettingsBlock), so the
|
||||
* card reads as a list of comparable options.
|
||||
*/
|
||||
export default function ProviderBlock({
|
||||
title, badge, tone = 'muted', children,
|
||||
}: ProviderBlockProps): React.ReactElement {
|
||||
return (
|
||||
<section className="overflow-hidden rounded-[14px] border border-edge-faint bg-surface-card">
|
||||
<div className="flex min-w-0 items-center gap-2 border-b border-edge-faint px-3.5 py-2.5">
|
||||
<h3 className="m-0 min-w-0 flex-1 truncate font-semibold text-content" style={fs(13, 'body')}>{title}</h3>
|
||||
{badge && <StatusPill tone={tone === 'caution' ? 'warning' : 'neutral'}>{badge}</StatusPill>}
|
||||
</div>
|
||||
<div className="flex flex-col gap-3 p-3.5">{children}</div>
|
||||
</section>
|
||||
<SettingsBlock title={title} badge={badge ? <StatusPill tone={tone === 'caution' ? 'warning' : 'neutral'}>{badge}</StatusPill> : undefined}>
|
||||
{children}
|
||||
</SettingsBlock>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
import React from 'react'
|
||||
import { Library, MapPin, Route, Search, X } from 'lucide-react'
|
||||
import TrekMark from '../../components/shared/TrekMark'
|
||||
import { fs } from '../../components/shared/DialogShell'
|
||||
import { StatusPill } from '../../components/Settings/settingsKit'
|
||||
import FoldSummary from './FoldSummary'
|
||||
import ServiceIdentityPanel from '../../components/Admin/ServiceIdentityPanel'
|
||||
import PlaceContribPanel from '../../components/Admin/PlaceContribPanel'
|
||||
import type { TranslationFn } from '../../types'
|
||||
import {
|
||||
TREK_API_SOURCES as SOURCES,
|
||||
trekApiAddressFeatures,
|
||||
trekApiFacts,
|
||||
trekApiFields,
|
||||
trekApiRoutingFeatures,
|
||||
} from '../../components/Admin/trekApiModel'
|
||||
import { TREK_API_SOURCES as SOURCES, trekApiFacts } from '../../components/Admin/trekApiModel'
|
||||
|
||||
interface TrekApiCardProps {
|
||||
t: TranslationFn
|
||||
@@ -35,30 +27,13 @@ interface TrekApiCardProps {
|
||||
* three places on the server rather than promised here, and the allowance below
|
||||
* the facts is what the service itself reports for this installation.
|
||||
*/
|
||||
const CHIP = 'rounded-full border px-2.5 py-[3px] font-medium'
|
||||
|
||||
/** One of the lists under "more": an icon and a name, chips, a note. */
|
||||
function FactGroup({ icon, title, note, children }: { icon: React.ReactNode; title: string; note: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="flex flex-col gap-2 px-3.5 py-3">
|
||||
<p className="m-0 flex items-center gap-1.5 font-semibold text-content" style={fs(12.5, 'body')}>
|
||||
{icon}
|
||||
{title}
|
||||
</p>
|
||||
<ul className="m-0 flex list-none flex-wrap gap-1.5 p-0" style={fs(11.5)}>{children}</ul>
|
||||
<p className="m-0 leading-normal text-content-faint" style={fs(11.5)}>{note}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): React.ReactElement {
|
||||
const fields = trekApiFields(t)
|
||||
const facts = trekApiFacts(t)
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden rounded-[14px] border bg-surface-card shadow-sm"
|
||||
<section className="overflow-hidden rounded-[12px] border bg-surface-card"
|
||||
style={{ borderColor: 'color-mix(in srgb, var(--accent) 40%, transparent)' }}>
|
||||
<div className="flex flex-col gap-3 px-3.5 pb-3.5 pt-3.5">
|
||||
<div className="flex flex-col gap-3 p-3.5">
|
||||
{/* The recommendation, moved here from the Google field. It is the whole
|
||||
point of the block: a key should be the exception, not the default.
|
||||
A pill beside the mark rather than a banner, so it does not shout
|
||||
@@ -72,13 +47,12 @@ export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): R
|
||||
{t('admin.trekApi.tagline')}
|
||||
</p>
|
||||
|
||||
<ul className="m-0 grid list-none grid-cols-1 gap-x-4 gap-y-1.5 p-0 sm:grid-cols-2">
|
||||
{/* What it offers as compact badges that wrap, not a list of rows. */}
|
||||
<ul className="m-0 flex list-none flex-wrap gap-1.5 p-0">
|
||||
{facts.map(({ Icon, text }) => (
|
||||
<li key={text} className="flex min-w-0 items-center gap-2 text-content-secondary" style={fs(12, 'body')}>
|
||||
<span className="grid h-6 w-6 flex-none place-items-center rounded-[8px] bg-surface-tertiary text-content-muted">
|
||||
<Icon size={13} strokeWidth={2} aria-hidden="true" />
|
||||
</span>
|
||||
<span className="min-w-0">{text}</span>
|
||||
<li key={text} className="inline-flex items-center gap-1.5 rounded-full border border-edge-faint bg-surface-secondary px-2.5 py-1 text-content-secondary" style={fs(11.5)}>
|
||||
<Icon size={12} strokeWidth={2} aria-hidden="true" className="flex-none text-content-muted" />
|
||||
{text}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -87,72 +61,11 @@ export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): R
|
||||
<PlaceContribPanel />
|
||||
</div>
|
||||
|
||||
<details className="group border-t border-edge-faint">
|
||||
<FoldSummary>
|
||||
<span className="font-medium text-content" style={fs(13, 'body')}>{t('admin.trekApi.more')}</span>
|
||||
</FoldSummary>
|
||||
<div className="divide-y divide-edge-faint border-t border-edge-faint bg-surface-secondary">
|
||||
{/* The fields as chips rather than a paragraph. A list of what you
|
||||
get is something you scan, not something you read, and a sentence
|
||||
forces the reader to parse commas to answer "is the phone number
|
||||
in there". One list per service, under the service's own name. */}
|
||||
<FactGroup
|
||||
icon={<MapPin size={14} strokeWidth={2.2} className="text-content-muted" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.quota.service.places')}
|
||||
note={t('admin.trekApi.includedNote')}
|
||||
>
|
||||
{fields.map(field => (
|
||||
<li key={field} className={`${CHIP} border-edge-faint bg-surface-card text-content-secondary`}>{field}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
{/* Named as plainly as what IS included. An admin who switches the
|
||||
source expecting ratings and a photograph of every restaurant
|
||||
should find that out here and not three weeks later. */}
|
||||
<FactGroup
|
||||
icon={<X size={14} strokeWidth={2.4} className="text-content-faint" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.notIncluded')}
|
||||
note={t('admin.trekApi.notIncludedNote')}
|
||||
>
|
||||
{[t('admin.trekApi.notRatings'), t('admin.trekApi.notPhotos')].map(item => (
|
||||
<li key={item} className={`${CHIP} border-dashed border-edge text-content-faint`}>{item}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
<FactGroup
|
||||
icon={<Search size={14} strokeWidth={2.2} className="text-content-muted" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.quota.service.photon')}
|
||||
note={t('admin.trekApi.addressNote')}
|
||||
>
|
||||
{trekApiAddressFeatures(t).map(item => (
|
||||
<li key={item} className={`${CHIP} border-edge-faint bg-surface-card text-content-secondary`}>{item}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
<FactGroup
|
||||
icon={<Route size={14} strokeWidth={2.2} className="text-content-muted" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.quota.service.valhalla')}
|
||||
note={t('admin.trekApi.routingNote')}
|
||||
>
|
||||
{trekApiRoutingFeatures(t).map(item => (
|
||||
<li key={item} className={`${CHIP} border-edge-faint bg-surface-card text-content-secondary`}>{item}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
|
||||
{/* Attribution, and not in the small print: the licences require the
|
||||
sources to be named, and naming them is also the answer to "where
|
||||
does this actually come from". */}
|
||||
<FactGroup
|
||||
icon={<Library size={14} strokeWidth={2} className="text-content-faint" aria-hidden="true" />}
|
||||
title={t('admin.trekApi.sourcesLabel')}
|
||||
note={t('admin.trekApi.sourcesNote')}
|
||||
>
|
||||
{SOURCES.map(source => (
|
||||
<li key={source} className={`${CHIP} border-edge-faint bg-surface-card text-content-secondary`}>{source}</li>
|
||||
))}
|
||||
</FactGroup>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
{/* The sources, named because their licences ask for it, in one line under
|
||||
the card instead of a list of every field the service answers. */}
|
||||
<p className="m-0 border-t border-edge-faint px-3.5 py-2.5 leading-snug text-content-faint" style={fs(11.5)}>
|
||||
<span className="font-semibold text-content-muted">{t('admin.trekApi.sourcesLabel')}:</span> {SOURCES.join(', ')}
|
||||
</p>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,10 +21,17 @@ import { passwordErrorKey } from '../../utils/passwordError'
|
||||
* sidebar. Labels and icons stay in AdminPage; this is only the vocabulary.
|
||||
*/
|
||||
const ADMIN_TAB_IDS = [
|
||||
'users', 'defaults', 'config', 'settings', 'addons', 'plugins', 'storage',
|
||||
'users', 'defaults', 'config', 'security', 'services', 'addons', 'plugins', 'storage',
|
||||
'notifications', 'mcp-tokens', 'github', 'backup', 'audit', 'dev-notifications',
|
||||
]
|
||||
|
||||
/**
|
||||
* Tab ids that were renamed, so a bookmark, a wiki page or a mail that names the
|
||||
* old one still lands. "Settings" was one tab for sign-in, services and the
|
||||
* danger zone; it opens on security, where the danger zone went too.
|
||||
*/
|
||||
const ADMIN_TAB_ALIASES: Record<string, string> = { settings: 'security' }
|
||||
|
||||
/**
|
||||
* The ones a managed install deliberately does not offer.
|
||||
*
|
||||
@@ -64,7 +71,8 @@ export function useAdmin() {
|
||||
// on every change, so the address bar keeps saying where the reader is.
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const [activeTab, setActiveTabState] = useState<string>(() => {
|
||||
const asked = searchParams.get('tab')
|
||||
const raw = searchParams.get('tab')
|
||||
const asked = raw ? (ADMIN_TAB_ALIASES[raw] ?? raw) : null
|
||||
const known = [...ADMIN_TAB_IDS, ...managedAdminTabs.map(tab => tab.id)]
|
||||
return asked && known.includes(asked) ? asked : 'users'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user