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 frontend normalization helpers
rcourtmane327e2c68125
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 6d2d59d10c..37a91daba1 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -66,8 +66,8 @@ not to alert-surface runtime delivery code.The alert webhook editor now mirrors that canonical Pushover field rule through`frontend-modern/src/utils/alertWebhookPresentation.ts`, so the UI shares the-same alias and preset mapping instead of carrying its own local webhook-field-normalization fork.+same alias, preset, and custom-field input mapping instead of carrying its own+local webhook-field normalization fork.The alert webhook service chooser also now derives its service set from thebackend webhook template registry, rather than keeping a second frontend-onlydiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex a6e16f01ba..7253caa8b0 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -116,6 +116,11 @@ must sort after the governed status order instead of forcing the selector pathto abandon the typed canonical order used by the infrastructure table and itsperformance proof surface.+The Infrastructure page now also normalizes source filter keys through the+shared `frontend-modern/src/utils/sourcePlatforms.ts` helper directly, so the+selector boundary keeps using the canonical source-platform contract instead of+maintaining a local source-normalization alias.+GitHub-hosted runner proof for the API performance surface now intentionallyuses a looser budget envelope than local/staging benchmark runs for themixed-endpoint load test and the infrastructure/workload chart p95 checks.diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 5a89b3f762..b07fe4ca7d 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -462,8 +462,8 @@ contracts that feed the infrastructure table and workload links.The same source-filter boundary now also applies to infrastructure filter UIoptions: `frontend-modern/src/pages/Infrastructure.tsx` may render friendlystring keys, but membership checks against available sources must normalize-through the canonical selector helper before consulting `KnownSourcePlatform`-sets.+through the shared `frontend-modern/src/utils/sourcePlatforms.ts` helper+before consulting `KnownSourcePlatform` sets.Canonical monitored-system counting now also depends on this subsystem. Thecounted commercial unit is a deduped top-level monitored system assembled fromcanonical unified-resource roots, so read-state helpers that derivediff --git a/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx b/frontend-modern/src/components/Alerts/WebhookConfig.test.tsxindex d30f55a190..e77fd41569 100644--- a/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx+++ b/frontend-modern/src/components/Alerts/WebhookConfig.test.tsx@@ -1183,6 +1183,8 @@ describe('WebhookConfig', () => {(el) => (el as HTMLInputElement).value === 'my-app-token',);expect(tokenInput).toBeTruthy();+ expect(screen.getByDisplayValue('my-app-token')).toBeInTheDocument();+ expect(screen.getByDisplayValue('my-user-key')).toBeInTheDocument();});it('shows shared pushover custom fields when creating a webhook', async () => {diff --git a/frontend-modern/src/components/Alerts/WebhookConfig.tsx b/frontend-modern/src/components/Alerts/WebhookConfig.tsxindex 4599d6fc1f..42196bc0ae 100644--- a/frontend-modern/src/components/Alerts/WebhookConfig.tsx+++ b/frontend-modern/src/components/Alerts/WebhookConfig.tsx@@ -30,7 +30,7 @@ import {getAlertWebhookMentionHelpFromTemplates,getAlertWebhookMentionPlaceholderFromTemplates,hasAlertWebhookMentionSupportFromTemplates,- getAlertWebhookCustomFieldPresets,+ getAlertWebhookCustomFieldInputs,getAlertWebhookNamePlaceholder,getAlertWebhookServiceLabelFromTemplates,getAlertWebhookServices,@@ -80,44 +80,6 @@ const buildMapFromInputs = (return map;};-const createCustomFieldInputs = (- service: string,- existing: Record<string, string> = {},-): CustomFieldInput[] => {- const presets = getAlertWebhookCustomFieldPresets(service);- const normalizedExisting = normalizeAlertWebhookCustomFields(service, existing);- const timestamp = Date.now();-- if (!presets) {- return Object.entries(normalizedExisting).map(([key, value], index) => ({- id: `custom-${key}-${timestamp}-${index}`,- key,- value,- }));- }-- const inputs: CustomFieldInput[] = presets.map((preset, index) => ({- id: `custom-${preset.key}-${timestamp}-${index}`,- key: preset.key,- value: normalizedExisting[preset.key] ?? '',- label: preset.label,- placeholder: preset.placeholder,- required: preset.required,- }));-- Object.entries(normalizedExisting)- .filter(([key]) => !presets.some((preset) => preset.key === key))- .forEach(([key, value], index) => {- inputs.push({- id: `custom-${key}-${timestamp}-${presets.length + index}`,- key,- value,- });- });-- return inputs;-};-export function WebhookConfig(props: WebhookConfigProps) {const [adding, setAdding] = createSignal(false);const [editingId, setEditingId] = createSignal<string | null>(null);@@ -160,15 +122,6 @@ export function WebhookConfig(props: WebhookConfigProps) {});};- const ensurePresetCustomFields = (service: string) => {- if (!getAlertWebhookCustomFieldPresets(service)) {- return;- }- const existing = normalizeAlertWebhookCustomFields(service, formData().customFields || {});- const inputs = createCustomFieldInputs(service, existing);- setCustomFieldInputs(inputs);- };-// Load webhook templatescreateEffect(async () => {try {@@ -190,10 +143,8 @@ export function WebhookConfig(props: WebhookConfigProps) {headers[input.key] = input.value;}});- const customFields = normalizeAlertWebhookCustomFields(- data.service,- buildMapFromInputs(customFieldInputs()),- );+ const customFields = buildMapFromInputs(customFieldInputs());+ const normalizedCustomFields = normalizeAlertWebhookCustomFields(data.service, customFields);if (editingId()) {props.onUpdate({@@ -202,7 +153,7 @@ export function WebhookConfig(props: WebhookConfigProps) {headers,service: data.service,template: data.payloadTemplate,- customFields,+ customFields: normalizedCustomFields,mention: data.mention,});setEditingId(null);@@ -219,7 +170,7 @@ export function WebhookConfig(props: WebhookConfigProps) {enabled: data.enabled,service: data.service,template: data.payloadTemplate,- customFields,+ customFields: normalizedCustomFields,mention: data.mention,};props.onAdd(newWebhook);@@ -267,10 +218,7 @@ export function WebhookConfig(props: WebhookConfigProps) {...webhook,service: webhook.service || 'generic',payloadTemplate: webhook.template || '',- customFields: normalizeAlertWebhookCustomFields(- webhook.service || 'generic',- webhook.customFields || {},- ),+ customFields: normalizeAlertWebhookCustomFields(webhook.service || 'generic', webhook.customFields || {}),mention: webhook.mention || '',});// Set up header inputs for editing@@ -284,15 +232,13 @@ export function WebhookConfig(props: WebhookConfigProps) {);const service = webhook.service || 'generic';- const existingCustomFields = normalizeAlertWebhookCustomFields(- service,- webhook.customFields || {},+ const existingCustomFields = webhook.customFields || {};+ setCustomFieldInputs(+ getAlertWebhookCustomFieldInputs(service, existingCustomFields).map((field, index) => ({+ id: `custom-${field.key}-${Date.now()}-${index}`,+ ...field,+ })),);- if (getAlertWebhookCustomFieldPresets(service) || Object.keys(existingCustomFields).length > 0) {- setCustomFieldInputs(createCustomFieldInputs(service, existingCustomFields));- } else {- setCustomFieldInputs([]);- }setAdding(true);};@@ -324,7 +270,12 @@ export function WebhookConfig(props: WebhookConfigProps) {service,});}- ensurePresetCustomFields(service);+ setCustomFieldInputs(+ getAlertWebhookCustomFieldInputs(service, formData().customFields || {}).map((field, index) => ({+ id: `custom-${field.key}-${Date.now()}-${index}`,+ ...field,+ })),+ );setShowServiceDropdown(false);};diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsxindex 8fdcb6978e..b7a6a7a937 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx@@ -182,6 +182,18 @@ describe('UnifiedResourceTable performance contract', () => {expect(getByText('Proxmox adapter 1')).toBeInTheDocument();});+ it('keeps source filtering on the shared canonical source-platform helper', () => {+ const resources = [+ makeResource(0, { platformData: { sources: ['proxmox'] } }),+ makeResource(1, { platformData: { sources: ['docker'] } }),+ ];++ const filtered = filterResources(resources, new Set(['proxmox-pve']), new Set(), []);++ expect(filtered).toHaveLength(1);+ expect(filtered[0]?.platformData?.sources).toEqual(['proxmox']);+ });+it('renders facet summary badges without changing the Profile S row budget', async () => {const resources = makeResources(PROFILES.S, (i) =>i === 0diff --git a/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.tsindex a880e7527a..96ceb4efe6 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts+++ b/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts@@ -11,11 +11,11 @@ import {getResourceSources,groupResources,matchesSearch,- normalizeInfrastructureSource,sortResources,splitPrimaryAndServiceResources,tokenizeSearch,} from '@/components/Infrastructure/infrastructureSelectors';+import { normalizeSourcePlatformKey } from '@/utils/sourcePlatforms';const makeResource = (i: number, overrides: Partial<Resource> = {}): Resource => ({id: `resource-${i}`,@@ -67,10 +67,10 @@ describe('infrastructureSelectors', () => {describe('getResourceSources and collectors', () => {it('normalizes legacy infrastructure source aliases to canonical platform keys', () => {- expect(normalizeInfrastructureSource('proxmox')).toBe('proxmox-pve');- expect(normalizeInfrastructureSource('pbs')).toBe('proxmox-pbs');- expect(normalizeInfrastructureSource('pmg')).toBe('proxmox-pmg');- expect(normalizeInfrastructureSource('k8s')).toBe('kubernetes');+ expect(normalizeSourcePlatformKey('proxmox')).toBe('proxmox-pve');+ expect(normalizeSourcePlatformKey('pbs')).toBe('proxmox-pbs');+ expect(normalizeSourcePlatformKey('pmg')).toBe('proxmox-pmg');+ expect(normalizeSourcePlatformKey('k8s')).toBe('kubernetes');});it('normalizes and deduplicates resource sources', () => {diff --git a/frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts b/frontend-modern/src/components/Infrastructure/infrastructureSelectors.tsindex 2e1cef8bf0..3ceebaa01e 100644--- a/frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts+++ b/frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts@@ -65,8 +65,6 @@ const buildIODistribution = (values: number[]): IODistributionStats => {return { median, mad, max, p97, p99, count: valid.length };};-export const normalizeInfrastructureSource = normalizeSourcePlatformKey;-const getSortValue = (resource: Resource, key: string): number | string | null => {switch (key) {case 'name':@@ -149,7 +147,7 @@ export const matchesSearch = (resource: Resource, term: string): boolean => {export const getResourceSources = (resource: Resource): KnownSourcePlatform[] => {const platformData = resource.platformData as { sources?: string[] } | undefined;const normalized = (platformData?.sources ?? [])- .map((source) => normalizeInfrastructureSource(source))+ .map((source) => normalizeSourcePlatformKey(source)).filter((source): source is KnownSourcePlatform => Boolean(source));return Array.from(new Set(normalized));};diff --git a/frontend-modern/src/pages/Infrastructure.tsx b/frontend-modern/src/pages/Infrastructure.tsxindex 2a3c7e1afb..7c34577006 100644--- a/frontend-modern/src/pages/Infrastructure.tsx+++ b/frontend-modern/src/pages/Infrastructure.tsx@@ -28,9 +28,9 @@ import {collectAvailableSources,collectAvailableStatuses,buildStatusOptions,- normalizeInfrastructureSource,} from '@/components/Infrastructure/infrastructureSelectors';import { DEFAULT_INFRASTRUCTURE_SOURCE_OPTIONS } from '@/utils/sourcePlatformOptions';+import { normalizeSourcePlatformKey } from '@/utils/sourcePlatforms';import {buildInfrastructurePath,INFRASTRUCTURE_PATH,@@ -165,7 +165,7 @@ export function Infrastructure() {return;}if (sourceParam === handledSourceParam()) return;- const normalized = normalizeInfrastructureSource(sourceParam) ?? '';+ const normalized = normalizeSourcePlatformKey(sourceParam) ?? '';setSelectedSource(normalized);setHandledSourceParam(sourceParam);});@@ -390,7 +390,7 @@ export function Infrastructure() {<option value="">All</option><Foreach={sourceOptions.filter((source) => {- const normalized = normalizeInfrastructureSource(source.key);+ const normalized = normalizeSourcePlatformKey(source.key);return normalized ? availableSources().has(normalized) : false;})}>diff --git a/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.tsindex 5af51fdb43..65fe9de0ba 100644--- a/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/alertWebhookPresentation.test.ts@@ -7,6 +7,7 @@ import {getAlertWebhookMentionHelpFromTemplates,getAlertWebhookMentionPlaceholderFromTemplates,hasAlertWebhookMentionSupportFromTemplates,+ getAlertWebhookCustomFieldInputs,getAlertWebhookServiceLabelFromTemplates,getAlertWebhookTestFailure,getAlertWebhookTestSuccess,@@ -60,6 +61,39 @@ describe('alertWebhookPresentation', () => {});});+ it('builds pushover custom-field inputs from canonical aliases and extra fields', () => {+ expect(+ getAlertWebhookCustomFieldInputs('pushover', {+ app_token: 'legacy-token',+ user_token: 'legacy-user',+ priority: '2',+ }),+ ).toEqual([+ {+ key: 'token',+ value: 'legacy-token',+ label: 'Application Token',+ placeholder: 'Your Pushover application token',+ required: true,+ },+ {+ key: 'user',+ value: 'legacy-user',+ label: 'User Key',+ placeholder: 'Primary user key or group key',+ required: true,+ },+ {+ key: 'priority',+ value: '2',+ },+ ]);++ expect(getAlertWebhookCustomFieldInputs('discord', { foo: 'bar' })).toEqual([+ { key: 'foo', value: 'bar' },+ ]);+ });+it('derives webhook service options from the backend template registry', () => {expect(getAlertWebhookServices([diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex f1ac37901e..40afb9054e 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -3065,7 +3065,7 @@ describe('frontend resource type boundaries', () => {it('keeps alert webhook service vocabulary and action copy in a shared presentation utility', () => {expect(webhookConfigSource).toContain('getAlertWebhookServices(templates())');expect(webhookConfigSource).toContain('getAlertWebhookServiceLabelFromTemplates');- expect(webhookConfigSource).toContain('getAlertWebhookCustomFieldPresets');+ expect(webhookConfigSource).toContain('getAlertWebhookCustomFieldInputs');expect(webhookConfigSource).toContain('normalizeAlertWebhookCustomFields');expect(webhookConfigSource).toContain('getAlertWebhookSummaryLabel');expect(webhookConfigSource).toContain('getAlertWebhookToggleAllLabel');@@ -3089,6 +3089,8 @@ describe('frontend resource type boundaries', () => {expect(webhookConfigSource).not.toContain('Primary user key or group key');expect(webhookConfigSource).not.toContain('app_token');expect(webhookConfigSource).not.toContain('user_token');+ expect(webhookConfigSource).not.toContain('createCustomFieldInputs');+ expect(webhookConfigSource).not.toContain('ensurePresetCustomFields');expect(webhookConfigSource).not.toContain('Enable All');expect(webhookConfigSource).not.toContain('Disable All');expect(webhookConfigSource).not.toContain('Enable this webhook');@@ -3111,6 +3113,9 @@ describe('frontend resource type boundaries', () => {expect(alertWebhookPresentationSource).toContain('export function getAlertWebhookCustomFieldPresets',);+ expect(alertWebhookPresentationSource).toContain(+ 'export function getAlertWebhookCustomFieldInputs',+ );expect(alertWebhookPresentationSource).toContain('export function normalizeAlertWebhookCustomFields',);diff --git a/frontend-modern/src/utils/alertWebhookPresentation.ts b/frontend-modern/src/utils/alertWebhookPresentation.tsindex dc7f5d88e7..2a63983d89 100644--- a/frontend-modern/src/utils/alertWebhookPresentation.ts+++ b/frontend-modern/src/utils/alertWebhookPresentation.ts@@ -26,6 +26,14 @@ type AlertWebhookCustomFieldPreset = {required?: boolean;};+export interface AlertWebhookCustomFieldInput {+ key: string;+ value: string;+ label?: string;+ placeholder?: string;+ required?: boolean;+}+const ALERT_WEBHOOK_SERVICE_PRESENTATION: Record<AlertWebhookService,AlertWebhookServicePresentation@@ -201,6 +209,40 @@ export function getAlertWebhookCustomFieldPresets(service: string) {return ALERT_WEBHOOK_CUSTOM_FIELD_PRESETS[service.trim().toLowerCase()];}+export function getAlertWebhookCustomFieldInputs(+ service: string,+ existing: Record<string, string> = {},+): AlertWebhookCustomFieldInput[] {+ const presets = getAlertWebhookCustomFieldPresets(service);+ const normalizedExisting = normalizeAlertWebhookCustomFields(service, existing);++ if (!presets) {+ return Object.entries(normalizedExisting).map(([key, value]) => ({+ key,+ value,+ }));+ }++ const inputs: AlertWebhookCustomFieldInput[] = presets.map((preset) => ({+ key: preset.key,+ value: normalizedExisting[preset.key] ?? '',+ label: preset.label,+ placeholder: preset.placeholder,+ required: preset.required,+ }));++ Object.entries(normalizedExisting)+ .filter(([key]) => !presets.some((preset) => preset.key === key))+ .forEach(([key, value]) => {+ inputs.push({+ key,+ value,+ });+ });++ return inputs;+}+export function normalizeAlertWebhookCustomFields(service: string,fields: Record<string, string> = {},