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.

Converge platform numeric fallbacks

rcourtmanaafd816fd16b
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 9e771aa50a..9f92ea1fd0 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2615,6 +2615,13 @@ canonical empty-cell marker behavior for dense platform table cells. Docker /
Podman native table helpers, Kubernetes node capacity cells, and TrueNAS
system/VM byte cells must compose that helper instead of declaring local
`formatBytes` wrappers or reimplementing byte-unit precision in table files.
+Platform table numeric fallback rendering is registry-backed too.
+`PlatformTableNumberValue` owns finite-number checking, tabular-number styling,
+custom empty-marker support, and caller-owned number formatting for dense
+optional numeric table cells. Docker / Podman native count helpers, Kubernetes
+optional count cells, and Proxmox Mail Gateway count columns must compose that
+primitive instead of declaring local `numberValue`, `numericValue`, or
+`countCell` helpers.
Platform table metric fallback rendering is also shared.
`PlatformTableMetricFallback` owns the centered muted empty marker used in
metric bar cells plus optional caller-owned fallback label/title text, and
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index cd3cfe638d..973777a79b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -250,6 +250,12 @@ right source-specific value, while dense platform table cells must use
`formatPlatformTableBytesValue` for positive byte formatting and unknown /
non-positive empty-cell markers instead of carrying table-local `formatBytes`
wrappers.
+Optional numeric table cells follow the same split: unified-resource consumers
+own which count or replica field is meaningful and whether a domain-specific
+formatter is needed, while dense platform table cells must use
+`PlatformTableNumberValue` for finite-number validation, tabular styling, and
+unknown empty-cell markers instead of carrying local `numberValue`,
+`numericValue`, or `countCell` helpers.
Metric bar fallbacks follow that split as well: unified-resource consumers own
which CPU or memory value is selected, plus any source-specific fallback reason
such as outdated standalone agent telemetry, while platform tables must use
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 7a17091405..6287a6a3fd 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1374,6 +1374,68 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-number-value-fallback",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must use the shared number-value fallback primitive for finite numeric table cells, tabular styling, and canonical empty-cell markers instead of recreating local numberValue/countCell helpers.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "PlatformTableNumberValue"
+ },
+ "requiredConsumers": [
+ { "path": "src/features/docker/DockerNativeTableShared.tsx" },
+ { "path": "src/features/kubernetes/KubernetesAutoscalingTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesControllersTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesEventsTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesPodsTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx" }
+ ],
+ "forbiddenPatterns": [
+ {
+ "path": "src/features/docker/DockerNativeTableShared.tsx",
+ "patterns": [
+ "typeof value === 'number' ? <span class=\"tabular-nums\">{value}</span> : <span>—</span>"
+ ]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesAutoscalingTable.tsx",
+ "patterns": [
+ "const numberValue",
+ "typeof value === 'number' ? <span class=\"tabular-nums\">{value}</span> : <span>—</span>"
+ ]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesControllersTable.tsx",
+ "patterns": [
+ "const numberValue",
+ "typeof value === 'number' ? <span class=\"tabular-nums\">{value}</span> : <span>—</span>"
+ ]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesEventsTable.tsx",
+ "patterns": [
+ "const numberValue",
+ "typeof value === 'number' ? <span class=\"tabular-nums\">{value}</span> : <span>—</span>"
+ ]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesPodsTable.tsx",
+ "patterns": [
+ "const numericValue",
+ "typeof value === 'number' ? <span class=\"tabular-nums\">{value}</span> : <span>—</span>"
+ ]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx",
+ "patterns": ["const countCell", "value.toLocaleString() : '—'"]
+ }
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-metric-fallback",
"category": "platform-table-metric",
@@ -1970,6 +2032,46 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-local-number-value-helper",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must not recreate local numberValue helpers for optional numeric table cells.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "PlatformTableNumberValue"
+ },
+ "scopes": ["src/features/docker", "src/features/kubernetes"],
+ "extensions": [".tsx"],
+ "allPatterns": ["<span class=\"tabular-nums\">{value}</span>", "<span>—</span>"],
+ "legacyReason": "Retired migration debt. Optional numeric platform table cells must use PlatformTableNumberValue for finite-number checks, tabular styling, and empty-cell markers.",
+ "allowedPaths": [],
+ "ignoredPaths": [],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
+ {
+ "id": "platform-table-local-count-cell-helper",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must not recreate local countCell helpers for locale-formatted optional numeric table cells.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "PlatformTableNumberValue"
+ },
+ "scopes": ["src/features/proxmox"],
+ "extensions": [".tsx"],
+ "allPatterns": ["const countCell", "value.toLocaleString() : '—'"],
+ "legacyReason": "Retired migration debt. Locale-formatted count cells must compose PlatformTableNumberValue with a caller-owned format function instead of owning fallback markup locally.",
+ "allowedPaths": [],
+ "ignoredPaths": [],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-local-metric-fallback-helper",
"category": "platform-table-metric",
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index f3c0db660d..0480999370 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -3754,6 +3754,115 @@ describe('shared primitive guardrails', () => {
);
});
+ it('keeps platform table number-value fallbacks on the shared primitive', () => {
+ const registry = JSON.parse(sharedTemplateRegistrySource) as {
+ rules?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
+ }>;
+ patternGuards?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ allPatterns?: string[];
+ scopes?: string[];
+ allowedPaths?: string[];
+ ignoredPaths?: string[];
+ }>;
+ };
+ const registeredRule = registry.rules?.find(
+ (rule) => rule.id === 'platform-table-number-value-fallback',
+ );
+ const localNumberGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-number-value-helper',
+ );
+ const localCountGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-count-cell-helper',
+ );
+ const platformNumberValueConsumers: Array<[string, string]> = [
+ ['src/features/docker/DockerNativeTableShared.tsx', dockerNativeTableSharedSource],
+ ['src/features/kubernetes/KubernetesAutoscalingTable.tsx', kubernetesAutoscalingTableSource],
+ ['src/features/kubernetes/KubernetesControllersTable.tsx', kubernetesControllersTableSource],
+ ['src/features/kubernetes/KubernetesEventsTable.tsx', kubernetesEventsTableSource],
+ ['src/features/kubernetes/KubernetesPodsTable.tsx', kubernetesPodsTableSource],
+ ['src/features/proxmox/ProxmoxMailGatewayTable.tsx', proxmoxMailGatewayTableSource],
+ ];
+ const platformNumberValueConsumerPaths = platformNumberValueConsumers.map(([path]) => path);
+ const optionalNumberMarkupPattern =
+ 'typeof value === \'number\' ? <span class="tabular-nums">{value}</span> : <span>—</span>';
+
+ expect(registeredRule?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(registeredRule?.canonical?.export).toBe('PlatformTableNumberValue');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(
+ platformNumberValueConsumerPaths,
+ );
+ expect(registeredRule?.forbiddenPatterns).toEqual([
+ {
+ path: 'src/features/docker/DockerNativeTableShared.tsx',
+ patterns: [optionalNumberMarkupPattern],
+ },
+ {
+ path: 'src/features/kubernetes/KubernetesAutoscalingTable.tsx',
+ patterns: ['const numberValue', optionalNumberMarkupPattern],
+ },
+ {
+ path: 'src/features/kubernetes/KubernetesControllersTable.tsx',
+ patterns: ['const numberValue', optionalNumberMarkupPattern],
+ },
+ {
+ path: 'src/features/kubernetes/KubernetesEventsTable.tsx',
+ patterns: ['const numberValue', optionalNumberMarkupPattern],
+ },
+ {
+ path: 'src/features/kubernetes/KubernetesPodsTable.tsx',
+ patterns: ['const numericValue', optionalNumberMarkupPattern],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxMailGatewayTable.tsx',
+ patterns: ['const countCell', "value.toLocaleString() : '—'"],
+ },
+ ]);
+ expect(localNumberGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localNumberGuard?.canonical?.export).toBe('PlatformTableNumberValue');
+ expect(localNumberGuard?.allPatterns).toEqual([
+ '<span class="tabular-nums">{value}</span>',
+ '<span>—</span>',
+ ]);
+ expect(localNumberGuard?.scopes).toEqual(['src/features/docker', 'src/features/kubernetes']);
+ expect(localNumberGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localNumberGuard?.ignoredPaths ?? []).toHaveLength(0);
+ expect(localCountGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localCountGuard?.canonical?.export).toBe('PlatformTableNumberValue');
+ expect(localCountGuard?.allPatterns).toEqual([
+ 'const countCell',
+ "value.toLocaleString() : '—'",
+ ]);
+ expect(localCountGuard?.scopes).toEqual(['src/features/proxmox']);
+ expect(localCountGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localCountGuard?.ignoredPaths ?? []).toHaveLength(0);
+
+ expect(sharedPlatformPageSource).toContain('export function PlatformTableNumberValue');
+ expect(sharedPlatformPageSource).toContain('Number.isFinite(value)');
+ expect(sharedPlatformPageSource).toContain('class="tabular-nums"');
+
+ for (const [path, source] of platformNumberValueConsumers) {
+ expect(source).toContain('PlatformTableNumberValue');
+ const forbiddenPatterns =
+ registeredRule?.forbiddenPatterns?.find((entry) => entry.path === path)?.patterns ?? [];
+ for (const pattern of forbiddenPatterns) {
+ expect(source).not.toContain(pattern);
+ }
+ }
+ expect(proxmoxMailGatewayTableSource).toContain('format={formatLocaleCount}');
+ });
+
it('keeps platform table compact value summaries on the shared helper', () => {
const registry = JSON.parse(sharedTemplateRegistrySource) as {
rules?: Array<{
diff --git a/frontend-modern/src/features/docker/DockerNativeTableShared.tsx b/frontend-modern/src/features/docker/DockerNativeTableShared.tsx
index 8ed14a359f..ca9bdf59bd 100644
--- a/frontend-modern/src/features/docker/DockerNativeTableShared.tsx
+++ b/frontend-modern/src/features/docker/DockerNativeTableShared.tsx
@@ -4,6 +4,7 @@ import { TableCell } from '@/components/shared/Table';
import { getSimpleStatusIndicator, type StatusIndicator } from '@/utils/status';
import { asTrimmedString } from '@/utils/stringUtils';
import {
+ PlatformTableNumberValue,
formatPlatformTableBytesValue,
getPlatformTableCellClassForKind,
} from '@/features/platformPage/sharedPlatformPage';
@@ -24,7 +25,7 @@ export type DockerNativeTableProps = {
export const dockerTextValue = (value: string | undefined): string => asTrimmedString(value) || '—';
export const dockerNumberValue = (value: number | undefined): JSX.Element =>
- typeof value === 'number' ? <span class="tabular-nums">{value}</span> : <span>—</span>;
+ PlatformTableNumberValue({ value });
export const dockerByteValue = (value: number | undefined): string =>
formatPlatformTableBytesValue(value);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
index 52e1a7947a..31a0199e3a 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
@@ -6,6 +6,7 @@ import { asTrimmedString } from '@/utils/stringUtils';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
+ PlatformTableNumberValue,
PlatformTableToolbar,
createPlatformTableFilterState,
formatPlatformTableTextValue,
@@ -47,9 +48,6 @@ const labelSummary = (resource: Resource): { label: string; title: string } => {
return summarizePlatformTableValues(resource.tags);
};
-const numberValue = (value: number | undefined): JSX.Element =>
- typeof value === 'number' ? <span class="tabular-nums">{value}</span> : <span>—</span>;
-
const bounds = (resource: Resource): string => {
const min = resource.kubernetes?.minReplicas;
const max = resource.kubernetes?.maxReplicas;
@@ -213,12 +211,16 @@ export const KubernetesAutoscalingTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {numberValue(resource.kubernetes?.currentReplicas)}
+ <PlatformTableNumberValue
+ value={resource.kubernetes?.currentReplicas}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {numberValue(resource.kubernetes?.desiredReplicas)}
+ <PlatformTableNumberValue
+ value={resource.kubernetes?.desiredReplicas}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx
index e855d7566f..12b4623d34 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx
@@ -6,6 +6,7 @@ import { asTrimmedString } from '@/utils/stringUtils';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
+ PlatformTableNumberValue,
PlatformTableToolbar,
createPlatformTableFilterState,
formatPlatformTableTextValue,
@@ -29,9 +30,6 @@ import {
type KubernetesResourceStatusFilter,
} from './kubernetesPageModel';
-const numberValue = (value: number | undefined): JSX.Element =>
- typeof value === 'number' ? <span class="tabular-nums">{value}</span> : <span>—</span>;
-
const controllerName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -317,17 +315,17 @@ export const KubernetesControllersTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {numberValue(currentValue(resource))}
+ <PlatformTableNumberValue value={currentValue(resource)} />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {numberValue(readyOrDoneValue(resource))}
+ <PlatformTableNumberValue value={readyOrDoneValue(resource)} />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content md:table-cell`}
>
- {numberValue(availableValue(resource))}
+ <PlatformTableNumberValue value={availableValue(resource)} />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx
index b09ea52133..33701dbcba 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx
@@ -6,6 +6,7 @@ import { formatRelativeTime } from '@/utils/format';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
+ PlatformTableNumberValue,
PlatformTableToolbar,
createPlatformTableFilterState,
formatPlatformTableTextValue,
@@ -50,9 +51,6 @@ const observedTimestamp = (resource: Resource): string =>
const observedTime = (resource: Resource): string =>
formatRelativeTime(observedTimestamp(resource), { compact: true, emptyText: '—' }) || '—';
-const numberValue = (value: number | undefined): JSX.Element =>
- typeof value === 'number' ? <span class="tabular-nums">{value}</span> : <span>—</span>;
-
export const KubernetesEventsTable: Component<{
resources: Resource[];
emptyIcon: JSX.Element;
@@ -220,7 +218,7 @@ export const KubernetesEventsTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {numberValue(resource.kubernetes?.count)}
+ <PlatformTableNumberValue value={resource.kubernetes?.count} />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx
index a128c3a404..5168fb9e8e 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx
@@ -5,6 +5,7 @@ import { asTrimmedString } from '@/utils/stringUtils';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
+ PlatformTableNumberValue,
PlatformTableToolbar,
createPlatformTableFilterState,
formatPlatformTableTextValue,
@@ -70,9 +71,6 @@ const ageValue = (resource: Resource): string => {
return `${Math.floor(seconds / 86_400)}d`;
};
-const numericValue = (value: number | undefined): JSX.Element =>
- typeof value === 'number' ? <span class="tabular-nums">{value}</span> : <span>—</span>;
-
export const KubernetesPodsTable: Component<{
resources: Resource[];
emptyIcon: JSX.Element;
@@ -250,7 +248,7 @@ export const KubernetesPodsTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {numericValue(restartCount(resource))}
+ <PlatformTableNumberValue value={restartCount(resource)} />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 2f6aac40b3..9aeefde0f9 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -4,6 +4,7 @@ import { createRoot, createSignal } from 'solid-js';
import type { Resource } from '@/types/resource';
import {
PlatformTableMetricFallback,
+ PlatformTableNumberValue,
createPlatformTableFilterState,
formatPlatformTableBytesValue,
formatPlatformTableTitleCaseValue,
@@ -302,6 +303,34 @@ describe('formatPlatformTableBytesValue', () => {
});
});
+describe('PlatformTableNumberValue', () => {
+ it('renders finite numbers with shared tabular styling and empty markers', () => {
+ const { container } = render(() => PlatformTableNumberValue({ value: 42 }));
+ const marker = container.querySelector('span');
+
+ expect(marker?.textContent).toBe('42');
+ expect(marker?.classList.contains('tabular-nums')).toBe(true);
+
+ cleanup();
+ render(() => PlatformTableNumberValue({ value: undefined }));
+ expect(screen.getByText('—')).toBeInTheDocument();
+ });
+
+ it('rejects non-finite values and supports caller-owned formatting', () => {
+ render(() => PlatformTableNumberValue({ value: Number.NaN, emptyText: '-' }));
+ expect(screen.getByText('-')).toBeInTheDocument();
+
+ cleanup();
+ render(() =>
+ PlatformTableNumberValue({
+ value: 1234,
+ format: (value) => value.toLocaleString(),
+ }),
+ );
+ expect(screen.getByText('1,234')).toBeInTheDocument();
+ });
+});
+
describe('getPlatformTableFiniteMetric', () => {
it('normalizes platform table metrics to finite numeric values only', () => {
expect(getPlatformTableFiniteMetric(42)).toBe(42);
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 9d9db1ee04..ea61ce19de 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -205,6 +205,22 @@ export const formatPlatformTableBytesValue = (
return formatBytes(bytes);
};
+export function PlatformTableNumberValue(props: {
+ value: number | undefined;
+ emptyText?: string;
+ format?: (value: number) => string | number;
+}) {
+ const label = () => {
+ const value = props.value;
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
+ return props.emptyText ?? '—';
+ }
+ return props.format?.(value) ?? value;
+ };
+
+ return <span class="tabular-nums">{label()}</span>;
+}
+
export const getPlatformTableFiniteMetric = (value: number | undefined): number | undefined =>
typeof value === 'number' && Number.isFinite(value) ? value : undefined;
diff --git a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx
index 934aef2143..733c5e7665 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx
@@ -1,4 +1,4 @@
-import { For, Show, createSignal, type Component, type JSX } from 'solid-js';
+import { For, Show, createSignal, type Component } from 'solid-js';
import { InlineDetailTableRow } from '@/components/shared/InlineDetailTableRow';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
@@ -6,6 +6,7 @@ import { getSimpleStatusIndicator } from '@/utils/status';
import { asTrimmedString } from '@/utils/stringUtils';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
+ PlatformTableNumberValue,
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
@@ -27,9 +28,7 @@ import { ProxmoxMailGatewayDrawer } from './ProxmoxMailGatewayDrawer';
// operator columns. This bespoke table reuses canonical shared
// primitives and surfaces those PMG-native columns.
-const countCell = (value: number | undefined): JSX.Element => (
- <span class="tabular-nums">{typeof value === 'number' ? value.toLocaleString() : '—'}</span>
-);
+const formatLocaleCount = (value: number): string => value.toLocaleString();
export const ProxmoxMailGatewayTable: Component<{
resources: Resource[];
@@ -150,9 +149,12 @@ export const ProxmoxMailGatewayTable: Component<{
{version()}
</TableCell>
<TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.nodeCount)}
+ <PlatformTableNumberValue
+ value={pmg()?.nodeCount}
+ format={formatLocaleCount}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
@@ -164,32 +166,50 @@ export const ProxmoxMailGatewayTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.mailCountTotal)}
+ <PlatformTableNumberValue
+ value={pmg()?.mailCountTotal}
+ format={formatLocaleCount}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.spamIn)}
+ <PlatformTableNumberValue
+ value={pmg()?.spamIn}
+ format={formatLocaleCount}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.virusIn)}
+ <PlatformTableNumberValue
+ value={pmg()?.virusIn}
+ format={formatLocaleCount}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.quarantine)}
+ <PlatformTableNumberValue
+ value={pmg()?.quarantine}
+ format={formatLocaleCount}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.queueTotal ?? pmg()?.queueActive)}
+ <PlatformTableNumberValue
+ value={pmg()?.queueTotal ?? pmg()?.queueActive}
+ format={formatLocaleCount}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {countCell(pmg()?.queueDeferred)}
+ <PlatformTableNumberValue
+ value={pmg()?.queueDeferred}
+ format={formatLocaleCount}
+ />
</TableCell>
</TableRow>
<Show when={isOpen()}>