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
+10 -4
View File
@@ -1,5 +1,4 @@
import MAdminSchoolHolidayCatalog from './MAdminSchoolHolidayCatalog'
import MAdminPaddleRegionsPanel from './MAdminPaddleRegionsPanel'
import { useState } from 'react'
import {
ArrowUp,
@@ -246,10 +245,17 @@ export default function MAdmin() {
onToggleBagTracking={toggleBagTracking}
collabFeatures={collabFeatures}
onToggleCollabFeature={toggleCollabFeature}
// Live flight status and the booking mail import are rows of the addon groups,
// and the paddle water data a row under Tours (desktop parity).
flightLive={{
on: admin.flightLive,
locked: admin.flightLiveLocked,
managed: !!managed,
onToggle: () =>
void admin.handleToggleAuthSetting('flight_live_enabled', !admin.flightLive, admin.setFlightLive),
}}
mailImport={!managed}
/>
{/* How the integrations reach the world (live flights, booking mails), beside the addons they serve. */}
<MAdminSettingsSection admin={admin} t={t} part="features" />
<MAdminPaddleRegionsPanel />
</div>
)}
{activeTab === 'plugins' && <MAdminPluginsPanel />}
@@ -3,7 +3,7 @@ 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, Mountain, CarFront, Settings2, ChevronRight,
Sparkles, Luggage, Plane, Bookmark, Users, Mountain, CarFront, Radar,
} from 'lucide-react'
import DawarichIcon from '../../../components/shared/DawarichIcon'
import AirTrailIcon from '../../../components/shared/AirTrailIcon'
@@ -21,7 +21,10 @@ import AiSettingsDialog from '../../../components/Admin/addons/AiAdminConfig'
import { AI_ADDON_ICONS, type AiAddonId } from '../../../components/Admin/addons/aiAddons'
import { useAiAddonTile } from '../../../components/Admin/addons/useAiAddonTile'
import { ImmichIcon, SynologyIcon } from '../../../components/Admin/addons/PhotoProviderIcons'
import { MAdminCard } from './MAdminUi'
import { MAdminCard, MAdminOptionRow, MAdminSetupRow } from './MAdminUi'
import MAdminPaddleRegionsPanel from './MAdminPaddleRegionsPanel'
import MMailIngestAdminCard from './MMailIngestAdminCard'
import type { FlightLiveOption } from '../../../components/Admin/AddonManager'
import MHintLabel from '../../components/MHintLabel'
import WandererMark from '../../../components/Tours/wanderer/WandererMark'
import MSkeleton from '../../components/MSkeleton'
@@ -59,7 +62,16 @@ function AddonIcon({ name, size = 18, enabled = true }: AddonIconProps) {
return <Icon size={size} />
}
export default function MAdminAddonManager({ bagTrackingEnabled, onToggleBagTracking, collabFeatures, onToggleCollabFeature }: { bagTrackingEnabled?: boolean; onToggleBagTracking?: () => void; collabFeatures?: CollabFeatures; onToggleCollabFeature?: (key: string) => void }) {
export default function MAdminAddonManager({ bagTrackingEnabled, onToggleBagTracking, collabFeatures, onToggleCollabFeature, flightLive, mailImport = false }: {
bagTrackingEnabled?: boolean
onToggleBagTracking?: () => void
collabFeatures?: CollabFeatures
onToggleCollabFeature?: (key: string) => void
/** Live flight status, a row of the trip group (desktop parity). */
flightLive?: FlightLiveOption
/** Booking mail import, a row of the integration group with its setup sheet; off on a managed install. */
mailImport?: boolean
}) {
const { t } = useTranslation()
const dark = useIsDark()
const {
@@ -98,7 +110,7 @@ export default function MAdminAddonManager({ bagTrackingEnabled, onToggleBagTrac
) : (
<>
{/* Trip Addons */}
{tripAddons.length > 0 && (
{(tripAddons.length > 0 || flightLive) && (
<MAdminCard>
<MGroupHead icon={Briefcase} label={t('admin.addons.type.trip')} hint={t('admin.addons.tripHint')} />
{tripAddons.map((addon, i) => (
@@ -135,6 +147,7 @@ export default function MAdminAddonManager({ bagTrackingEnabled, onToggleBagTrac
onToggle={() => void toggle()}
/>
))}
<MAdminPaddleRegionsPanel />
</>
)}
{addon.id === 'collab' && addon.enabled && collabFeatures && onToggleCollabFeature && (
@@ -153,6 +166,7 @@ export default function MAdminAddonManager({ bagTrackingEnabled, onToggleBagTrac
)}
</div>
))}
{flightLive && <MFlightLiveRow option={flightLive} first={tripAddons.length === 0} />}
</MAdminCard>
)}
@@ -171,13 +185,14 @@ export default function MAdminAddonManager({ bagTrackingEnabled, onToggleBagTrac
)}
{/* Integration Addons, headed by the AI ones as one group, as on the desktop */}
{(integrationAddons.length > 0 || aiAddons.length > 0) && (
{(integrationAddons.length > 0 || aiAddons.length > 0 || mailImport) && (
<MAdminCard>
<MGroupHead icon={Link2} label={t('admin.addons.type.integration')} hint={t('admin.addons.integrationHint')} />
{aiAddons.length > 0 && <MAiAddons addons={aiAddons} onToggle={handleToggle} />}
{integrationAddons.map((addon, i) => (
<MAddonRow key={addon.id} addon={addon} onToggle={handleToggle} t={t} first={i === 0 && aiAddons.length === 0} />
))}
{mailImport && <MMailIngestAdminCard first={integrationAddons.length === 0 && aiAddons.length === 0} />}
</MAdminCard>
)}
</>
@@ -216,16 +231,28 @@ interface MAddonRowProps {
function MAddonRow({ addon, onToggle, t, first }: MAddonRowProps) {
const label = getAddonLabel(t, addon)
return (
<div className={`flex items-center gap-3 py-[11px] ${first ? '' : 'border-t border-[color:var(--m-rowbr)]'}`}>
{/* overflow-hidden so a brand mark that fills the slot keeps its rounded corners. */}
<span className="flex h-[38px] w-[38px] flex-none items-center justify-center overflow-hidden rounded-[11px] bg-[color:var(--m-ic)] text-m-ink">
<AddonIcon name={addon.icon} size={18} enabled={addon.enabled} />
</span>
<div className="min-w-0 flex-1">
<MHintLabel label={label.name} hint={label.description} />
</div>
<MToggle checked={addon.enabled} ariaLabel={label.name} onChange={() => onToggle(addon)} />
</div>
<MAdminOptionRow
icon={<AddonIcon name={addon.icon} size={18} enabled={addon.enabled} />}
title={label.name}
hint={label.description}
first={first}
trailing={<MToggle checked={addon.enabled} ariaLabel={label.name} onChange={() => onToggle(addon)} />}
/>
)
}
/** Live flight status as a trip row, locked with a word when the server environment holds it. */
function MFlightLiveRow({ option, first }: { option: FlightLiveOption; first: boolean }) {
const { t } = useTranslation()
const hint = option.managed ? t('flightLive.adminHintManaged') : t('flightLive.adminHint')
return (
<MAdminOptionRow
icon={<Radar size={18} />}
title={t('flightLive.adminTitle')}
hint={option.locked ? `${hint} ${t('flightLive.envLocked')}` : hint}
first={first}
trailing={<MToggle checked={option.on} ariaLabel={t('flightLive.adminToggle')} disabled={option.locked} onChange={option.onToggle} />}
/>
)
}
@@ -301,17 +328,7 @@ function MAiAddons({ addons, onToggle }: { addons: Addon[]; onToggle: (addon: Ad
/>
)
})}
{tile.canSetUp && (
<button
type="button"
onClick={tile.openDialog}
className="flex w-full items-center gap-3 border-t border-[color:var(--m-rowbr)] py-[11px] ps-[50px] text-start"
>
<Settings2 size={14} className="flex-none text-m-faint" />
<span className="min-w-0 flex-1 truncate text-[0.75rem] font-bold text-m-ink">{t('admin.addons.ai.setup')}</span>
<ChevronRight size={15} className="flex-none text-m-faint rtl:rotate-180" />
</button>
)}
{tile.canSetUp && <MAdminSetupRow label={t('admin.addons.ai.setup')} onOpen={tile.openDialog} />}
{tile.dialogOpen && <AiSettingsDialog addons={addons} onClose={tile.closeDialog} />}
</div>
)
@@ -15,6 +15,7 @@ import {
Waves,
WifiOff,
} from 'lucide-react';
import { useState } from 'react';
import {
AUTO_LOAD_MODES,
autoLoadSizes,
@@ -28,8 +29,9 @@ import { useTranslation } from '../../../i18n';
import { formatDisplayDate } from '../../../utils/dateFormat';
import MBadge from '../../components/MBadge';
import MChip from '../../components/MChip';
import MSheet from '../../components/MSheet';
import MConfirmSheet from '../settings/MConfirmSheet';
import { MAdminButton, MAdminCard, MAdminClampedText } from './MAdminUi';
import { MAdminButton, MAdminClampedText, MAdminSetupRow, MAdminSheetFrame } from './MAdminUi';
type Admin = ReturnType<typeof usePaddleRegionsAdmin>;
@@ -393,32 +395,49 @@ function Regions({ admin }: { admin: Admin }) {
/**
* PAD-05A/PAD-11C on the phone: the regions TREK reads paddle data for, how it
* loads a paddler's region by itself and the regions that wait for an admin.
* usePaddleRegionsAdmin is the desktop card's state; this is only the markup.
* loads a paddler's region by itself and the regions that wait for an admin, as
* a row under the Tours addon that opens them in a sheet. The row counts the
* open requests, else the regions. usePaddleRegionsAdmin is the desktop
* dialog's state; this is only the markup.
*/
export default function MAdminPaddleRegionsPanel() {
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 ? (
<MBadge caps={false} tone="strong">
{waiting}
</MBadge>
) : admin.regions.length > 0 ? (
<MBadge caps={false}>{admin.regions.length}</MBadge>
) : undefined;
return (
<MAdminCard>
<div className="flex items-start gap-3">
<span className="flex h-[38px] w-[38px] flex-none items-center justify-center rounded-[11px] bg-[color:var(--m-ic)] text-m-ink">
<Waves size={18} />
</span>
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className="min-w-0 truncate text-[length:calc(14px*var(--fs-scale-body,1))] font-extrabold text-m-ink">
{t('admin.paddleRegions.title')}
</span>
{admin.regions.length > 0 && <MBadge caps={false}>{admin.regions.length}</MBadge>}
</div>
<MAdminClampedText className="mt-[2px] text-[length:calc(10px*var(--fs-scale-caption,1))]">
{t('admin.paddleRegions.hint')}
</MAdminClampedText>
</div>
</div>
<>
<MAdminSetupRow label={title} onOpen={() => setOpen(true)} badge={badge} />
{open && (
<MSheet open onClose={() => setOpen(false)} variant="bottom" material="glass" ariaLabel={title}>
<MAdminSheetFrame icon={<Waves size={19} strokeWidth={1.8} />} title={title} onClose={() => setOpen(false)}>
<p className="m-0 font-geist text-[length:calc(10px*var(--fs-scale-caption,1))] leading-relaxed text-m-muted">
{t('admin.paddleRegions.hint')}
</p>
<PanelBody admin={admin} />
</MAdminSheetFrame>
</MSheet>
)}
</>
);
}
/** What the sheet holds: the state of the list, the settings, the requests, the search and the regions. */
function PanelBody({ admin }: { admin: Admin }) {
const { t } = useTranslation();
return (
<>
{admin.offline && (
<p
role="status"
@@ -462,6 +481,6 @@ export default function MAdminPaddleRegionsPanel() {
danger
onConfirm={admin.confirmRemove}
/>
</MAdminCard>
</>
);
}
@@ -6,7 +6,6 @@ import type { useAdmin } from '../../../pages/admin/useAdmin'
import MToggle from '../../components/MToggle'
import { MBlockDisclosure, MProviderBlock, MTrekApiBlock } from './MApiProviderBlocks'
import MAdminOidcCard from './MAdminOidcCard'
import MMailIngestAdminCard from './MMailIngestAdminCard'
import MAdminGoogleDailyLimit from './MAdminGoogleDailyLimit'
import MAdminPlaceContrib from './MAdminPlaceContrib'
import MAdminServiceQuota from './MAdminServiceQuota'
@@ -27,41 +26,22 @@ interface MAdminSettingsSectionProps {
t: TranslationFn
/**
* Which section this renders, cut the way the desktop tabs are: who may sign
* in and what it takes (security), what the install talks to outside
* (services), and the setup of the features the addons switch on (features).
* in and what it takes (security) or what the install talks to outside
* (services). Live flight status and the booking mail import are rows of the
* addon groups (MAdminAddonManager).
*/
part: 'security' | 'services' | 'features'
part: 'security' | 'services'
}
type PartProps = Omit<MAdminSettingsSectionProps, 'part'>
// The admin's security, services and feature setup sections as phone cards,
// The admin's security and services sections as phone cards,
// one function each. All state and mutations come from useAdmin.
export default function MAdminSettingsSection({ admin, t, part }: MAdminSettingsSectionProps) {
if (part === 'features') return <FeaturesPart admin={admin} t={t} />
if (part === 'security') return <SecurityPart admin={admin} t={t} />
return <ServicesPart admin={admin} t={t} />
}
/** Live flights and booking mails: how the integrations of the addons tab reach the world. */
function FeaturesPart({ admin, t }: PartProps) {
const { managed, flightLive, setFlightLive, flightLiveLocked, handleToggleAuthSetting } = admin
return (
<div className="space-y-3">
{/* Live flight status: open ADS-B data, no key, on by default (desktop parity). */}
<FlightLiveCard
t={t}
managed={!!managed}
on={flightLive}
locked={flightLiveLocked}
onChange={(v) => void handleToggleAuthSetting('flight_live_enabled', v, setFlightLive)}
/>
{/* Booking mail import: self-hosted only, the operator runs the TREK Cloud relay (desktop parity). */}
{!managed && <MMailIngestAdminCard />}
</div>
)
}
/** Who may sign in and what it takes, with the one destructive action last. */
function SecurityPart({ admin, t }: PartProps) {
const {
@@ -482,23 +462,3 @@ function ServicesPart({ admin, t }: PartProps) {
</div>
)
}
/** The live flight status switch, locked with a word when the server environment holds it. */
function FlightLiveCard({ t, managed, on, locked, onChange }: {
t: TranslationFn
managed: boolean
on: boolean
locked: boolean
onChange: (on: boolean) => void
}) {
return (
<MAdminCard>
<MAdminCardHead title={t('flightLive.adminTitle')} hint={managed ? t('flightLive.adminHintManaged') : t('flightLive.adminHint')} />
<MAdminRow
title={t('flightLive.adminToggle')}
hint={locked ? t('flightLive.envLocked') : undefined}
trailing={<MToggle checked={on} ariaLabel={t('flightLive.adminToggle')} disabled={locked} onChange={onChange} />}
/>
</MAdminCard>
)
}
+53 -1
View File
@@ -1,5 +1,5 @@
import { InputHTMLAttributes, ReactNode, useState } from 'react'
import { ChevronDown, Eye, EyeOff, Loader2, X } from 'lucide-react'
import { ChevronDown, ChevronRight, Eye, EyeOff, Loader2, Settings2, X } from 'lucide-react'
import { useTranslation } from '../../../i18n'
import MIconBtn from '../../components/MIconBtn'
import MHintLabel from '../../components/MHintLabel'
@@ -61,6 +61,58 @@ export function MAdminRow({
)
}
/**
* A row of the addons screen: the icon tile, the name with its description
* behind the info mark, and the switch. Addons and the instance options that
* sit with them (live flight status, booking mails) share it.
*/
export function MAdminOptionRow({
icon,
title,
hint,
trailing,
first = false,
}: {
icon: ReactNode
title: string
hint?: string
trailing: ReactNode
first?: boolean
}) {
return (
<div className={`flex items-center gap-3 py-[11px] ${first ? '' : 'border-t border-[color:var(--m-rowbr)]'}`}>
{/* overflow-hidden so a brand mark that fills the slot keeps its rounded corners. */}
<span className="flex h-[38px] w-[38px] flex-none items-center justify-center overflow-hidden rounded-[11px] bg-[color:var(--m-ic)] text-m-ink">
{icon}
</span>
<div className="min-w-0 flex-1">
<MHintLabel label={title} hint={hint} />
</div>
{trailing}
</div>
)
}
/**
* The last row under an addon that opens its settings: a gear, what it sets up,
* an optional badge for what waits inside, and a chevron (AI, booking mails,
* paddle water data).
*/
export function MAdminSetupRow({ label, onOpen, badge }: { label: string; onOpen: () => void; badge?: ReactNode }) {
return (
<button
type="button"
onClick={onOpen}
className="flex w-full items-center gap-3 border-t border-[color:var(--m-rowbr)] py-[11px] ps-[50px] text-start"
>
<Settings2 size={14} className="flex-none text-m-faint" />
<span className="min-w-0 flex-1 truncate text-[length:calc(12px*var(--fs-scale-body,1))] font-bold text-m-ink">{label}</span>
{badge}
<ChevronRight size={15} className="flex-none text-m-faint rtl:rotate-180" />
</button>
)
}
/**
* A description that keeps to two lines until it is tapped. On a phone the long
* ones (a map provider's terms, how a loader decides) pushed every control off
@@ -1,4 +1,5 @@
import { Inbox, Upload, Webhook, type LucideIcon } from 'lucide-react';
import { Inbox, Mail, Upload, Webhook, type LucideIcon } from 'lucide-react';
import { useState } from 'react';
import {
TRANSPORTS,
problemText,
@@ -15,15 +16,16 @@ import { useTranslation } from '../../../i18n';
import type { TranslationFn } from '../../../types';
import { relativeTime } from '../../../utils/relativeTime';
import MSegmented from '../../components/MSegmented';
import MSheet from '../../components/MSheet';
import MToggle from '../../components/MToggle';
import {
MAdminButton,
MAdminCard,
MAdminCardHead,
MAdminField,
MAdminInput,
MAdminRow,
MAdminOptionRow,
MAdminSecretInput,
MAdminSetupRow,
MAdminSheetFrame,
} from './MAdminUi';
interface PartProps {
@@ -250,19 +252,23 @@ function Setup({ admin, form, t, locale }: PartProps & { locale: string }) {
}
/**
* The booking mail import in the phone's admin settings, the same card as on
* the desktop (useMailIngestAdmin): the switch, how mail arrives, the address
* template, the AI allowance, the test and the status. Self-hosted only.
* The booking mail import as a row of the phone's integration group, the same
* as on the desktop (useMailIngestAdmin): the switch, and while it is on a row
* to the sheet that sets it up (how mail arrives, the address template, the AI
* allowance, the test and the status). Self-hosted only.
*/
export default function MMailIngestAdminCard() {
export default function MMailIngestAdminCard({ first = false }: { first?: boolean }) {
const { t, locale } = useTranslation();
const admin = useMailIngestAdmin(true);
const [open, setOpen] = useState(false);
const setupLabel = t('mailAdmin.setup');
return (
<MAdminCard>
<MAdminCardHead title={t('mailAdmin.title')} hint={t('mailAdmin.hint')} />
<MAdminRow
title={t('mailAdmin.enabled')}
hint={t('mailAdmin.enabledHint')}
<>
<MAdminOptionRow
icon={<Mail size={18} />}
title={t('mailAdmin.title')}
hint={`${t('mailAdmin.hint')} ${t('mailAdmin.enabledHint')}`}
first={first}
trailing={
<MToggle
checked={admin.enabled}
@@ -272,7 +278,18 @@ export default function MMailIngestAdminCard() {
/>
}
/>
{admin.enabled && admin.form && <Setup admin={admin} form={admin.form} t={t} locale={locale} />}
</MAdminCard>
{admin.enabled && admin.form && <MAdminSetupRow label={setupLabel} onOpen={() => setOpen(true)} />}
{open && admin.enabled && admin.form && (
<MSheet open onClose={() => setOpen(false)} variant="bottom" material="glass" ariaLabel={setupLabel}>
<MAdminSheetFrame
icon={<Mail size={19} strokeWidth={1.8} />}
title={setupLabel}
onClose={() => setOpen(false)}
>
<Setup admin={admin} form={admin.form} t={t} locale={locale} />
</MAdminSheetFrame>
</MSheet>
)}
</>
);
}