From 56536ae803891082624eca2ac8d5a1ab3a171295 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 30 Oct 2026 20:19:04 +0100 Subject: [PATCH] admin: the allowance and the sharing blocks take the settings' own card head Both blocks in the TREK API card now use SettingsCard like Single Sign-On and two-factor: an icon tile, the title with its state as a badge, the note under it and the switch or badges on the right, with a flush variant for a card inside a card. A figure badge no longer cuts the last pixels of its value, and the withdrawal toast names how many values it took back. --- .../components/Admin/PlaceContribPanel.tsx | 37 +++---- .../components/Admin/ServiceIdentityPanel.tsx | 98 ++++++++++--------- .../src/components/Settings/settingsKit.tsx | 6 +- .../components/Tours/paddle/FigureBadge.tsx | 2 +- 4 files changed, 69 insertions(+), 74 deletions(-) diff --git a/client/src/components/Admin/PlaceContribPanel.tsx b/client/src/components/Admin/PlaceContribPanel.tsx index 4f7ee256e..0fbaa7c9b 100644 --- a/client/src/components/Admin/PlaceContribPanel.tsx +++ b/client/src/components/Admin/PlaceContribPanel.tsx @@ -4,7 +4,7 @@ import { useState } from 'react'; import { useTranslation } from '../../i18n'; import type { TranslationFn } from '../../types'; import { getApiErrorMessage } from '../../utils/apiError'; -import { StatusPill } from '../Settings/settingsKit'; +import { SettingsCard, StatusPill } from '../Settings/settingsKit'; import ToggleSwitch from '../Settings/ToggleSwitch'; import ConfirmDialog from '../shared/ConfirmDialog'; import { fs } from '../shared/DialogShell'; @@ -97,38 +97,27 @@ export default function PlaceContribPanel() { setConfirm(null); contrib.withdraw().then((r) => { const total = Object.values(r.withdrawn).reduce((a, b) => a + b, 0); - toast.success(t('admin.contribute.withdrawn', { count: total })); + toast.success(t('admin.contribute.withdrawn', { total })); }, fail); }; return ( -
-
- - -
-
-

- {t('admin.contribute.title')} -

- {t(`admin.contribute.status.${status}`)} -
-

- {contribNote(t, state)} -

-
+ {t(`admin.contribute.status.${status}`)}} + hint={contribNote(t, state)} + action={ (agreed && state.consent.enabled ? setConfirm('off') : setPrompting(true))} /> -
- + } + bodyClassName="flex flex-col gap-3 p-4" + > {agreed && state.consent.enabled && ( <> @@ -206,6 +195,6 @@ export default function PlaceContribPanel() { confirmLabel={t('admin.contribute.withdraw')} danger /> -
+ ); } diff --git a/client/src/components/Admin/ServiceIdentityPanel.tsx b/client/src/components/Admin/ServiceIdentityPanel.tsx index aa58649b3..5078c2e95 100644 --- a/client/src/components/Admin/ServiceIdentityPanel.tsx +++ b/client/src/components/Admin/ServiceIdentityPanel.tsx @@ -1,11 +1,12 @@ import type { ServiceAllowance, ServiceIdentityState, ServiceIdentityStatus, ServiceQuotaView } from '@trek/shared'; -import { MapPin, RefreshCw, Route, Search, type LucideIcon } from 'lucide-react'; +import { MapPin, RefreshCw, Route, Search, Signal, type LucideIcon } from 'lucide-react'; import { useRef, useState } from 'react'; import { useTranslation } from '../../i18n'; import { useSettingsStore } from '../../store/settingsStore'; import type { TranslationFn } from '../../types'; import { getApiErrorMessage } from '../../utils/apiError'; import { formatClockTime } from '../../utils/formatters'; +import { SettingsCard } from '../Settings/settingsKit'; import ConfirmDialog from '../shared/ConfirmDialog'; import { useToast } from '../shared/Toast'; import { FigureBadge } from '../Tours/paddle/FigureBadge'; @@ -121,7 +122,7 @@ function stateHint(t: TranslationFn, status: ServiceIdentityStatus | null, faile export default function ServiceIdentityPanel({ managed = false }: { managed?: boolean }) { const { t } = useTranslation(); const toast = useToast(); - const panel = useRef(null); + const panel = useRef(null); const { status, failed, regenerating, regenerate } = useServiceIdentity(panel); const [confirming, setConfirming] = useState(false); const resetAt = useResetTime(status); @@ -140,31 +141,34 @@ export default function ServiceIdentityPanel({ managed = false }: { managed?: bo const canRegenerate = !managed && status !== null && status.keySource !== 'env' && status.state !== 'off'; return ( -
- {/* Head band: where the installation stands, apart from the figures below it. */} -
-

-

-
- {status?.tier && } - {status?.keySource === 'env' && ( - + +
-
- -
+ {status ? t(`admin.trekApi.quota.state.${status.state}`) : '…'} + + } + action={ + <> + {status?.tier && } + {status?.keySource === 'env' && ( + + )} + {resetAt && } + + } + > {status && status.services.length > 0 && (
    )} {hint &&

    {hint}

    } -
- {/* Foot band: the one action, kept off the figures. */} - {canRegenerate && ( -
- -
- )} + {/* The one action, on a rule of its own below the figures. */} + {canRegenerate && ( +
+ +
+ )} + -
+ ); } diff --git a/client/src/components/Settings/settingsKit.tsx b/client/src/components/Settings/settingsKit.tsx index c05d86513..150d156aa 100644 --- a/client/src/components/Settings/settingsKit.tsx +++ b/client/src/components/Settings/settingsKit.tsx @@ -38,7 +38,7 @@ export function SettingsHeader({ icon: Icon, title, subtitle, actions }: { * badge and an action on the right) and its body below. `tone` tints the band: * neutral for ordinary groups, danger for the destructive ones. */ -export function SettingsCard({ icon: Icon, title, hint, badge, action, tone = 'neutral', children, id, bodyClassName }: { +export function SettingsCard({ icon: Icon, title, hint, badge, action, tone = 'neutral', children, id, bodyClassName, flush = false }: { icon?: IconLike title: ReactNode /** One line under the title in the band. */ @@ -50,10 +50,12 @@ export function SettingsCard({ icon: Icon, title, hint, badge, action, tone = 'n id?: string /** Replaces the body's padded column. */ bodyClassName?: string + /** Inside another card: no gap below, the parent spaces its children. */ + flush?: boolean }) { const tint = tone === 'danger' ? 'color-mix(in srgb, var(--danger) 9%, transparent)' : NEUTRAL_TINT return ( -
+
{Icon && ( diff --git a/client/src/components/Tours/paddle/FigureBadge.tsx b/client/src/components/Tours/paddle/FigureBadge.tsx index f419c38ce..63fcf1503 100644 --- a/client/src/components/Tours/paddle/FigureBadge.tsx +++ b/client/src/components/Tours/paddle/FigureBadge.tsx @@ -35,7 +35,7 @@ export function FigureBadge({ style={fs(11)} > {icon} - {value} + {value} );