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:
Maurice
2026-11-13 23:18:28 +01:00
parent 5fe3dea4cc
commit 94ac7673a5
138 changed files with 1299 additions and 2188 deletions
@@ -53,12 +53,6 @@ function isOn(toggle: HTMLElement): boolean {
return toggle.getAttribute('aria-pressed') === 'true';
}
/** A shelf of more than one row starts folded; open every one so its rows can be read. */
async function unfoldShelves(): Promise<void> {
const bars = await screen.findAllByRole('button', { name: /\d+ options?/, expanded: false });
for (const bar of bars) await userEvent.click(bar);
}
beforeAll(() => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
@@ -236,7 +230,6 @@ describe('AddonManager', () => {
)
);
render(<AddonManager />);
await unfoldShelves();
// Provider sub-rows are visible under Journey addon
await screen.findByText('Unsplash');
@@ -272,15 +265,6 @@ describe('AddonManager', () => {
expect(screen.getByText('No addons available')).toBeInTheDocument();
});
it('FE-ADMIN-ADDON-013: dark mode swaps the wordmark in the header', async () => {
// The wordmark reads the .dark class, the same source applyAppearance() writes.
document.documentElement.classList.add('dark');
render(<AddonManager />);
await screen.findByText('No addons available');
expect(screen.getByAltText('TREK')).toHaveAttribute('src', '/text-light.svg');
});
it('FE-ADMIN-ADDON-014: photo-flavoured trip addons are hidden from the trip section', async () => {
server.use(addonsRoute([
buildAddon({ id: 'photos', name: 'Memories', icon: 'Image' }),
@@ -302,7 +286,6 @@ describe('AddonManager', () => {
buildAddon({ id: 'unsplash', name: 'Unsplash', description: 'Stock photos', type: 'photo_provider', enabled: false }),
]));
render(<AddonManager />);
await unfoldShelves();
await screen.findByText('Immich');
// immich and synologyphotos ship a vendor glyph, unsplash does not
@@ -437,7 +420,6 @@ describe('AddonManager', () => {
]));
render(<AddonManager />);
await unfoldShelves();
await screen.findByText('Paperless-ngx');
const paperlessRow = screen.getByText('Paperless-ngx').closest('li') as HTMLElement;
@@ -536,7 +518,6 @@ describe('AddonManager', () => {
/>,
);
await unfoldShelves();
await screen.findByText('Chat');
expect(screen.getByText('Notes')).toBeInTheDocument();
@@ -567,7 +548,6 @@ describe('AddonManager', () => {
onToggleCollabFeature={vi.fn()}
/>
);
await unfoldShelves();
const links = await screen.findByText('Links');
expect(links).toHaveAttribute('title');
@@ -623,7 +603,7 @@ describe('AddonManager', () => {
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
});
it('FE-ADMIN-ADDON-040: a shelf of several options starts folded and says how many there are and how many are on', async () => {
it('FE-ADMIN-ADDON-040: the options of an addon are listed under it at once, nothing to unfold', async () => {
server.use(addonsRoute([buildAddon({ id: 'collab', name: 'Collab', enabled: true })]));
render(
<AddonManager
@@ -632,16 +612,9 @@ describe('AddonManager', () => {
/>
);
const bar = await screen.findByRole('button', { name: /5 options/, expanded: false });
expect(bar).toHaveTextContent('2 on');
expect(screen.queryByText('Chat')).not.toBeInTheDocument();
await userEvent.click(bar);
expect(bar).toHaveAttribute('aria-expanded', 'true');
expect(screen.getByText('Chat')).toBeInTheDocument();
await userEvent.click(bar);
expect(screen.queryByText('Chat')).not.toBeInTheDocument();
expect(await screen.findByRole('button', { name: 'Chat' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Polls' })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /\d+ options?/ })).not.toBeInTheDocument();
});
it('FE-ADMIN-ADDON-041: a shelf of one option shows it at once, without a fold', async () => {
@@ -668,10 +641,6 @@ describe('AddonManager', () => {
</>
);
// Folded like Collab's and Documents' options until the bar is opened.
await screen.findByRole('button', { name: /\d+ options?/, expanded: false });
expect(screen.queryByRole('button', { name: 'wanderer' })).not.toBeInTheDocument();
await unfoldShelves();
const toggle = await screen.findByRole('button', { name: 'wanderer' });
expect(isOn(toggle)).toBe(false);
await userEvent.click(toggle);
@@ -685,8 +654,7 @@ describe('AddonManager', () => {
server.use(addonsRoute([buildAddon({ id: 'tours', name: 'Tours', icon: 'Mountain', enabled: true })]));
render(<AddonManager />);
await screen.findByRole('button', { name: /\d+ options?/, expanded: false });
await unfoldShelves();
await screen.findByText('Tours');
expect(screen.queryByRole('button', { name: 'wanderer' })).not.toBeInTheDocument();
});
@@ -702,7 +670,6 @@ describe('AddonManager', () => {
</>
);
await unfoldShelves();
await userEvent.click(await screen.findByRole('button', { name: 'wanderer' }));
await waitFor(() => expect(isOn(screen.getByRole('button', { name: 'wanderer' }))).toBe(false));
@@ -723,33 +690,4 @@ describe('AddonManager', () => {
expect(roadtrip.querySelector('svg.lucide-car-front')).toBeInTheDocument();
expect(tours.querySelector('svg.lucide-puzzle')).not.toBeInTheDocument();
});
it('FE-ADMIN-ADDON-045: finds an addon by name or description and shows the ones on or off', async () => {
const user = userEvent.setup();
server.use(
addonsRoute([
buildAddon({ id: 'x-lists', name: 'Todo List', description: 'Track tasks', type: 'trip', enabled: true }),
buildAddon({ id: 'x-costs', name: 'Budget', description: 'Split costs', type: 'trip', enabled: false }),
buildAddon({ id: 'x-holiday', name: 'Vacay', description: 'Holiday planner', type: 'global', enabled: true }),
])
);
render(<AddonManager />);
await screen.findByText('Todo List');
await user.type(screen.getByRole('searchbox', { name: 'Search addons' }), 'costs');
expect(screen.getByText('Budget')).toBeInTheDocument();
expect(screen.queryByText('Todo List')).toBeNull();
expect(screen.queryByText('Vacay')).toBeNull();
await user.clear(screen.getByRole('searchbox', { name: 'Search addons' }));
await user.click(screen.getByRole('button', { name: 'On' }));
expect(screen.getByText('Todo List')).toBeInTheDocument();
expect(screen.getByText('Vacay')).toBeInTheDocument();
expect(screen.queryByText('Budget')).toBeNull();
await user.click(screen.getByRole('button', { name: 'Off' }));
await user.type(screen.getByRole('searchbox', { name: 'Search addons' }), 'nothing like this');
expect(screen.getByText('No addon matches the search or the filter.')).toBeInTheDocument();
});
});
+21 -130
View File
@@ -1,7 +1,6 @@
import { useState, type ComponentType } from 'react'
import type { ComponentType, ReactNode } from 'react'
import { useTranslation } from '../../i18n'
import { useIsDark } from '../../hooks/useIsDark'
import { Puzzle, ListChecks, Wallet, FileText, CalendarDays, Globe, Briefcase, Image, Terminal, Link2, Compass, BookOpen, Sparkles, Luggage, Plane, Bookmark, Users, Loader2, Mountain, CarFront, Search } from 'lucide-react'
import { Puzzle, ListChecks, Wallet, FileText, CalendarDays, Globe, Briefcase, Image, Terminal, Link2, Compass, BookOpen, Sparkles, Luggage, Plane, Bookmark, Users, Loader2, Mountain, CarFront } from 'lucide-react'
import EmptyState from '../shared/EmptyState'
import DawarichIcon from '../shared/DawarichIcon'
import AirTrailIcon from '../shared/AirTrailIcon'
@@ -9,8 +8,7 @@ import { DOCUMENT_PROVIDER_ICONS } from '../shared/documentProviderIconMap'
import AddonTile from './AddonTile'
import AddonSubRow from './AddonSubRow'
import { Tooltip } from '../shared/Tooltip'
import { fs } from '../shared/DialogShell'
import { SettingsCard, StatusPill } from '../Settings/settingsKit'
import { SettingsCard, SettingsColumns, StatusPill } from '../Settings/settingsKit'
import { type Addon, type CollabFeatures, COLLAB_SUB_FEATURES, getAddonLabel } from './addons/addonModel'
import { useAddonManager } from './addons/useAddonManager'
import AiAddonTile from './addons/AiAddonTile'
@@ -67,9 +65,15 @@ const TYPE_META: Record<string, { icon: ComponentType<{ size?: number }>; labelK
integration: { icon: Link2, labelKey: 'admin.addons.type.integration', hintKey: 'admin.addons.integrationHint' },
}
export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking, collabFeatures, onToggleCollabFeature }: { bagTrackingEnabled?: boolean; onToggleBagTracking?: () => void; collabFeatures?: CollabFeatures; onToggleCollabFeature?: (key: string) => void }) {
export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking, collabFeatures, onToggleCollabFeature, aside }: {
bagTrackingEnabled?: boolean
onToggleBagTracking?: () => void
collabFeatures?: CollabFeatures
onToggleCollabFeature?: (key: string) => void
/** Cards that set up what the integrations reach (flight status, booking mails), under them in the right column. */
aside?: ReactNode
}) {
const { t } = useTranslation()
const dark = useIsDark()
const {
addons, loading, handleToggle, tripAddons, globalAddons, integrationAddons, aiAddons, providerOptions, documentProviderOptions,
toursWanderer,
@@ -77,9 +81,6 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
toggleToursWanderer,
mapSwitches,
} = useAddonManager()
const [query, setQuery] = useState('')
const [view, setView] = useState<AddonView>('all')
if (loading) {
return (
<SettingsCard icon={Puzzle} title={t('admin.addons.title')}>
@@ -210,32 +211,12 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
{ key: 'global', addons: globalAddons },
{ key: 'integration', addons: integrationAddons },
].filter(g => g.addons.length > 0 || (g.key === 'integration' && aiAddons.length > 0))
const enabledCount = addons.filter(a => a.type !== 'photo_provider' && a.type !== 'document_provider' && a.enabled).length
const totalCount = tripAddons.length + globalAddons.length + integrationAddons.length + aiAddons.length
const subtitle = (
<span className="inline-flex flex-wrap items-center gap-1">
{t('admin.addons.subtitleBefore')}
<img src={dark ? '/text-light.svg' : '/text-dark.svg'} alt="TREK" style={{ height: 10, verticalAlign: 'middle', opacity: 0.7 }} />
{t('admin.addons.subtitleAfter')}
</span>
)
/** Whether an addon is shown under the search and the filter. */
const shown = (addon: Addon) => {
if (view === 'on' && !addon.enabled) return false
if (view === 'off' && addon.enabled) return false
const q = query.trim().toLocaleLowerCase()
if (!q) return true
const label = getAddonLabel(t, addon)
return `${label.name} ${label.description ?? ''}`.toLocaleLowerCase().includes(q)
}
const card = (g: (typeof groups)[number]) => {
const meta = TYPE_META[g.key]
const all = g.key === 'integration' ? [...aiAddons, ...g.addons] : g.addons
const visible = g.addons.filter(shown)
const ai = g.key === 'integration' && aiAddons.some(shown)
const visible = g.addons
const ai = g.key === 'integration' && aiAddons.length > 0
if (!visible.length && !ai) return null
const on = all.filter(a => a.enabled).length
return (
@@ -249,8 +230,8 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
<span className="inline-flex"><StatusPill tone={on > 0 ? 'success' : 'neutral'}>{on}/{all.length}</StatusPill></span>
</Tooltip>
)}
bodyClassName="p-3"
>
{/* The addons in one rounded block of rows, as every settings card holds its rows. */}
<div className="divide-y divide-edge-faint overflow-hidden rounded-[12px] border border-edge-faint bg-surface-card">
{/* The AI addons share a connection and a settings dialog, so they head the card as one tile. */}
{ai && <AiAddonTile addons={aiAddons} onToggle={handleToggle} />}
@@ -263,103 +244,13 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
const [first, ...rest] = groups
const cards = { start: first ? card(first) : null, end: rest.map(card).filter(Boolean) }
return (
<>
<SettingsCard
icon={Puzzle}
title={t('admin.addons.title')}
hint={subtitle}
badge={totalCount > 0 ? (
<Tooltip label={t('admin.addons.group.count', { enabled: enabledCount, total: totalCount })}>
<span className="inline-flex">
<StatusPill tone={enabledCount > 0 ? 'success' : 'neutral'}>{enabledCount}/{totalCount}</StatusPill>
</span>
</Tooltip>
) : undefined}
>
{addons.length === 0
? <EmptyState scene="idle" title={t('admin.addons.noAddons')} surface="var(--bg-secondary)" />
: <AddonToolbar groups={groups.map(g => ({ key: g.key, addons: g.key === 'integration' ? [...aiAddons, ...g.addons] : g.addons }))} query={query} onQuery={setQuery} view={view} onView={setView} t={t} />}
if (addons.length === 0) {
return (
<SettingsCard icon={Puzzle} title={t('admin.addons.title')}>
<EmptyState scene="idle" title={t('admin.addons.noAddons')} surface="var(--bg-secondary)" />
</SettingsCard>
)
}
{addons.length > 0 && (cards.start || cards.end.length > 0 ? (
<div className="grid grid-cols-1 gap-x-5 xl:grid-cols-2 xl:items-start">
<div className="min-w-0">{cards.start}</div>
<div className="min-w-0">{cards.end}</div>
</div>
) : (
<p className="m-0 rounded-2xl border border-dashed border-edge-faint px-4 py-8 text-center text-content-muted" style={fs(13, 'body')}>
{t('admin.addons.noMatch')}
</p>
))}
</>
)
}
type AddonView = 'all' | 'on' | 'off'
/**
* The head card's body: a tile per type with how many of it are on, then a
* search over the addons' names and descriptions and a switch between all,
* the ones on and the ones off.
*/
function AddonToolbar({ groups, query, onQuery, view, onView, t }: {
groups: { key: string; addons: Addon[] }[]
query: string
onQuery: (q: string) => void
view: AddonView
onView: (v: AddonView) => void
t: (key: string, params?: Record<string, unknown>) => string
}) {
return (
<>
<div className="grid grid-cols-1 gap-2 sm:grid-cols-3">
{groups.map(g => {
const meta = TYPE_META[g.key]
const Icon = meta.icon
const on = g.addons.filter(a => a.enabled).length
return (
<div key={g.key} className="flex items-center gap-3 rounded-[12px] border border-edge-faint bg-surface-card px-3 py-2.5">
<span className="grid h-8 w-8 flex-none place-items-center rounded-[10px] bg-surface-secondary text-content-secondary">
<Icon size={15} />
</span>
<span className="min-w-0 flex-1">
<span className="block truncate font-semibold text-content" style={fs(12.5, 'body')}>{t(meta.labelKey)}</span>
<span className="block text-content-faint" style={fs(11)}>{t('admin.addons.group.count', { enabled: on, total: g.addons.length })}</span>
</span>
<span className={`font-geist font-bold tabular-nums ${on > 0 ? 'text-content' : 'text-content-faint'}`} style={fs(18, 'body')} aria-hidden>{on}</span>
</div>
)
})}
</div>
<div className="flex flex-col gap-2 sm:flex-row sm:items-center">
<label className="relative flex min-w-0 flex-1 items-center">
<Search size={14} className="pointer-events-none absolute start-3 text-content-faint" />
<input
type="search"
value={query}
onChange={e => onQuery(e.target.value)}
placeholder={t('admin.addons.search')}
aria-label={t('admin.addons.search')}
className="h-9 w-full rounded-[10px] border border-edge-faint bg-surface-card ps-8 pe-3 text-content outline-none transition-colors placeholder:text-content-faint focus:border-accent"
style={fs(13, 'body')}
/>
</label>
<div className="inline-flex flex-none gap-1 rounded-[10px] bg-surface-tertiary p-1" role="group" aria-label={t('admin.addons.filter')}>
{(['all', 'on', 'off'] as const).map(v => (
<button
key={v}
type="button"
onClick={() => onView(v)}
aria-pressed={view === v}
className={`h-7 rounded-[8px] px-3 font-medium transition-colors ${view === v ? 'bg-surface-card text-content shadow-sm' : 'text-content-muted hover:text-content'}`}
style={fs(12.5, 'body')}
>
{t(`admin.addons.filter.${v}`)}
</button>
))}
</div>
</div>
</>
)
return <SettingsColumns left={cards.start} right={<>{cards.end}{aside}</>} />
}
+2 -1
View File
@@ -33,7 +33,8 @@ export default function AddonSubRow({
onToggle: () => void
}) {
return (
<li className="flex min-h-[44px] items-center gap-2.5 px-3 py-1.5">
// Indented under the addon's name (16 + 32 + 12 px), one step quieter than it.
<li className="flex min-h-[44px] items-center gap-2.5 py-1.5 pe-4 ps-[60px]">
{icon
? <span className={`grid h-6 w-6 flex-none place-items-center ${enabled ? 'text-content-muted' : 'text-content-faint'}`}>{icon}</span>
: <span className="w-6 flex-none" aria-hidden />}
+26 -86
View File
@@ -1,30 +1,18 @@
import { Children, type ReactNode, isValidElement, useId, useState } from 'react'
import { Children, type ReactNode } from 'react'
import ToggleSwitch from '../Settings/ToggleSwitch'
import { HintMark } from '../Settings/settingsKit'
import { fs } from '../shared/DialogShell'
import { ChevronDown } from 'lucide-react'
import { useTranslation } from '../../i18n'
/** How many of the shelf's rows are switched on, read from the rows' own `enabled`. */
function enabledRows(rows: ReactNode[]): number {
return rows.filter((row) => isValidElement<{ enabled?: boolean }>(row) && row.props.enabled === true).length
}
/**
* One addon in its type's card: a row like the bag sidebar's (#2541), with the
* icon tile on the left, name and description beside it and the switch on the
* right. Its sub-features sit under it in a grey inset box of hairline rows.
* One addon in its type's card, as a settings row: the icon tile, the name with
* its description behind an info mark, and the switch on the right. Its
* sub-features follow as indented rows while it is on, in the same list and with
* the same hairlines: no box of their own, nothing folded away.
*
* The on/off state rides on the icon tile and the switch: a switched-off addon
* greys its tile and its description, but keeps its name at full strength. The
* name is the tile's identity, not its state; greying it out reads as "broken"
* rather than "not enabled".
*
* The row is not a click target, only the switches are. No lift, no pointer
* cursor, no `role="button"`.
*
* A shelf of more than one row starts folded behind a bar that says how many
* options there are and how many are on, so a page of addons stays short and
* the options are still plain to see.
* greys its tile but keeps its name at full strength. The name is the row's
* identity, not its state; greying it out reads as "broken" rather than "not
* enabled". The row is not a click target, only the switches are.
*/
export default function AddonTile({
icon,
@@ -32,90 +20,42 @@ export default function AddonTile({
description,
enabled,
onToggle,
trailing,
children,
}: {
icon: ReactNode
name: string
description?: string
enabled: boolean
onToggle: () => void
/** The sub-shelf: `<AddonSubRow>` children. */
/** The addon's switch; leave it out for a row that shows a state instead (`trailing`). */
onToggle?: () => void
/** Shown in place of the switch. */
trailing?: ReactNode
/** The sub-features: `<AddonSubRow>` children. */
children?: ReactNode
}) {
const { t } = useTranslation()
const shelfId = useId()
const [open, setOpen] = useState(false)
const rows = Children.toArray(children)
const foldable = rows.length > 1
const active = enabledRows(rows)
return (
<article className="px-3.5 py-3 transition-colors duration-150 focus-within:bg-surface-secondary">
<div className="flex items-start gap-3">
<article>
<div className="flex items-center gap-3 px-4 py-3">
<div
// overflow-hidden so a brand mark that fills the slot keeps the slot's
// rounded corners instead of squaring them off.
className={`grid h-9 w-9 flex-none place-items-center overflow-hidden rounded-[10px] transition-colors ${
enabled ? 'bg-surface-card text-content shadow-sm ring-1 ring-edge-faint' : 'bg-surface-tertiary text-content-faint'
className={`grid h-8 w-8 flex-none place-items-center overflow-hidden rounded-[10px] transition-colors ${
enabled ? 'bg-surface-card text-content-secondary shadow-sm ring-1 ring-edge-faint' : 'bg-surface-tertiary text-content-faint'
}`}
>
{icon}
</div>
<div className="min-w-0 flex-1 pt-px">
<h4 className="m-0 truncate font-semibold text-content" style={fs(13, 'body')} title={name}>
{name}
</h4>
<p
className={`m-0 mt-0.5 line-clamp-2 leading-snug ${enabled ? 'text-content-muted' : 'text-content-faint'}`}
style={fs(11.5)}
title={description}
>
{description}
</p>
<div className="flex min-w-0 flex-1 items-center gap-1.5">
<h4 className="m-0 truncate font-medium text-content" style={fs(13, 'body')}>{name}</h4>
{description && <HintMark hint={description} />}
</div>
<div className="flex-none pt-1.5">
<ToggleSwitch on={enabled} onToggle={onToggle} label={name} />
<div className="flex flex-none items-center">
{trailing ?? (onToggle && <ToggleSwitch on={enabled} onToggle={onToggle} label={name} />)}
</div>
</div>
{rows.length > 0 && (
<div className="mt-3 overflow-hidden rounded-[12px] border border-edge-faint bg-surface-secondary">
{foldable && (
<button
type="button"
onClick={() => setOpen((value) => !value)}
aria-expanded={open}
aria-controls={shelfId}
className={`flex min-h-[44px] w-full items-center gap-2.5 px-3 py-1.5 text-start transition-colors hover:bg-surface-tertiary focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent ${open ? 'border-b border-edge-faint' : ''}`}
>
{/* The same slot and type as a row below, so the bar reads as one more row. */}
<span className="grid h-6 w-6 flex-none place-items-center text-content-muted">
<ChevronDown
size={15}
strokeWidth={2.2}
className={`transition-transform duration-150 ${open ? 'rotate-180' : ''}`}
/>
</span>
<span className="min-w-0 flex-1 truncate font-medium text-content" style={fs(12.5, 'body')}>
{t('admin.addons.subOptions', { count: rows.length })}
</span>
<span
className={`flex-none rounded-full px-2 py-0.5 font-semibold ${active > 0 ? 'bg-accent text-accent-text' : 'bg-surface-tertiary text-content-muted'}`}
style={fs(10.5, 'body')}
>
{t('admin.addons.subOptionsOn', { count: active })}
</span>
</button>
)}
{/* Sitting inside the parent on its own fill is enough to say these belong
to it: no rail, no indent guides. */}
{(!foldable || open) && (
<ul id={shelfId} className="m-0 list-none divide-y divide-edge-faint p-0">{children}</ul>
)}
</div>
)}
{/* An empty shelf (a tours addon without its options here) draws no line. */}
{Children.count(children) > 0 && <ul className="m-0 list-none divide-y divide-edge-faint border-t border-edge-faint p-0">{children}</ul>}
</article>
)
}
@@ -5,7 +5,7 @@ import { useFormatDate } from '../../hooks/useDateFormat'
import ConfirmDialog from '../shared/ConfirmDialog'
import { Tooltip } from '../shared/Tooltip'
import { fs } from '../shared/DialogShell'
import { SETTINGS_ICON_BUTTON, SettingRows, SettingsCard, SettingsHint, StatusPill } from '../Settings/settingsKit'
import { SETTINGS_ICON_BUTTON, SettingRows, SettingsCard, SettingsHint, StatusPill, SettingsColumns } from '../Settings/settingsKit'
import { SCOPES_PREVIEW, useMcpTokensAdmin } from './useMcpTokensAdmin'
const ROW = 'flex flex-wrap items-center gap-x-4 gap-y-2 px-3.5 py-3'
@@ -72,6 +72,9 @@ export default function AdminMcpTokensPanel() {
return (
<div>
{/* The sessions and the tokens side by side: two lists of the same kind. */}
<SettingsColumns
left={<>
{/* OAuth Sessions. The tab's own subtitle sits in its band: the sidebar
already names the tab, so a bare heading over the cards only repeated it. */}
<SettingsCard
@@ -116,7 +119,8 @@ export default function AdminMcpTokensPanel() {
</SettingRows>
)}
</SettingsCard>
</>}
right={<>
{/* MCP Tokens */}
<SettingsCard
icon={KeyRound}
@@ -147,6 +151,8 @@ export default function AdminMcpTokensPanel() {
</SettingRows>
)}
</SettingsCard>
</>}
/>
{/* Revoke OAuth session */}
<ConfirmDialog
@@ -184,7 +184,7 @@ export default function AdminPluginsPanel() {
<input id="plugin-dev-link" value={linkPath} onChange={(e) => setLinkPath(e.target.value)} spellCheck={false}
placeholder={t('admin.plugins.devLinkPathPlaceholder')} className={`${INPUT} font-mono`} />
</EditorField>
<button type="submit" disabled={!linkPath.trim() || busy === '__link'} className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
<button type="submit" disabled={!linkPath.trim() || busy === '__link'} className={SETTINGS_BUTTON_PRIMARY}>
<Link2 size={14} /> {t('admin.plugins.devLinkButton')}
</button>
</div>
@@ -223,7 +223,7 @@ export default function AdminPluginsPanel() {
surface="var(--bg-secondary)"
size={88}
action={(
<button type="button" onClick={openDiscover} className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
<button type="button" onClick={openDiscover} className={SETTINGS_BUTTON_PRIMARY}>
<Download size={14} /> {t('admin.plugins.tabDiscover')}
</button>
)}
@@ -627,7 +627,7 @@ function EgressDialog({ data, draft, setDraft, saving, error, onSave, onClose, t
className={`${INPUT} flex-1 font-mono`}
/>
<button type="button" disabled={saving || !draft.trim()} onClick={() => onSave([...data.hosts, draft.trim()])}
className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
className={SETTINGS_BUTTON_PRIMARY}>
{t('common.add')}
</button>
</div>
@@ -68,14 +68,14 @@ export default function AuditLogPanel({ serverTimezone }: AuditLogPanelProps): R
icon={ClipboardList}
title={t('admin.tabs.audit')}
hint={t('admin.audit.subtitle')}
badge={<StatusPill>{t('admin.audit.showing', { count: entries.length, total })}</StatusPill>}
// The count only once there is one: never "0 of 0" while the first page loads.
badge={total > 0 ? <StatusPill>{t('admin.audit.showing', { count: entries.length, total })}</StatusPill> : undefined}
action={
<button
type="button"
disabled={loading}
onClick={() => loadFirstPage()}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
<RefreshCw size={14} strokeWidth={2.2} className={loading ? 'animate-spin' : ''} />
{t('admin.audit.refresh')}
@@ -91,7 +91,6 @@ export default function AuditLogPanel({ serverTimezone }: AuditLogPanelProps): R
disabled={loading}
onClick={() => loadMore()}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
{t('admin.audit.loadMore')}
</button>
+1 -4
View File
@@ -56,7 +56,6 @@ export default function BackupPanel() {
onClick={() => fileInputRef.current?.click()}
disabled={isUploading}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
title={isUploading ? t('backup.uploading') : t('backup.upload')}
>
{isUploading
@@ -69,7 +68,6 @@ export default function BackupPanel() {
onClick={handleCreate}
disabled={isCreating}
className={SETTINGS_BUTTON_PRIMARY}
style={fs(12.5, 'body')}
title={isCreating ? t('backup.creating') : t('backup.create')}
>
{isCreating
@@ -97,7 +95,7 @@ export default function BackupPanel() {
surface="var(--bg-secondary)"
className="!py-6"
action={
<button type="button" onClick={handleCreate} className={SETTINGS_BUTTON} style={fs(12.5, 'body')}>
<button type="button" onClick={handleCreate} className={SETTINGS_BUTTON}>
<Plus size={14} strokeWidth={2.2} />
{t('backup.createFirst')}
</button>
@@ -295,7 +293,6 @@ export default function BackupPanel() {
onClick={handleSaveAutoSettings}
disabled={autoSettingsSaving || !autoSettingsDirty}
className={SETTINGS_BUTTON_PRIMARY}
style={fs(13, 'body')}
>
{autoSettingsSaving
? <Loader2 size={14} strokeWidth={2.2} className="animate-spin" />
@@ -135,7 +135,7 @@ export default function CategoryManager() {
hint={t('categories.subtitle')}
badge={!isLoading && categories.length > 0 ? <StatusPill>{categories.length}</StatusPill> : undefined}
action={
<button type="button" onClick={handleStartCreate} className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
<button type="button" onClick={handleStartCreate} className={SETTINGS_BUTTON_PRIMARY}>
<Plus size={14} strokeWidth={2.2} />
<span className="hidden sm:inline">{t('categories.new')}</span>
</button>
@@ -1,8 +1,8 @@
import React from 'react'
import { Loader2, Map as MapIcon, Settings2 } from 'lucide-react'
import { Loader2, Map as MapIcon, Settings2, Route } from 'lucide-react'
import { useTranslation } from '../../i18n'
import Section from '../Settings/Section'
import { SettingRows, SettingsHint } from '../Settings/settingsKit'
import { SettingRow, SettingRows, SettingsColumns } from '../Settings/settingsKit'
import { fs } from '../shared/DialogShell'
import { EditorField, INPUT, Segmented } from '../shared/dialogParts'
import CustomSelect from '../shared/CustomSelect'
@@ -34,15 +34,8 @@ function ChoiceRow({
stacked?: boolean
children: React.ReactNode
}) {
return (
<div className={stacked ? 'flex flex-col gap-2.5 px-3.5 py-3' : 'flex flex-wrap items-center gap-x-4 gap-y-2 px-3.5 py-3'}>
<label className={`block font-medium text-content ${stacked ? '' : 'min-w-0 flex-1 basis-40'}`} style={fs(13, 'body')}>
{label}
</label>
{hint && <p className="-mt-2 m-0 leading-snug text-content-faint" style={fs(11.5)}>{hint}</p>}
<div className={stacked ? 'min-w-0' : 'flex min-w-0 flex-none items-center'}>{children}</div>
</div>
)
// The settings row every page uses, so a default reads like the setting it presets.
return <SettingRow label={label} hint={hint} control={children} stacked={stacked} />
}
/** A wide field box inside the white rows, for the map card's token and style. */
@@ -114,23 +107,11 @@ export default function DefaultUserSettingsTab(): React.ReactElement {
const darkMode = defaults.dark_mode
return (
<div>
<SettingsHint className="mb-4">
{t('admin.defaultSettings.description')}
</SettingsHint>
<SettingsColumns
left={
<>
{/* Two columns from xl up, the same idea as the Settings tab: as one flat list
the map fields sat a screen below the units while the right half of the page
stayed empty. Grouped by subject rather than by height — what a user ends up
seeing on the left, everything that configures the map on the right.
The columns are deliberately uneven: the left one never needs more than the
widest option row, while the right one holds four text fields whose values
are 60-character tile URLs. Only the column gap is set, because Section
carries its own bottom margin and a row gap would double it once the grid
collapses. Two cards can sit straight in the grid; a third would need the
explicit per-column stacks the Settings tab uses, or it leaves a hole. */}
<div className="grid grid-cols-1 gap-x-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)] xl:items-start">
<Section title={t('admin.defaultSettings.title')} icon={Settings2}>
<Section title={t('admin.defaultSettings.title')} icon={Settings2} hint={t('admin.defaultSettings.description')}>
<SettingRows>
{/* Color Mode */}
<ChoiceRow label={<>{t('settings.colorMode')} <ResetButton {...resetOf('dark_mode')} /></>}>
@@ -207,7 +188,7 @@ export default function DefaultUserSettingsTab(): React.ReactElement {
</ChoiceRow>
{/* Default Currency */}
<ChoiceRow label={<>{t('settings.currency')} <ResetButton {...resetOf('default_currency')} /></>}>
<ChoiceRow label={<>{t('settings.currency')} <ResetButton {...resetOf('default_currency')} /></>} hint={t('settings.currencyHint')}>
<div className="w-[220px] max-w-full">
<CustomSelect
value={defaults.default_currency || ''}
@@ -232,9 +213,17 @@ export default function DefaultUserSettingsTab(): React.ReactElement {
/>
</ChoiceRow>
</SettingRows>
<SettingsHint className="-mt-2">{t('settings.currencyHint')}</SettingsHint>
</Section>
{/* Which engines answer routes, under the defaults: on its own card it keeps
the two columns about as long as each other. */}
{!managed && (
<Section title={t('admin.defaultSettings.routing')} icon={Route}>
<RoutingInstanceFields defaults={defaults} onSave={save} onReset={reset} />
</Section>
)}
</>
}
right={
<Section title={t('settings.map')} icon={MapIcon}>
{/* Map Tile URL */}
<EditorField label={<>{t('settings.mapTemplate')}<ResetButton {...resetOf('map_tile_url')} /></>} hint={t('settings.mapDefaultHint')}>
@@ -270,7 +259,6 @@ export default function DefaultUserSettingsTab(): React.ReactElement {
/>
</EditorField>
)}
{!managed && <RoutingInstanceFields defaults={defaults} onSave={save} onReset={reset} />}
<div className="relative h-[200px] w-full overflow-hidden rounded-[12px] border border-edge-faint">
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
{React.createElement(MapView as any, {
@@ -386,7 +374,7 @@ export default function DefaultUserSettingsTab(): React.ReactElement {
)}
</SettingRows>
</Section>
</div>
</div>
}
/>
)
}
@@ -205,7 +205,6 @@ export default function GitHubPanel({ isPrerelease = false }: { isPrerelease?: b
target="_blank"
rel="noopener noreferrer"
className={`${SETTINGS_BUTTON} no-underline`}
style={fs(12.5, 'body')}
>
<ExternalLink size={13} strokeWidth={2.2} />
GitHub
@@ -298,7 +297,6 @@ export default function GitHubPanel({ isPrerelease = false }: { isPrerelease?: b
onClick={handleLoadMore}
disabled={loadingMore}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
{loadingMore ? <Loader2 size={13} className="animate-spin" /> : <ChevronDown size={13} strokeWidth={2.2} />}
{loadingMore ? t('admin.github.loading') : t('admin.github.loadMore')}
@@ -1,44 +1,40 @@
import { AlertTriangle, Check } from 'lucide-react'
import { Check } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { NumericInput } from '../shared/NumericInput'
import { fs } from '../shared/DialogShell'
import { INPUT } from '../shared/dialogParts'
import { SETTINGS_BUTTON_PRIMARY, StatusPill } from '../Settings/settingsKit'
import { HintMark, SETTINGS_BUTTON_PRIMARY } from '../Settings/settingsKit'
import { useGoogleQuota } from './useGoogleQuota'
/**
* The daily ceiling on Google calls (#1582), as one row of the Google options:
* today's count as a pill beside the name, the number on the right, a save
* today's count as a quiet line under the name, the number on the right, a save
* button only while there is something to save. Laid out like settingsKit's
* SettingRow, but with the pill outside the <label> so the field keeps the
* plain name as its accessible name.
* SettingRow; the count stays outside the <label>, so the field keeps the plain
* name as its accessible name.
*/
export default function GoogleDailyLimitRow() {
const { t } = useTranslation()
const { status, draft, setDraft, dirty, saving, save } = useGoogleQuota()
return (
<div className={`px-3.5 py-3 ${saving ? 'opacity-60' : ''}`}>
<div className={`px-4 py-3 ${saving ? 'opacity-60' : ''}`}>
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
<div className="min-w-0 flex-1 basis-56">
<div className="flex flex-wrap items-center gap-2">
<div className="flex min-w-0 items-center gap-1.5">
<label htmlFor="admin-google-daily-limit" className="font-medium text-content" style={fs(13, 'body')}>{t('admin.googleQuota.title')}</label>
{/* Today's count beside the name it belongs to: a green dot while there is room, amber once the day is used up. */}
{status && (
status.exhausted ? (
<StatusPill tone="warning" icon={<AlertTriangle size={11} strokeWidth={2.4} />}>
{t('admin.googleQuota.reached', { used: status.used_today })}
</StatusPill>
) : (
<StatusPill icon={<span aria-hidden className="me-0.5 h-1.5 w-1.5 rounded-full bg-success" />}>
{status.daily_limit == null
? t('admin.googleQuota.usedToday', { used: status.used_today })
: t('admin.googleQuota.usedOfLimit', { used: status.used_today, limit: status.daily_limit })}
</StatusPill>
)
)}
<HintMark hint={t('admin.googleQuota.subtitle')} />
</div>
<p className="m-0 mt-0.5 leading-snug text-content-faint" style={fs(11.5)}>{t('admin.googleQuota.subtitle')}</p>
{/* Today's count as plain text under the name; in the warning colour once the day is used up. */}
{status && (
<p className={`m-0 mt-0.5 tabular-nums ${status.exhausted ? 'text-warning' : 'text-content-faint'}`} style={fs(11.5)}>
{status.exhausted
? t('admin.googleQuota.reached', { used: status.used_today })
: status.daily_limit == null
? t('admin.googleQuota.usedToday', { used: status.used_today })
: t('admin.googleQuota.usedOfLimit', { used: status.used_today, limit: status.daily_limit })}
</p>
)}
</div>
<div className="flex flex-none items-center gap-2">
<div className="w-32">
@@ -55,7 +51,7 @@ export default function GoogleDailyLimitRow() {
</div>
{dirty && (
<button type="button" onClick={() => void save()} disabled={saving}
className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
className={SETTINGS_BUTTON_PRIMARY}>
<Check size={14} strokeWidth={2.2} />
{t('common.save')}
</button>
@@ -48,7 +48,7 @@ export default function PackingTemplateManager() {
hint={t('admin.packingTemplates.subtitle')}
badge={!isLoading && templates.length > 0 ? <StatusPill>{templates.length}</StatusPill> : undefined}
action={
<button type="button" onClick={() => setShowCreate(true)} className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>
<button type="button" onClick={() => setShowCreate(true)} className={SETTINGS_BUTTON_PRIMARY}>
<Plus size={14} strokeWidth={2.2} /> <span className="hidden sm:inline">{t('admin.packingTemplates.create')}</span>
</button>
}
@@ -1,5 +1,5 @@
import type { PlaceContribField, PlaceContribState } from '@trek/shared';
import { ChevronRight, HeartHandshake, Undo2 } from 'lucide-react';
import { HeartHandshake, Undo2 } from 'lucide-react';
import { useState } from 'react';
import { useTranslation } from '../../i18n';
import type { TranslationFn } from '../../types';
@@ -152,19 +152,13 @@ export default function PlaceContribPanel({ hideWhenSwitchedOff = false }: { hid
)}
{(agreed || state.consent.decision === 'off') && (
<details className="group overflow-hidden rounded-[12px] border border-edge-faint bg-surface-card">
{/* The admin page's fold head (pages/admin/FoldSummary), which a component cannot import. */}
<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"
/>
<div className="overflow-hidden rounded-[12px] border border-edge-faint bg-surface-card">
{/* A plain section head: the settings fold nothing away. */}
<div className="flex items-center gap-2.5 px-3.5 py-2.5">
<span className="font-medium text-content" style={fs(12.5, 'body')}>
{t('admin.contribute.log.title')}
</span>
</summary>
</div>
<div className="flex flex-col gap-3 border-t border-edge-faint p-3">
<PlaceContribLog />
<button
@@ -178,7 +172,7 @@ export default function PlaceContribPanel({ hideWhenSwitchedOff = false }: { hid
{t('admin.contribute.withdraw')}
</button>
</div>
</details>
</div>
)}
{showPrompt && state.eligible && (
@@ -3,6 +3,7 @@ import type { ValhallaProvider } from '@trek/shared'
import { useTranslation } from '../../i18n/TranslationContext'
import { fs } from '../shared/DialogShell'
import { INPUT, LABEL } from '../shared/dialogParts'
import CustomSelect from '../shared/CustomSelect'
export interface RoutingDefaults {
routing_base_url?: string
@@ -121,10 +122,20 @@ function RoutingProviderField({ defaults, onSave, onReset, hintClassName }: Rout
<div className={look.head}>
<label htmlFor={id} className={look.label}>{t('settings.valhallaProvider')}</label>
</div>
<select id={id} value={defaults.routing_valhalla_provider ?? ''} disabled={saving}
onChange={e => void pick(e.target.value)} aria-describedby={`${id}-hint`} className={look.input}>
{PROVIDERS.map(option => <option key={option.value} value={option.value}>{t(option.labelKey)}</option>)}
</select>
{phone ? (
<select id={id} value={defaults.routing_valhalla_provider ?? ''} disabled={saving}
onChange={e => void pick(e.target.value)} aria-describedby={`${id}-hint`} className={look.input}>
{PROVIDERS.map(option => <option key={option.value} value={option.value}>{t(option.labelKey)}</option>)}
</select>
) : (
// The desktop's own select, like every other choice on its settings pages.
<CustomSelect
value={defaults.routing_valhalla_provider ?? ''}
onChange={value => void pick(String(value))}
options={PROVIDERS.map(option => ({ value: option.value, label: t(option.labelKey) }))}
disabled={saving}
/>
)}
<FieldHint id={`${id}-hint`} text={t('settings.valhallaProviderHint')} hintClassName={hintClassName} />
</div>
)
@@ -39,7 +39,7 @@ function Catalog() {
{state.loading && <p role="status" className="m-0 flex items-center gap-2 text-content-muted" style={fs(12.5, 'body')}><Loader2 size={14} className="flex-none animate-spin" />{t('common.loading')}</p>}
{state.error && !state.editor && <div role="alert" className="flex flex-wrap items-center gap-3 rounded-[12px] bg-danger-soft px-3.5 py-2.5 text-danger" style={fs(12.5, 'body')}>
<span className="min-w-0 flex-1 basis-48">{state.error}</span>
<button type="button" disabled={disabled} onClick={() => void state.refresh()} className={SETTINGS_BUTTON} style={fs(12.5, 'body')}>{t('schoolCatalog.retry')}</button>
<button type="button" disabled={disabled} onClick={() => void state.refresh()} className={SETTINGS_BUTTON}>{t('schoolCatalog.retry')}</button>
</div>}
<fieldset disabled={disabled} className={`m-0 flex min-w-0 flex-col gap-4 border-0 p-0 ${state.busy ? 'opacity-60' : ''}`}>
{state.catalog.countries.length > 0 && <div className="flex items-end gap-2">
@@ -59,7 +59,7 @@ function Catalog() {
</Tooltip>
</div>}
{!adding && state.catalog.countries.length === 0 && <div>
<button type="button" onClick={() => setAdding(true)} className={SETTINGS_BUTTON} style={fs(13, 'body')}><Plus size={14} strokeWidth={2.2} />{t('schoolCatalog.addCountry')}</button>
<button type="button" onClick={() => setAdding(true)} className={SETTINGS_BUTTON}><Plus size={14} strokeWidth={2.2} />{t('schoolCatalog.addCountry')}</button>
</div>}
{adding && <form className={PANEL} onSubmit={async event => {
event.preventDefault()
@@ -74,8 +74,8 @@ function Catalog() {
</EditorField>
</div>
<div className="flex justify-end gap-2">
<button type="button" onClick={() => setAdding(false)} className={SETTINGS_BUTTON} style={fs(13, 'body')}>{t('common.cancel')}</button>
<button type="submit" className={SETTINGS_BUTTON_PRIMARY} style={fs(13, 'body')}>{t('common.save')}</button>
<button type="button" onClick={() => setAdding(false)} className={SETTINGS_BUTTON}>{t('common.cancel')}</button>
<button type="submit" className={SETTINGS_BUTTON_PRIMARY}>{t('common.save')}</button>
</div>
</form>}
{selectedCountry && <>
@@ -39,11 +39,10 @@ describe('ServiceIdentityPanel', () => {
const bar = screen.getByRole('progressbar', { name: 'admin.trekApi.quota.service.places' });
expect(bar).toHaveAttribute('aria-valuenow', '2500');
expect(bar).toHaveAttribute('aria-valuemax', '10000');
// What is left is the figure of the tile; used and the limit sit beside it as badges.
expect(screen.getByText('7,500')).toBeInTheDocument();
expect(screen.getByText('2,500')).toBeInTheDocument();
expect(screen.getByText('10,000')).toBeInTheDocument();
expect(screen.getByText('admin.trekApi.quota.limit')).toBeInTheDocument();
// One row per service: used of the limit beside the bar, what is left in its title.
const figure = screen.getByText('2,500').parentElement as HTMLElement;
expect(figure).toHaveTextContent('2,500 / 10,000');
expect(figure).toHaveAttribute('title', 'admin.trekApi.quota.remaining: 7,500');
// The day starts again at the same time for every service, so it is said once, in the header.
expect(screen.getAllByText('admin.trekApi.quota.resets')).toHaveLength(1);
expect(screen.queryByText(/admin\.trekApi\.quota\.hint\./)).toBeNull();
@@ -64,44 +64,39 @@ function ServiceTile({ allowance }: { allowance: ServiceAllowance }) {
const Icon = SERVICE_ICON[allowance.service] ?? MapPin;
const share = quota && quota.limit > 0 ? Math.min(100, (quota.used / quota.limit) * 100) : 100;
// One row per service: its name, the day's use as a bar, used of the limit.
return (
<li
className={`flex min-w-0 flex-col gap-2.5 rounded-xl border border-edge-faint bg-surface-card p-3 shadow-sm ${allowance.inUse ? '' : 'opacity-60'}`}
>
<div className="flex min-w-0 items-center gap-2">
<span className="grid h-7 w-7 flex-none place-items-center rounded-lg bg-surface-tertiary text-content-muted">
<Icon size={14} strokeWidth={2} aria-hidden="true" />
<li className={`flex min-w-0 flex-col gap-1 px-3 py-2.5 ${allowance.inUse ? '' : 'opacity-60'}`}>
<div className="flex min-w-0 items-center gap-3">
<span className="flex w-[34%] min-w-0 flex-none items-center gap-2">
<Icon size={14} strokeWidth={2} aria-hidden="true" className="flex-none text-content-muted" />
<span className="truncate text-caption font-medium text-content-secondary">{name}</span>
</span>
<p className="m-0 truncate text-caption font-medium text-content-secondary">{name}</p>
</div>
{quota && (
<>
<div className="min-w-0">
<p className={`m-0 truncate text-title font-semibold tabular-nums leading-tight ${figureTone(quota)}`}>
{number.format(quota.remaining)}
</p>
<p className="m-0 text-caption text-content-muted">{t('admin.trekApi.quota.remaining')}</p>
</div>
<div
role="progressbar"
aria-label={name}
aria-valuemin={0}
aria-valuemax={quota.limit}
aria-valuenow={quota.used}
className="h-1.5 overflow-hidden rounded-full bg-surface-tertiary"
>
{quota && (
<>
<div
className={`h-full rounded-full transition-[width] duration-500 ${barTone(quota)}`}
style={{ width: `${share}%` }}
/>
</div>
<div className="flex flex-wrap gap-1.5">
<FigureBadge label={t('admin.trekApi.quota.used')} value={number.format(quota.used)} />
<FigureBadge label={t('admin.trekApi.quota.limit')} value={number.format(quota.limit)} />
</div>
</>
)}
role="progressbar"
aria-label={name}
aria-valuemin={0}
aria-valuemax={quota.limit}
aria-valuenow={quota.used}
className="h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-surface-tertiary"
>
<div
className={`h-full rounded-full transition-[width] duration-500 ${barTone(quota)}`}
style={{ width: `${share}%` }}
/>
</div>
<span
className="flex-none text-caption tabular-nums text-content-faint"
title={`${t('admin.trekApi.quota.remaining')}: ${number.format(quota.remaining)}`}
>
<span className={`font-semibold ${figureTone(quota)}`}>{number.format(quota.used)}</span>
{' / '}{number.format(quota.limit)}
</span>
</>
)}
</div>
{note && <p className="m-0 text-caption leading-snug text-content-muted">{note}</p>}
</li>
);
@@ -172,7 +167,7 @@ export default function ServiceIdentityPanel({ managed = false }: { managed?: bo
{status && status.services.length > 0 && (
<ul
aria-label={t('admin.trekApi.quota.title')}
className="m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-3"
className="m-0 flex list-none flex-col divide-y divide-edge-faint overflow-hidden rounded-xl border border-edge-faint bg-surface-card p-0"
>
{status.services.map((allowance) => (
<ServiceTile key={allowance.service} allowance={allowance} />
@@ -4,6 +4,7 @@ import { useTranslation } from '../../../i18n';
import { StatusPill } from '../../Settings/settingsKit';
import { fs } from '../../shared/DialogShell';
import AddonSubRow from '../AddonSubRow';
import AddonTile from '../AddonTile';
import { type Addon, getAddonLabel } from './addonModel';
import { AI_ADDON_ICONS, type AiAddonId } from './aiAddons';
import AiSettingsDialog from './AiAdminConfig';
@@ -26,72 +27,53 @@ export default function AiAddonTile({
const tile = useAiAddonTile(addons);
const anyOn = tile.enabledCount > 0;
return (
<article className="px-3.5 py-3 transition-colors duration-150 focus-within:bg-surface-secondary">
<div className="flex items-start gap-3">
<div
className={`grid h-9 w-9 flex-none place-items-center rounded-[10px] transition-colors ${
anyOn
? 'bg-surface-card text-content shadow-sm ring-1 ring-edge-faint'
: 'bg-surface-tertiary text-content-faint'
}`}
>
<Sparkles size={18} />
</div>
<div className="min-w-0 flex-1 pt-px">
<h4 className="m-0 truncate font-semibold text-content" style={fs(13, 'body')}>
{t('admin.addons.ai.name')}
</h4>
<p
className={`m-0 mt-0.5 line-clamp-2 leading-snug ${anyOn ? 'text-content-muted' : 'text-content-faint'}`}
style={fs(11.5)}
>
{t('admin.addons.ai.description')}
</p>
</div>
<div className="flex-none pt-1">
<>
<AddonTile
icon={<Sparkles size={15} />}
name={t('admin.addons.ai.name')}
description={t('admin.addons.ai.description')}
enabled={anyOn}
trailing={
<StatusPill tone={anyOn ? 'success' : 'neutral'}>
{tile.enabledCount}/{addons.length}
</StatusPill>
</div>
</div>
<div className="mt-3 overflow-hidden rounded-[12px] border border-edge-faint bg-surface-secondary">
<ul className="m-0 list-none divide-y divide-edge-faint p-0">
{addons.map((addon) => {
const Icon = AI_ADDON_ICONS[addon.id as AiAddonId];
const label = getAddonLabel(t, addon);
return (
<AddonSubRow
key={addon.id}
icon={<Icon size={14} />}
title={label.name}
description={label.description}
badge={addon.id === 'ai_assistant' ? <BetaBadge label={t('assistant.setup.beta')} /> : undefined}
enabled={addon.enabled}
onToggle={() => onToggle(addon)}
/>
);
})}
</ul>
}
>
{addons.map((addon) => {
const Icon = AI_ADDON_ICONS[addon.id as AiAddonId];
const label = getAddonLabel(t, addon);
return (
<AddonSubRow
key={addon.id}
icon={<Icon size={14} />}
title={label.name}
description={label.description}
badge={addon.id === 'ai_assistant' ? <BetaBadge label={t('assistant.setup.beta')} /> : undefined}
enabled={addon.enabled}
onToggle={() => onToggle(addon)}
/>
);
})}
{tile.canSetUp && (
<button
type="button"
onClick={tile.openDialog}
className="flex min-h-[44px] w-full items-center gap-2.5 border-t border-edge-faint px-3 py-1.5 text-start transition-colors hover:bg-surface-tertiary focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent"
>
<span className="grid h-6 w-6 flex-none place-items-center text-content-muted">
<Settings2 size={14} />
</span>
<span className="min-w-0 flex-1 truncate font-medium text-content" style={fs(12.5, 'body')}>
{t('admin.addons.ai.setup')}
</span>
<ChevronRight size={15} strokeWidth={2.2} className="flex-none text-content-faint rtl:rotate-180" />
</button>
<li>
<button
type="button"
onClick={tile.openDialog}
className="flex min-h-[44px] w-full items-center gap-2.5 border-0 bg-transparent py-1.5 pe-4 ps-[60px] text-start transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover focus-visible:outline-none"
>
<span className="grid h-6 w-6 flex-none place-items-center text-content-muted">
<Settings2 size={14} />
</span>
<span className="min-w-0 flex-1 truncate font-medium text-content" style={fs(12.5, 'body')}>
{t('admin.addons.ai.setup')}
</span>
<ChevronRight size={15} strokeWidth={2.2} className="flex-none text-content-faint rtl:rotate-180" />
</button>
</li>
)}
</div>
</AddonTile>
{tile.dialogOpen && <AiSettingsDialog addons={addons} onClose={tile.closeDialog} />}
</article>
</>
);
}
@@ -128,7 +128,6 @@ function InstanceConnection({ A }: { A: AiAdmin }) {
type="button"
onClick={cancelReplace}
className={`${SETTINGS_BUTTON} self-start`}
style={fs(12.5, 'body')}
>
{t('common.cancel')}
</button>
@@ -61,7 +61,6 @@ function ParsingSource({ A, P, onOpenConnection }: { A: AiAdmin; P: Parsing; onO
onClick={() => void P.switchToShared()}
disabled={P.saving}
className={`${SETTINGS_BUTTON} self-start`}
style={fs(12.5, 'body')}
>
{t('admin.addons.ai.parsing.useShared')}
</button>
@@ -166,7 +165,6 @@ function LocalModels({ P }: { P: Parsing }) {
onClick={() => P.setModel(m.id)}
disabled={chosen}
className={SETTINGS_BUTTON}
style={fs(12, 'body')}
>
{chosen ? <Check size={13} strokeWidth={2.4} /> : null}
{t(chosen ? 'admin.addons.ai.parsing.selected' : 'admin.addons.ai.parsing.use')}
@@ -177,7 +175,6 @@ function LocalModels({ P }: { P: Parsing }) {
onClick={() => void P.pull(m.id)}
disabled={!!P.pulling}
className={SETTINGS_BUTTON_PRIMARY}
style={fs(12, 'body')}
>
{t(P.pulling === m.id ? 'admin.addons.ai.parsing.pulling' : 'admin.addons.ai.parsing.pull')}
</button>
@@ -1,29 +1,16 @@
import {
AlertTriangle,
CheckCircle,
Copy,
Inbox,
Loader2,
Mail,
PlugZap,
Save,
Upload,
Webhook,
XCircle,
type LucideIcon,
} from 'lucide-react';
import { AlertTriangle, CheckCircle, Copy, Loader2, Mail, PlugZap, Save, XCircle } from 'lucide-react';
import type { ReactNode } from 'react';
import { useTranslation } from '../../../i18n';
import type { TranslationFn } from '../../../types';
import { copyText } from '../../../utils/clipboard';
import { relativeTime } from '../../../utils/relativeTime';
import {
HintMark,
SETTINGS_BUTTON,
SETTINGS_BUTTON_PRIMARY,
SettingRow,
SettingRows,
SettingsCard,
SettingsHint,
StatusPill,
} from '../../Settings/settingsKit';
import ToggleSwitch from '../../Settings/ToggleSwitch';
@@ -45,9 +32,6 @@ import { useMailIngestAdmin, type MailIngestAdmin } from './useMailIngestAdmin';
type T = TranslationFn;
/** The card's buttons sit inside the form, one size below the page's: caption type, tighter padding. */
const SMALL = 'px-3 py-1.5 text-caption';
/** The address a mail service posts to, shown so the admin can paste it into the sender's settings. */
function InboundUrl({ t }: { t: T }) {
const toast = useToast();
@@ -58,7 +42,7 @@ function InboundUrl({ t }: { t: T }) {
<span className={READONLY_BOX}>{url}</span>
<button
type="button"
className={`${SETTINGS_BUTTON} ${SMALL}`}
className={SETTINGS_BUTTON}
aria-label={t('mailAdmin.copyUrl')}
onClick={() => void copyText(url).then((ok) => (ok ? toast.success(t('common.copied')) : undefined))}
>
@@ -171,43 +155,18 @@ function WebhookFields({ admin, form, t, error }: FieldsProps) {
);
}
const STAT_TONE: Record<StatTone, { icon: string; value: string }> = {
neutral: { icon: 'bg-surface-tertiary text-content-muted', value: 'text-content' },
success: { icon: 'bg-success-soft text-success', value: 'text-content' },
warning: { icon: 'bg-warning-soft text-warning', value: 'text-content' },
danger: { icon: 'bg-danger-soft text-danger', value: 'text-danger' },
/** The colour a count takes once it is not zero. */
const STAT_COLOUR: Record<StatTone, string> = {
neutral: 'text-content',
success: 'text-success',
warning: 'text-warning',
danger: 'text-danger',
};
/** One number of the status: its icon in the tone's soft colour, the count large, the label under it. */
function StatTile({
icon: Icon,
label,
value,
tone,
}: {
icon: LucideIcon;
label: string;
value: number;
tone: StatTone;
}) {
const look = STAT_TONE[tone];
return (
<div className="flex min-w-0 items-center gap-2 rounded-lg border border-edge-faint bg-surface-card px-2.5 py-1.5 shadow-sm">
<span className={`grid h-6 w-6 flex-none place-items-center rounded-full ${look.icon}`}>
<Icon size={12} strokeWidth={2.2} />
</span>
<div className="min-w-0">
<div className={`text-body font-semibold tabular-nums leading-tight ${look.value}`}>{value}</div>
<div className="truncate text-caption leading-tight text-content-faint">{label}</div>
</div>
</div>
);
}
/**
* How the import runs, in counts only: no subject, sender or content of a mail
* is ever shown here. A head line with the last successful read (green, or
* amber while the last run failed), then the day's numbers as tiles.
* is ever shown here. One line: the last successful read (green, or amber while
* the last run failed), then the day's numbers as badges.
*/
function StatusBlock({ admin, t, locale }: { admin: MailIngestAdmin; t: T; locale: string }) {
const status = admin.status;
@@ -218,21 +177,25 @@ function StatusBlock({ admin, t, locale }: { admin: MailIngestAdmin; t: T; local
: t('mailAdmin.status.never');
const healthy = !status.last_error && !!status.last_ok_at;
return (
<div className="flex flex-col gap-2 rounded-xl border border-edge-faint bg-surface-secondary p-2.5">
<div className="flex flex-wrap items-center justify-between gap-2">
<span className="text-caption font-semibold uppercase tracking-[0.08em] text-content-faint">
{t('mailAdmin.status.title')}
</span>
<span className="inline-flex items-center gap-1.5 text-caption font-medium text-content-secondary">
<span className={`h-2 w-2 rounded-full ${healthy ? 'bg-success' : 'bg-warning'}`} />
{t('mailAdmin.status.lastRead', { time: lastRead })}
</span>
</div>
<div className="grid grid-cols-4 gap-1.5 max-md:grid-cols-2">
{statTiles(facts, t).map(({ key, ...tile }) => (
<StatTile key={key} {...tile} />
<div className="flex flex-col gap-2">
{/* When it last read, as a plain line with a dot: green while it runs, amber after a failed run. */}
<p className="m-0 flex items-center gap-1.5 text-caption text-content-muted">
<span className={`h-1.5 w-1.5 flex-none rounded-full ${healthy ? 'bg-success' : 'bg-warning'}`} />
{t('mailAdmin.status.lastRead', { time: lastRead })}
</p>
{/* The day's counts as one quiet strip: the number over its name, coloured only when it is not zero. */}
<dl className="m-0 grid grid-cols-2 divide-edge-faint overflow-hidden rounded-[12px] border border-edge-faint bg-surface-card sm:grid-cols-4 sm:divide-x">
{statTiles(facts, t).map(({ key, label, value, tone }) => (
<div key={key} className="flex min-w-0 flex-col-reverse px-3 py-2">
<dt className="truncate text-caption text-content-faint">{label}</dt>
<dd
className={`m-0 text-body font-semibold tabular-nums ${value > 0 ? STAT_COLOUR[tone] : 'text-content'}`}
>
{value}
</dd>
</div>
))}
</div>
</dl>
{status.last_error && (
<p className="m-0 flex items-start gap-1.5 rounded-lg bg-warning-soft px-3 py-2 text-caption leading-snug text-warning">
<AlertTriangle size={13} strokeWidth={2.2} className="mt-px flex-none" />
@@ -256,31 +219,20 @@ function TestResult({ admin, t }: { admin: MailIngestAdmin; t: T }) {
);
}
const TRANSPORT_ICON = { off: Upload, imap: Inbox, webhook: Webhook } as const;
/** What the chosen way of taking mail in means, as a calm blue note under the choice. */
function TransportInfo({ transport, t }: { transport: MailAdminForm['transport']; t: T }) {
const Icon = TRANSPORT_ICON[transport];
return (
<div className="flex items-center gap-3 rounded-xl border border-[color-mix(in_srgb,var(--info)_22%,transparent)] bg-info-soft px-3.5 py-3">
<span className="grid h-8 w-8 flex-none place-items-center rounded-full bg-[color-mix(in_srgb,var(--info)_16%,transparent)] text-info">
<Icon size={15} strokeWidth={2.1} />
</span>
<div className="min-w-0">
<p className="m-0 text-caption font-semibold text-info">{transportLabel(transport, t)}</p>
<p className="m-0 mt-0.5 text-caption leading-snug text-content-secondary">{transportInfo(transport, t)}</p>
</div>
</div>
);
}
/** Everything under the switch: how mail arrives, its fields, then save, test and the status. */
function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailAdminForm; t: T; locale: string }) {
const error = (problem: MailAdminProblem) => (admin.problems.includes(problem) ? problemText(problem, t) : undefined);
return (
<div className="flex flex-col gap-4">
<div className={GRID_2}>
<EditorField label={t('mailAdmin.transport.label')}>
<EditorField
label={
<span className="inline-flex items-center gap-1.5">
{t('mailAdmin.transport.label')}
<HintMark hint={`${transportLabel(form.transport, t)}: ${transportInfo(form.transport, t)}`} />
</span>
}
>
<CustomSelect
value={form.transport}
onChange={(value) => admin.set('transport', TRANSPORTS.find((x) => x === value) ?? 'off')}
@@ -288,9 +240,13 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
/>
</EditorField>
<EditorField
label={t('mailAdmin.aiDaily')}
label={
<span className="inline-flex items-center gap-1.5">
{t('mailAdmin.aiDaily')}
<HintMark hint={t('mailAdmin.aiDailyHint')} />
</span>
}
htmlFor="mail-ai-daily"
hint={t('mailAdmin.aiDailyHint')}
error={error('dailyInvalid')}
>
<input
@@ -302,11 +258,14 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
/>
</EditorField>
</div>
<TransportInfo transport={form.transport} t={t} />
<EditorField
label={t('mailAdmin.template')}
label={
<span className="inline-flex items-center gap-1.5">
{t('mailAdmin.template')}
<HintMark hint={t('mailAdmin.templateHint', { token: '{token}' })} />
</span>
}
htmlFor="mail-template"
hint={t('mailAdmin.templateHint', { token: '{token}' })}
error={error('templateToken')}
>
<input
@@ -319,11 +278,10 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
</EditorField>
{form.transport === 'imap' && <ImapFields admin={admin} form={form} t={t} error={error} />}
{form.transport === 'webhook' && <WebhookFields admin={admin} form={form} t={t} error={error} />}
<SettingsHint>{t('mailAdmin.envHint')}</SettingsHint>
<div className="flex flex-wrap items-center gap-2">
<button
type="button"
className={`${SETTINGS_BUTTON_PRIMARY} ${SMALL}`}
className={SETTINGS_BUTTON_PRIMARY}
disabled={!admin.dirty || admin.problems.length > 0 || admin.saving}
onClick={admin.save}
>
@@ -332,7 +290,7 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
</button>
<button
type="button"
className={`${SETTINGS_BUTTON} ${SMALL}`}
className={SETTINGS_BUTTON}
disabled={admin.testing || admin.dirty || form.transport === 'off'}
onClick={admin.runTest}
>
@@ -340,6 +298,7 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
{t('mailAdmin.test.run')}
</button>
<TestResult admin={admin} t={t} />
<HintMark hint={t('mailAdmin.envHint')} />
</div>
<StatusBlock admin={admin} t={t} locale={locale} />
</div>
@@ -107,7 +107,6 @@ function RequestRow({ request, admin }: { request: PaddleRegionPending; admin: A
disabled={admin.busyId !== null}
onClick={() => void admin.decline(request.id)}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
{t('admin.paddleRegions.requests.decline')}
</button>
@@ -117,7 +116,6 @@ function RequestRow({ request, admin }: { request: PaddleRegionPending; admin: A
disabled={admin.busyId !== null}
onClick={() => void admin.approve(request.id)}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
{busy ? <Loader2 size={13} className="animate-spin" /> : <CloudDownload size={13} strokeWidth={2.2} />}
{t('admin.paddleRegions.requests.approve')}
@@ -66,7 +66,7 @@ function Panel() {
style={fs(12.5, 'body')}
>
<span className="min-w-0 flex-1 basis-48">{admin.error}</span>
<button type="button" onClick={admin.retry} className={SETTINGS_BUTTON} style={fs(12.5, 'body')}>
<button type="button" onClick={admin.retry} className={SETTINGS_BUTTON}>
{t('admin.paddleRegions.retry')}
</button>
</div>
@@ -159,7 +159,6 @@ function CatalogSearch({ admin }: { admin: Admin }) {
disabled={admin.busyId !== null}
onClick={() => void admin.add(hit.id)}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
{admin.busyId === hit.id ? (
<Loader2 size={13} className="animate-spin" />
@@ -29,14 +29,7 @@ import CustomSelect from '../../shared/CustomSelect'
import { Tooltip } from '../../shared/Tooltip'
import { NEUTRAL_TINT, fs } from '../../shared/DialogShell'
import Section from '../../Settings/Section'
import {
SETTINGS_BUTTON,
SETTINGS_BUTTON_PRIMARY,
SETTINGS_ICON_BUTTON,
SettingRows,
SettingsHint,
StatusPill,
} from '../../Settings/settingsKit'
import { SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY, SETTINGS_ICON_BUTTON, SettingRows, SettingsHint, StatusPill, SettingsColumns } from '../../Settings/settingsKit'
import BackendForm from './BackendForm'
import StorageReclaimSection from './StorageReclaimSection'
import { CACHE_CATEGORIES, primaryNameOf } from './storageModel'
@@ -142,6 +135,10 @@ export default function AdminStoragePanel(): React.ReactElement {
</div>
)}
{/* Two columns by length: the health and the backends on the left, which
category goes where on the right, its save bar at the card's foot. */}
<SettingsColumns
left={<>
<Section title={t('storage.health.title')} icon={Activity}>
{state.health.replicaFailures.length === 0 ? (
<p className="m-0 flex items-center gap-2 text-content-muted" style={fs(12.5, 'body')}>
@@ -180,7 +177,6 @@ export default function AdminStoragePanel(): React.ReactElement {
<button type="button"
onClick={startAdd}
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
>
<Plus size={14} strokeWidth={2.2} />
{t('storage.backends.add')}
@@ -486,7 +482,18 @@ export default function AdminStoragePanel(): React.ReactElement {
</SettingRows>
)}
</Section>
{/* Under the backends it cleans up after, which keeps the two columns even. */}
<StorageReclaimSection
reclaim={reclaim}
checking={reclaimChecking}
saving={reclaimSaving}
confirming={reclaimConfirming}
onConfirm={(request) => void handleReclaimConfirm(request)}
onCheck={() => void handleReclaimCheck()}
onDelete={(enabled) => void handleReclaimDelete(enabled)}
/>
</>}
right={<>
<Section title={t('storage.categories.title')} icon={FolderTree}>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
{STORAGE_CATEGORIES.map((category) => {
@@ -544,26 +551,24 @@ export default function AdminStoragePanel(): React.ReactElement {
)
})}
</div>
{/* Saving is part of the card it saves, under a hairline at its foot. */}
<div className="flex flex-wrap items-center gap-3 border-t border-edge-faint pt-4">
<button type="button"
onClick={save}
disabled={!admin.dirty || admin.saving}
className={SETTINGS_BUTTON_PRIMARY}
>
{admin.saving ? <Loader2 size={14} strokeWidth={2.2} className="animate-spin" /> : <Check size={14} strokeWidth={2.2} />}
{t('storage.save')}
</button>
{admin.dirty && <StatusPill tone="warning">{t('storage.unsaved')}</StatusPill>}
{migrationQueue.length > 0 && (
<SettingsHint className="min-w-0 flex-1">
{t('storage.migrate.queued', { categories: categoryNames(t, migrationQueue.map((c) => c.category)) })}
</SettingsHint>
)}
</div>
</Section>
<div className="flex flex-wrap items-center gap-3 rounded-2xl border border-edge-faint bg-surface-secondary px-4 py-3">
<button type="button"
onClick={save}
disabled={!admin.dirty || admin.saving}
className={SETTINGS_BUTTON_PRIMARY}
style={fs(13, 'body')}
>
{admin.saving ? <Loader2 size={14} strokeWidth={2.2} className="animate-spin" /> : <Check size={14} strokeWidth={2.2} />}
{t('storage.save')}
</button>
{admin.dirty && <StatusPill tone="warning">{t('storage.unsaved')}</StatusPill>}
{migrationQueue.length > 0 && (
<SettingsHint className="min-w-0 flex-1">
{t('storage.migrate.queued', { categories: categoryNames(t, migrationQueue.map((c) => c.category)) })}
</SettingsHint>
)}
</div>
{migratePromptOpen && (
<div
role="alertdialog"
@@ -586,7 +591,6 @@ export default function AdminStoragePanel(): React.ReactElement {
<div className="flex flex-wrap items-center gap-2 border-t border-edge-faint px-4 py-3">
<button type="button"
className={SETTINGS_BUTTON}
style={fs(13, 'body')}
onClick={closeMigratePrompt}
>
{t('storage.migrate.promptCancel')}
@@ -594,14 +598,12 @@ export default function AdminStoragePanel(): React.ReactElement {
<span className="flex-1" />
<button type="button"
className={SETTINGS_BUTTON}
style={fs(13, 'body')}
onClick={() => void routeOnlySave()}
>
{t('storage.migrate.routeOnly')}
</button>
<button type="button"
className={SETTINGS_BUTTON_PRIMARY}
style={fs(13, 'body')}
onClick={() => void moveAndSave()}
>
{t('storage.migrate.move')}
@@ -609,6 +611,8 @@ export default function AdminStoragePanel(): React.ReactElement {
</div>
</div>
)}
</>}
/>
{admin.saveError && (
<div role="alert" className="mt-3 flex flex-wrap items-start gap-3 rounded-2xl border border-edge-faint bg-danger-soft px-4 py-3">
<AlertTriangle size={16} strokeWidth={2.2} className="mt-0.5 flex-none text-danger" />
@@ -629,17 +633,6 @@ export default function AdminStoragePanel(): React.ReactElement {
</div>
)}
<div className="mt-5">
<StorageReclaimSection
reclaim={reclaim}
checking={reclaimChecking}
saving={reclaimSaving}
confirming={reclaimConfirming}
onConfirm={(request) => void handleReclaimConfirm(request)}
onCheck={() => void handleReclaimCheck()}
onDelete={(enabled) => void handleReclaimDelete(enabled)}
/>
</div>
{editing && (
<BackendForm
@@ -50,7 +50,6 @@ export default function StorageReclaimSection({
<button
type="button"
className={SETTINGS_BUTTON}
style={fs(12.5, 'body')}
onClick={onCheck}
disabled={checking}
>
@@ -132,7 +131,6 @@ export default function StorageReclaimSection({
<button
type="button"
className={SETTINGS_BUTTON}
style={fs(12, 'body')}
onClick={() => onConfirm({ category: line.category, unreferenced: line.unreferenced })}
disabled={confirming === line.category}
>