From 393c6ca6b415236c21861c8d40d7f264d9ce701e Mon Sep 17 00:00:00 2001 From: rcourtman <8825017+rcourtman@users.noreply.github.com> Date: Wed, 7 Oct 2026 11:51:53 +0100 Subject: [PATCH] Remove status and disk helpers left unused by the selector removal Deleting infrastructureSelectors.ts removed the only production caller of three more exports. getInfrastructureSystemIdentitySortLabel is handled in a separate change; this removes the other two: STATUS_SORT_ORDER in utils/status.ts and getResourceDiskSummary in utils/format.ts, along with the tests that only pinned them. Neither is used inside its own module, and the helpers getResourceDiskSummary relied on (normalizeDiskArray, NormalizedDisk) keep their other callers. Rollup was already tree-shaking both, so the production build is byte-identical to its parent's. --- .../b5563a7bd4ae414b.json | 42 +++++++++++++++++++ .../src/utils/__tests__/formatExtra.test.ts | 31 -------------- .../src/utils/__tests__/status.test.ts | 13 ------ frontend-modern/src/utils/format.ts | 32 -------------- frontend-modern/src/utils/status.ts | 10 ----- 5 files changed, 42 insertions(+), 86 deletions(-) create mode 100644 frontend-modern/browser-verification/b5563a7bd4ae414b.json diff --git a/frontend-modern/browser-verification/b5563a7bd4ae414b.json b/frontend-modern/browser-verification/b5563a7bd4ae414b.json new file mode 100644 index 0000000000..ee03f3ee3d --- /dev/null +++ b/frontend-modern/browser-verification/b5563a7bd4ae414b.json @@ -0,0 +1,42 @@ +{ + "version": 1, + "base_sha": "dcd409f9da0a7a7f35a2a4ad5a4354e0b1d3ee44", + "verified_at": "2026-10-07T10:50:00Z", + "result": "passed", + "changed_paths": [ + "frontend-modern/src/utils/format.ts", + "frontend-modern/src/utils/status.ts" + ], + "content_sha256": { + "frontend-modern/src/utils/format.ts": "7fe003f3aba64378896fc55a810e54642962296c14b2445335cd684dc7c26268", + "frontend-modern/src/utils/status.ts": "87df830a90ba87d28b74910244b1a8e2870cb2fcc6057c95207656860795fc94" + }, + "routes": [ + "/proxmox/overview", + "/docker" + ], + "viewports": [ + { + "width": 1920, + "height": 1080 + }, + { + "width": 1440, + "height": 900 + }, + { + "width": 390, + "height": 844 + } + ], + "states": [ + "Production vite build of this tree is byte-identical (sha256 of every dist file) to the build of its parent dcd409f9da, because both removed exports were already tree-shaken; served embedded by a private DEMO_MODE mock backend on its own port", + "Proxmox overview workloads table at 1920: 161 guest rows, 512 Net I/O and Disk I/O values with top-outlier emphasis on 6 of them; at 390: 45 guest rows render with I/O columns hidden as before", + "Docker containers inline resource drawer for branch-portal-3 (REST list and websocket frames edited in Playwright to carry its real change history plus widened facet counts): Change history shows all nine facet badges with no +N chip, one line at 1440 and four wrapped lines at 390, no clipped badge", + "Console shows only the 401 and inline-style CSP messages the origin/main build also logs on these routes" + ], + "interactions": [ + "Demo auto sign-in, then direct navigation to /proxmox/overview and /docker", + "Typed branch-portal-3 into Search containers and clicked its row to open the inline resource drawer, then scrolled the Change history facet summary into view" + ] +} diff --git a/frontend-modern/src/utils/__tests__/formatExtra.test.ts b/frontend-modern/src/utils/__tests__/formatExtra.test.ts index 0de416527a..60b66edb4d 100644 --- a/frontend-modern/src/utils/__tests__/formatExtra.test.ts +++ b/frontend-modern/src/utils/__tests__/formatExtra.test.ts @@ -3,7 +3,6 @@ import { formatPowerOnHours, estimateTextWidth, formatAnomalyRatio, - getResourceDiskSummary, getShortImageName, normalizeDiskArray, ANOMALY_SEVERITY_CLASS, @@ -338,33 +337,3 @@ describe('normalizeDiskArray', () => { ).toBeUndefined(); }); }); - -describe('getResourceDiskSummary', () => { - it('aggregates multiple agent-reported Windows volumes when the resource summary is absent', () => { - const gib = 1024 ** 3; - const summary = getResourceDiskSummary({ - disk: undefined, - agent: { - disks: [ - { device: 'C:', mountpoint: 'C:\\', total: 499 * gib, used: 49.5 * gib }, - { device: 'F:', mountpoint: 'F:\\', total: 250 * gib, used: 2.75 * gib }, - ], - }, - }); - - expect(summary).toMatchObject({ - total: 749 * gib, - used: 52.25 * gib, - }); - expect(summary?.usage).toBeCloseTo(6.98, 2); - }); - - it('keeps the canonical resource summary when one is available', () => { - expect( - getResourceDiskSummary({ - disk: { current: 25, total: 400, used: 100, free: 300 }, - agent: { disks: [{ total: 1000, used: 900 }] }, - }), - ).toEqual({ total: 400, used: 100, free: 300, usage: 25 }); - }); -}); diff --git a/frontend-modern/src/utils/__tests__/status.test.ts b/frontend-modern/src/utils/__tests__/status.test.ts index 66cfe411a1..9db1c3470b 100644 --- a/frontend-modern/src/utils/__tests__/status.test.ts +++ b/frontend-modern/src/utils/__tests__/status.test.ts @@ -25,7 +25,6 @@ import { DEGRADED_HEALTH_STATUSES, STOPPED_CONTAINER_STATES, ERROR_CONTAINER_STATES, - STATUS_SORT_ORDER, } from '@/utils/status'; describe('isNodeOnline', () => { @@ -71,18 +70,6 @@ describe('status label helpers', () => { expect(getCanonicalStatusLabel('custom_state')).toBe('custom_state'); }); - it('exports the canonical status sort order used by selectors', () => { - expect(Array.from(STATUS_SORT_ORDER)).toEqual([ - 'online', - 'degraded', - 'paused', - 'offline', - 'stopped', - 'unknown', - 'running', - ]); - }); - it('returns a generic indicator for simple online/offline/warning states', () => { expect(getSimpleStatusIndicator('online')).toEqual({ variant: 'success', label: 'Online' }); expect(getSimpleStatusIndicator('running')).toEqual({ variant: 'success', label: 'Running' }); diff --git a/frontend-modern/src/utils/format.ts b/frontend-modern/src/utils/format.ts index 0abbaf3b8c..147c64ef8e 100644 --- a/frontend-modern/src/utils/format.ts +++ b/frontend-modern/src/utils/format.ts @@ -1,6 +1,5 @@ // Type-safe formatting utilities import type { Disk } from '@/types/api'; -import type { Resource } from '@/types/resource'; type DiskInput = { device?: string; @@ -548,34 +547,3 @@ export function normalizeDiskArray(disks?: DiskInput[]): NormalizedDisk[] | unde }); return normalized.length > 0 ? normalized : undefined; } - -export function getResourceDiskSummary( - resource: Pick, -): NormalizedDisk | undefined { - if (resource.disk) { - const total = resource.disk.total ?? 0; - const used = resource.disk.used ?? 0; - return { - total, - used, - free: resource.disk.free ?? Math.max(total - used, 0), - usage: total > 0 ? (used / total) * 100 : resource.disk.current, - }; - } - - // Disks with unknown usage (sentinel -1) have no measured used/free to sum. - const disks = normalizeDiskArray(resource.agent?.disks)?.filter((disk) => disk.usage >= 0); - if (!disks || disks.length === 0) return undefined; - - const total = disks.reduce((sum, disk) => sum + disk.total, 0); - if (total <= 0) return undefined; - const used = disks.reduce((sum, disk) => sum + disk.used, 0); - const free = disks.reduce((sum, disk) => sum + disk.free, 0); - - return { - total, - used, - free, - usage: (used / total) * 100, - }; -} diff --git a/frontend-modern/src/utils/status.ts b/frontend-modern/src/utils/status.ts index bf5e3bd735..0c74302094 100644 --- a/frontend-modern/src/utils/status.ts +++ b/frontend-modern/src/utils/status.ts @@ -24,16 +24,6 @@ const STATUS_LABELS: Record = { stopped: 'Stopped', }; -export const STATUS_SORT_ORDER = [ - 'online', - 'degraded', - 'paused', - 'offline', - 'stopped', - 'unknown', - 'running', -] as const; - const normalize = (value?: string | null): string => (value || '').trim().toLowerCase(); export const formatStatusLabel = (value?: string | null, fallback = 'Unknown'): string => {