feat(admin): live flight status, booking mail import and paddle water data as rows of the addon cards

The addons page listed the trip, global and integration addons and then three
loose cards under them: live flight status, the booking mail import and the
paddle water data. They now sit where they belong, as rows of the cards:

- Live flight status is a row of the trip card, with its switch, locked when
  FLIGHT_LIVE_ENABLED holds it.
- The booking mail import is a row of the integration card with its switch;
  while it is on, "Set up mail import" opens the transport, address, AI
  allowance, test and status in a dialog, the way AI is set up.
- The paddle water data are a row under the Tours addon that opens the
  regions in a dialog, counting the open requests, else the regions.

The phone follows with the same rows and bottom sheets. The setup row and the
setup dialog are shared components (AddonSetupRow, AddonSetupDialog on the
desktop, MAdminOptionRow and MAdminSetupRow on the phone), the card counts
stay the addons' own, and the settings tab loses its features part.
This commit is contained in:
Maurice
2026-11-21 00:23:13 +01:00
parent 6ebd5cf0c7
commit 711015d5fd
52 changed files with 596 additions and 263 deletions
@@ -7,6 +7,7 @@ import { useAuthStore } from '../../store/authStore';
import { useSettingsStore } from '../../store/settingsStore';
import { useAddonStore } from '../../store/addonStore';
import { ToastContainer } from '../shared/Toast';
import { mailIngestRepo } from '../../repo/mailIngestRepo';
import AddonManager from './AddonManager';
function buildAddon(overrides = {}) {
@@ -691,4 +692,40 @@ describe('AddonManager', () => {
expect(roadtrip.querySelector('svg.lucide-car-front')).toBeInTheDocument();
expect(tours.querySelector('svg.lucide-puzzle')).not.toBeInTheDocument();
});
it('FE-ADMIN-ADDON-045: live flight status is a row of the trip card, switched there and locked by the environment', async () => {
server.use(addonsRoute([buildAddon({ id: 'packing', name: 'Lists', icon: 'ListChecks', type: 'trip', enabled: true })]));
const onToggle = vi.fn();
const { unmount } = render(<AddonManager flightLive={{ on: false, locked: false, managed: false, onToggle }} />);
const trip = (await screen.findByRole('heading', { name: 'Trip' })).closest('section')!;
await userEvent.click(within(trip).getByRole('button', { name: 'Follow booked flights live' }));
expect(onToggle).toHaveBeenCalledTimes(1);
// The count stays the addons': the flight row is an instance option beside them.
expect(within(trip).getByText('1/1')).toBeInTheDocument();
unmount();
render(<AddonManager flightLive={{ on: true, locked: true, managed: false, onToggle }} />);
expect(await screen.findByRole('button', { name: 'Follow booked flights live' })).toBeDisabled();
});
it('FE-ADMIN-ADDON-046: the booking mail import is a row of the integration card whose setup opens in a dialog', async () => {
server.use(addonsRoute([buildAddon({ id: 'mcp', name: 'MCP', icon: 'Terminal', type: 'integration', enabled: false })]));
vi.spyOn(mailIngestRepo, 'adminSettings').mockResolvedValue({ mail_ingest_enabled: 'true' });
vi.spyOn(mailIngestRepo, 'adminStatus').mockRejectedValue(new Error('no status'));
render(<AddonManager mailImport />);
const integration = (await screen.findByRole('heading', { name: 'Integration' })).closest('section')!;
expect(within(integration).getByText('Booking mail import')).toBeInTheDocument();
await userEvent.click(await within(integration).findByRole('button', { name: 'Set up mail import' }));
const dialog = await screen.findByRole('dialog');
expect(within(dialog).getByText('How mail arrives')).toBeInTheDocument();
});
it('FE-ADMIN-ADDON-047: without the mail option the integration card has no mail row and nothing is loaded', async () => {
server.use(addonsRoute([buildAddon({ id: 'mcp', name: 'MCP', icon: 'Terminal', type: 'integration', enabled: false })]));
const load = vi.spyOn(mailIngestRepo, 'adminSettings');
render(<AddonManager />);
await screen.findByRole('heading', { name: 'Integration' });
expect(screen.queryByText('Booking mail import')).not.toBeInTheDocument();
expect(load).not.toHaveBeenCalled();
});
});
+47 -8
View File
@@ -1,6 +1,6 @@
import type { ComponentType, ReactNode } from 'react'
import type { ComponentType } from 'react'
import { useTranslation } from '../../i18n'
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 { Puzzle, ListChecks, Wallet, FileText, CalendarDays, Globe, Briefcase, Image, Terminal, Link2, Compass, BookOpen, Sparkles, Luggage, Plane, Bookmark, Users, Loader2, Mountain, CarFront, Radar } from 'lucide-react'
import EmptyState from '../shared/EmptyState'
import DawarichIcon from '../shared/DawarichIcon'
import AirTrailIcon from '../shared/AirTrailIcon'
@@ -12,6 +12,9 @@ import { SettingsCard, SettingsColumns, StatusPill } from '../Settings/settingsK
import { type Addon, type CollabFeatures, COLLAB_SUB_FEATURES, getAddonLabel } from './addons/addonModel'
import { useAddonManager } from './addons/useAddonManager'
import AiAddonTile from './addons/AiAddonTile'
import MailIngestAddonTile from './mailIngest/MailIngestAddonTile'
import PaddleRegionsPanel from './paddle/PaddleRegionsPanel'
import ToggleSwitch from '../Settings/ToggleSwitch'
import { ImmichIcon, SynologyIcon } from './addons/PhotoProviderIcons'
import WandererMark from '../Tours/wanderer/WandererMark'
@@ -65,13 +68,24 @@ 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, aside }: {
/** The live flight status switch, an instance setting that sits with the trip addons. */
export interface FlightLiveOption {
on: boolean
/** The server environment (FLIGHT_LIVE_ENABLED) holds it; the switch shows the state and says why. */
locked: boolean
managed: boolean
onToggle: () => void
}
export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking, collabFeatures, onToggleCollabFeature, flightLive, mailImport = false }: {
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
/** Live flight status, a row of the trip card: it follows the trips' booked flights. */
flightLive?: FlightLiveOption
/** Booking mail import, a row of the integration card with its setup dialog; off on a managed install. */
mailImport?: boolean
}) {
const { t } = useTranslation()
const {
@@ -181,6 +195,8 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
onToggle={() => void toggle()}
/>
)),
// The paddle water data the tour planner reads, set up in a dialog of its own.
<PaddleRegionsPanel key="paddle-regions" />,
]
}
return null
@@ -202,6 +218,9 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
)
}
/** Whether a card holds rows beside its own addons: the AI tile, an instance option. */
const extraRows = (key: string) =>
(key === 'trip' && !!flightLive) || (key === 'integration' && (aiAddons.length > 0 || mailImport))
/* A card per type, the way every other admin tab sets its cards: Trip in the
left column, Global and Integration in the right one, each card with the
dialogs' head band carrying the type, its count and what it means. */
@@ -209,14 +228,14 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
{ key: 'trip', addons: tripAddons },
{ key: 'global', addons: globalAddons },
{ key: 'integration', addons: integrationAddons },
].filter(g => g.addons.length > 0 || (g.key === 'integration' && aiAddons.length > 0))
].filter(g => g.addons.length > 0 || extraRows(g.key))
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
const ai = g.key === 'integration' && aiAddons.length > 0
if (!visible.length && !ai) return null
if (!visible.length && !ai && !extraRows(g.key)) return null
const on = all.filter(a => a.enabled).length
return (
<SettingsCard
@@ -235,6 +254,10 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
{/* The AI addons share a connection and a settings dialog, so they head the card as one tile. */}
{ai && <AiAddonTile addons={aiAddons} onToggle={handleToggle} />}
{visible.map(tile)}
{/* Not addons but instance options of the same kind, as rows of the same card;
the count above stays the addons'. */}
{g.key === 'trip' && flightLive && <FlightLiveTile option={flightLive} />}
{g.key === 'integration' && mailImport && <MailIngestAddonTile />}
</div>
</SettingsCard>
)
@@ -251,5 +274,21 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking,
)
}
return <SettingsColumns start={cards.start} end={<>{cards.end}{aside}</>} />
return <SettingsColumns start={cards.start} end={cards.end} />
}
/** Live flight status as a trip row: on, it follows every booked flight on its day. */
function FlightLiveTile({ option }: { option: FlightLiveOption }) {
const { t } = useTranslation()
const name = t('flightLive.adminTitle')
const hint = option.managed ? t('flightLive.adminHintManaged') : t('flightLive.adminHint')
return (
<AddonTile
icon={<Radar size={18} />}
name={name}
description={option.locked ? `${hint} ${t('flightLive.envLocked')}` : hint}
enabled={option.on}
trailing={<ToggleSwitch on={option.on} label={t('flightLive.adminToggle')} disabled={option.locked} onToggle={option.onToggle} />}
/>
)
}
@@ -0,0 +1,68 @@
import React, { useId, type ReactNode } from 'react';
import { useTranslation } from '../../i18n';
import {
DialogButton,
DialogFooter,
DialogHeader,
DialogShell,
DialogTile,
FooterSpacer,
NEUTRAL_TINT,
} from '../shared/DialogShell';
/**
* The dialog an addon's setup row opens: the icon tile, the addon it belongs
* to above the title, what it sets up below, and one Close, since everything
* inside saves on its own (booking mails, paddle water data).
*/
export default function AddonSetupDialog({
icon,
eyebrow,
title,
sub,
onClose,
blocked = false,
children,
}: {
icon: ReactNode;
eyebrow: string;
title: string;
sub: string;
onClose: () => void;
/** A confirmation stacked on top holds the dialog while it is open. */
blocked?: boolean;
children: ReactNode;
}): React.ReactElement {
const { t } = useTranslation();
const labelId = useId();
return (
<DialogShell
onClose={onClose}
labelledBy={labelId}
width="detail"
blocked={blocked}
header={
<DialogHeader
tile={<DialogTile>{icon}</DialogTile>}
tint={NEUTRAL_TINT}
labelId={labelId}
eyebrow={eyebrow}
title={title}
sub={sub}
subWraps
onClose={onClose}
/>
}
footer={
<DialogFooter>
<FooterSpacer />
<DialogButton variant="primary" onClick={onClose}>
{t('common.close')}
</DialogButton>
</DialogFooter>
}
>
{children}
</DialogShell>
);
}
@@ -0,0 +1,38 @@
import { ChevronRight, Settings2 } from 'lucide-react';
import React, { type ReactNode } from 'react';
import { fs } from '../shared/DialogShell';
/**
* The last row of an addon's shelf that opens its settings dialog: a gear, what
* the dialog sets up, and a chevron. It keeps a card of addons as short as its
* switches and puts the long forms behind one tap (AI, booking mails, paddle
* water data). A badge says what waits inside, such as requests to look at.
*/
export default function AddonSetupRow({
label,
onOpen,
badge,
}: {
label: string;
onOpen: () => void;
badge?: ReactNode;
}): React.ReactElement {
return (
<li>
<button
type="button"
onClick={onOpen}
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')}>
{label}
</span>
{badge}
<ChevronRight size={15} strokeWidth={2.2} className="flex-none text-content-faint rtl:rotate-180" />
</button>
</li>
);
}
@@ -1,8 +1,9 @@
import { ChevronRight, Settings2, Sparkles } from 'lucide-react';
import { Sparkles } from 'lucide-react';
import React from 'react';
import { useTranslation } from '../../../i18n';
import { StatusPill } from '../../Settings/settingsKit';
import { fs } from '../../shared/DialogShell';
import AddonSetupRow from '../AddonSetupRow';
import AddonSubRow from '../AddonSubRow';
import AddonTile from '../AddonTile';
import { type Addon, getAddonLabel } from './addonModel';
@@ -54,23 +55,7 @@ export default function AiAddonTile({
/>
);
})}
{tile.canSetUp && (
<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>
)}
{tile.canSetUp && <AddonSetupRow label={t('admin.addons.ai.setup')} onOpen={tile.openDialog} />}
</AddonTile>
{tile.dialogOpen && <AiSettingsDialog addons={addons} onClose={tile.closeDialog} />}
</>
@@ -1,22 +1,17 @@
import { AlertTriangle, CheckCircle, Copy, Loader2, Mail, PlugZap, Save, XCircle } from 'lucide-react';
import type { ReactNode } from 'react';
import { useState, 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,
StatusPill,
} from '../../Settings/settingsKit';
import { HintMark, SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY, StatusPill } from '../../Settings/settingsKit';
import ToggleSwitch from '../../Settings/ToggleSwitch';
import CustomSelect from '../../shared/CustomSelect';
import { EditorField, GRID_2, INPUT, READONLY_BOX } from '../../shared/dialogParts';
import { useToast } from '../../shared/Toast';
import AddonSetupDialog from '../AddonSetupDialog';
import AddonSetupRow from '../AddonSetupRow';
import AddonTile from '../AddonTile';
import {
TRANSPORTS,
problemText,
@@ -306,32 +301,46 @@ function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailA
}
/**
* The booking mail import in the admin settings of a self-hosted install: the
* instance switch, how mail arrives (IMAP or a signed webhook), the forwarding
* address template, the AI allowance per person and day, a connection test and
* the status in counts. Not shown on a managed install, where the operator
* runs the TREK Cloud relay.
* The booking mail import as a row of the integration card: its switch, and
* while it is on one row to the dialog that sets it up (how mail arrives, the
* forwarding address template, the AI allowance per person and day, a
* connection test and the status in counts). Not shown on a managed install,
* where the operator runs the TREK Cloud relay.
*/
export default function MailIngestAdminCard() {
export default function MailIngestAddonTile() {
const { t, locale } = useTranslation();
const admin = useMailIngestAdmin(true);
const [open, setOpen] = useState(false);
const name = t('mailAdmin.title');
return (
<SettingsCard icon={Mail} title={t('mailAdmin.title')} hint={t('mailAdmin.hint')}>
<SettingRows>
<SettingRow
label={t('mailAdmin.enabled')}
hint={t('mailAdmin.enabledHint')}
control={
<ToggleSwitch
on={admin.enabled}
label={t('mailAdmin.enabled')}
disabled={!admin.loaded}
onToggle={() => admin.toggle(!admin.enabled)}
/>
}
/>
</SettingRows>
{admin.enabled && admin.form && <Setup admin={admin} form={admin.form} t={t} locale={locale} />}
</SettingsCard>
<>
<AddonTile
icon={<Mail size={15} />}
name={name}
description={`${t('mailAdmin.hint')} ${t('mailAdmin.enabledHint')}`}
enabled={admin.enabled}
trailing={
<ToggleSwitch
on={admin.enabled}
label={t('mailAdmin.enabled')}
disabled={!admin.loaded}
onToggle={() => admin.toggle(!admin.enabled)}
/>
}
>
{admin.enabled && admin.form && <AddonSetupRow label={t('mailAdmin.setup')} onOpen={() => setOpen(true)} />}
</AddonTile>
{open && admin.enabled && admin.form && (
<AddonSetupDialog
icon={<Mail size={20} strokeWidth={2} />}
eyebrow={name}
title={t('mailAdmin.setup')}
sub={t('mailAdmin.hint')}
onClose={() => setOpen(false)}
>
<Setup admin={admin} form={admin.form} t={t} locale={locale} />
</AddonSetupDialog>
)}
</>
);
}
@@ -78,17 +78,22 @@ function adminState(overrides: Partial<Admin> = {}, search: Partial<Admin['searc
};
}
function show(overrides: Partial<Admin> = {}, search: Partial<Admin['search']> = {}) {
/** The panel as the Tours shelf shows it: a setup row, opened into its dialog unless asked not to. */
function show(overrides: Partial<Admin> = {}, search: Partial<Admin['search']> = {}, { open = true } = {}) {
const state = adminState(overrides, search);
hook.usePaddleRegionsAdmin.mockReturnValue(state);
return { state, ...render(<PaddleRegionsPanel />) };
const view = render(
<ul>
<PaddleRegionsPanel />
</ul>
);
if (open && state.toursOn) fireEvent.click(setupRow());
return { state, ...view };
}
/** The card's title row, where the number of regions sits beside the title. */
function titleRow(): HTMLElement {
const row = screen.getByRole('heading', { name: 'Paddle water data' }).parentElement;
if (!row) throw new Error('no title row');
return row;
/** The shelf row that opens the dialog, where the count of requests or regions sits beside the title. */
function setupRow(): HTMLElement {
return screen.getAllByRole('button', { name: /^Paddle water data/ })[0];
}
function rowOf(name: string): HTMLElement {
@@ -100,7 +105,7 @@ function rowOf(name: string): HTMLElement {
describe('PaddleRegionsPanel', () => {
it('FE-ADMIN-PADDLEREG-001: renders nothing while the Tours addon is off', () => {
const { container } = show({ toursOn: false, regions: [READY] });
expect(container).toBeEmptyDOMElement();
expect(container.querySelector('ul')).toBeEmptyDOMElement();
});
it('FE-ADMIN-PADDLEREG-002: shows the card with its hint, the attribution and the empty state', () => {
@@ -110,7 +115,7 @@ describe('PaddleRegionsPanel', () => {
expect(screen.getByText(EMPTY)).toBeInTheDocument();
expect(screen.getByText(ATTRIBUTION)).toBeInTheDocument();
// No count beside the title while there is no region.
expect(titleRow()).toHaveTextContent(/^Paddle water data$/);
expect(setupRow()).toHaveTextContent(/^Paddle water data$/);
const search = screen.getByRole('searchbox', { name: 'Add a region' });
expect(search).toBeEnabled();
expect(search).toHaveAttribute('placeholder', 'Search Geofabrik, for example Oberpfalz');
@@ -277,12 +282,31 @@ describe('PaddleRegionsPanel', () => {
}
});
it('FE-ADMIN-PADDLEREG-019: the title carries the number of regions', () => {
it('FE-ADMIN-PADDLEREG-019: the setup row carries the open requests, else the number of regions', () => {
show({ regions: [READY, WAITING, FAILED_FIRST] });
expect(within(titleRow()).getByText('3')).toBeInTheDocument();
expect(within(setupRow()).getByText('3')).toBeInTheDocument();
expect(screen.getAllByTestId('paddle-region-row')).toHaveLength(3);
});
it('FE-ADMIN-PADDLEREG-019b: an open request outranks the region count, a declined one does not count', () => {
const base = { bytes: 1, requested_by: 'elmo', requested_at: '2026-10-18T09:00:00Z' };
show(
{
regions: [READY, WAITING],
requests: [
{ ...base, id: 'norway', name: 'Norway', reason: 'too_large', declined: true },
{ ...base, id: 'saale', name: 'Saale', reason: 'limit', declined: false },
],
},
{},
{ open: false }
);
expect(within(setupRow()).getByText('1')).toBeInTheDocument();
expect(within(setupRow()).queryByText('2')).toBeNull();
// Closed until the row is opened.
expect(screen.queryByRole('dialog')).toBeNull();
});
it('FE-ADMIN-PADDLEREG-020: removing asks first, naming the region, and confirming hands it to the hook', () => {
const { state } = show({ regions: [READY], removing: READY });
const message = 'Oberpfalz and its obstacle data are removed. Paddle tours there then show no data.';
@@ -1,6 +1,6 @@
import type { PaddleRegion, PaddleRegionCatalogEntry } from '@trek/shared';
import { Check, ChevronRight, Loader2, Plus, RefreshCw, Search, Trash2, Waves, WifiOff } from 'lucide-react';
import { useId } from 'react';
import { useId, useState } from 'react';
import { useDateFormat } from '../../../hooks/useDateFormat';
import { useTranslation } from '../../../i18n';
import { formatDisplayDate } from '../../../utils/dateFormat';
@@ -8,7 +8,6 @@ import {
SettingRows,
SETTINGS_BUTTON,
SETTINGS_ICON_BUTTON,
SettingsCard,
SettingsHint,
StatusPill,
} from '../../Settings/settingsKit';
@@ -17,6 +16,8 @@ import { EditorField, INPUT } from '../../shared/dialogParts';
import { fs } from '../../shared/DialogShell';
import ErrorBoundary from '../../shared/ErrorBoundary';
import { Tooltip } from '../../shared/Tooltip';
import AddonSetupDialog from '../AddonSetupDialog';
import AddonSetupRow from '../AddonSetupRow';
import { AutoLoadSettings, AutoOriginPill, RequestList } from './PaddleAutoLoadParts';
import { progressPercent, regionStatusTone } from './paddleRegionsModel';
import { usePaddleRegionsAdmin } from './usePaddleRegionsAdmin';
@@ -27,8 +28,10 @@ type Admin = ReturnType<typeof usePaddleRegionsAdmin>;
* PAD-05A in the admin area: the regions TREK reads paddle obstacles for,
* picked from Geofabrik's list, and (PAD-11C) how TREK loads the region of a
* place a paddler plans in by itself, with the regions that wait for an admin.
* The desktop admin shows this card under the addons while the Tours addon
* is on; the phone has MAdminPaddleRegionsPanel on the same hook.
* The desktop admin shows it as a row of the Tours addon that opens it as a
* dialog while the addon is on; the row counts what waits for the admin (the
* requests) or else the regions. The phone has MAdminPaddleRegionsPanel on
* the same hook.
*/
export default function PaddleRegionsPanel() {
return (
@@ -41,14 +44,42 @@ export default function PaddleRegionsPanel() {
function Panel() {
const { t } = useTranslation();
const admin = usePaddleRegionsAdmin();
const [open, setOpen] = useState(false);
if (!admin.toursOn) return null;
const title = t('admin.paddleRegions.title');
// A declined request no longer waits for anyone; only the open ones ask for a look.
const waiting = admin.requests.filter((r) => !r.declined).length;
const badge =
waiting > 0 ? (
<StatusPill tone="warning">{waiting}</StatusPill>
) : admin.regions.length > 0 ? (
<StatusPill>{admin.regions.length}</StatusPill>
) : undefined;
const close = () => setOpen(false);
return (
<SettingsCard
icon={Waves}
title={t('admin.paddleRegions.title')}
hint={t('admin.paddleRegions.hint')}
badge={admin.regions.length > 0 ? <StatusPill>{admin.regions.length}</StatusPill> : undefined}
>
<>
<AddonSetupRow label={title} onOpen={() => setOpen(true)} badge={badge} />
{open && (
<AddonSetupDialog
icon={<Waves size={20} strokeWidth={2} />}
eyebrow={t('admin.addons.catalog.tours.name')}
title={title}
sub={t('admin.paddleRegions.hint')}
onClose={close}
blocked={admin.removing !== null}
>
<PanelBody admin={admin} />
</AddonSetupDialog>
)}
</>
);
}
/** What the dialog holds: the state of the list, the settings, the requests, the search and the regions. */
function PanelBody({ admin }: { admin: Admin }) {
const { t } = useTranslation();
return (
<div className="flex flex-col gap-4">
{admin.offline && (
<p
role="status"
@@ -86,7 +117,7 @@ function Panel() {
message={t('admin.paddleRegions.removeMessage', { name: admin.removing?.name ?? '' })}
confirmLabel={t('common.remove')}
/>
</SettingsCard>
</div>
);
}