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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Centralize dashboard view mode parsing
rcourtman844e765d2a9a
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex fbfb21674f..74171fc6f0 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -46,6 +46,7 @@ regression protection.2. Add query-plan guardrails for DB-backed hot paths3. Optimize hot paths only when backed by benchmarks or proven query issues4. Extend dashboard hot-path selectors through `frontend-modern/src/components/Dashboard/workloadSelectors.ts` rather than duplicating filtering/grouping logic in `frontend-modern/src/components/Dashboard/Dashboard.tsx`+5. Normalize dashboard workload view-mode aliases through `frontend-modern/src/utils/workloads.ts` instead of keeping local URL/storage parsing in `frontend-modern/src/components/Dashboard/Dashboard.tsx`## Forbidden Pathsdiff --git a/frontend-modern/src/components/Dashboard/Dashboard.tsx b/frontend-modern/src/components/Dashboard/Dashboard.tsxindex b09e827e28..baa870ec59 100644--- a/frontend-modern/src/components/Dashboard/Dashboard.tsx+++ b/frontend-modern/src/components/Dashboard/Dashboard.tsx@@ -52,7 +52,11 @@ import {getDashboardInfrastructureEmptyState,getDashboardLoadingState,} from '@/utils/dashboardEmptyStatePresentation';-import { getCanonicalWorkloadId, resolveWorkloadType } from '@/utils/workloads';+import {+ getCanonicalWorkloadId,+ normalizeWorkloadViewModeParam,+ resolveWorkloadType,+} from '@/utils/workloads';import {WorkloadsSummary,type WorkloadSummarySnapshot,@@ -542,19 +546,9 @@ export function Dashboard(props: DashboardProps) {return Array.from(runtimes).sort((a, b) => a.localeCompare(b));});- function normalizeViewModeParam(value: string): ViewMode | null {- const normalized = value.trim().toLowerCase();- if (normalized === 'all') return 'all';- if (normalized === 'vm') return 'vm';- if (normalized === 'system-container') return 'system-container';- if (normalized === 'docker' || normalized === 'app-container') return 'app-container';- if (normalized === 'k8s' || normalized === 'kubernetes' || normalized === 'pod') return 'pod';- return null;- }-// Initialize from localStorage with proper type checkingconst [viewMode, setViewMode] = usePersistentSignal<ViewMode>('dashboardViewMode', 'all', {- deserialize: (raw) => normalizeViewModeParam(raw) ?? 'all',+ deserialize: (raw) => normalizeWorkloadViewModeParam(raw) ?? 'all',});const [containerRuntime, setContainerRuntime] = usePersistentSignal<string>(@@ -618,7 +612,7 @@ export function Dashboard(props: DashboardProps) {// Context/namespace implies pod view; ignore conflicting type params.const hasK8sScope =Boolean((parsed.context ?? '').trim()) || Boolean((parsed.namespace ?? '').trim());- const nextMode = normalizeViewModeParam(normalizedType);+ const nextMode = normalizeWorkloadViewModeParam(normalizedType);if (!nextMode) {setHandledTypeParam(normalizedType);return;@@ -704,7 +698,7 @@ export function Dashboard(props: DashboardProps) {const hasContext = Boolean(urlContext.trim());const hasNamespace = Boolean((parsed.namespace ?? '').trim());const urlType = parsed.type ?? '';- const nextMode = normalizeViewModeParam(urlType);+ const nextMode = normalizeWorkloadViewModeParam(urlType);const runtimeRelevant =!hasContext && !hasNamespace && (nextMode === 'app-container' || !urlType.trim());diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsxindex 87f50e76e9..cd32bb2dc0 100644--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx@@ -8,6 +8,7 @@ import {groupWorkloads,computeWorkloadStats,} from '../workloadSelectors';+import { normalizeWorkloadViewModeParam } from '@/utils/workloads';// Stub ResizeObserver for jsdomif (typeof globalThis.ResizeObserver === 'undefined') {@@ -375,6 +376,13 @@ describe('Dashboard performance contract', () => {});describe('Workload derivation contracts', () => {+ it('normalizes dashboard view mode aliases through the shared workload helper', () => {+ expect(normalizeWorkloadViewModeParam('all')).toBe('all');+ expect(normalizeWorkloadViewModeParam('docker')).toBe('app-container');+ expect(normalizeWorkloadViewModeParam('Kubernetes')).toBe('pod');+ expect(normalizeWorkloadViewModeParam('host')).toBeNull();+ });+it('filterWorkloads returns all guests when no filters active', () => {const guests = makeGuests(PROFILES.S);const result = filterWorkloads({diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 3df517e74c..08b85d24c2 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -312,6 +312,9 @@ describe('frontend resource type boundaries', () => {expect(workloadTypePresentationSource).toContain('canonicalizeFrontendResourceType');expect(workloadTypeBadgesSource).not.toContain('canonicalizeFrontendResourceType');expect(workloadTypeBadgesSource).toContain('getWorkloadTypePresentation');+ expect(workloadsSource).toContain('export const normalizeWorkloadViewModeParam');+ expect(dashboardSource).toContain('normalizeWorkloadViewModeParam');+ expect(dashboardSource).not.toContain('function normalizeViewModeParam');expect(emptyStateSource).toContain('getEmptyStatePresentation');expect(emptyStateSource).not.toContain('const iconBgClass: Record<EmptyStateTone, string> =');expect(emptyStateSource).not.toContain(diff --git a/frontend-modern/src/utils/__tests__/workloads.test.ts b/frontend-modern/src/utils/__tests__/workloads.test.tsindex b60f50ef88..52b63b2e02 100644--- a/frontend-modern/src/utils/__tests__/workloads.test.ts+++ b/frontend-modern/src/utils/__tests__/workloads.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';import {canonicalizeWorkloadFilterType,getDiscoveryResourceTypeForWorkload,+ normalizeWorkloadViewModeParam,resolveWorkloadType,resolveWorkloadTypeFromString,getWorkloadMetricsKind,@@ -237,3 +238,22 @@ describe('getWebInterfaceTargetLabelForWorkload', () => {expect(getWebInterfaceTargetLabelForWorkload(guest)).toBe('workload');});});++describe('normalizeWorkloadViewModeParam', () => {+ it('normalizes supported dashboard view mode aliases', () => {+ expect(normalizeWorkloadViewModeParam('all')).toBe('all');+ expect(normalizeWorkloadViewModeParam('VM')).toBe('vm');+ expect(normalizeWorkloadViewModeParam('system-container')).toBe('system-container');+ expect(normalizeWorkloadViewModeParam('docker')).toBe('app-container');+ expect(normalizeWorkloadViewModeParam('app-container')).toBe('app-container');+ expect(normalizeWorkloadViewModeParam('k8s')).toBe('pod');+ expect(normalizeWorkloadViewModeParam('Kubernetes')).toBe('pod');+ expect(normalizeWorkloadViewModeParam('pod')).toBe('pod');+ });++ it('rejects unsupported dashboard view mode aliases', () => {+ expect(normalizeWorkloadViewModeParam('host')).toBeNull();+ expect(normalizeWorkloadViewModeParam('container')).toBeNull();+ expect(normalizeWorkloadViewModeParam('')).toBeNull();+ });+});diff --git a/frontend-modern/src/utils/workloads.ts b/frontend-modern/src/utils/workloads.tsindex 445688f3f2..009682c6e7 100644--- a/frontend-modern/src/utils/workloads.ts+++ b/frontend-modern/src/utils/workloads.ts@@ -1,4 +1,4 @@-import type { WorkloadGuest, WorkloadType } from '@/types/workloads';+import type { WorkloadGuest, WorkloadType, ViewMode } from '@/types/workloads';import type { ResourceType as DiscoveryResourceType } from '@/types/discovery';import type { MetricResourceKind } from '@/utils/metricsKeys';import { canonicalizeFrontendResourceType } from '@/utils/resourceTypeCompat';@@ -38,6 +38,16 @@ export const canonicalizeWorkloadFilterType = (value?: string | null): string =>return canonicalizeFrontendResourceType(normalized) || normalized;};+export const normalizeWorkloadViewModeParam = (value: string): ViewMode | null => {+ const normalized = value.trim().toLowerCase();+ if (normalized === 'all') return 'all';+ if (normalized === 'vm') return 'vm';+ if (normalized === 'system-container') return 'system-container';+ if (normalized === 'docker' || normalized === 'app-container') return 'app-container';+ if (normalized === 'k8s' || normalized === 'kubernetes' || normalized === 'pod') return 'pod';+ return null;+};+export const resolveWorkloadType = (guest: Pick<WorkloadGuest, 'workloadType' | 'type'>,): WorkloadType => {