Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(ui): reserve red backup status for missing backups

rcourtman364a3f458938
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 18a084c6c2..8debc2567c 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -950,6 +950,14 @@ not a replacement status card, CTA band, or page-local nested card.
Proxmox backup source/state chips follow the same boundary: storage/recovery
owns backup-source labels and state semantics, while the visible chip shell
and tone vocabulary route through `MetadataBadge`.
+ Workload backup freshness follows a separate shared presentation boundary:
+ `frontend-modern/src/utils/workloadGuestPresentation.ts` owns the canonical
+ tone and icon mapping consumed by workload rows and drawers. A recorded
+ backup may be green or amber according to the configured freshness
+ thresholds, but age alone must not produce a red failure treatment. Red is
+ reserved for the materially different `never` state where no backup has
+ been recorded; unsupported workloads and templates remain neutral rather
+ than being classified as unprotected.
Inline detail content belongs to the shared detail-section primitive family.
Feature surfaces may own the platform-specific rows, section labels, and
source model, but section row shaping, empty-row compaction, value tone
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index d072dfac4d..0dd9c16d52 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -545,12 +545,21 @@ change may globally weaken the Task 03 lifecycle-state idempotency invariant.
from the row's scalar `lastBackup` value, but they must remain
presentation-only: no per-row backup API calls, recovery evidence joins, or
provider-specific backup fetches belong in the shared workload hot path.
+ Freshness classification must reuse the configured backup thresholds and
+ the shared `getBackupInfo` / `workloadGuestPresentation` vocabulary:
+ existing stale or overdue backups stay amber, while red is reserved for a
+ supported guest with no recorded backup. The compact row must not infer a
+ red failure state from a fixed backup age.
11. Extend workload drawer derivations and runtime wiring through `frontend-modern/src/components/Workloads/guestDrawerModel.ts` and `frontend-modern/src/components/Workloads/useGuestDrawerState.ts`, and extend drawer overview rendering through `frontend-modern/src/components/Workloads/GuestDrawerOverview.tsx`, rather than rebuilding canonical guest identity, discovery routing, or drawer-local normalization inside `frontend-modern/src/components/Workloads/GuestDrawer.tsx`
Drawer history charts belong to `frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx`.
History cards must let the plot area stretch to the card height instead of
pinning the SVG wrapper to a fixed short height, so guest and node drawer
history cards do not leave unused card space when headers have different
legend heights.
+ The drawer backup card must consume the same configured thresholds and
+ shared freshness presentation as the workload row. Drawer-local 7-day,
+ 30-day, or other fixed color cutoffs are forbidden because they can
+ contradict both user policy and the table beside the drawer.
12. Extend workload disk-list derivations and fallback runtime wiring through `frontend-modern/src/components/Workloads/diskListModel.ts` and `frontend-modern/src/components/Workloads/useDiskListState.ts` rather than rebuilding usage math, progress-state mapping, or tooltip fallback logic inside `frontend-modern/src/components/Workloads/DiskList.tsx`
13. Extend workload guest metadata cache persistence, metadata refresh, org-scope switching, and optimistic custom-URL updates through `frontend-modern/src/components/Workloads/useWorkloadGuestMetadataState.ts` rather than rebuilding workload-local storage caches, event listeners, or guest metadata API wiring inside `frontend-modern/src/components/Workloads/useWorkloadsState.ts`
14. Extend workload deep-link selection and hovered-row continuity semantics through `frontend-modern/src/components/Workloads/workloadSelectionModel.ts`, and extend table scroll preservation plus reactive selection state through `frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts`, rather than rebuilding resource-query parsing, selected-row scroll pinning, or hovered-row invalidation inside `frontend-modern/src/components/Workloads/useWorkloadsState.ts`; canonical typed workload IDs such as `app-container:<host>:<provider-id>` must remain exact route/selection keys and must not be reinterpreted into synthetic node scopes
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index fa3c2493e6..4d414c97ab 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,37 +1,40 @@
{
"version": 1,
- "base_sha": "9524c6ac79e68c95f1a1760ccfdca65233da6f36",
- "verified_at": "2026-08-05T12:43:32Z",
+ "base_sha": "9a7afbd2eb5dd511eeadb30588c8479743e9c992",
+ "verified_at": "2026-08-05T13:13:29Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/features/platformPage/sharedPlatformPage.tsx",
- "frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx",
- "frontend-modern/src/features/vmware/VsphereAlertsTable.tsx"
+ "frontend-modern/src/components/Workloads/GuestRowCells.tsx",
+ "frontend-modern/src/components/Workloads/guestDrawerModel.ts",
+ "frontend-modern/src/components/Workloads/useGuestDrawerState.ts",
+ "frontend-modern/src/utils/format.ts",
+ "frontend-modern/src/utils/workloadGuestPresentation.ts"
],
"content_sha256": {
- "frontend-modern/src/features/platformPage/sharedPlatformPage.tsx": "195d9d568f05d075cf82f9d3f09b76332d9b7438c7db00b2854fd59385672874",
- "frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx": "4dcfeaa8e4a4b79e37d6121e25fcd5395257c32ad1e947e4551584c672935339",
- "frontend-modern/src/features/vmware/VsphereAlertsTable.tsx": "5562fdee0d1b74a9ea819962183a5860b9fb4a9677fd66ed7182639e5218b1b4"
+ "frontend-modern/src/components/Workloads/GuestRowCells.tsx": "6be782b43d9918672cee3cf10dab559bced312f7fcaac1f73a37b6273e64ccda",
+ "frontend-modern/src/components/Workloads/guestDrawerModel.ts": "df599fe2a2d282fdf1b2afcde4fe813fe8e23df86a2d1255792ccaa9436f7833",
+ "frontend-modern/src/components/Workloads/useGuestDrawerState.ts": "149410968bfb29f845d47a9d9288fa264751fb7f43816cff78b8ab42d605ee27",
+ "frontend-modern/src/utils/format.ts": "d9e3d7fe2fe58e10666a414f208ed7aef53f2028db4f59c9c8a0e3bfd76e6901",
+ "frontend-modern/src/utils/workloadGuestPresentation.ts": "b1d16be6ee3393d91161f2a97902fd152b7058f12a560e62baa9d023c02fb48b"
},
"routes": [
- "/truenas/protection",
- "/vmware/health"
+ "/proxmox/overview"
],
"viewports": [
- { "width": 390, "height": 844 },
+ { "width": 600, "height": 900 },
{ "width": 1440, "height": 1000 }
],
"states": [
- "vSphere health default history with the compact counted Attention filter and no posture banner",
- "vSphere Attention filter selected with all five warning health signals visible",
- "TrueNAS protection default history with one failed event and the compact counted Attention filter",
- "TrueNAS Attention filter selected with the one matching failed event",
- "Filters expanded at the narrow viewport on both routes"
+ "Proxmox workload table with fresh backups green, aging and overdue backups amber, and missing backups red",
+ "Desktop backup tooltips for a 15-day existing backup and a guest with no backup",
+ "Desktop workload drawer showing the 15-day backup in the policy-derived amber tone",
+ "Narrow workload table using amber and red shield indicators beside workload names",
+ "Narrow workload drawer scrolled to the visible 15-day backup card"
],
"interactions": [
- "Selected and cleared the vSphere Attention filter at desktop and narrow viewports",
- "Selected and cleared the TrueNAS Attention filter at desktop and narrow viewports",
- "Verified the vSphere and TrueNAS result counts track each counted Attention filter",
- "Verified both narrow layouts keep document scroll width equal to client width"
+ "Hovered the 15-day and no-backup indicators and verified their tooltip copy and placement",
+ "Opened and closed the 15-day workload drawer at desktop and narrow viewports",
+ "Scrolled the narrow workload view until the full backup card was visible",
+ "Verified the 15-day drawer value stays amber and the browser console remains error-free"
]
}
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
index 5cfd9f88d8..64b6b19c91 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
@@ -837,22 +837,23 @@ describe('GuestDrawer', () => {
expect(screen.getByText('5d ago')).toBeInTheDocument();
});
- it('applies warning color for backups older than 7 days', () => {
+ it('applies the caution color for an aging backup', () => {
const tenDaysAgo = new Date('2026-02-20T12:00:00Z').getTime();
render(() => <GuestDrawer guest={makeGuest({ lastBackup: tenDaysAgo })} onClose={vi.fn()} />);
expect(screen.getByText('10d ago')).toBeInTheDocument();
const ageEl = screen.getByText('10d ago');
- expect(ageEl.className).toContain('amber');
+ expect(ageEl.className).toContain('yellow');
});
- it('applies critical color for backups older than 30 days', () => {
+ it('keeps an old existing backup in the caution color rather than red', () => {
const fortyDaysAgo = new Date('2026-01-21T12:00:00Z').getTime();
render(() => (
<GuestDrawer guest={makeGuest({ lastBackup: fortyDaysAgo })} onClose={vi.fn()} />
));
expect(screen.getByText('40d ago')).toBeInTheDocument();
const ageEl = screen.getByText('40d ago');
- expect(ageEl.className).toContain('red');
+ expect(ageEl.className).toContain('yellow');
+ expect(ageEl.className).not.toContain('red');
});
it('applies green color for recent backups', () => {
diff --git a/frontend-modern/src/components/Workloads/GuestRowCells.tsx b/frontend-modern/src/components/Workloads/GuestRowCells.tsx
index 5cf3be70e3..ac9c21e88c 100644
--- a/frontend-modern/src/components/Workloads/GuestRowCells.tsx
+++ b/frontend-modern/src/components/Workloads/GuestRowCells.tsx
@@ -26,7 +26,7 @@ function BackupIndicator(props: {
const shouldShow = createMemo(() => {
const status = backupInfo().status;
- return status === 'stale' || status === 'critical' || status === 'never';
+ return status === 'stale' || status === 'overdue' || status === 'never';
});
const tooltipText = createMemo(() => {
@@ -88,11 +88,10 @@ function getBackupAgeBadgeLabel(
function getBackupAgeBadgeClass(status: BackupInfo['status']): string {
const layout =
'inline-flex h-5 min-w-[3.25rem] items-center justify-center gap-1 px-1.5 text-[10px] font-semibold leading-none tabular-nums cursor-help';
- // A healthy backup only needs its shield. The colour already carries the
- // verdict and the threshold already decides what counts as acceptable, so the
- // exact age is decoration on the rows nobody has to act on; it stays in the
- // tooltip and the aria-label. Age and pill chrome are reserved for the states
- // that need attention.
+ // A healthy backup only needs its shield. Existing backups that cross an age
+ // threshold remain amber because age is a policy-relative caution, while red
+ // is reserved for the materially different state where no backup exists.
+ // The exact age stays visible for every non-fresh state.
const pill = `${layout} rounded-full border`;
switch (status) {
@@ -100,10 +99,10 @@ function getBackupAgeBadgeClass(status: BackupInfo['status']): string {
return `${layout} text-green-600 dark:text-green-400`;
case 'stale':
return `${pill} border-yellow-200 bg-yellow-50 text-yellow-700 dark:border-yellow-900/70 dark:bg-yellow-950/40 dark:text-yellow-300`;
- case 'critical':
- return `${pill} border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/40 dark:text-red-300`;
+ case 'overdue':
+ return `${pill} border-yellow-200 bg-yellow-50 text-yellow-700 dark:border-yellow-900/70 dark:bg-yellow-950/40 dark:text-yellow-300`;
case 'never':
- return `${pill} border-border bg-surface-alt text-muted`;
+ return `${pill} border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/40 dark:text-red-300`;
}
}
@@ -319,7 +318,7 @@ function BackupStatusCell(props: { lastBackup: string | number | null | undefine
const badgeLabel = createMemo(() => getBackupAgeBadgeLabel(props.lastBackup, info()));
const ariaLabel = createMemo(() => {
const currentInfo = info();
- if (currentInfo.status === 'never') return 'Backup status: never';
+ if (currentInfo.status === 'never') return 'Backup status: no backup found';
return `Backup status: ${currentInfo.status}, last backup ${currentInfo.ageFormatted}`;
});
@@ -376,7 +375,7 @@ function BackupStatusCell(props: { lastBackup: string | number | null | undefine
<div class="text-slate-300">{new Date(props.lastBackup!).toLocaleTimeString()}</div>
</div>
<div class="pt-1 mt-1 border-t border-border">
- <span class={config().color}>{info().ageFormatted} ago</span>
+ <span class={config().color}>{info().ageFormatted}</span>
</div>
</Show>
<Show when={info().status === 'never'}>
diff --git a/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx b/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx
index f22c33e123..e78d25bb1f 100644
--- a/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx
@@ -43,19 +43,21 @@ describe('BackupStatusCell', () => {
expect(badge.className).toContain('border-yellow-200');
});
- it('draws the age and pill chrome when the backup is critical', () => {
+ it('keeps the age and amber pill chrome when the backup is overdue', () => {
const badge = renderCell(Date.now() - 200 * HOUR_MS);
expect(badge.textContent?.trim()).not.toBe('');
expect(badge.className).toContain('rounded-full');
- expect(badge.className).toContain('border-red-200');
+ expect(badge.className).toContain('border-yellow-200');
+ expect(badge.className).not.toContain('border-red-200');
});
- it('labels a guest that has never been backed up', () => {
+ it('labels a guest that has never been backed up in red', () => {
const badge = renderCell(null);
expect(badge.textContent?.trim()).toBe('None');
expect(badge.className).toContain('rounded-full');
- expect(badge.getAttribute('aria-label')).toBe('Backup status: never');
+ expect(badge.className).toContain('border-red-200');
+ expect(badge.getAttribute('aria-label')).toBe('Backup status: no backup found');
});
});
diff --git a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
index 130d837123..67aa6e6b1c 100644
--- a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
@@ -1397,12 +1397,34 @@ describe('backup column', () => {
expect(badge?.textContent?.trim()).toMatch(/\d/);
});
- it('shows None for supported guests without a backup', () => {
- renderGuestRow({
+ it('keeps an overdue backup amber because a backup still exists', () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date('2026-05-26T12:00:00Z'));
+
+ const { container } = renderGuestRow({
+ guest: makeGuest({
+ type: 'qemu',
+ workloadType: 'vm',
+ lastBackup: Date.parse('2026-05-21T12:00:00Z'),
+ }),
+ visibleColumnIds: ['name', 'backup'],
+ });
+
+ const badge = container.querySelector('[aria-label^="Backup status: overdue"]');
+ expect(badge).toBeTruthy();
+ expect(badge?.classList.contains('text-yellow-700')).toBe(true);
+ expect(badge?.className).not.toContain('text-red');
+ });
+
+ it('reserves red for supported guests without a backup', () => {
+ const { container } = renderGuestRow({
guest: makeGuest({ type: 'qemu', workloadType: 'vm', lastBackup: 0 }),
visibleColumnIds: ['name', 'backup'],
});
expect(screen.getByText('None')).toBeTruthy();
+ const badge = container.querySelector('[aria-label="Backup status: no backup found"]');
+ expect(badge).toBeTruthy();
+ expect(badge?.classList.contains('text-red-700')).toBe(true);
});
it('shows dash for app-container workloads (no backup support)', () => {
diff --git a/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts b/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts
index 5eb27f0ee8..e82294d942 100644
--- a/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts
@@ -655,7 +655,7 @@ describe('guestDrawerModel (branch coverage)', () => {
const expectPresentation = (days: number) => {
const lastBackup = backupNDaysAgo(days);
- const result = getGuestDrawerBackupPresentation(lastBackup, now);
+ const result = getGuestDrawerBackupPresentation(lastBackup, undefined, now);
expect(result.dateLabel).toBe(new Date(lastBackup).toLocaleDateString());
return result;
};
@@ -674,33 +674,35 @@ describe('guestDrawerModel (branch coverage)', () => {
expect(result.ageClass).toBe('text-green-600 dark:text-green-400');
});
- it('uses the green class up to and including day 7 (isOld = daysSince > 7)', () => {
- expect(expectPresentation(7).ageClass).toBe('text-green-600 dark:text-green-400');
- expect(expectPresentation(7).ageLabel).toBe('7d ago');
- });
+ it('uses the configured policy to keep a 15-day-old backup green', () => {
+ const lastBackup = backupNDaysAgo(15);
+ const result = getGuestDrawerBackupPresentation(
+ lastBackup,
+ { freshHours: 15 * 24, staleHours: 30 * 24 },
+ now,
+ );
- it('switches to the amber class at day 8', () => {
- const result = expectPresentation(8);
- expect(result.ageClass).toBe('text-amber-600 dark:text-amber-400');
- expect(result.ageLabel).toBe('8d ago');
+ expect(result.ageClass).toBe('text-green-600 dark:text-green-400');
+ expect(result.ageLabel).toBe('15d ago');
});
- it('keeps the amber class at day 30 (isCritical = daysSince > 30)', () => {
- expect(expectPresentation(30).ageClass).toBe('text-amber-600 dark:text-amber-400');
- expect(expectPresentation(30).ageLabel).toBe('30d ago');
+ it('uses the yellow caution class after the fresh threshold', () => {
+ const result = expectPresentation(2);
+ expect(result.ageClass).toBe('text-yellow-600 dark:text-yellow-400');
+ expect(result.ageLabel).toBe('2d ago');
});
- it('switches to the red (critical) class at day 31', () => {
+ it('keeps overdue existing backups yellow rather than red', () => {
const result = expectPresentation(31);
- expect(result.ageClass).toBe('text-red-600 dark:text-red-400');
+ expect(result.ageClass).toBe('text-yellow-600 dark:text-yellow-400');
expect(result.ageLabel).toBe('31d ago');
});
it('accepts a numeric (ms) lastBackup value', () => {
const lastBackup = backupNDaysAgo(10).getTime();
- const result = getGuestDrawerBackupPresentation(lastBackup, now);
+ const result = getGuestDrawerBackupPresentation(lastBackup, undefined, now);
expect(result.ageLabel).toBe('10d ago');
- expect(result.ageClass).toBe('text-amber-600 dark:text-amber-400');
+ expect(result.ageClass).toBe('text-yellow-600 dark:text-yellow-400');
expect(result.dateLabel).toBe(new Date(lastBackup).toLocaleDateString());
});
});
diff --git a/frontend-modern/src/components/Workloads/guestDrawerModel.ts b/frontend-modern/src/components/Workloads/guestDrawerModel.ts
index 7ce8b5c1f5..04baa5de6c 100644
--- a/frontend-modern/src/components/Workloads/guestDrawerModel.ts
+++ b/frontend-modern/src/components/Workloads/guestDrawerModel.ts
@@ -7,7 +7,8 @@ import type {
} from '@/api/charts';
import { formatHistoryChartTooltipValue } from '@/components/shared/historyChartModel';
-import { formatBytes, formatPercent } from '@/utils/format';
+import { formatBytes, formatPercent, getBackupInfo, type BackupThresholds } from '@/utils/format';
+import { getWorkloadsGuestBackupStatusPresentation } from '@/utils/workloadGuestPresentation';
import {
getCanonicalWorkloadId,
getWorkloadCPUPercent,
@@ -355,19 +356,19 @@ export const normalizeGuestDrawerTags = (tags: Guest['tags']): string[] => {
export const getGuestDrawerBackupPresentation = (
lastBackup: string | number | Date,
+ thresholds?: BackupThresholds,
now: Date = new Date(),
): GuestDrawerBackupPresentation => {
const backupDate = new Date(lastBackup);
- const daysSince = Math.floor((now.getTime() - backupDate.getTime()) / (1000 * 60 * 60 * 24));
- const isOld = daysSince > 7;
- const isCritical = daysSince > 30;
+ const daysSince = Math.max(
+ 0,
+ Math.floor((now.getTime() - backupDate.getTime()) / (1000 * 60 * 60 * 24)),
+ );
+ const info = getBackupInfo(backupDate.getTime(), thresholds, now);
+ const statusPresentation = getWorkloadsGuestBackupStatusPresentation(info.status);
return {
- ageClass: isCritical
- ? 'text-red-600 dark:text-red-400'
- : isOld
- ? 'text-amber-600 dark:text-amber-400'
- : 'text-green-600 dark:text-green-400',
+ ageClass: statusPresentation.color,
ageLabel: daysSince === 0 ? 'Today' : daysSince === 1 ? 'Yesterday' : `${daysSince}d ago`,
dateLabel: backupDate.toLocaleDateString(),
};
diff --git a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts b/frontend-modern/src/components/Workloads/useGuestDrawerState.ts
index c0486a39d5..a9621ff0d0 100644
--- a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts
+++ b/frontend-modern/src/components/Workloads/useGuestDrawerState.ts
@@ -102,7 +102,12 @@ export function useGuestDrawerState(props: GuestDrawerProps) {
const hasNetworkInterfaces = createMemo(() => networkInterfaces().length > 0);
const normalizedTags = createMemo(() => normalizeGuestDrawerTags(props.guest.tags));
const backupPresentation = createMemo(() =>
- props.guest.lastBackup ? getGuestDrawerBackupPresentation(props.guest.lastBackup) : null,
+ props.guest.lastBackup
+ ? getGuestDrawerBackupPresentation(
+ props.guest.lastBackup,
+ alertsActivation.getBackupThresholds(),
+ )
+ : null,
);
const hasDiscoverySupport = createMemo(() => hasDiscoverySupportForWorkload(props.guest));
const historyTarget = createMemo(() => getGuestDrawerHistoryTarget(props.guest));
diff --git a/frontend-modern/src/utils/__tests__/format.test.ts b/frontend-modern/src/utils/__tests__/format.test.ts
index 436c8e007c..b501850bae 100644
--- a/frontend-modern/src/utils/__tests__/format.test.ts
+++ b/frontend-modern/src/utils/__tests__/format.test.ts
@@ -271,11 +271,11 @@ describe('getBackupInfo', () => {
expect(result.ageFormatted).toBe('2 days ago');
});
- it('returns critical status for backup older than 72 hours', () => {
+ it('returns overdue status for backup older than 72 hours', () => {
const now = Date.now();
const fourDaysAgo = now - 4 * 24 * 60 * 60 * 1000;
const result = getBackupInfo(fourDaysAgo);
- expect(result.status).toBe('critical');
+ expect(result.status).toBe('overdue');
expect(result.ageFormatted).toBe('4 days ago');
});
@@ -315,11 +315,11 @@ describe('getBackupInfo', () => {
expect(result.status).toBe('stale');
});
- it('critical just after 72 hours', () => {
+ it('overdue just after 72 hours', () => {
const now = Date.now();
const justOver72Hours = now - (72 * 60 * 60 * 1000 + 1000);
const result = getBackupInfo(justOver72Hours);
- expect(result.status).toBe('critical');
+ expect(result.status).toBe('overdue');
});
});
@@ -349,7 +349,7 @@ describe('getBackupInfo', () => {
// With custom threshold of 24h stale (same as fresh)
const resultCustom = getBackupInfo(twoDaysAgo, { freshHours: 12, staleHours: 24 });
- expect(resultCustom.status).toBe('critical'); // 48 hours > 24 hours stale threshold
+ expect(resultCustom.status).toBe('overdue'); // 48 hours > 24 hours stale threshold
});
it('handles partial custom thresholds', () => {
diff --git a/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts b/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts
index a42d734b2f..82baed940e 100644
--- a/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts
@@ -14,10 +14,15 @@ describe('workloadGuestPresentation', () => {
icon: 'check',
});
expect(getWorkloadsGuestBackupStatusPresentation('never')).toEqual({
- color: 'text-muted',
- bgColor: 'bg-surface-alt',
+ color: 'text-red-600 dark:text-red-400',
+ bgColor: 'bg-red-100 dark:bg-red-900',
icon: 'x',
});
+ expect(getWorkloadsGuestBackupStatusPresentation('overdue')).toEqual({
+ color: 'text-yellow-600 dark:text-yellow-400',
+ bgColor: 'bg-yellow-100 dark:bg-yellow-900',
+ icon: 'warning',
+ });
});
it('returns canonical guest backup tooltip copy', () => {
diff --git a/frontend-modern/src/utils/format.ts b/frontend-modern/src/utils/format.ts
index 28112bbcdf..df9675671e 100644
--- a/frontend-modern/src/utils/format.ts
+++ b/frontend-modern/src/utils/format.ts
@@ -189,7 +189,7 @@ function formatTimeDiff(diffMs: number, compact?: boolean): string {
}
}
-export type BackupStatus = 'fresh' | 'stale' | 'critical' | 'never';
+export type BackupStatus = 'fresh' | 'stale' | 'overdue' | 'never';
export interface BackupInfo {
status: BackupStatus;
@@ -210,11 +210,13 @@ export interface BackupThresholds {
* Analyzes backup freshness for a guest.
* @param lastBackup - ISO timestamp string or Unix timestamp (ms)
* @param thresholds - Optional thresholds for fresh/stale determination (in hours)
+ * @param now - Optional current time override for deterministic consumers and tests
* @returns BackupInfo with status and formatted age
*/
export function getBackupInfo(
lastBackup: string | number | null | undefined,
thresholds?: BackupThresholds,
+ now: number | Date = Date.now(),
): BackupInfo {
if (!lastBackup) {
return { status: 'never', ageMs: null, ageFormatted: 'Never' };
@@ -231,8 +233,8 @@ export function getBackupInfo(
return { status: 'never', ageMs: null, ageFormatted: 'Never' };
}
- const now = Date.now();
- const ageMs = now - timestamp;
+ const nowMs = typeof now === 'number' ? now : now.getTime();
+ const ageMs = nowMs - timestamp;
// Use provided thresholds or fall back to defaults
const freshHours = thresholds?.freshHours ?? DEFAULT_FRESH_HOURS;
@@ -246,7 +248,7 @@ export function getBackupInfo(
} else if (ageMs <= staleThresholdMs) {
status = 'stale';
} else {
- status = 'critical';
+ status = 'overdue';
}
return {
diff --git a/frontend-modern/src/utils/workloadGuestPresentation.ts b/frontend-modern/src/utils/workloadGuestPresentation.ts
index 8bc8079fc1..2beea83b1c 100644
--- a/frontend-modern/src/utils/workloadGuestPresentation.ts
+++ b/frontend-modern/src/utils/workloadGuestPresentation.ts
@@ -17,14 +17,14 @@ const BACKUP_STATUS_PRESENTATION: Record<BackupStatus, WorkloadsGuestBackupStatu
bgColor: 'bg-yellow-100 dark:bg-yellow-900',
icon: 'warning',
},
- critical: {
- color: 'text-red-600 dark:text-red-400',
- bgColor: 'bg-red-100 dark:bg-red-900',
- icon: 'x',
+ overdue: {
+ color: 'text-yellow-600 dark:text-yellow-400',
+ bgColor: 'bg-yellow-100 dark:bg-yellow-900',
+ icon: 'warning',
},
never: {
- color: 'text-muted',
- bgColor: 'bg-surface-alt',
+ color: 'text-red-600 dark:text-red-400',
+ bgColor: 'bg-red-100 dark:bg-red-900',
icon: 'x',
},
};