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.

Remove recovery exports and fallbacks the Recovery page left dead

rcourtman18a994002018
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 58a4641c83..3db042c03b 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -6473,23 +6473,27 @@ The Proxmox Backups tab parses `/api/backups/pve` and `/api/backups/pbs`
inside `ProxmoxBackupsTable.tsx` and reads posture through
`frontend-modern/src/hooks/useProtectionPostures.ts`. The TrueNAS Protection
tab reads recovery points, and what binds that path is the decode boundary.
-`frontend-modern/src/utils/recoveryPlatformModel.ts` maps legacy transport
-aliases onto the canonical runtime model: `provider` to `platform`,
+`frontend-modern/src/utils/recoveryPlatformModel.ts` maps the transport
+names onto the canonical runtime model: `provider` to `platform`,
`subjectResourceId` to `itemResourceId`, `subjectRef` to `itemRef`, and
`display.subjectLabel` / `display.subjectType` to `display.itemLabel` /
-`display.itemType`. `frontend-modern/src/hooks/useRecoveryPoints.ts`, the
-only recovery-points reader, applies `normalizeRecoveryPointsResponse` to
-every `/api/recovery/points` response, so the TrueNAS Protection tab receives
-platform-first, item-first points. The `display.subjectLabel`,
-`display.subjectType`, and `subjectRef` fallbacks that
-`TrueNASProtectionTable.tsx` and `truenasPageModel.ts` still read are dead on
-that path, because normalized points never carry those fields; new recovery
-code reads the canonical fields only. New recovery filters, links, or view
+`display.itemType`. The points handler sends the item label only as
+`display.subjectLabel`, so that fold is what names TrueNAS Protection rows.
+`frontend-modern/src/hooks/useRecoveryPoints.ts`, the only recovery-points
+reader, applies `normalizeRecoveryPointsResponse` to every
+`/api/recovery/points` response. `frontend-modern/src/types/recovery.ts`
+declares the subject names on the transport types alone
+(`RecoveryPointTransport`, `RecoveryPointDisplayTransport`), so
+`TrueNASProtectionTable.tsx` and `truenasPageModel.ts` label, sort, and search
+rows by `display.itemLabel`, `display.itemType`, and `itemRef`, and a read of
+`subjectRef` or `display.subjectLabel` off a normalized point fails the type
+check. `frontend-modern/src/api/__tests__/recoveryTransport.test.ts` pins the
+type split and the decode that names the rows. New recovery filters, links, or view
switches belong to the platform tab that owns the rows, on the platform-page primitives, rather than in a revived
cross-platform recovery shell or a shared recovery serializer in
-`frontend-modern/src/routing/resourceLinks.ts`. The rollup normalizer
-(`normalizeRecoveryRollupsResponse`) has had no production reader since
-`useRecoveryRollups.ts` was deleted.
+`frontend-modern/src/routing/resourceLinks.ts`. The frontend decodes no
+rollups: the rollup normalizer and the rollup, series, and facet types went
+with their last readers.
The retired dashboard action queue must not be reintroduced as a compact
Patrol or infrastructure issue panel. Patrol-owned runtime findings remain
governed by `frontend-modern/src/utils/aiFindingPresentation.ts` and their
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 2703ddc73a..f22a83d7d6 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -7821,7 +7821,6 @@
"frontend-modern/src/hooks/useProtectionPostures.ts",
"frontend-modern/src/hooks/useRecoveryPoints.ts",
"frontend-modern/src/types/recovery.ts",
- "frontend-modern/src/utils/recoveryArtifactModePresentation.ts",
"frontend-modern/src/utils/recoveryDatePresentation.ts",
"frontend-modern/src/utils/recoveryOutcomePresentation.ts",
"frontend-modern/src/utils/recoveryTimelineChartPresentation.ts",
@@ -7865,7 +7864,6 @@
"frontend-modern/src/hooks/useProtectionPostures.ts",
"frontend-modern/src/hooks/useRecoveryPoints.ts",
"frontend-modern/src/types/recovery.ts",
- "frontend-modern/src/utils/recoveryArtifactModePresentation.ts",
"frontend-modern/src/utils/recoveryDatePresentation.ts",
"frontend-modern/src/utils/recoveryOutcomePresentation.ts",
"frontend-modern/src/utils/recoveryTimelineChartPresentation.ts",
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 1855dc3029..9775907807 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -4260,7 +4260,9 @@ may coexist with AI controls, but they must keep consuming the canonical AI
settings payload rather than reviving storage-local provider defaults, modal
setup logic, or route-specific BYOK model guesses when shared handlers change.
The retained-value recovery transport helper is now shared too.
-Recovery still owns when rollups, points, facets, and series refetch, but the
+Recovery still owns when recovery points and protection postures refetch
+(`useRecoveryPoints.ts` and `useProtectionPostures.ts` each set a 30-second
+poll interval; the rollup, facet, and series hooks are gone), but the
non-suspending query primitive itself now lives under the shared frontend
primitives contract so other governed surfaces can reuse the same app-shell
fallback boundary without forking it.
@@ -4608,10 +4610,11 @@ recomputable guest identity keep their stored keys unchanged.
The frontend decode boundary owns the runtime recovery display model:
`frontend-modern/src/utils/recoveryPlatformModel.ts`, which
`frontend-modern/src/hooks/useRecoveryPoints.ts` applies to every response,
-exposes `display.itemLabel` and `display.itemType` to recovery consumers, while
-legacy transport fields such as `subjectLabel` and `subjectType` remain
-decode-only compatibility aliases in that normalization layer instead of
-leaking into tables.
+exposes `display.itemLabel` and `display.itemType` to recovery consumers. The
+points handler's display carries the item label only as `subjectLabel`, so the
+transport's `subjectLabel`, `subjectType`, and `subjectRef` stay decode-only:
+`frontend-modern/src/types/recovery.ts` declares them on the transport types
+alone, and tables read the canonical item fields.
That same canonical item-label boundary must prefer recognizable protected-item
names over raw entity IDs. When unresolved Proxmox-backed recovery points only
have a VMID/CTID in the subject ref but still carry a richer backup comment or
@@ -4849,11 +4852,13 @@ implementation detail: `frontend-modern/src/hooks/useRecoveryPoints.ts` and
survived the page: `frontend-modern/src/types/recovery.ts`,
`frontend-modern/src/utils/recoveryDatePresentation.ts`,
`frontend-modern/src/utils/recoveryOutcomePresentation.ts`,
-`frontend-modern/src/utils/recoveryArtifactModePresentation.ts`,
`frontend-modern/src/utils/recoveryTimelinePresentation.ts`, and
`frontend-modern/src/utils/recoveryTimelineChartPresentation.ts`. They must not
inherit release-control coverage only through the platform tabs that render
-them.
+them. They hold only what those tabs read: the date and timeline helpers serve
+the Proxmox Backups tab and the outcome helper the TrueNAS Protection tab.
+Exports no tab reads, and `recoveryArtifactModePresentation.ts`, which only
+those exports read, have been removed.
`useRecoveryPoints.ts` also owns recovery transport normalization at the
frontend boundary: raw compatibility fields such as `provider` may still
arrive from older `/api/recovery/points` payloads, but the points it returns
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index ac2cdfa09f..17eca43781 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -5734,8 +5734,14 @@ recovery timeline day, chart range, workspace `view`, inventory `state`,
Recovery page. The Proxmox Backups tab owns its own day selection through
`PROXMOX_BACKUPS_QUERY_PARAMS.day`; its chart range is component state. Readers
of `/api/recovery/*` payloads must still prefer canonical `platform` /
-`platforms` response fields over legacy `provider` aliases, which
-`frontend-modern/src/utils/recoveryPlatformModel.ts` rewrites at decode time.
+`platforms` response fields over legacy `provider` aliases. The frontend's
+only recovery-points reader is `useRecoveryPoints.ts`, and
+`frontend-modern/src/utils/recoveryPlatformModel.ts` rewrites `provider`,
+`subjectRef`, and `display.subjectLabel` onto `platform`, `itemRef`, and
+`display.itemLabel` at decode time. The TrueNAS Protection tab
+(`TrueNASProtectionTable.tsx`, `truenasPageModel.ts`) reads only those
+canonical fields; the normalized `RecoveryPoint` type does not declare the
+subject names.
Shared API consumers now also depend on a single registry-list snapshot per
request when deriving canonical type aggregations for resource list and stats
responses. Re-reading `registry.List()` for the same `/api/resources` request
diff --git a/frontend-modern/browser-verification/1e721a086b69cef7.json b/frontend-modern/browser-verification/1e721a086b69cef7.json
new file mode 100644
index 0000000000..85c746f6e9
--- /dev/null
+++ b/frontend-modern/browser-verification/1e721a086b69cef7.json
@@ -0,0 +1,56 @@
+{
+ "version": 1,
+ "base_sha": "7606b72a8b85e70696e8bfa52a0792fbb146a34d",
+ "verified_at": "2026-10-08T10:01:00Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx",
+ "frontend-modern/src/features/truenas/truenasPageModel.ts",
+ "frontend-modern/src/types/recovery.ts",
+ "frontend-modern/src/utils/recoveryArtifactModePresentation.ts",
+ "frontend-modern/src/utils/recoveryDatePresentation.ts",
+ "frontend-modern/src/utils/recoveryOutcomePresentation.ts",
+ "frontend-modern/src/utils/recoveryPlatformModel.ts",
+ "frontend-modern/src/utils/recoveryTimelineChartPresentation.ts",
+ "frontend-modern/src/utils/recoveryTimelinePresentation.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx": "0ec586a6c69aca82bab09d684972700fe5cc2b6f0784f3d0f1a38a802711a661",
+ "frontend-modern/src/features/truenas/truenasPageModel.ts": "4908cb79fbfb3e8d38a66f835dcc4ed0937f197c69d73828dfa57e69c4e66bc9",
+ "frontend-modern/src/types/recovery.ts": "b88ebc335c77fecc07f0c4e6d02dc6727d53c03ddf817aaf9764f95f459a3aaf",
+ "frontend-modern/src/utils/recoveryArtifactModePresentation.ts": "deleted",
+ "frontend-modern/src/utils/recoveryDatePresentation.ts": "594bcb5679a79d78ef8b62277582be86240f4afc1d8f7bde4f4c5384dc28982f",
+ "frontend-modern/src/utils/recoveryOutcomePresentation.ts": "61df2fb6c642fd7a674160cc62ab467a59163dff522758a73f34521625ca5996",
+ "frontend-modern/src/utils/recoveryPlatformModel.ts": "aa2243a0271cf023a81b9d8abfc41a017754de2dc3486bd886f04e342468c9d6",
+ "frontend-modern/src/utils/recoveryTimelineChartPresentation.ts": "060cc9680ff2560150a9ada0f921732f0c58dcc265ea539001c2d4c53a149f5f",
+ "frontend-modern/src/utils/recoveryTimelinePresentation.ts": "f31112eb1923a0f762f1f72c136e62044159a821b8c956bc03b4089b6065901b"
+ },
+ "routes": [
+ "/truenas/protection",
+ "/proxmox/backups/date"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Before/after pair on pulse-dev: production vite builds of the parent d2ac0c5112 and of this tree, each served with vite preview proxied to the 50-node mock rig on :7699 (which includes the TrueNAS recovery fixtures), driven by the same headless Chromium script at 1440x900 and 390x844.",
+ "TrueNAS Protection: 10 rows in both builds, every row named by its dataset (archive/backups, tank/apps, vault/compliance, tank/photos, tank/media, fast/vm-images) and none by a raw id; the status filter shows All 10, Attention 1, Healthy 8, Warning 0, Failed 1, Running 1, Unknown 0 at desktop; the labels come from display.itemLabel, which the decode produces from the backend display.subjectLabel.",
+ "TrueNAS Protection search for \"backups\" narrows to the same three rows (archive/backups, tank/media, archive/backups) in both builds at both widths; opening the first row shows the identical Protection detail panel (Kind Replication, Outcome Failed, Dataset archive/backups, Host truenas-main, Replication and Target sections) apart from the mock clock minute.",
+ "Proxmox Backups by date: the Activity range group offers 7d 30d 90d 1y and 30 day columns render in both builds; hovering the last active day (Wed, Oct 7: 834 backups) shows the same tooltip (Timeline day; PBS snapshots 267 (32%), PVE backup files 456 (55%), Guest snapshots 111 (13%)); clicking it selects the day (\"selected\" in the column label, Day filter badge, 144 table rows at desktop and 40 at phone, identical in both builds) and clicking again clears it.",
+ "Results JSON: 31 measurements, 29 identical; the two that differ are the TrueNAS detail text, which is identical once the mock clock minute (02:54 vs 02:55) is masked. No failing responses and no console errors in either build; the same /api/recovery/points?platform=truenas and /api/recovery/postures reads are the only recovery requests.",
+ "Dist proof: 189 files each side; 93 byte-identical, 93 differ only in chunk-hash names and SRI strings, 3 differ in code. After normalising hashes and short identifiers, TrueNAS-*.js loses only the display.subjectLabel and subjectRef terms in datasetLabel, truenasPageModel-*.js loses only the subject terms in the search tokens and the sort label, and the CSS loses exactly four unused rules (.bg-gray-400, .min-w-[8px], .min-w-[14px], .min-w-[28px]); no source references those classes any more.",
+ "check-bundle-size.mjs passes on both builds with no chunk renamed and .bundlesize.json unchanged: TrueNAS 16.87 to 16.86 kB gzip, truenasPageModel 5.96 to 5.92 kB, total JS 1367.68 to 1367.63 kB, total CSS 32.15 to 32.13 kB."
+ ],
+ "interactions": [
+ "Sign in with the rig login, load /truenas/protection, read the row labels, status filter options and row count, type \"backups\" into \"Search snapshots or replication\", read the narrowed rows, clear it, expand the first row and read the Protection detail panel; repeat at 390x844.",
+ "Load /proxmox/backups/date, read the activity range options and day-column count, hover the last day column with activity and read the tooltip rows, click it to select the day and read the column label, filter badge and table row count, click again to clear; repeat at 390x844.",
+ "Run the same script against the before and after builds and diff the JSON; screenshots of every state inspected."
+ ]
+}
diff --git a/frontend-modern/scripts/canonical-platform-audit.mjs b/frontend-modern/scripts/canonical-platform-audit.mjs
index 8ec3b24526..3ccadfc2cc 100644
--- a/frontend-modern/scripts/canonical-platform-audit.mjs
+++ b/frontend-modern/scripts/canonical-platform-audit.mjs
@@ -115,7 +115,6 @@ const ALLOWLIST = new Set([
'src/utils/organizationSettingsPresentation.ts',
'src/utils/ssoProviderPresentation.ts',
'src/utils/thresholdSliderPresentation.ts',
- 'src/utils/recoveryArtifactModePresentation.ts',
'src/utils/recoveryActionPresentation.ts',
'src/utils/recoveryDatePresentation.ts',
'src/utils/recoveryEmptyStatePresentation.ts',
@@ -968,13 +967,6 @@ const HELPER_RULES = [
message:
'Do not inline SSO certificate tone ternaries in component code. Use @/utils/ssoProviderPresentation instead.',
},
- {
- rule: 'canonical-recovery/no-local-artifact-mode-presentation-maps',
- regex:
- /\bconst\s+MODE_LABELS\s*:\s*Record<ArtifactMode,\s*string>\s*=|\bconst\s+MODE_BADGE_CLASS\s*:\s*Record<ArtifactMode,\s*string>\s*=|\bconst\s+CHART_SEGMENT_CLASS\s*:\s*Record<ArtifactMode,\s*string>\s*=/g,
- message:
- 'Do not define local recovery artifact mode presentation maps in page code. Use @/utils/recoveryArtifactModePresentation instead.',
- },
{
rule: 'canonical-recovery/no-local-filter-chip-presentation',
regex:
@@ -1012,7 +1004,7 @@ const HELPER_RULES = [
{
rule: 'canonical-recovery/no-local-date-presentation-helpers',
regex:
- /\bconst\s+dateKeyFromTimestamp\s*=\s*\(|\bconst\s+parseDateKey\s*=\s*\(|\bconst\s+prettyDateLabel\s*=\s*\(|\bconst\s+fullDateLabel\s*=\s*\(|\bconst\s+compactAxisLabel\s*=\s*\(|\bconst\s+formatTimeOnly\s*=\s*\(|\bconst\s+niceAxisMax\s*=\s*\(/g,
+ /\bconst\s+dateKeyFromTimestamp\s*=\s*\(|\bconst\s+parseDateKey\s*=\s*\(|\bconst\s+prettyDateLabel\s*=\s*\(|\bconst\s+fullDateLabel\s*=\s*\(|\bconst\s+compactAxisLabel\s*=\s*\(|\bconst\s+niceAxisMax\s*=\s*\(/g,
message:
'Do not define local recovery date or timeline formatting helpers in component code. Use @/utils/recoveryDatePresentation instead.',
},
@@ -1040,7 +1032,7 @@ const HELPER_RULES = [
{
rule: 'canonical-recovery/no-local-timeline-chart-presentation',
regex:
- /\bconst\s+labelEvery\s*=\s*dayCount\s*<=\s*7\s*\?\s*1\s*:\s*dayCount\s*<=\s*30\s*\?\s*3\s*:\s*10|inline-flex\s+rounded\s+border\s+border-border\s+bg-surface\s+p-0\.5\s+text-xs|font-semibold\s+text-blue-700\s+dark:text-blue-300|chartRangeDays\(\)\s*===\s*7[\s\S]{0,120}min-w-\[28px\][\s\S]{0,120}chartRangeDays\(\)\s*===\s*30[\s\S]{0,120}min-w-\[14px\]/g,
+ /\bconst\s+labelEvery\s*=\s*dayCount\s*<=\s*7\s*\?\s*1\s*:\s*dayCount\s*<=\s*30\s*\?\s*3\s*:\s*10|font-semibold\s+text-blue-700\s+dark:text-blue-300/g,
message:
'Do not define local recovery timeline chart presentation in component code. Use @/utils/recoveryTimelineChartPresentation instead.',
},
diff --git a/frontend-modern/src/api/__tests__/recoveryTransport.test.ts b/frontend-modern/src/api/__tests__/recoveryTransport.test.ts
index 9d15b54939..5c8391cf57 100644
--- a/frontend-modern/src/api/__tests__/recoveryTransport.test.ts
+++ b/frontend-modern/src/api/__tests__/recoveryTransport.test.ts
@@ -1,14 +1,21 @@
-import { afterEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, describe, expect, expectTypeOf, it, vi } from 'vitest';
import { existsSync, readdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { createRoot } from 'solid-js';
+import {
+ filterTrueNASProtectionPoints,
+ sortTrueNASProtectionPoints,
+} from '@/features/truenas/truenasPageModel';
import { resetCreateNonSuspendingQueryCacheForTest } from '@/hooks/createNonSuspendingQuery';
import { useRecoveryPoints } from '@/hooks/useRecoveryPoints';
-import {
- normalizeRecoveryPointsResponse,
- normalizeRecoveryRollupsResponse,
-} from '@/utils/recoveryPlatformModel';
+import type {
+ RecoveryPoint,
+ RecoveryPointDisplay,
+ RecoveryPointDisplayTransport,
+ RecoveryPointTransport,
+} from '@/types/recovery';
+import { normalizeRecoveryPointsResponse } from '@/utils/recoveryPlatformModel';
const apiFetchJSONMock = vi.hoisted(() => vi.fn());
vi.mock('@/utils/apiClient', () => ({ apiFetchJSON: apiFetchJSONMock }));
@@ -60,32 +67,6 @@ describe('recovery transport', () => {
],
meta: { page: 1, limit: 100, total: 1, totalPages: 1 },
});
-
- expect(
- normalizeRecoveryRollupsResponse({
- data: [
- {
- rollupId: 'rollup-1',
- lastOutcome: 'success',
- providers: ['truenas'],
- subjectResourceId: 'res-1',
- subjectRef: { type: 'truenas-dataset', name: 'tank/apps' },
- },
- ],
- meta: { page: 1, limit: 100, total: 1, totalPages: 1 },
- }),
- ).toEqual({
- data: [
- {
- rollupId: 'rollup-1',
- lastOutcome: 'success',
- platforms: ['truenas'],
- itemResourceId: 'res-1',
- itemRef: { type: 'truenas-dataset', name: 'tank/apps' },
- },
- ],
- meta: { page: 1, limit: 100, total: 1, totalPages: 1 },
- });
});
it('normalizes legacy display aliases onto the canonical item labels', () => {
@@ -144,6 +125,55 @@ describe('recovery transport', () => {
}
});
+ it('labels, sorts and finds TrueNAS rows by the backend subject label only through the decode', async () => {
+ // The points handler sends the dataset label only as display.subjectLabel.
+ // The TrueNAS Protection tab reads display.itemLabel, never the subject
+ // names, so the fold in recoveryPlatformModel is what names these rows.
+ // Ids sort opposite to labels, so an unlabelled row would sort by id.
+ const backendPoint = (id: string, label: string) => ({
+ id,
+ platform: 'truenas',
+ provider: 'truenas',
+ kind: 'snapshot',
+ mode: 'snapshot',
+ outcome: 'success',
+ completedAt: '2026-10-01T00:00:00Z',
+ display: { subjectLabel: label, subjectType: 'dataset', itemType: 'dataset' },
+ });
+ apiFetchJSONMock.mockResolvedValue({
+ data: [backendPoint('point-a', 'tank/zeta'), backendPoint('point-b', 'tank/alpha')],
+ meta: { page: 1, limit: 200, total: 2, totalPages: 1 },
+ });
+ let dispose = () => {};
+ const points = createRoot((rootDispose) => {
+ dispose = rootDispose;
+ return useRecoveryPoints(() => ({ platform: 'truenas', page: 1, limit: 200 })).points;
+ });
+ try {
+ await vi.waitFor(() => expect(points()).toHaveLength(2));
+ expect(sortTrueNASProtectionPoints(points()).map((point) => point.id)).toEqual([
+ 'point-b',
+ 'point-a',
+ ]);
+ expect(
+ filterTrueNASProtectionPoints(points(), 'zeta', 'all').map((point) => point.id),
+ ).toEqual(['point-a']);
+ } finally {
+ dispose();
+ }
+ });
+
+ it('keeps the backend subject names on the transport types only', () => {
+ // Enforced by the frontend type check, not at runtime: a consumer cannot
+ // read subjectRef or display.subjectLabel off a normalized point.
+ expectTypeOf<RecoveryPoint>().not.toHaveProperty('subjectRef');
+ expectTypeOf<RecoveryPointDisplay>().not.toHaveProperty('subjectLabel');
+ expectTypeOf<RecoveryPointDisplay>().not.toHaveProperty('subjectType');
+ expectTypeOf<RecoveryPointTransport>().toHaveProperty('subjectRef');
+ expectTypeOf<RecoveryPointDisplayTransport>().toHaveProperty('subjectLabel');
+ expectTypeOf<RecoveryPointDisplayTransport>().toHaveProperty('subjectType');
+ });
+
it('keeps useRecoveryPoints the only recovery-points reader', () => {
// The rollup, facet and series hooks went with the aggregate Recovery
// page, and the item-type helper with the recovery query serializer that
@@ -160,6 +190,7 @@ describe('recovery transport', () => {
'src/hooks/useRecoveryPointsFacets.ts',
'src/hooks/useRecoveryPointsSeries.ts',
'src/utils/recoveryItemTypePresentation.ts',
+ 'src/utils/recoveryArtifactModePresentation.ts',
]) {
expect(existsSync(retired), retired).toBe(false);
}
diff --git a/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx b/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
index d6b94745ed..9566203592 100644
--- a/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
@@ -101,9 +101,7 @@ const protectionVariant = (status: TrueNASProtectionStatusBucket): StatusIndicat
const datasetLabel = (point: RecoveryPoint): string =>
asTrimmedString(point.display?.itemLabel) ||
- asTrimmedString(point.display?.subjectLabel) ||
asTrimmedString(point.itemRef?.name) ||
- asTrimmedString(point.subjectRef?.name) ||
detailString(point, 'dataset') ||
detailStringList(point, 'sourceDatasets')[0] ||
point.id;
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.branchcov0723pm.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.branchcov0723pm.test.ts
index 0a59857e5e..4001c2eea2 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.branchcov0723pm.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.branchcov0723pm.test.ts
@@ -230,18 +230,18 @@ describe('truenasPageModel branchcov0723pm', () => {
// Each operand of the `||` chain must be the resolving label for both
// sides at least once. Equal timestamps force the label tiebreak.
- it('resolves both labels via display.subjectLabel (itemLabel absent)', () => {
+ it('resolves both labels via display.itemLabel', () => {
const z = makeRecoveryPoint({
id: 'z-id',
kind: 'snapshot',
mode: 'snapshot',
- display: { subjectLabel: 'zzz' },
+ display: { itemLabel: 'zzz' },
});
const a = makeRecoveryPoint({
id: 'a-id',
kind: 'snapshot',
mode: 'snapshot',
- display: { subjectLabel: 'aaa' },
+ display: { itemLabel: 'aaa' },
});
expect(sortTrueNASProtectionPoints([z, a]).map((p) => p.id)).toEqual(['a-id', 'z-id']);
});
@@ -261,49 +261,33 @@ describe('truenasPageModel branchcov0723pm', () => {
});
expect(sortTrueNASProtectionPoints([z, a]).map((p) => p.id)).toEqual(['a-id', 'z-id']);
});
-
- it('resolves both labels via subjectRef.name (display and itemRef absent)', () => {
- const z = makeRecoveryPoint({
- id: 'z-id',
- kind: 'snapshot',
- mode: 'snapshot',
- subjectRef: { type: 'truenas-dataset', name: 'zzz' },
- });
- const a = makeRecoveryPoint({
- id: 'a-id',
- kind: 'snapshot',
- mode: 'snapshot',
- subjectRef: { type: 'truenas-dataset', name: 'aaa' },
- });
- expect(sortTrueNASProtectionPoints([z, a]).map((p) => p.id)).toEqual(['a-id', 'z-id']);
- });
});
- describe('trueNASProtectionSearchTokens subjectRef optional-chaining arms (via filterTrueNASProtectionPoints)', () => {
- it('matches by subjectRef namespace, uid, id, and name when subjectRef is fully populated', () => {
+ describe('trueNASProtectionSearchTokens itemRef optional-chaining arms (via filterTrueNASProtectionPoints)', () => {
+ it('matches by itemRef namespace, uid, id, and name when itemRef is fully populated', () => {
const point = makeRecoveryPoint({
id: 'p',
kind: 'snapshot',
mode: 'snapshot',
- subjectRef: {
+ itemRef: {
type: 'truenas-dataset',
- namespace: 'subj-ns-token',
- name: 'subj-name-token',
- uid: 'subj-uid-token',
- id: 'subj-id-token',
+ namespace: 'item-ns-token',
+ name: 'item-name-token',
+ uid: 'item-uid-token',
+ id: 'item-id-token',
},
});
expect(
- filterTrueNASProtectionPoints([point], 'subj-ns-token', 'all').map((p) => p.id),
+ filterTrueNASProtectionPoints([point], 'item-ns-token', 'all').map((p) => p.id),
).toEqual(['p']);
expect(
- filterTrueNASProtectionPoints([point], 'subj-uid-token', 'all').map((p) => p.id),
+ filterTrueNASProtectionPoints([point], 'item-uid-token', 'all').map((p) => p.id),
).toEqual(['p']);
expect(
- filterTrueNASProtectionPoints([point], 'subj-id-token', 'all').map((p) => p.id),
+ filterTrueNASProtectionPoints([point], 'item-id-token', 'all').map((p) => p.id),
).toEqual(['p']);
expect(
- filterTrueNASProtectionPoints([point], 'subj-name-token', 'all').map((p) => p.id),
+ filterTrueNASProtectionPoints([point], 'item-name-token', 'all').map((p) => p.id),
).toEqual(['p']);
});
});
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.coverage2.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.coverage2.test.ts
index 5c6bb7a038..ff9309076f 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.coverage2.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.coverage2.test.ts
@@ -425,12 +425,13 @@ describe('truenasPageModel coverage2', () => {
});
describe('sortTrueNASProtectionPoints label-fallback chain', () => {
- it('uses display.subjectLabel when display.itemLabel is absent', () => {
- const usesSubject = makeRecoveryPoint({
+ it('uses display.itemLabel ahead of itemRef.name and the id', () => {
+ const usesLabel = makeRecoveryPoint({
id: 'zzz-id',
kind: 'snapshot',
mode: 'snapshot',
- display: { subjectLabel: 'aaa' },
+ display: { itemLabel: 'aaa' },
+ itemRef: { type: 'truenas-dataset', name: 'zzz' },
});
const usesItem = makeRecoveryPoint({
id: 'mmm-id',
@@ -438,9 +439,9 @@ describe('truenasPageModel coverage2', () => {
mode: 'snapshot',
display: { itemLabel: 'zzz' },
});
- // Equal timestamps -> label tiebreak. usesSubject's label resolves to
- // subjectLabel 'aaa' (not its id 'zzz-id'), so it sorts first.
- expect(sortTrueNASProtectionPoints([usesSubject, usesItem]).map((p) => p.id)).toEqual([
+ // Equal timestamps -> label tiebreak. usesLabel's label resolves to
+ // itemLabel 'aaa' (not its itemRef 'zzz' or id 'zzz-id'), so it sorts first.
+ expect(sortTrueNASProtectionPoints([usesLabel, usesItem]).map((p) => p.id)).toEqual([
'zzz-id',
'mmm-id',
]);
@@ -463,24 +464,6 @@ describe('truenasPageModel coverage2', () => {
'mmm-id',
]);
});
-
- it('uses subjectRef.name when display and itemRef are absent', () => {
- const usesSubjectRef = makeRecoveryPoint({
- id: 'zzz-id',
- kind: 'snapshot',
- mode: 'snapshot',
- subjectRef: { type: 'truenas-dataset', name: 'aaa' },
- });
- const fallbackId = makeRecoveryPoint({
- id: 'mmm-id',
- kind: 'snapshot',
- mode: 'snapshot',
- });
- expect(sortTrueNASProtectionPoints([usesSubjectRef, fallbackId]).map((p) => p.id)).toEqual([
- 'zzz-id',
- 'mmm-id',
- ]);
- });
});
describe('trueNASProtectionSearchTokens (via filterTrueNASProtectionPoints)', () => {
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index 75c13bcf0b..24e8edf79d 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -936,9 +936,7 @@ const trueNASProtectionSearchTokens = (point: RecoveryPoint): string[] => {
point.node,
point.namespace,
point.display?.itemLabel,
- point.display?.subjectLabel,
point.display?.itemType,
- point.display?.subjectType,
point.display?.clusterLabel,
point.display?.nodeHostLabel,
point.display?.nodeAgentLabel,
@@ -951,11 +949,6 @@ const trueNASProtectionSearchTokens = (point: RecoveryPoint): string[] => {
point.itemRef?.name,
point.itemRef?.uid,
point.itemRef?.id,
- point.subjectRef?.type,
- point.subjectRef?.namespace,
- point.subjectRef?.name,
- point.subjectRef?.uid,
- point.subjectRef?.id,
point.repositoryRef?.type,
point.repositoryRef?.namespace,
point.repositoryRef?.name,
@@ -992,17 +985,9 @@ export function sortTrueNASProtectionPoints(points: readonly RecoveryPoint[]): R
const timeDelta = getRecoveryPointTimestampMs(right) - getRecoveryPointTimestampMs(left);
if (timeDelta !== 0) return timeDelta;
const leftLabel =
- asTrimmedString(left.display?.itemLabel) ||
- asTrimmedString(left.display?.subjectLabel) ||
- asTrimmedString(left.itemRef?.name) ||
- asTrimmedString(left.subjectRef?.name) ||
- left.id;
+ asTrimmedString(left.display?.itemLabel) || asTrimmedString(left.itemRef?.name) || left.id;
const rightLabel =
- asTrimmedString(right.display?.itemLabel) ||
- asTrimmedString(right.display?.subjectLabel) ||
- asTrimmedString(right.itemRef?.name) ||
- asTrimmedString(right.subjectRef?.name) ||
- right.id;
+ asTrimmedString(right.display?.itemLabel) || asTrimmedString(right.itemRef?.name) || right.id;
return leftLabel.localeCompare(rightLabel);
});
}
diff --git a/frontend-modern/src/types/recovery.ts b/frontend-modern/src/types/recovery.ts
index 5dd8734ec4..3f47b3b69e 100644
--- a/frontend-modern/src/types/recovery.ts
+++ b/frontend-modern/src/types/recovery.ts
@@ -17,8 +17,6 @@ export interface RecoveryExternalRef {
}
export interface RecoveryPointDisplay {
- subjectLabel?: string;
- subjectType?: string;
itemLabel?: string;
itemType?: string;
isWorkload?: boolean;
@@ -31,7 +29,13 @@ export interface RecoveryPointDisplay {
detailsSummary?: string;
}
-export type RecoveryPointDisplayTransport = RecoveryPointDisplay;
+// The backend display names the item label and type subjectLabel and
+// subjectType. recoveryPlatformModel folds them onto itemLabel and itemType,
+// so normalized points never carry them.
+export interface RecoveryPointDisplayTransport extends RecoveryPointDisplay {
+ subjectLabel?: string;
+ subjectType?: string;
+}
export interface RecoveryPoint {
id: string;
@@ -59,7 +63,6 @@ export interface RecoveryPoint {
providerScope?: string;
evidence?: EvidenceEnvelope | null;
itemRef?: RecoveryExternalRef | null;
- subjectRef?: RecoveryExternalRef | null;
repositoryRef?: RecoveryExternalRef | null;
details?: Record<string, unknown> | null;
@@ -70,6 +73,7 @@ export interface RecoveryPointTransport extends RecoveryPoint {
display?: RecoveryPointDisplayTransport | null;
provider?: RecoveryPlatform;
subjectResourceId?: string;
+ subjectRef?: RecoveryExternalRef | null;
}
export interface RecoveryResponseMeta {
@@ -89,63 +93,6 @@ export interface RecoveryPointsTransportResponse {
meta: RecoveryResponseMeta;
}
-export type VerifyIntent = 'verified' | 'stale' | 'unknown';
-
-export interface ProtectionRollup {
- rollupId: string;
- itemResourceId?: string;
- itemRef?: RecoveryExternalRef | null;
- subjectRef?: RecoveryExternalRef | null;
- display?: RecoveryPointDisplay | null;
-
- lastAttemptAt?: string | null;
- lastSuccessAt?: string | null;
- // Older payloads may omit this even though the canonical backend contract now supplies it.
- lastOutcome?: RecoveryOutcome;
-
- platforms?: RecoveryPlatform[];
-
- // VerifyIntent tracks whether the most recent successful backup for this
- // subject has been verified within the staleness window. Omitted by older
- // backends; absence is equivalent to "unknown".
- verifyIntent?: VerifyIntent;
- lastVerifiedAt?: string | null;
-}
-
-export interface ProtectionRollupTransport extends ProtectionRollup {
- display?: RecoveryPointDisplayTransport | null;
- providers?: RecoveryPlatform[];
- subjectResourceId?: string;
-}
-
-export interface RecoveryRollupsResponse {
- data: ProtectionRollup[];
- meta: RecoveryResponseMeta;
-}
-
-export interface RecoveryRollupsTransportResponse {
- data: ProtectionRollupTransport[];
- meta: RecoveryResponseMeta;
-}
-
-export interface RecoveryPointsSeriesBucket {
- day: string; // YYYY-MM-DD (client timezone)
- total: number;
- snapshot: number;
- local: number;
- remote: number;
-}
-
-export interface RecoveryPointsFacets {
- clusters?: string[];
- nodesAgents?: string[];
- namespaces?: string[];
- itemTypes?: string[];
- hasSize?: boolean;
- hasVerification?: boolean;
- hasEntityId?: boolean;
-}
-
export type ProtectionState = 'protected' | 'attention' | 'unprotected' | 'unknown';
export type ProtectionFreshness = 'current' | 'stale' | 'unknown';
export type ProtectionVerification = 'verified' | 'unverified' | 'stale' | 'unknown';
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 6690fbc986..2c3198c3b0 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -120,7 +120,6 @@ import environmentLockPresentationSource from '@/utils/environmentLockPresentati
import dockerRuntimeSettingsCardSource from '@/components/Settings/DockerRuntimeSettingsCard.tsx?raw';
import discoveryTargetSource from '@/utils/discoveryTarget.ts?raw';
import recoveryOutcomePresentationSource from '@/utils/recoveryOutcomePresentation.ts?raw';
-import recoveryArtifactModePresentationSource from '@/utils/recoveryArtifactModePresentation.ts?raw';
import recoveryDatePresentationSource from '@/utils/recoveryDatePresentation.ts?raw';
import recoveryTimelineChartPresentationSource from '@/utils/recoveryTimelineChartPresentation.ts?raw';
import recoveryTimelinePresentationSource from '@/utils/recoveryTimelinePresentation.ts?raw';
@@ -932,9 +931,6 @@ describe('frontend resource type boundaries', () => {
expect(emptyStatePresentationSource).toContain('export function getEmptyStatePresentation');
expect(discoveryTargetSource).toContain('canonicalizeFrontendResourceType');
expect(recoveryOutcomePresentationSource).toContain('import type { RecoveryOutcome }');
- expect(recoveryArtifactModePresentationSource).toContain(
- 'export function getRecoveryArtifactModePresentation',
- );
expect(recoveryDatePresentationSource).toContain(
'export function recoveryDateKeyFromTimestamp',
);
@@ -943,14 +939,10 @@ describe('frontend resource type boundaries', () => {
expect(recoveryDatePresentationSource).toContain('export function getRecoveryFullDateLabel');
expect(recoveryDatePresentationSource).toContain('export function getRecoveryFilterDateLabel');
expect(recoveryDatePresentationSource).toContain('export function getRecoveryCompactAxisLabel');
- expect(recoveryDatePresentationSource).toContain('export function formatRecoveryTimeOnly');
expect(recoveryDatePresentationSource).toContain('export function getRecoveryNiceAxisMax');
expect(recoveryTimelineChartPresentationSource).toContain(
'export function getRecoveryTimelineAxisLabelClass',
);
- expect(recoveryTimelineChartPresentationSource).toContain(
- 'export function getRecoveryTimelineBarMinWidthClass',
- );
expect(recoveryTimelineChartPresentationSource).toContain(
'export function getRecoveryTimelineLabelEvery',
);
diff --git a/frontend-modern/src/utils/__tests__/recoveryArtifactModePresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryArtifactModePresentation.test.ts
deleted file mode 100644
index 32e2dd33da..0000000000
--- a/frontend-modern/src/utils/__tests__/recoveryArtifactModePresentation.test.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import { getRecoveryArtifactModePresentation } from '@/utils/recoveryArtifactModePresentation';
-
-describe('recoveryArtifactModePresentation', () => {
- it('returns canonical singular and aggregate labels, badge tones, and chart segment classes', () => {
- expect(getRecoveryArtifactModePresentation('snapshot')).toEqual({
- label: 'Snapshot',
- aggregateLabel: 'Snapshots',
- badgeClassName: 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/25 dark:text-yellow-300',
- segmentClassName: 'bg-yellow-500',
- });
- expect(getRecoveryArtifactModePresentation('local')).toEqual({
- label: 'Local Copy',
- aggregateLabel: 'Local Copies',
- badgeClassName: 'bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300',
- segmentClassName: 'bg-orange-500',
- });
- expect(getRecoveryArtifactModePresentation('remote')).toEqual({
- label: 'Remote Copy',
- aggregateLabel: 'Remote Copies',
- badgeClassName: 'bg-indigo-100 text-indigo-700 dark:bg-indigo-900/25 dark:text-indigo-300',
- segmentClassName: 'bg-indigo-500',
- });
- });
-});
diff --git a/frontend-modern/src/utils/__tests__/recoveryDatePresentation.branchcov2.test.ts b/frontend-modern/src/utils/__tests__/recoveryDatePresentation.branchcov2.test.ts
index a84c9beea3..8552afd1e5 100644
--- a/frontend-modern/src/utils/__tests__/recoveryDatePresentation.branchcov2.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryDatePresentation.branchcov2.test.ts
@@ -1,31 +1,7 @@
import { describe, expect, it } from 'vitest';
-import {
- normalizeRecoveryDateSearchText,
- parseRecoveryDateKey,
- resolveRecoveryDateSearchKey,
-} from '@/utils/recoveryDatePresentation';
+import { parseRecoveryDateKey } from '@/utils/recoveryDatePresentation';
describe('recoveryDatePresentation branch coverage (part 2)', () => {
- describe('normalizeRecoveryDateSearchText', () => {
- it('returns an empty string for a falsy value (value || "" branch)', () => {
- expect(normalizeRecoveryDateSearchText('')).toBe('');
- });
-
- it('strips 1st/2nd/3rd/4th and 21st-style ordinals before punctuation collapse', () => {
- expect(normalizeRecoveryDateSearchText('The 1st 2nd 3rd 4th and 21st')).toBe(
- 'the 1 2 3 4 and 21',
- );
- });
-
- it('collapses mixed punctuation, tabs, and repeated whitespace into single spaces', () => {
- expect(normalizeRecoveryDateSearchText(' Friday, Feb\t14th ')).toBe('friday feb 14');
- });
-
- it('lowercases and trims alphabetic-only input without ordinals', () => {
- expect(normalizeRecoveryDateSearchText(' FEBRUARY ')).toBe('february');
- });
- });
-
describe('parseRecoveryDateKey', () => {
it('falls back to new Date(key) when the year component is missing/NaN', () => {
const date = parseRecoveryDateKey('');
@@ -49,113 +25,4 @@ describe('recoveryDatePresentation branch coverage (part 2)', () => {
expect(date.getDate()).toBe(12);
});
});
-
- describe('resolveRecoveryDateSearchKey', () => {
- describe('length guard', () => {
- it('returns null when normalized text is shorter than 5 characters', () => {
- expect(resolveRecoveryDateSearchKey('Feb', [])).toBeNull();
- });
-
- it('proceeds when normalized text is exactly 5 characters (boundary)', () => {
- expect(resolveRecoveryDateSearchKey('vm 12', [])).toBeNull();
- });
- });
-
- describe('ISO-ish branch (yyyy m d)', () => {
- it('resolves a normalized ISO-ish date to a key', () => {
- expect(resolveRecoveryDateSearchKey('2026-02-14', [])).toBe('2026-02-14');
- });
-
- it('returns null when the ISO-ish month overflows (rollover guard in getRecoveryDateSearchKey)', () => {
- expect(resolveRecoveryDateSearchKey('2026 13 01', [])).toBeNull();
- });
-
- it('returns null when the ISO-ish day is impossible for the month (Feb 30 rollover)', () => {
- expect(resolveRecoveryDateSearchKey('2026 2 30', [])).toBeNull();
- });
- });
-
- describe('weekday prefix stripping', () => {
- it('strips a long weekday name before parsing the remainder', () => {
- expect(resolveRecoveryDateSearchKey('Monday Feb 14 2026', [])).toBe('2026-02-14');
- });
-
- it('strips a short weekday alias before parsing the remainder', () => {
- expect(resolveRecoveryDateSearchKey('Tue Feb 14 2026', [])).toBe('2026-02-14');
- });
- });
-
- describe('token count guard', () => {
- it('returns null when only a single non-weekday token remains (length < 2)', () => {
- expect(resolveRecoveryDateSearchKey('hello', [])).toBeNull();
- });
-
- it('returns null when a weekday is the only token (length 0 after shift)', () => {
- expect(resolveRecoveryDateSearchKey('monday', [])).toBeNull();
- });
-
- it('returns null when more than 3 tokens remain (length > 3)', () => {
- expect(resolveRecoveryDateSearchKey('feb 14 2026 foo', [])).toBeNull();
- });
- });
-
- describe('month/day validation', () => {
- it('returns null when the month token is not a recognized month alias (monthIndex null)', () => {
- expect(resolveRecoveryDateSearchKey('vm 14', [])).toBeNull();
- });
-
- it('returns null when the day token is non-numeric (Number.isInteger(day) false)', () => {
- expect(resolveRecoveryDateSearchKey('Feb ab', [])).toBeNull();
- });
- });
-
- describe('explicit-year (tokens[2]) branch', () => {
- it('returns null when tokens[2] is not a 4-digit year', () => {
- expect(resolveRecoveryDateSearchKey('Feb 14 26', [])).toBeNull();
- });
-
- it('returns null when the explicit year + month + day roll over (getRecoveryDateSearchKey guard)', () => {
- expect(resolveRecoveryDateSearchKey('Feb 30 2026', [])).toBeNull();
- });
- });
-
- describe('candidate resolution branch', () => {
- it('returns the single candidate key matching month/day', () => {
- expect(resolveRecoveryDateSearchKey('Feb 14', ['2026-02-13', '2026-02-14'])).toBe(
- '2026-02-14',
- );
- });
-
- it('returns null when multiple distinct candidate keys match the month/day', () => {
- expect(resolveRecoveryDateSearchKey('Feb 14', ['2025-02-14', '2026-02-14'])).toBeNull();
- });
-
- it('ignores falsy/blank candidate entries via the String(key || "") defensive mapping', () => {
- const keys = [null, undefined, '', '2026-02-14'] as unknown as readonly string[];
- expect(resolveRecoveryDateSearchKey('Feb 14', keys)).toBe('2026-02-14');
- });
-
- it('de-duplicates repeated matching candidate keys before the count check', () => {
- expect(
- resolveRecoveryDateSearchKey('Feb 14', ['2026-02-14', '2026-02-14', '2026-02-14']),
- ).toBe('2026-02-14');
- });
-
- it('falls back to the current year when candidates are present but none match', () => {
- expect(resolveRecoveryDateSearchKey('Feb 14', ['2026-03-09'], new Date(2026, 0, 1))).toBe(
- '2026-02-14',
- );
- });
-
- it('falls back to the provided now year when there are no candidates', () => {
- expect(resolveRecoveryDateSearchKey('Feb 14', [], new Date(2026, 4, 14))).toBe(
- '2026-02-14',
- );
- });
-
- it('returns null when the fallback date rolls over for the current year (Feb 30)', () => {
- expect(resolveRecoveryDateSearchKey('Feb 30', [], new Date(2026, 0, 1))).toBeNull();
- });
- });
- });
});
diff --git a/frontend-modern/src/utils/__tests__/recoveryDatePresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryDatePresentation.test.ts
index d721c1bb5c..6d14599ad7 100644
--- a/frontend-modern/src/utils/__tests__/recoveryDatePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryDatePresentation.test.ts
@@ -1,15 +1,12 @@
import { describe, expect, it } from 'vitest';
import {
- formatRecoveryTimeOnly,
getRecoveryCompactAxisLabel,
getRecoveryFilterDateLabel,
getRecoveryFullDateLabel,
getRecoveryNiceAxisMax,
getRecoveryPrettyDateLabel,
- normalizeRecoveryDateSearchText,
parseRecoveryDateKey,
recoveryDateKeyFromTimestamp,
- resolveRecoveryDateSearchKey,
} from '@/utils/recoveryDatePresentation';
describe('recoveryDatePresentation', () => {
@@ -37,24 +34,10 @@ describe('recoveryDatePresentation', () => {
expect(getRecoveryCompactAxisLabel(key, 90)).toBe('3/9');
});
- it('formats time-only and nice axis max values', () => {
- expect(formatRecoveryTimeOnly(null)).toBe('—');
- expect(formatRecoveryTimeOnly(Date.UTC(2026, 2, 9, 7, 5, 0))).toMatch(/\d{2}:\d{2}/);
+ it('formats nice axis max values', () => {
expect(getRecoveryNiceAxisMax(0)).toBe(1);
expect(getRecoveryNiceAxisMax(3)).toBe(3);
expect(getRecoveryNiceAxisMax(37)).toBe(50);
expect(getRecoveryNiceAxisMax(101)).toBe(200);
});
-
- it('resolves clear date search text to recovery day keys', () => {
- const candidateKeys = ['2026-02-13', '2026-02-14'];
-
- expect(normalizeRecoveryDateSearchText('Friday, Feb 14th')).toBe('friday feb 14');
- expect(resolveRecoveryDateSearchKey('2026-02-14', candidateKeys)).toBe('2026-02-14');
- expect(resolveRecoveryDateSearchKey('Feb 14', candidateKeys)).toBe('2026-02-14');
- expect(resolveRecoveryDateSearchKey('February 14, 2026', candidateKeys)).toBe('2026-02-14');
- expect(resolveRecoveryDateSearchKey('Feb 14', [], new Date(2026, 4, 14))).toBe('2026-02-14');
- expect(resolveRecoveryDateSearchKey('VM 123', candidateKeys)).toBeNull();
- expect(resolveRecoveryDateSearchKey('Feb', candidateKeys)).toBeNull();
- });
});
diff --git a/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.branchcov2.test.ts b/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.branchcov2.test.ts
index a8357597b0..7394c7f39d 100644
--- a/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.branchcov2.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.branchcov2.test.ts
@@ -2,9 +2,7 @@ import { describe, expect, it } from 'vitest';
import type { RecoveryOutcome } from '@/types/recovery';
import {
getRecoveryOutcomeBadgeClass,
- getRecoveryOutcomeBarClass,
getRecoveryOutcomeLabel,
- getRecoveryOutcomeTextClass,
normalizeRecoveryOutcome,
} from '@/utils/recoveryOutcomePresentation';
@@ -93,32 +91,4 @@ describe('recoveryOutcomePresentation — branch coverage (branchcov2)', () => {
);
});
});
-
- describe('getRecoveryOutcomeBarClass', () => {
- it('returns a solid bar color for each canonical outcome', () => {
- expect(getRecoveryOutcomeBarClass('success')).toBe('bg-emerald-500');
- expect(getRecoveryOutcomeBarClass('warning')).toBe('bg-amber-400');
- expect(getRecoveryOutcomeBarClass('failed')).toBe('bg-red-500');
- expect(getRecoveryOutcomeBarClass('running')).toBe('bg-blue-500');
- });
-
- it('falls back to gray for the default arm', () => {
- expect(getRecoveryOutcomeBarClass('unknown')).toBe('bg-gray-400');
- expect(getRecoveryOutcomeBarClass(NON_CANONICAL)).toBe('bg-gray-400');
- });
- });
-
- describe('getRecoveryOutcomeTextClass', () => {
- it('returns a dark-mode-aware text tone for each canonical outcome', () => {
- expect(getRecoveryOutcomeTextClass('success')).toBe('text-emerald-600 dark:text-emerald-400');
- expect(getRecoveryOutcomeTextClass('warning')).toBe('text-amber-600 dark:text-amber-400');
- expect(getRecoveryOutcomeTextClass('failed')).toBe('text-red-600 dark:text-red-400');
- expect(getRecoveryOutcomeTextClass('running')).toBe('text-blue-600 dark:text-blue-400');
- });
-
- it('falls back to text-muted for the default arm', () => {
- expect(getRecoveryOutcomeTextClass('unknown')).toBe('text-muted');
- expect(getRecoveryOutcomeTextClass(NON_CANONICAL)).toBe('text-muted');
- });
- });
});
diff --git a/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.test.ts
index 40b0491f59..6f05a901ad 100644
--- a/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryOutcomePresentation.test.ts
@@ -1,18 +1,11 @@
import { describe, expect, it } from 'vitest';
import {
- RECOVERY_OUTCOMES,
- getRecoveryOutcomeBarClass,
getRecoveryOutcomeBadgeClass,
getRecoveryOutcomeLabel,
- getRecoveryOutcomeTextClass,
normalizeRecoveryOutcome,
} from '@/utils/recoveryOutcomePresentation';
describe('recoveryOutcomePresentation', () => {
- it('exports the canonical outcome order', () => {
- expect(RECOVERY_OUTCOMES).toEqual(['success', 'warning', 'failed', 'running', 'unknown']);
- });
-
it('normalizes known outcomes', () => {
expect(normalizeRecoveryOutcome(' Failed ')).toBe('failed');
});
@@ -35,9 +28,7 @@ describe('recoveryOutcomePresentation', () => {
expect(getRecoveryOutcomeBadgeClass('running')).toContain('blue-100');
});
- it('exposes canonical outcome labels and summary tones', () => {
+ it('exposes canonical outcome labels', () => {
expect(getRecoveryOutcomeLabel('success')).toBe('Healthy');
- expect(getRecoveryOutcomeBarClass('warning')).toBe('bg-amber-400');
- expect(getRecoveryOutcomeTextClass('unknown')).toBe('text-muted');
});
});
diff --git a/frontend-modern/src/utils/__tests__/recoveryPlatformModel.branchcov2.test.ts b/frontend-modern/src/utils/__tests__/recoveryPlatformModel.branchcov2.test.ts
index 86a47450b0..fd886c713c 100644
--- a/frontend-modern/src/utils/__tests__/recoveryPlatformModel.branchcov2.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryPlatformModel.branchcov2.test.ts
@@ -2,11 +2,8 @@ import { describe, expect, it } from 'vitest';
import {
getRecoveryPointPlatform,
- getRecoveryRollupPlatforms,
normalizeRecoveryPoint,
normalizeRecoveryPointsResponse,
- normalizeRecoveryRollup,
- normalizeRecoveryRollupsResponse,
} from '@/utils/recoveryPlatformModel';
/**
@@ -54,35 +51,6 @@ describe('recoveryPlatformModel.branchcov2', () => {
});
});
- describe('getRecoveryRollupPlatforms', () => {
- it('falls back to providers when platforms is an empty array', () => {
- expect(getRecoveryRollupPlatforms({ platforms: [], providers: ['x'] })).toEqual(['x']);
- });
-
- it('falls back to providers when platforms is not an array', () => {
- const malformed = {
- platforms: 'nope',
- providers: ['kubernetes'],
- } as unknown as Parameters<typeof getRecoveryRollupPlatforms>[0];
- expect(getRecoveryRollupPlatforms(malformed)).toEqual(['kubernetes']);
- });
-
- it('returns an empty array when both platforms and providers are absent', () => {
- expect(getRecoveryRollupPlatforms({})).toEqual([]);
- expect(getRecoveryRollupPlatforms(null)).toEqual([]);
- expect(getRecoveryRollupPlatforms(undefined)).toEqual([]);
- });
-
- it('trims and filters blank entries from the resolved values', () => {
- expect(getRecoveryRollupPlatforms({ platforms: [' a ', '', ' ', 'b'] })).toEqual([
- 'a',
- 'b',
- ]);
- // All entries normalize to empty -> filter(Boolean) yields [].
- expect(getRecoveryRollupPlatforms({ platforms: [' ', ''] })).toEqual([]);
- });
- });
-
describe('normalizeRecoveryDisplay (via normalizeRecoveryPoint)', () => {
const basePoint = {
id: 'p1',
@@ -229,19 +197,6 @@ describe('recoveryPlatformModel.branchcov2', () => {
});
});
- describe('normalizeRecoveryRollup', () => {
- it('returns a minimal rollup unchanged when optional fields are absent', () => {
- const minimal = { rollupId: 'r-min', lastOutcome: 'warning' as const };
- expect(normalizeRecoveryRollup(minimal)).toStrictEqual(minimal);
- });
-
- it('passes a null display through unchanged', () => {
- expect(
- normalizeRecoveryRollup({ rollupId: 'r1', lastOutcome: 'success', display: null }),
- ).toStrictEqual({ rollupId: 'r1', lastOutcome: 'success', display: null });
- });
- });
-
describe('normalizeRecoveryMeta (via response normalizers)', () => {
it('passes valid finite numeric meta through unchanged', () => {
const meta = { page: 2, limit: 50, total: 7, totalPages: 1 };
@@ -259,10 +214,10 @@ describe('recoveryPlatformModel.branchcov2', () => {
} as unknown as Parameters<typeof normalizeRecoveryPointsResponse>[0]),
).toStrictEqual({ data: [], meta: defaults });
expect(
- normalizeRecoveryRollupsResponse({
+ normalizeRecoveryPointsResponse({
data: [],
meta: null,
- } as unknown as Parameters<typeof normalizeRecoveryRollupsResponse>[0]),
+ } as unknown as Parameters<typeof normalizeRecoveryPointsResponse>[0]),
).toStrictEqual({ data: [], meta: defaults });
});
});
@@ -280,36 +235,4 @@ describe('recoveryPlatformModel.branchcov2', () => {
});
});
});
-
- describe('normalizeRecoveryRollupsResponse', () => {
- it('normalizes an array of rollups and preserves finite meta', () => {
- expect(
- normalizeRecoveryRollupsResponse({
- data: [
- {
- rollupId: 'r1',
- lastOutcome: 'success',
- providers: ['truenas'],
- },
- ],
- meta: { page: 1, limit: 10, total: 1, totalPages: 1 },
- }),
- ).toStrictEqual({
- data: [{ rollupId: 'r1', lastOutcome: 'success', platforms: ['truenas'] }],
- meta: { page: 1, limit: 10, total: 1, totalPages: 1 },
- });
- });
-
- it('returns empty data and default meta for a malformed payload', () => {
- expect(
- normalizeRecoveryRollupsResponse({
- data: null,
- meta: undefined,
- } as unknown as Parameters<typeof normalizeRecoveryRollupsResponse>[0]),
- ).toStrictEqual({
- data: [],
- meta: { page: 1, limit: 0, total: 0, totalPages: 1 },
- });
- });
- });
});
diff --git a/frontend-modern/src/utils/__tests__/recoveryPlatformModel.test.ts b/frontend-modern/src/utils/__tests__/recoveryPlatformModel.test.ts
index f1f81374aa..89e6631f27 100644
--- a/frontend-modern/src/utils/__tests__/recoveryPlatformModel.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryPlatformModel.test.ts
@@ -2,11 +2,8 @@ import { describe, expect, it } from 'vitest';
import {
getRecoveryPointPlatform,
- getRecoveryRollupPlatforms,
normalizeRecoveryPoint,
normalizeRecoveryPointsResponse,
- normalizeRecoveryRollup,
- normalizeRecoveryRollupsResponse,
} from '@/utils/recoveryPlatformModel';
describe('recoveryPlatformModel', () => {
@@ -17,13 +14,6 @@ describe('recoveryPlatformModel', () => {
provider: 'proxmox-pve',
}),
).toBe('truenas');
-
- expect(
- getRecoveryRollupPlatforms({
- platforms: ['truenas'],
- providers: ['proxmox-pve'],
- }),
- ).toEqual(['truenas']);
});
it('falls back to legacy provider fields when canonical fields are absent', () => {
@@ -32,12 +22,6 @@ describe('recoveryPlatformModel', () => {
provider: 'proxmox-pbs',
}),
).toBe('proxmox-pbs');
-
- expect(
- getRecoveryRollupPlatforms({
- providers: ['proxmox-pbs', 'kubernetes'],
- }),
- ).toEqual(['proxmox-pbs', 'kubernetes']);
});
it('normalizes legacy recovery transport records into canonical runtime models', () => {
@@ -74,36 +58,6 @@ describe('recoveryPlatformModel', () => {
itemType: 'proxmox-vm',
},
});
-
- expect(
- normalizeRecoveryRollup({
- rollupId: 'rollup-1',
- lastOutcome: 'success',
- subjectResourceId: 'vm-123',
- subjectRef: {
- type: 'truenas-dataset',
- name: 'Legacy Dataset',
- },
- providers: ['proxmox-pbs', 'kubernetes'],
- display: {
- subjectLabel: 'Legacy Dataset',
- subjectType: 'truenas-dataset',
- },
- }),
- ).toEqual({
- rollupId: 'rollup-1',
- lastOutcome: 'success',
- itemResourceId: 'vm-123',
- itemRef: {
- type: 'truenas-dataset',
- name: 'Legacy Dataset',
- },
- platforms: ['proxmox-pbs', 'kubernetes'],
- display: {
- itemLabel: 'Legacy Dataset',
- itemType: 'truenas-dataset',
- },
- });
});
it('normalizes recovery transport responses to platform-first data', () => {
@@ -136,32 +90,6 @@ describe('recoveryPlatformModel', () => {
],
meta: { page: 1, limit: 100, total: 1, totalPages: 1 },
});
-
- expect(
- normalizeRecoveryRollupsResponse({
- data: [
- {
- rollupId: 'rollup-1',
- lastOutcome: 'warning',
- subjectResourceId: 'res-1',
- subjectRef: { type: 'truenas-dataset', name: 'tank/apps' },
- providers: ['truenas'],
- },
- ],
- meta: { page: 1, limit: 100, total: 1, totalPages: 1 },
- }),
- ).toEqual({
- data: [
- {
- rollupId: 'rollup-1',
- lastOutcome: 'warning',
- itemResourceId: 'res-1',
- itemRef: { type: 'truenas-dataset', name: 'tank/apps' },
- platforms: ['truenas'],
- },
- ],
- meta: { page: 1, limit: 100, total: 1, totalPages: 1 },
- });
});
it('preserves display fallback data when degraded recovery metadata fields are omitted', () => {
@@ -192,27 +120,5 @@ describe('recoveryPlatformModel', () => {
detailsSummary: 'Immutable copy',
},
});
-
- expect(
- normalizeRecoveryRollup({
- rollupId: 'rollup-malformed',
- lastOutcome: 'warning',
- subjectResourceId: 'pvc-1',
- providers: ['kubernetes'],
- display: {
- subjectLabel: 'default/data',
- subjectType: 'k8s-pvc',
- },
- }),
- ).toEqual({
- rollupId: 'rollup-malformed',
- lastOutcome: 'warning',
- itemResourceId: 'pvc-1',
- platforms: ['kubernetes'],
- display: {
- itemLabel: 'default/data',
- itemType: 'k8s-pvc',
- },
- });
});
});
diff --git a/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts
index b11939612d..9b07176b33 100644
--- a/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts
@@ -2,28 +2,20 @@ import { describe, expect, it } from 'vitest';
import {
getRecoveryTimelineAxisLabelClass,
getRecoveryTimelineAxisTicks,
- getRecoveryTimelineBarMinWidthClass,
getRecoveryTimelineChartGapPx,
getRecoveryTimelineChartMinWidthPx,
getRecoveryTimelineLabelEvery,
RECOVERY_TIMELINE_LEGEND_ITEM_CLASS,
- RECOVERY_TIMELINE_RANGE_GROUP_CLASS,
} from '@/utils/recoveryTimelineChartPresentation';
describe('recoveryTimelineChartPresentation', () => {
- it('exposes shared legend and range-group classes', () => {
+ it('exposes the shared legend item class', () => {
expect(RECOVERY_TIMELINE_LEGEND_ITEM_CLASS).toContain('items-center');
- expect(RECOVERY_TIMELINE_RANGE_GROUP_CLASS).toContain('border-border');
});
- it('derives axis label and bar width classes', () => {
+ it('derives axis label classes', () => {
expect(getRecoveryTimelineAxisLabelClass(true)).toContain('text-blue-700');
expect(getRecoveryTimelineAxisLabelClass(false)).toBe('text-muted');
- expect(getRecoveryTimelineBarMinWidthClass(true, 30)).toBe('');
- expect(getRecoveryTimelineBarMinWidthClass(false, 7)).toBe('min-w-[28px]');
- expect(getRecoveryTimelineBarMinWidthClass(false, 30)).toBe('min-w-[14px]');
- expect(getRecoveryTimelineBarMinWidthClass(false, 90)).toBe('min-w-[8px]');
- expect(getRecoveryTimelineBarMinWidthClass(false, 365)).toBe('');
});
it('derives label cadence from day count', () => {
diff --git a/frontend-modern/src/utils/__tests__/recoveryTimelinePresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryTimelinePresentation.test.ts
index b7aa2c472d..0718a72e0f 100644
--- a/frontend-modern/src/utils/__tests__/recoveryTimelinePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryTimelinePresentation.test.ts
@@ -1,13 +1,9 @@
import { describe, expect, it } from 'vitest';
import {
getRecoveryTimelineBarMarkerClass,
- getRecoveryTimelineColumnAriaLabel,
getRecoveryTimelineColumnButtonClass,
- getRecoveryTimelineDayFilterLabel,
getRecoveryTimelineDayFilterStateLabel,
getRecoveryTimelineEmptyMarkerClass,
- getRecoveryTimelinePointTotalLabel,
- getRecoveryTimelineTooltipRows,
} from '@/utils/recoveryTimelinePresentation';
describe('getRecoveryTimelineColumnButtonClass', () => {
@@ -37,48 +33,8 @@ describe('getRecoveryTimelineColumnButtonClass', () => {
expect(getRecoveryTimelineEmptyMarkerClass(false, true)).toContain('opacity-40');
});
- it('builds accessible selected-day labels', () => {
- expect(getRecoveryTimelineColumnAriaLabel('Feb 13, 2026', 1, false)).toBe(
- 'Feb 13, 2026: 1 recovery point',
- );
- expect(getRecoveryTimelineColumnAriaLabel('Feb 14, 2026', 2, true)).toBe(
- 'Feb 14, 2026: 2 recovery points, selected',
- );
- });
-
- it('builds tooltip rows as a vertical mode breakdown', () => {
- expect(
- getRecoveryTimelineTooltipRows({ total: 10, snapshot: 2, local: 3, remote: 5 }).map((row) => [
- row.label,
- row.value,
- row.muted,
- ]),
- ).toEqual([
- ['Snapshots', '2 (20%)', false],
- ['Local Copies', '3 (30%)', false],
- ['Remote Copies', '5 (50%)', false],
- ]);
-
- expect(
- getRecoveryTimelineTooltipRows({ total: 2, snapshot: 0, local: 2, remote: 0 }).map((row) => [
- row.label,
- row.value,
- row.muted,
- ]),
- ).toEqual([
- ['Snapshots', '0', true],
- ['Local Copies', '2 (100%)', false],
- ['Remote Copies', '0', true],
- ]);
- });
-
- it('formats timeline tooltip and selected-day labels', () => {
- expect(getRecoveryTimelinePointTotalLabel(1)).toBe('1 recovery point');
- expect(getRecoveryTimelinePointTotalLabel(0)).toBe('0 recovery points');
+ it('formats selected-day filter state labels', () => {
expect(getRecoveryTimelineDayFilterStateLabel(true, true)).toBe('Day filter');
expect(getRecoveryTimelineDayFilterStateLabel(false, true)).toBe('Outside day filter');
- expect(getRecoveryTimelineDayFilterLabel('Feb 14, 2026', 2)).toBe(
- 'Feb 14, 2026 - 2 recovery points',
- );
});
});
diff --git a/frontend-modern/src/utils/recoveryArtifactModePresentation.ts b/frontend-modern/src/utils/recoveryArtifactModePresentation.ts
deleted file mode 100644
index 2847c7240a..0000000000
--- a/frontend-modern/src/utils/recoveryArtifactModePresentation.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-export type RecoveryArtifactMode = 'snapshot' | 'local' | 'remote';
-
-export interface RecoveryArtifactModePresentation {
- label: string;
- aggregateLabel: string;
- badgeClassName: string;
- segmentClassName: string;
-}
-
-export function getRecoveryArtifactModePresentation(
- mode: RecoveryArtifactMode,
-): RecoveryArtifactModePresentation {
- switch (mode) {
- case 'snapshot':
- return {
- label: 'Snapshot',
- aggregateLabel: 'Snapshots',
- badgeClassName: 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/25 dark:text-yellow-300',
- segmentClassName: 'bg-yellow-500',
- };
- case 'remote':
- return {
- label: 'Remote Copy',
- aggregateLabel: 'Remote Copies',
- badgeClassName: 'bg-indigo-100 text-indigo-700 dark:bg-indigo-900/25 dark:text-indigo-300',
- segmentClassName: 'bg-indigo-500',
- };
- default:
- return {
- label: 'Local Copy',
- aggregateLabel: 'Local Copies',
- badgeClassName: 'bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300',
- segmentClassName: 'bg-orange-500',
- };
- }
-}
diff --git a/frontend-modern/src/utils/recoveryDatePresentation.ts b/frontend-modern/src/utils/recoveryDatePresentation.ts
index ab3ba539df..591ffd6445 100644
--- a/frontend-modern/src/utils/recoveryDatePresentation.ts
+++ b/frontend-modern/src/utils/recoveryDatePresentation.ts
@@ -6,38 +6,6 @@ export function recoveryDateKeyFromTimestamp(timestamp: number): string {
return `${year}-${month}-${day}`;
}
-const RECOVERY_DATE_SEARCH_MONTHS = [
- ['january', 'jan'],
- ['february', 'feb'],
- ['march', 'mar'],
- ['april', 'apr'],
- ['may', 'may'],
- ['june', 'jun'],
- ['july', 'jul'],
- ['august', 'aug'],
- ['september', 'sep', 'sept'],
- ['october', 'oct'],
- ['november', 'nov'],
- ['december', 'dec'],
-] as const;
-
-const RECOVERY_DATE_SEARCH_WEEKDAYS = new Set([
- 'monday',
- 'mon',
- 'tuesday',
- 'tue',
- 'wednesday',
- 'wed',
- 'thursday',
- 'thu',
- 'friday',
- 'fri',
- 'saturday',
- 'sat',
- 'sunday',
- 'sun',
-]);
-
export function parseRecoveryDateKey(key: string): Date {
const [year, month, day] = key.split('-').map((value) => Number.parseInt(value, 10));
if (!year || !month || !day) return new Date(key);
@@ -69,78 +37,6 @@ export function getRecoveryFilterDateLabel(key: string): string {
});
}
-function getRecoveryDateSearchMonthIndex(value: string): number | null {
- const normalized = value.toLowerCase();
- const index = RECOVERY_DATE_SEARCH_MONTHS.findIndex((aliases) =>
- (aliases as readonly string[]).includes(normalized),
- );
- return index >= 0 ? index : null;
-}
-
-function getRecoveryDateSearchKey(year: number, monthIndex: number, day: number): string | null {
- if (!Number.isInteger(year) || !Number.isInteger(monthIndex) || !Number.isInteger(day)) {
- return null;
- }
- const date = new Date(year, monthIndex, day);
- if (date.getFullYear() !== year || date.getMonth() !== monthIndex || date.getDate() !== day) {
- return null;
- }
- return recoveryDateKeyFromTimestamp(date.getTime());
-}
-
-export function normalizeRecoveryDateSearchText(value: string): string {
- return String(value || '')
- .toLowerCase()
- .replace(/\b(\d{1,2})(st|nd|rd|th)\b/g, '$1')
- .replace(/[^a-z0-9]+/g, ' ')
- .trim()
- .replace(/\s+/g, ' ');
-}
-
-export function resolveRecoveryDateSearchKey(
- value: string,
- candidateKeys: readonly string[] = [],
- now: Date = new Date(),
-): string | null {
- const normalized = normalizeRecoveryDateSearchText(value);
- if (normalized.length < 5) return null;
-
- const isoMatch = normalized.match(/^(\d{4}) (\d{1,2}) (\d{1,2})$/);
- if (isoMatch) {
- return getRecoveryDateSearchKey(
- Number.parseInt(isoMatch[1], 10),
- Number.parseInt(isoMatch[2], 10) - 1,
- Number.parseInt(isoMatch[3], 10),
- );
- }
-
- const tokens = normalized.split(' ').filter(Boolean);
- if (RECOVERY_DATE_SEARCH_WEEKDAYS.has(tokens[0])) tokens.shift();
- if (tokens.length < 2 || tokens.length > 3) return null;
-
- const monthIndex = getRecoveryDateSearchMonthIndex(tokens[0]);
- const day = Number.parseInt(tokens[1], 10);
- if (monthIndex === null || !Number.isInteger(day)) return null;
-
- if (tokens[2]) {
- if (!/^\d{4}$/.test(tokens[2])) return null;
- return getRecoveryDateSearchKey(Number.parseInt(tokens[2], 10), monthIndex, day);
- }
-
- const candidateMatches = candidateKeys
- .map((key) => String(key || '').trim())
- .filter(Boolean)
- .filter((key) => {
- const date = parseRecoveryDateKey(key);
- return date.getMonth() === monthIndex && date.getDate() === day;
- });
- const uniqueCandidateMatches = [...new Set(candidateMatches)];
- if (uniqueCandidateMatches.length === 1) return uniqueCandidateMatches[0];
- if (uniqueCandidateMatches.length > 1) return null;
-
- return getRecoveryDateSearchKey(now.getFullYear(), monthIndex, day);
-}
-
export function getRecoveryCompactAxisLabel(key: string, days: 7 | 30 | 90 | 365): string {
const date = parseRecoveryDateKey(key);
if (days <= 30) {
@@ -150,15 +46,6 @@ export function getRecoveryCompactAxisLabel(key: string, days: 7 | 30 | 90 | 365
return `${date.getMonth() + 1}/${date.getDate()}`;
}
-export function formatRecoveryTimeOnly(timestamp: number | null): string {
- if (!timestamp) return '—';
- return new Date(timestamp).toLocaleTimeString(undefined, {
- hour: '2-digit',
- minute: '2-digit',
- hour12: false,
- });
-}
-
export function getRecoveryNiceAxisMax(value: number): number {
if (!Number.isFinite(value) || value <= 0) return 1;
if (value <= 5) return Math.max(1, value);
diff --git a/frontend-modern/src/utils/recoveryOutcomePresentation.ts b/frontend-modern/src/utils/recoveryOutcomePresentation.ts
index ff62c5b2db..5b8fa6d672 100644
--- a/frontend-modern/src/utils/recoveryOutcomePresentation.ts
+++ b/frontend-modern/src/utils/recoveryOutcomePresentation.ts
@@ -1,13 +1,5 @@
import type { RecoveryOutcome } from '@/types/recovery';
-export const RECOVERY_OUTCOMES: RecoveryOutcome[] = [
- 'success',
- 'warning',
- 'failed',
- 'running',
- 'unknown',
-];
-
export function normalizeRecoveryOutcome(value: string | null | undefined): RecoveryOutcome {
const normalized = (value || '').trim().toLowerCase();
if (normalized === 'success' || normalized === 'ok') return 'success';
@@ -52,33 +44,3 @@ export function getRecoveryOutcomeBadgeClass(outcome: RecoveryOutcome): string {
return `${base} bg-surface-alt text-muted`;
}
}
-
-export function getRecoveryOutcomeBarClass(outcome: RecoveryOutcome): string {
- switch (outcome) {
- case 'success':
- return 'bg-emerald-500';
- case 'warning':
- return 'bg-amber-400';
- case 'failed':
- return 'bg-red-500';
- case 'running':
- return 'bg-blue-500';
- default:
- return 'bg-gray-400';
- }
-}
-
-export function getRecoveryOutcomeTextClass(outcome: RecoveryOutcome): string {
- switch (outcome) {
- case 'success':
- return 'text-emerald-600 dark:text-emerald-400';
- case 'warning':
- return 'text-amber-600 dark:text-amber-400';
- case 'failed':
- return 'text-red-600 dark:text-red-400';
- case 'running':
- return 'text-blue-600 dark:text-blue-400';
- default:
- return 'text-muted';
- }
-}
diff --git a/frontend-modern/src/utils/recoveryPlatformModel.ts b/frontend-modern/src/utils/recoveryPlatformModel.ts
index f320e74514..229679bb0a 100644
--- a/frontend-modern/src/utils/recoveryPlatformModel.ts
+++ b/frontend-modern/src/utils/recoveryPlatformModel.ts
@@ -1,6 +1,4 @@
import type {
- ProtectionRollup,
- ProtectionRollupTransport,
RecoveryPointDisplay,
RecoveryPointDisplayTransport,
RecoveryPoint,
@@ -8,8 +6,6 @@ import type {
RecoveryPointsTransportResponse,
RecoveryPointTransport,
RecoveryResponseMeta,
- RecoveryRollupsResponse,
- RecoveryRollupsTransportResponse,
} from '@/types/recovery';
const toTrimmedString = (value: unknown): string => (typeof value === 'string' ? value.trim() : '');
@@ -19,11 +15,6 @@ interface RecoveryPointPlatformLike {
provider?: string | null;
}
-interface RecoveryRollupPlatformsLike {
- platforms?: string[] | null;
- providers?: string[] | null;
-}
-
interface RecoveryItemResourceLike {
itemResourceId?: string | null;
subjectResourceId?: string | null;
@@ -31,7 +22,7 @@ interface RecoveryItemResourceLike {
interface RecoveryItemRefLike {
itemRef?: RecoveryPoint['itemRef'];
- subjectRef?: RecoveryPoint['subjectRef'];
+ subjectRef?: RecoveryPointTransport['subjectRef'];
}
const normalizeRecoveryDisplay = (
@@ -68,17 +59,6 @@ export const getRecoveryPointPlatform = (
point: RecoveryPointPlatformLike | null | undefined,
): string => toTrimmedString(point?.platform) || toTrimmedString(point?.provider);
-export const getRecoveryRollupPlatforms = (
- rollup: RecoveryRollupPlatformsLike | null | undefined,
-): string[] => {
- const values =
- Array.isArray(rollup?.platforms) && rollup.platforms.length > 0
- ? rollup.platforms
- : rollup?.providers || [];
-
- return values.map((value) => toTrimmedString(value)).filter(Boolean);
-};
-
const normalizeRecoveryMeta = (
meta: RecoveryResponseMeta | null | undefined,
): RecoveryResponseMeta => {
@@ -118,39 +98,9 @@ export const normalizeRecoveryPoint = (
};
};
-export const normalizeRecoveryRollup = (
- rollup: ProtectionRollupTransport | ProtectionRollup,
-): ProtectionRollup => {
- const {
- providers: _providers,
- subjectResourceId: _subjectResourceId,
- subjectRef: _subjectRef,
- display,
- ...rest
- } = rollup as ProtectionRollupTransport;
- const platforms = getRecoveryRollupPlatforms(rollup);
- const itemResourceId = getRecoveryItemResourceId(rollup);
- const itemRef = getRecoveryItemRef(rollup);
- const normalizedDisplay = normalizeRecoveryDisplay(display);
- return {
- ...(rest as ProtectionRollup),
- ...(platforms.length > 0 ? { platforms } : {}),
- ...(itemResourceId ? { itemResourceId } : {}),
- ...(itemRef ? { itemRef } : {}),
- ...(display !== undefined ? { display: normalizedDisplay } : {}),
- };
-};
-
export const normalizeRecoveryPointsResponse = (
response: RecoveryPointsTransportResponse,
): RecoveryPointsResponse => ({
data: Array.isArray(response?.data) ? response.data.map(normalizeRecoveryPoint) : [],
meta: normalizeRecoveryMeta(response?.meta),
});
-
-export const normalizeRecoveryRollupsResponse = (
- response: RecoveryRollupsTransportResponse,
-): RecoveryRollupsResponse => ({
- data: Array.isArray(response?.data) ? response.data.map(normalizeRecoveryRollup) : [],
- meta: normalizeRecoveryMeta(response?.meta),
-});
diff --git a/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts b/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts
index af7b792947..f9c6292132 100644
--- a/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts
+++ b/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts
@@ -1,6 +1,4 @@
export const RECOVERY_TIMELINE_LEGEND_ITEM_CLASS = 'flex items-center gap-1';
-export const RECOVERY_TIMELINE_RANGE_GROUP_CLASS =
- 'inline-flex rounded-sm border border-border bg-surface p-0.5 text-xs';
export type RecoveryTimelineRangeDays = 7 | 30 | 90 | 365;
@@ -14,17 +12,6 @@ export function getRecoveryTimelineAxisLabelClass(selected: boolean): string {
return selected ? 'font-semibold text-blue-700 dark:text-blue-300' : 'text-muted';
}
-export function getRecoveryTimelineBarMinWidthClass(
- isMobile: boolean,
- days: 7 | 30 | 90 | 365,
-): string {
- if (isMobile) return '';
- if (days === 7) return 'min-w-[28px]';
- if (days === 30) return 'min-w-[14px]';
- if (days === 365) return '';
- return 'min-w-[8px]';
-}
-
export function getRecoveryTimelineChartMinWidthPx(
isMobile: boolean,
days: RecoveryTimelineRangeDays,
diff --git a/frontend-modern/src/utils/recoveryTimelinePresentation.ts b/frontend-modern/src/utils/recoveryTimelinePresentation.ts
index 931a2937cd..d392e18f23 100644
--- a/frontend-modern/src/utils/recoveryTimelinePresentation.ts
+++ b/frontend-modern/src/utils/recoveryTimelinePresentation.ts
@@ -1,59 +1,3 @@
-import {
- getRecoveryArtifactModePresentation,
- type RecoveryArtifactMode,
-} from './recoveryArtifactModePresentation';
-
-export interface RecoveryTimelineBreakdownPoint {
- total: number;
- snapshot: number;
- local: number;
- remote: number;
-}
-
-export interface RecoveryTimelineTooltipRow {
- mode: RecoveryArtifactMode;
- label: string;
- count: number;
- value: string;
- segmentClassName: string;
- muted: boolean;
-}
-
-const RECOVERY_TIMELINE_TOOLTIP_MODES: RecoveryArtifactMode[] = ['snapshot', 'local', 'remote'];
-
-function getRecoveryTimelineModeValue(
- point: RecoveryTimelineBreakdownPoint,
- mode: RecoveryArtifactMode,
-): number {
- return Math.max(0, Number(point[mode] || 0));
-}
-
-export function getRecoveryTimelinePointTotalLabel(total: number): string {
- const normalized = Math.max(0, Number(total || 0));
- return `${normalized} recovery point${normalized === 1 ? '' : 's'}`;
-}
-
-export function getRecoveryTimelineTooltipRows(
- point: RecoveryTimelineBreakdownPoint,
-): RecoveryTimelineTooltipRow[] {
- const total = Math.max(0, Number(point.total || 0));
-
- return RECOVERY_TIMELINE_TOOLTIP_MODES.map((mode) => {
- const presentation = getRecoveryArtifactModePresentation(mode);
- const count = getRecoveryTimelineModeValue(point, mode);
- const percentage = total > 0 && count > 0 ? Math.round((count / total) * 100) : 0;
-
- return {
- mode,
- label: presentation.aggregateLabel,
- count,
- value: percentage > 0 ? `${count} (${percentage}%)` : String(count),
- segmentClassName: presentation.segmentClassName,
- muted: count === 0,
- };
- });
-}
-
export function getRecoveryTimelineDayFilterStateLabel(
selected: boolean,
timelineHasDayFilter: boolean,
@@ -63,10 +7,6 @@ export function getRecoveryTimelineDayFilterStateLabel(
return 'Timeline day';
}
-export function getRecoveryTimelineDayFilterLabel(dateLabel: string, total: number): string {
- return `${dateLabel} - ${getRecoveryTimelinePointTotalLabel(total)}`;
-}
-
export function getRecoveryTimelineColumnButtonClass(
_selected: boolean,
_timelineHasSelection = false,
@@ -107,12 +47,3 @@ export function getRecoveryTimelineEmptyMarkerClass(
: 'opacity-100';
return `${base} h-0.5 bg-transparent ${focusClass}`;
}
-
-export function getRecoveryTimelineColumnAriaLabel(
- dateLabel: string,
- total: number,
- selected: boolean,
-): string {
- const countLabel = `${total} recovery point${total === 1 ? '' : 's'}`;
- return selected ? `${dateLabel}: ${countLabel}, selected` : `${dateLabel}: ${countLabel}`;
-}