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 Kubernetes table text fallbacks

rcourtmanc65b51186cca
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 8d106d4cf0..14069c2177 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2584,6 +2584,13 @@ Platform table loading states are registry-backed too.
`role="status"` loading row for platform pages and tables; platform consumers
own only the title and description copy. Platform feature surfaces must not
recreate the `TableCard` plus compact status-row shell locally.
+Platform table text-cell fallback formatting is a shared primitive as well.
+`formatPlatformTableTextValue` in
+`frontend-modern/src/features/platformPage/sharedPlatformPage.tsx` owns the
+trimmed-string plus canonical empty-cell marker behavior. Kubernetes platform
+tables must compose that helper instead of declaring local `textValue` helpers
+or inlining `asTrimmedString(...) || '—'` fallback expressions for table text
+cells.
Platform load-failure states are registry-backed as well.
`PlatformErrorState` owns the repeated table-card error shell, warning icon,
and Refresh action for platform page and table load failures; platform
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index a2fc090bf0..ff9338d785 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -224,6 +224,11 @@ filter semantics, drawer handoffs, and resource projections, while
Future platform tables must keep that split: row data and platform semantics
stay in the unified-resource consumer, and the repeated table shell stays in the
shared frontend primitive.
+Shared text-cell fallback behavior follows the same boundary:
+unified-resource consumers own which source field is displayed, but platform
+tables must use the frontend-primitives-owned `formatPlatformTableTextValue`
+helper for trimmed-string empty-cell rendering instead of recreating local
+`textValue` helpers or inline `asTrimmedString(...) || '—'` fallbacks.
Platform filter option semantics follow that split too: unified-resource
consumers own the source-specific status buckets and labels, while the repeated
FilterBar chip leading-dot presentation must use the frontend-primitives-owned
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 499d958404..fcd960c8eb 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1114,6 +1114,84 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-text-value-fallback",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must use the shared text-cell fallback helper for trimmed strings and canonical empty-cell markers instead of recreating local textValue helpers.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableTextValue"
+ },
+ "requiredConsumers": [
+ { "path": "src/features/kubernetes/KubernetesAutoscalingTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesClustersTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesConfigTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesControllersTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesDeploymentsTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesEventsTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesNetworkingTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesNodesTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesPodsTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesPolicyTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesServicesTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesStorageTable.tsx" }
+ ],
+ "forbiddenPatterns": [
+ {
+ "path": "src/features/kubernetes/KubernetesAutoscalingTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesClustersTable.tsx",
+ "patterns": ["asTrimmedString(cluster.kubernetes?.context) || '—'"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesConfigTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesControllersTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesDeploymentsTable.tsx",
+ "patterns": ["asTrimmedString(deployment.kubernetes?.namespace) || '—'"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesEventsTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesNetworkingTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesNodesTable.tsx",
+ "patterns": ["asTrimmedString(meta()?.kubeletVersion) || '—'"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesPodsTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesPolicyTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesServicesTable.tsx",
+ "patterns": ["const textValue"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesStorageTable.tsx",
+ "patterns": ["const textValue"]
+ }
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-error-state",
"category": "platform-error-state",
@@ -1516,6 +1594,26 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "kubernetes-platform-table-local-text-value-helper",
+ "category": "platform-table-text-value",
+ "summary": "Kubernetes platform tables must not recreate local textValue helpers for trimmed-string empty-cell fallback.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableTextValue"
+ },
+ "scopes": ["src/features/kubernetes"],
+ "extensions": [".tsx"],
+ "allPatterns": ["const textValue", "asTrimmedString(value) || '—'"],
+ "legacyReason": "Retired migration debt. Kubernetes platform table text cells must use formatPlatformTableTextValue for the shared trimmed-string empty-cell marker.",
+ "allowedPaths": [],
+ "ignoredPaths": [],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-section-tabs-local-nav",
"category": "platform-section-tabs",
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 3e0f92452d..52d1c0edb8 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -149,7 +149,18 @@ import workloadPanelSource from '@/components/Workloads/WorkloadPanel.tsx?raw';
import guestRowStateSource from '@/components/Workloads/useGuestRowState.ts?raw';
import workloadSelectionStateSource from '@/components/Workloads/useWorkloadSelectionState.ts?raw';
import dockerHostsTableSource from '@/features/docker/DockerHostsTable.tsx?raw';
+import kubernetesAutoscalingTableSource from '@/features/kubernetes/KubernetesAutoscalingTable.tsx?raw';
+import kubernetesClustersTableSource from '@/features/kubernetes/KubernetesClustersTable.tsx?raw';
+import kubernetesConfigTableSource from '@/features/kubernetes/KubernetesConfigTable.tsx?raw';
+import kubernetesControllersTableSource from '@/features/kubernetes/KubernetesControllersTable.tsx?raw';
+import kubernetesDeploymentsTableSource from '@/features/kubernetes/KubernetesDeploymentsTable.tsx?raw';
+import kubernetesEventsTableSource from '@/features/kubernetes/KubernetesEventsTable.tsx?raw';
+import kubernetesNetworkingTableSource from '@/features/kubernetes/KubernetesNetworkingTable.tsx?raw';
import kubernetesNodesTableSource from '@/features/kubernetes/KubernetesNodesTable.tsx?raw';
+import kubernetesPodsTableSource from '@/features/kubernetes/KubernetesPodsTable.tsx?raw';
+import kubernetesPolicyTableSource from '@/features/kubernetes/KubernetesPolicyTable.tsx?raw';
+import kubernetesServicesTableSource from '@/features/kubernetes/KubernetesServicesTable.tsx?raw';
+import kubernetesStorageTableSource from '@/features/kubernetes/KubernetesStorageTable.tsx?raw';
import proxmoxBackupsTableSource from '@/features/proxmox/ProxmoxBackupsTable.tsx?raw';
import proxmoxCephTableSource from '@/features/proxmox/ProxmoxCephTable.tsx?raw';
import proxmoxCoverageTableSource from '@/features/proxmox/ProxmoxCoverageTable.tsx?raw';
@@ -3433,6 +3444,79 @@ describe('shared primitive guardrails', () => {
}
});
+ it('keeps Kubernetes platform table text fallbacks on the shared helper', () => {
+ 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-text-value-fallback',
+ );
+ const localHelperGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'kubernetes-platform-table-local-text-value-helper',
+ );
+ const kubernetesTextValueConsumers: Array<[string, string]> = [
+ ['src/features/kubernetes/KubernetesAutoscalingTable.tsx', kubernetesAutoscalingTableSource],
+ ['src/features/kubernetes/KubernetesClustersTable.tsx', kubernetesClustersTableSource],
+ ['src/features/kubernetes/KubernetesConfigTable.tsx', kubernetesConfigTableSource],
+ ['src/features/kubernetes/KubernetesControllersTable.tsx', kubernetesControllersTableSource],
+ ['src/features/kubernetes/KubernetesDeploymentsTable.tsx', kubernetesDeploymentsTableSource],
+ ['src/features/kubernetes/KubernetesEventsTable.tsx', kubernetesEventsTableSource],
+ ['src/features/kubernetes/KubernetesNetworkingTable.tsx', kubernetesNetworkingTableSource],
+ ['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],
+ ['src/features/kubernetes/KubernetesPodsTable.tsx', kubernetesPodsTableSource],
+ ['src/features/kubernetes/KubernetesPolicyTable.tsx', kubernetesPolicyTableSource],
+ ['src/features/kubernetes/KubernetesServicesTable.tsx', kubernetesServicesTableSource],
+ ['src/features/kubernetes/KubernetesStorageTable.tsx', kubernetesStorageTableSource],
+ ];
+ const kubernetesTextValueConsumerPaths = kubernetesTextValueConsumers.map(([path]) => path);
+
+ expect(registeredRule?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(registeredRule?.canonical?.export).toBe('formatPlatformTableTextValue');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(
+ kubernetesTextValueConsumerPaths,
+ );
+ expect(localHelperGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localHelperGuard?.canonical?.export).toBe('formatPlatformTableTextValue');
+ expect(localHelperGuard?.allPatterns).toEqual([
+ 'const textValue',
+ "asTrimmedString(value) || '—'",
+ ]);
+ expect(localHelperGuard?.scopes).toEqual(['src/features/kubernetes']);
+ expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
+
+ expect(sharedPlatformPageSource).toContain('export const formatPlatformTableTextValue');
+ expect(sharedPlatformPageSource).toContain("asTrimmedString(value) || emptyText");
+
+ for (const [path, source] of kubernetesTextValueConsumers) {
+ expect(source).toContain('formatPlatformTableTextValue');
+ expect(source).not.toContain('const textValue');
+ expect(source).not.toContain("asTrimmedString(value) || '—'");
+ const forbiddenPatterns =
+ registeredRule?.forbiddenPatterns?.find((entry) => entry.path === path)?.patterns ?? [];
+ for (const pattern of forbiddenPatterns) {
+ expect(source).not.toContain(pattern);
+ }
+ }
+ });
+
it('keeps platform section navigation on the shared tabs template', () => {
const registry = JSON.parse(sharedTemplateRegistrySource) as {
rules?: Array<{
diff --git a/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
index 65ae64eb3e..22ea17481e 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -26,13 +27,11 @@ import {
type KubernetesResourceStatusFilter,
} from './kubernetesPageModel';
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const autoscalerName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
const targetRef = (resource: Resource): string =>
- textValue(
+ formatPlatformTableTextValue(
[resource.kubernetes?.targetKind, resource.kubernetes?.targetName].filter(Boolean).join('/'),
);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx
index 7d412d97b8..2c4d88de24 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx
@@ -11,6 +11,7 @@ import {
PlatformTableToolbar,
PlatformTableEmptyState,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -171,8 +172,8 @@ export const KubernetesClustersTable: Component<{
asTrimmedString(cluster.kubernetes?.clusterName) ||
asTrimmedString(cluster.name) ||
cluster.id;
- const context = () => asTrimmedString(cluster.kubernetes?.context) || '—';
- const version = () => asTrimmedString(cluster.kubernetes?.version) || '—';
+ const context = () => formatPlatformTableTextValue(cluster.kubernetes?.context);
+ const version = () => formatPlatformTableTextValue(cluster.kubernetes?.version);
const metricsKey = () => buildMetricKeyForUnifiedResource(cluster);
const cpuPercent = () => finiteMetric(cluster.cpu?.current);
const memoryTotal = () => finiteMetric(cluster.memory?.total) ?? 0;
diff --git a/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx
index 56bc0568c5..375ce47fb4 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -30,8 +31,6 @@ import {
// know that keys exist, but metadata-only collection must never imply that
// payload data was read or expose key names in this table.
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const configName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -65,7 +64,7 @@ const summarizeValues = (
const lifecycleOrTrust = (resource: Resource): string => {
if (resource.type === 'k8s-namespace') {
- return textValue(resource.kubernetes?.phase);
+ return formatPlatformTableTextValue(resource.kubernetes?.phase);
}
if (resource.type === 'k8s-configmap') {
const parts = [
@@ -108,7 +107,7 @@ const lifecycleOrTrust = (resource: Resource): string => {
if (kind && name) return `${kind}/${name}`;
return kind || name || '—';
}
- return textValue(resource.status);
+ return formatPlatformTableTextValue(resource.status);
};
const dataShape = (resource: Resource): { label: string; title: string } => {
diff --git a/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx
index 013539bcb0..e855d7566f 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesControllersTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -28,8 +29,6 @@ import {
type KubernetesResourceStatusFilter,
} from './kubernetesPageModel';
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const numberValue = (value: number | undefined): JSX.Element =>
typeof value === 'number' ? <span class="tabular-nums">{value}</span> : <span>—</span>;
@@ -49,7 +48,7 @@ const targetValue = (resource: Resource): string => {
case 'k8s-job':
return `${resource.kubernetes?.desiredReplicas ?? 0} completions`;
case 'k8s-cronjob':
- return textValue(resource.kubernetes?.schedule);
+ return formatPlatformTableTextValue(resource.kubernetes?.schedule);
default:
return '—';
}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx
index 061b90855b..444702b709 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesDeploymentsTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableToolbar,
PlatformTableEmptyState,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -155,7 +156,8 @@ export const KubernetesDeploymentsTable: Component<{
<For each={sortedRows()}>
{(deployment) => {
const name = () => asTrimmedString(deployment.name) || deployment.id;
- const ns = () => asTrimmedString(deployment.kubernetes?.namespace) || '—';
+ const ns = () =>
+ formatPlatformTableTextValue(deployment.kubernetes?.namespace);
const cluster = () => kubernetesClusterLabel(deployment) || '—';
const indicator = () => mapKubernetesDeploymentStatus(deployment);
const age = () => formatAge(deployment.kubernetes?.createdAt);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx
index e75378dad9..b09ea52133 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesEventsTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -28,13 +29,11 @@ import {
type KubernetesResourceStatusFilter,
} from './kubernetesPageModel';
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const eventName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
const involvedObject = (resource: Resource): string =>
- textValue(
+ formatPlatformTableTextValue(
[resource.kubernetes?.involvedKind, resource.kubernetes?.involvedName]
.filter(Boolean)
.join('/'),
@@ -151,7 +150,8 @@ export const KubernetesEventsTable: Component<{
const name = () => eventName(resource);
const scope = () => kubernetesScopeLabel(resource);
const observed = () => observedTime(resource);
- const message = () => textValue(resource.kubernetes?.message);
+ const message = () =>
+ formatPlatformTableTextValue(resource.kubernetes?.message);
const detailRowId = () => drawer.detailRowId(resource);
const isExpanded = () => drawer.isExpanded(resource);
@@ -195,16 +195,16 @@ export const KubernetesEventsTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
>
- {textValue(resource.kubernetes?.eventType)}
+ {formatPlatformTableTextValue(resource.kubernetes?.eventType)}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
>
<span
class="inline-block max-w-[12rem] truncate"
- title={textValue(resource.kubernetes?.reason)}
+ title={formatPlatformTableTextValue(resource.kubernetes?.reason)}
>
- {textValue(resource.kubernetes?.reason)}
+ {formatPlatformTableTextValue(resource.kubernetes?.reason)}
</span>
</TableCell>
<TableCell
diff --git a/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx
index 3a2bb82019..08dd47fbdb 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -26,8 +27,6 @@ import {
type KubernetesResourceStatusFilter,
} from './kubernetesPageModel';
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const resourceName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -65,7 +64,7 @@ const portLabel = (resource: Resource): { label: string; title: string } => {
};
const typeOrClass = (resource: Resource): string =>
- textValue(resource.kubernetes?.className || resource.kubernetes?.addressType);
+ formatPlatformTableTextValue(resource.kubernetes?.className || resource.kubernetes?.addressType);
const addressOrHosts = (resource: Resource): { label: string; title: string } => {
if (resource.type === 'k8s-ingress') {
@@ -100,7 +99,7 @@ const targetSummary = (resource: Resource): { label: string; title: string } =>
: hosts.label;
return { label, title: hosts.title || label };
}
- const service = textValue(resource.kubernetes?.serviceName);
+ const service = formatPlatformTableTextValue(resource.kubernetes?.serviceName);
const ready = resource.kubernetes?.readyEndpointCount;
const total = resource.kubernetes?.endpointCount;
const endpointLabel =
diff --git a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
index 59248a2e23..c7aecf7c33 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
@@ -11,6 +11,7 @@ import {
PlatformTableShell,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
} from '@/features/platformPage/sharedPlatformPage';
@@ -196,8 +197,9 @@ export const KubernetesNodesTable: Component<{
const meta = () => node.kubernetes;
const name = () => asTrimmedString(node.name) || node.id;
const cluster = () => kubernetesClusterLabel(node) || '—';
- const kubelet = () => asTrimmedString(meta()?.kubeletVersion) || '—';
- const runtime = () => asTrimmedString(meta()?.containerRuntimeVersion) || '—';
+ const kubelet = () => formatPlatformTableTextValue(meta()?.kubeletVersion);
+ const runtime = () =>
+ formatPlatformTableTextValue(meta()?.containerRuntimeVersion);
const capacityLabel = () => {
const cores = meta()?.capacityCpuCores;
const mem = meta()?.capacityMemoryBytes;
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx
index 878c326a0e..a128c3a404 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPodsTable.tsx
@@ -7,6 +7,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -27,8 +28,6 @@ import {
type KubernetesResourceStatusFilter,
} from './kubernetesPageModel';
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const podName = (resource: Resource): string =>
asTrimmedString(resource.kubernetes?.podName) ||
asTrimmedString(resource.displayName) ||
@@ -60,7 +59,7 @@ const ownerValue = (resource: Resource): string => {
};
const imageValue = (resource: Resource): string =>
- textValue(resource.kubernetes?.image || podContainers(resource)[0]?.image);
+ formatPlatformTableTextValue(resource.kubernetes?.image || podContainers(resource)[0]?.image);
const ageValue = (resource: Resource): string => {
const seconds = resource.kubernetes?.uptimeSeconds ?? resource.uptime;
@@ -182,7 +181,7 @@ export const KubernetesPodsTable: Component<{
const indicator = () => mapKubernetesPodStatus(resource);
const name = () => podName(resource);
const scope = () => kubernetesScopeLabel(resource);
- const node = () => textValue(resource.kubernetes?.nodeName);
+ const node = () => formatPlatformTableTextValue(resource.kubernetes?.nodeName);
const owner = () => ownerValue(resource);
const image = () => imageValue(resource);
const age = () => ageValue(resource);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx
index 501eebe55e..5bdc1700e4 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -30,8 +31,6 @@ import {
// on the documented NetworkPolicy, PDB, ResourceQuota, and LimitRange shapes
// instead of collapsing them into generic spec/detail text.
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const policyName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -146,7 +145,7 @@ const policyShape = (resource: Resource): { label: string; title: string } => {
if (resource.type === 'k8s-limit-range') {
return { label: 'Limit range', title: '' };
}
- return { label: textValue(resource.kubernetes?.resourceKind), title: '' };
+ return { label: formatPlatformTableTextValue(resource.kubernetes?.resourceKind), title: '' };
};
const policySpec = (resource: Resource): { label: string; title: string } => {
@@ -183,7 +182,7 @@ const policyState = (resource: Resource): { label: string; title: string } => {
if (resource.type === 'k8s-limit-range') {
return { label: 'Namespace defaults', title: '' };
}
- return { label: textValue(resource.status), title: '' };
+ return { label: formatPlatformTableTextValue(resource.status), title: '' };
};
const labelSummary = (resource: Resource): { label: string; title: string } =>
diff --git a/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
index f3e7099b22..bf726826aa 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
@@ -8,6 +8,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -30,8 +31,6 @@ import {
// operators need the Service type, virtual IP, exposed ports, node ports, and
// selector together rather than in a generic networking/detail table.
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const serviceName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -169,8 +168,10 @@ export const KubernetesServicesTable: Component<{
const indicator = () => getSimpleStatusIndicator(resource.status);
const name = () => serviceName(resource);
const scope = () => kubernetesScopeLabel(resource);
- const serviceType = () => textValue(resource.kubernetes?.serviceType);
- const clusterIp = () => textValue(resource.kubernetes?.clusterIp);
+ const serviceType = () =>
+ formatPlatformTableTextValue(resource.kubernetes?.serviceType);
+ const clusterIp = () =>
+ formatPlatformTableTextValue(resource.kubernetes?.clusterIp);
const externalIps = () => externalIpSummary(resource);
const ports = () => portSummary(resource);
const selector = () => selectorSummary(resource);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesStorageTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesStorageTable.tsx
index 802f8e4e94..c91aad1afa 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesStorageTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesStorageTable.tsx
@@ -9,6 +9,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableShell,
@@ -41,8 +42,6 @@ const ACCESS_MODE_LABELS: Record<string, string> = {
ReadWriteOncePod: 'RWOP',
};
-const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
-
const storageName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -55,14 +54,14 @@ const storageKind = (resource: Resource): string => {
const bindingOrPhase = (resource: Resource): string => {
if (resource.type === 'k8s-storage-class') {
- return textValue(resource.kubernetes?.volumeBindingMode || 'Immediate');
+ return formatPlatformTableTextValue(resource.kubernetes?.volumeBindingMode || 'Immediate');
}
- return textValue(resource.kubernetes?.phase);
+ return formatPlatformTableTextValue(resource.kubernetes?.phase);
};
const storageClass = (resource: Resource): string => {
if (resource.type === 'k8s-storage-class') return storageName(resource);
- return textValue(resource.kubernetes?.storageClass);
+ return formatPlatformTableTextValue(resource.kubernetes?.storageClass);
};
const capacityLabel = (resource: Resource): string => {
@@ -119,7 +118,7 @@ const policyLabel = (resource: Resource): { label: string; title: string } => {
const bindingTarget = (resource: Resource): { label: string; title: string } => {
if (resource.type === 'k8s-storage-class') {
- const provisioner = textValue(resource.kubernetes?.provisioner);
+ const provisioner = formatPlatformTableTextValue(resource.kubernetes?.provisioner);
const parameterKeys = resource.kubernetes?.parameterKeys ?? [];
return {
label: provisioner,
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 36eb6d0e26..7f3187d1e0 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 type { Resource } from '@/types/resource';
import {
createPlatformTableFilterState,
filterPlatformResources,
+ formatPlatformTableTextValue,
type PlatformResourceStatusFilter,
} from '../sharedPlatformPage';
@@ -212,3 +213,13 @@ describe('filterPlatformResources', () => {
});
});
});
+
+describe('formatPlatformTableTextValue', () => {
+ it('trims text values and uses the canonical platform-table empty cell marker', () => {
+ expect(formatPlatformTableTextValue(' kubelet ')).toBe('kubelet');
+ expect(formatPlatformTableTextValue('')).toBe('—');
+ expect(formatPlatformTableTextValue(undefined)).toBe('—');
+ expect(formatPlatformTableTextValue(null)).toBe('—');
+ expect(formatPlatformTableTextValue(' ', 'n/a')).toBe('n/a');
+ });
+});
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index fe98cd7933..fc751eafca 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -12,6 +12,7 @@ import { TableCardHeader } from '@/components/shared/TableCardHeader';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import { UnifiedResourceTable } from '@/components/Infrastructure/UnifiedResourceTable';
import type { Resource } from '@/types/resource';
+import { asTrimmedString } from '@/utils/stringUtils';
import { formatVmwareClusterServices } from '@/utils/vmwareDisplay';
import { getPlatformColumnAlign, type PlatformTableColumnKind } from './columnAlignment';
@@ -140,6 +141,9 @@ export const getPlatformTableHeadClassForKind = (kind: PlatformTableColumnKind):
export const getPlatformTableCellClassForKind = (kind: PlatformTableColumnKind): string =>
getPlatformTableCellClass(getPlatformColumnAlign(kind));
+export const formatPlatformTableTextValue = (value: unknown, emptyText = '—'): string =>
+ asTrimmedString(value) || emptyText;
+
export function PlatformErrorState(props: {
title: string;
description: string;