mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
feat(storage): show running checks, confirmations and the nightly result in Admin > Storage
The panels follow the reworked reclaim state: Check now starts a check in the background and the panel polls until it is done, a category with an unusually large share of unused files offers Confirm, Freed comes from the last run that deleted, a stopped check says why and no longer reads as nothing found, the switch waits for its answer and a poll that was in flight cannot flip it back, and refusals name their reason in the operator's language. Strings updated in all 28 languages.
This commit is contained in:
@@ -173,7 +173,7 @@ export default function MAdminStoragePanel(): React.ReactElement {
|
||||
const {
|
||||
admin, editing, setEditing, confirmRemove, setConfirmRemove, syncPrompt, setSyncPrompt, migratePrompt,
|
||||
handleCancelMigration, handleRefreshStats, handleStartBackfill, handleCancelBackfill, loaded,
|
||||
reclaim, reclaimChecking, handleReclaimCheck, handleReclaimDelete,
|
||||
reclaim, reclaimChecking, reclaimSaving, handleReclaimCheck, handleReclaimDelete, handleReclaimConfirm,
|
||||
} = useStoragePanel()
|
||||
const [categoryPicker, setCategoryPicker] = useState<StorageCategory | null>(null)
|
||||
|
||||
@@ -570,6 +570,8 @@ export default function MAdminStoragePanel(): React.ReactElement {
|
||||
<MStorageReclaimCard
|
||||
reclaim={reclaim}
|
||||
checking={reclaimChecking}
|
||||
saving={reclaimSaving}
|
||||
onConfirm={(category) => void handleReclaimConfirm(category)}
|
||||
onCheck={() => void handleReclaimCheck()}
|
||||
onDelete={(enabled) => void handleReclaimDelete(enabled)}
|
||||
/>
|
||||
|
||||
@@ -9,13 +9,24 @@ import { MAdminButton, MAdminCard, MAdminCardHead, MAdminRow } from './MAdminUi'
|
||||
|
||||
interface Props {
|
||||
reclaim: ReclaimView;
|
||||
/** A check was asked for or is running. */
|
||||
checking: boolean;
|
||||
/** The switch is on its way to the server. */
|
||||
saving: boolean;
|
||||
onCheck: () => void;
|
||||
onDelete: (enabled: boolean) => void;
|
||||
onConfirm: (category: ReclaimView['lines'][number]['category']) => void;
|
||||
}
|
||||
|
||||
/** Unreferenced files on the phone's storage panel, off the view model StorageReclaimSection shows on desktop. */
|
||||
export default function MStorageReclaimCard({ reclaim, checking, onCheck, onDelete }: Props): React.ReactElement {
|
||||
export default function MStorageReclaimCard({
|
||||
reclaim,
|
||||
checking,
|
||||
saving,
|
||||
onCheck,
|
||||
onDelete,
|
||||
onConfirm,
|
||||
}: Props): React.ReactElement {
|
||||
const { t, locale } = useTranslation();
|
||||
const count = (c: ReclaimCount) => t('storage.usage.line', { count: c.objects, size: formatBytes(c.bytes) });
|
||||
const checked = reclaim.checkedAt !== null;
|
||||
@@ -27,7 +38,7 @@ export default function MStorageReclaimCard({ reclaim, checking, onCheck, onDele
|
||||
hint={t('storage.reclaim.hint')}
|
||||
trailing={
|
||||
<MAdminButton variant="ghost" busy={checking} onClick={onCheck}>
|
||||
{t('storage.reclaim.check')}
|
||||
{checking ? t('storage.reclaim.running') : t('storage.reclaim.check')}
|
||||
</MAdminButton>
|
||||
}
|
||||
/>
|
||||
@@ -36,7 +47,12 @@ export default function MStorageReclaimCard({ reclaim, checking, onCheck, onDele
|
||||
title={t('storage.reclaim.delete')}
|
||||
hint={t('storage.reclaim.deleteHint')}
|
||||
trailing={
|
||||
<MToggle checked={reclaim.deleteEnabled} onChange={onDelete} ariaLabel={t('storage.reclaim.delete')} />
|
||||
<MToggle
|
||||
checked={reclaim.deleteEnabled}
|
||||
onChange={onDelete}
|
||||
disabled={saving}
|
||||
ariaLabel={t('storage.reclaim.delete')}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<div className="border-t border-[color:var(--m-rowbr)] pt-[11px]" data-testid="m-storage-reclaim-summary">
|
||||
@@ -47,17 +63,17 @@ export default function MStorageReclaimCard({ reclaim, checking, onCheck, onDele
|
||||
</p>
|
||||
{reclaim.stopped && (
|
||||
<p role="note" className="mt-1 font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.stopped')}
|
||||
{t(reclaim.stopped === 'failed' ? 'storage.reclaim.stoppedFailed' : 'storage.reclaim.stopped')}
|
||||
</p>
|
||||
)}
|
||||
{checked && (
|
||||
<div className="mt-2 space-y-1">
|
||||
<Figure label={t('storage.reclaim.freeable')} value={count(reclaim.freeable)} />
|
||||
<Figure label={t('storage.reclaim.waiting')} value={count(reclaim.waiting)} />
|
||||
<Figure label={t('storage.reclaim.deleted')} value={count(reclaim.deleted)} />
|
||||
<Figure label={t('storage.reclaim.deleted')} value={count(reclaim.freed)} />
|
||||
</div>
|
||||
)}
|
||||
{checked && reclaim.lines.length === 0 && (
|
||||
{checked && !reclaim.stopped && reclaim.lines.length === 0 && (
|
||||
<p className="mt-2 font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.nothing')}
|
||||
</p>
|
||||
@@ -69,23 +85,30 @@ export default function MStorageReclaimCard({ reclaim, checking, onCheck, onDele
|
||||
<p className="font-bold text-m-ink" style={fs(12, 'body')}>
|
||||
{t(`storage.category.${line.category}`)}
|
||||
</p>
|
||||
{line.skipped ? (
|
||||
{line.skipped && (
|
||||
<p className="font-geist text-m-muted" style={fs(10)}>
|
||||
{t(`storage.reclaim.skip.${line.skipped}`)}
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
{line.freeable.objects > 0 && (
|
||||
<p className="font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.freeable')}: {count(line.freeable)}
|
||||
</p>
|
||||
)}
|
||||
{line.waiting.objects > 0 && (
|
||||
<p className="font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.waiting')}: {count(line.waiting)}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{line.freeable.objects > 0 && (
|
||||
<p className="font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.freeable')}: {count(line.freeable)}
|
||||
</p>
|
||||
)}
|
||||
{line.waiting.objects > 0 && (
|
||||
<p className="font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.waiting')}: {count(line.waiting)}
|
||||
</p>
|
||||
)}
|
||||
{line.confirmationRequired && (
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
<p className="min-w-0 flex-1 font-geist text-m-muted" style={fs(10)}>
|
||||
{t('storage.reclaim.confirmNeeded')}
|
||||
</p>
|
||||
<MAdminButton variant="ghost" onClick={() => onConfirm(line.category)}>
|
||||
{t('storage.reclaim.confirm')}
|
||||
</MAdminButton>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user