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 value summaries

rcourtmande906dfbd7fd
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 52efa23316..ce1b343f93 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2599,8 +2599,9 @@ local `titleCase` helpers.
Platform table compact list summaries follow the same rule.
`summarizePlatformTableValues` owns the repeated trimming, empty-marker label,
visible-value count, `+N` overflow suffix, full-title text, and normalized
-value-list behavior for dense platform table cells. vSphere datastore/network
-tables and TrueNAS network-share tables must compose that helper instead of
+value-list behavior for dense platform table cells. Kubernetes
+service/network/config/policy/autoscaling tables, vSphere datastore/network
+tables, and TrueNAS network-share tables must compose that helper instead of
declaring local `compactList` or `summarizeValues` helpers.
Platform table uptime formatting follows that rule too.
`formatPlatformTableUptimeValue` owns the repeated one-unit uptime label plus
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 98ce984a54..000a6b1fa4 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -234,11 +234,11 @@ unified-resource consumers own which TrueNAS state or status value is shown,
but TrueNAS platform tables must use `formatPlatformTableTitleCaseValue`
instead of recreating local `titleCase` helpers.
Compact list summaries follow the same boundary: unified-resource consumers
-own which source values belong in host, VM, access, client, or security cells,
-while platform tables must use `summarizePlatformTableValues` for trimming,
-empty-marker labels, `+N` overflow labels, full title text, and normalized
-value lists instead of recreating local `compactList` or `summarizeValues`
-helpers.
+own which source values belong in host, VM, access, client, security, label,
+port, selector, policy type, or quota cells, while platform tables must use
+`summarizePlatformTableValues` for trimming, empty-marker labels, `+N` overflow
+labels, full title text, and normalized value lists instead of recreating local
+`compactList` or `summarizeValues` helpers.
One-unit platform table uptime labels follow the same boundary:
unified-resource consumers own which uptime field is displayed, but platform
tables must use `formatPlatformTableUptimeValue` instead of recreating local
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 87b93f08ca..df141cdfcd 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1244,11 +1244,36 @@
"export": "summarizePlatformTableValues"
},
"requiredConsumers": [
+ { "path": "src/features/kubernetes/KubernetesAutoscalingTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesConfigTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesNetworkingTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesPolicyTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesServicesTable.tsx" },
{ "path": "src/features/truenas/TrueNASNetworkSharesTable.tsx" },
{ "path": "src/features/vmware/VsphereDatastoresTable.tsx" },
{ "path": "src/features/vmware/VsphereNetworksTable.tsx" }
],
"forbiddenPatterns": [
+ {
+ "path": "src/features/kubernetes/KubernetesAutoscalingTable.tsx",
+ "patterns": ["const compactList", "const summarizeValues"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesConfigTable.tsx",
+ "patterns": ["const compactList", "const summarizeValues"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesNetworkingTable.tsx",
+ "patterns": ["const compactList", "const summarizeValues"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesPolicyTable.tsx",
+ "patterns": ["const compactList", "const summarizeValues"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesServicesTable.tsx",
+ "patterns": ["const compactList", "const summarizeValues"]
+ },
{
"path": "src/features/truenas/TrueNASNetworkSharesTable.tsx",
"patterns": ["const compactList", "const summarizeValues"]
@@ -1809,7 +1834,7 @@
"path": "src/features/platformPage/sharedPlatformPage.tsx",
"export": "summarizePlatformTableValues"
},
- "scopes": ["src/features/truenas", "src/features/vmware"],
+ "scopes": ["src/features/kubernetes", "src/features/truenas", "src/features/vmware"],
"extensions": [".tsx"],
"allPatterns": ["const compactList"],
"legacyReason": "Retired migration debt. Platform table compact list normalization must use summarizePlatformTableValues for shared trimming and normalized values.",
@@ -1829,7 +1854,7 @@
"path": "src/features/platformPage/sharedPlatformPage.tsx",
"export": "summarizePlatformTableValues"
},
- "scopes": ["src/features/truenas", "src/features/vmware"],
+ "scopes": ["src/features/kubernetes", "src/features/truenas", "src/features/vmware"],
"extensions": [".tsx"],
"allPatterns": ["const summarizeValues"],
"legacyReason": "Retired migration debt. Platform table compact value summaries must use summarizePlatformTableValues for shared labels, overflow counts, and title text.",
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 756a4023b9..fb8771f64b 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -3689,6 +3689,11 @@ describe('shared primitive guardrails', () => {
(guard) => guard.id === 'platform-table-local-value-summary-helper',
);
const platformValueSummaryConsumers: Array<[string, string]> = [
+ ['src/features/kubernetes/KubernetesAutoscalingTable.tsx', kubernetesAutoscalingTableSource],
+ ['src/features/kubernetes/KubernetesConfigTable.tsx', kubernetesConfigTableSource],
+ ['src/features/kubernetes/KubernetesNetworkingTable.tsx', kubernetesNetworkingTableSource],
+ ['src/features/kubernetes/KubernetesPolicyTable.tsx', kubernetesPolicyTableSource],
+ ['src/features/kubernetes/KubernetesServicesTable.tsx', kubernetesServicesTableSource],
['src/features/truenas/TrueNASNetworkSharesTable.tsx', truenasNetworkSharesTableSource],
['src/features/vmware/VsphereDatastoresTable.tsx', vsphereDatastoresTableSource],
['src/features/vmware/VsphereNetworksTable.tsx', vsphereNetworksTableSource],
@@ -3713,7 +3718,11 @@ describe('shared primitive guardrails', () => {
);
expect(localCompactListGuard?.canonical?.export).toBe('summarizePlatformTableValues');
expect(localCompactListGuard?.allPatterns).toEqual(['const compactList']);
- expect(localCompactListGuard?.scopes).toEqual(['src/features/truenas', 'src/features/vmware']);
+ expect(localCompactListGuard?.scopes).toEqual([
+ 'src/features/kubernetes',
+ 'src/features/truenas',
+ 'src/features/vmware',
+ ]);
expect(localCompactListGuard?.allowedPaths ?? []).toHaveLength(0);
expect(localCompactListGuard?.ignoredPaths ?? []).toHaveLength(0);
expect(localSummaryGuard?.canonical?.path).toBe(
@@ -3721,7 +3730,11 @@ describe('shared primitive guardrails', () => {
);
expect(localSummaryGuard?.canonical?.export).toBe('summarizePlatformTableValues');
expect(localSummaryGuard?.allPatterns).toEqual(['const summarizeValues']);
- expect(localSummaryGuard?.scopes).toEqual(['src/features/truenas', 'src/features/vmware']);
+ expect(localSummaryGuard?.scopes).toEqual([
+ 'src/features/kubernetes',
+ 'src/features/truenas',
+ 'src/features/vmware',
+ ]);
expect(localSummaryGuard?.allowedPaths ?? []).toHaveLength(0);
expect(localSummaryGuard?.ignoredPaths ?? []).toHaveLength(0);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
index 22ea17481e..52e1a7947a 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesAutoscalingTable.tsx
@@ -11,6 +11,7 @@ import {
formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
+ summarizePlatformTableValues,
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import {
@@ -36,23 +37,14 @@ const targetRef = (resource: Resource): string =>
);
const metricSources = (resource: Resource): { label: string; title: string } => {
- const sources = (resource.kubernetes?.metricTypes ?? [])
- .map((source) => asTrimmedString(source))
- .filter((source): source is string => typeof source === 'string' && source.length > 0);
- if (sources.length === 0) return { label: 'Default CPU', title: 'Default CPU utilization' };
- const shown = sources.slice(0, 3);
- const suffix = sources.length > shown.length ? ` +${sources.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: sources.join(', ') };
+ const sources = summarizePlatformTableValues(resource.kubernetes?.metricTypes, { maxVisible: 3 });
+ if (sources.values.length === 0)
+ return { label: 'Default CPU', title: 'Default CPU utilization' };
+ return sources;
};
const labelSummary = (resource: Resource): { label: string; title: string } => {
- const labels = (resource.tags ?? [])
- .map((label) => asTrimmedString(label))
- .filter((label): label is string => typeof label === 'string' && label.length > 0);
- if (labels.length === 0) return { label: '—', title: '' };
- const shown = labels.slice(0, 2);
- const suffix = labels.length > shown.length ? ` +${labels.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: labels.join(', ') };
+ return summarizePlatformTableValues(resource.tags);
};
const numberValue = (value: number | undefined): JSX.Element =>
diff --git a/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx
index 375ce47fb4..5878a4732b 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesConfigTable.tsx
@@ -11,6 +11,7 @@ import {
formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
+ summarizePlatformTableValues,
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import {
@@ -49,19 +50,6 @@ const configKind = (resource: Resource): string => {
const plural = (count: number, singular: string, pluralLabel = `${singular}s`): string =>
`${count} ${count === 1 ? singular : pluralLabel}`;
-const summarizeValues = (
- values: readonly (string | undefined)[] | undefined,
- visible = 2,
-): { label: string; title: string } => {
- const normalized = (values ?? [])
- .map((value) => asTrimmedString(value))
- .filter((value): value is string => typeof value === 'string' && value.length > 0);
- if (normalized.length === 0) return { label: '—', title: '' };
- const shown = normalized.slice(0, visible);
- const suffix = normalized.length > shown.length ? ` +${normalized.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: normalized.join(', ') };
-};
-
const lifecycleOrTrust = (resource: Resource): string => {
if (resource.type === 'k8s-namespace') {
return formatPlatformTableTextValue(resource.kubernetes?.phase);
@@ -116,7 +104,7 @@ const dataShape = (resource: Resource): { label: string; title: string } => {
if (subjectCount === 0) {
return { label: 'No subjects', title: '' };
}
- const kinds = summarizeValues(resource.kubernetes?.subjectKinds);
+ const kinds = summarizePlatformTableValues(resource.kubernetes?.subjectKinds);
const label =
kinds.label !== '—'
? `${plural(subjectCount, 'subject')} · ${kinds.label}`
@@ -146,7 +134,7 @@ const dataShape = (resource: Resource): { label: string; title: string } => {
const serviceAccountRefs = (resource: Resource): { label: string; title: string } => {
if (resource.type !== 'k8s-serviceaccount') return { label: '—', title: '' };
- const imagePullSecrets = summarizeValues(resource.kubernetes?.imagePullSecrets);
+ const imagePullSecrets = summarizePlatformTableValues(resource.kubernetes?.imagePullSecrets);
const parts = [
typeof resource.kubernetes?.secretCount === 'number'
? plural(resource.kubernetes.secretCount, 'secret')
@@ -165,7 +153,7 @@ const serviceAccountRefs = (resource: Resource): { label: string; title: string
};
const labelSummary = (resource: Resource): { label: string; title: string } =>
- summarizeValues(resource.tags);
+ summarizePlatformTableValues(resource.tags);
export const KubernetesConfigTable: Component<{
resources: Resource[];
diff --git a/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx
index 08dd47fbdb..05cc632ea8 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx
@@ -11,6 +11,7 @@ import {
formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
+ summarizePlatformTableValues,
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import {
@@ -36,22 +37,9 @@ const networkKind = (resource: Resource): string => {
return resource.kubernetes?.resourceKind || resource.type;
};
-const summarizeValues = (
- values: readonly (string | undefined)[] | undefined,
- visible = 2,
-): { label: string; title: string } => {
- const normalized = (values ?? [])
- .map((value) => asTrimmedString(value))
- .filter((value): value is string => typeof value === 'string' && value.length > 0);
- if (normalized.length === 0) return { label: '—', title: '' };
- const shown = normalized.slice(0, visible);
- const suffix = normalized.length > shown.length ? ` +${normalized.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: normalized.join(', ') };
-};
-
const portLabel = (resource: Resource): { label: string; title: string } => {
if (resource.kubernetes?.endpointPorts?.length) {
- return summarizeValues(
+ return summarizePlatformTableValues(
resource.kubernetes.endpointPorts.map((port) => {
if (!port.port) return undefined;
const protocol = port.protocol ? `/${port.protocol.toLowerCase()}` : '';
@@ -68,7 +56,7 @@ const typeOrClass = (resource: Resource): string =>
const addressOrHosts = (resource: Resource): { label: string; title: string } => {
if (resource.type === 'k8s-ingress') {
- return summarizeValues([
+ return summarizePlatformTableValues([
...(resource.kubernetes?.hosts ?? []),
...(resource.kubernetes?.addresses ?? []),
]);
@@ -83,13 +71,13 @@ const addressOrHosts = (resource: Resource): { label: string; title: string } =>
title: `${readyValue}/${totalValue} ready`,
};
}
- return summarizeValues(resource.kubernetes?.addresses);
+ return summarizePlatformTableValues(resource.kubernetes?.addresses);
};
const targetSummary = (resource: Resource): { label: string; title: string } => {
if (resource.type === 'k8s-ingress') {
const rules = resource.kubernetes?.ingressRuleCount;
- const hosts = summarizeValues(resource.kubernetes?.hosts);
+ const hosts = summarizePlatformTableValues(resource.kubernetes?.hosts);
const hostCount = resource.kubernetes?.hosts?.length ?? 0;
const label =
typeof rules === 'number'
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx
index 5bdc1700e4..a20fb4fc2f 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPolicyTable.tsx
@@ -11,6 +11,7 @@ import {
formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
+ summarizePlatformTableValues,
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import {
@@ -42,31 +43,18 @@ const policyKind = (resource: Resource): string => {
return resource.kubernetes?.resourceKind || resource.type;
};
-const summarizeValues = (
- values: readonly (string | undefined)[] | undefined,
- visible = 2,
-): { label: string; title: string } => {
- const normalized = (values ?? [])
- .map((value) => asTrimmedString(value))
- .filter((value): value is string => typeof value === 'string' && value.length > 0);
- if (normalized.length === 0) return { label: '—', title: '' };
- const shown = normalized.slice(0, visible);
- const suffix = normalized.length > shown.length ? ` +${normalized.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: normalized.join(', ') };
-};
-
const plural = (count: number, singular: string, pluralLabel = `${singular}s`): string =>
`${count} ${count === 1 ? singular : pluralLabel}`;
const policyTypes = (resource: Resource): { label: string; title: string } => {
- const explicit = summarizeValues(resource.kubernetes?.policyTypes);
+ const explicit = summarizePlatformTableValues(resource.kubernetes?.policyTypes);
if (explicit.label !== '—') return explicit;
const inferred = [
typeof resource.kubernetes?.ingressRuleCount === 'number' ? 'Ingress' : undefined,
typeof resource.kubernetes?.egressRuleCount === 'number' ? 'Egress' : undefined,
];
- return summarizeValues(inferred);
+ return summarizePlatformTableValues(inferred);
};
const quotaKeys = (resource: Resource): string[] => {
@@ -81,9 +69,7 @@ const quotaUsage = (resource: Resource, visible = 2): { label: string; title: st
const hard = resource.kubernetes?.hard ?? {};
const used = resource.kubernetes?.used ?? {};
const values = keys.map((key) => `${key} ${used[key] ?? '0'}/${hard[key] ?? '—'}`);
- const shown = values.slice(0, visible);
- const suffix = values.length > shown.length ? ` +${values.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: values.join(', ') };
+ return summarizePlatformTableValues(values, { maxVisible: visible });
};
const pdbBudget = (resource: Resource): string => {
@@ -163,7 +149,7 @@ const policySpec = (resource: Resource): { label: string; title: string } => {
};
}
if (resource.type === 'k8s-limit-range') {
- return summarizeValues(resource.kubernetes?.limitTypes, 3);
+ return summarizePlatformTableValues(resource.kubernetes?.limitTypes, { maxVisible: 3 });
}
return { label: '—', title: '' };
};
@@ -186,7 +172,7 @@ const policyState = (resource: Resource): { label: string; title: string } => {
};
const labelSummary = (resource: Resource): { label: string; title: string } =>
- summarizeValues(resource.tags);
+ summarizePlatformTableValues(resource.tags);
export const KubernetesPolicyTable: Component<{
resources: Resource[];
diff --git a/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
index bf726826aa..4090e590f7 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
@@ -11,6 +11,7 @@ import {
formatPlatformTableTextValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
+ summarizePlatformTableValues,
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import {
@@ -34,19 +35,6 @@ import {
const serviceName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
-const summarizeValues = (
- values: readonly (string | undefined)[] | undefined,
- visible = 2,
-): { label: string; title: string } => {
- const normalized = (values ?? [])
- .map((value) => asTrimmedString(value))
- .filter((value): value is string => typeof value === 'string' && value.length > 0);
- if (normalized.length === 0) return { label: '—', title: '' };
- const shown = normalized.slice(0, visible);
- const suffix = normalized.length > shown.length ? ` +${normalized.length - shown.length}` : '';
- return { label: `${shown.join(', ')}${suffix}`, title: normalized.join(', ') };
-};
-
const portSummary = (resource: Resource): { label: string; title: string } => {
const ports = resource.kubernetes?.servicePorts ?? [];
const labels = ports.map((port) => {
@@ -56,7 +44,7 @@ const portSummary = (resource: Resource): { label: string; title: string } => {
const nodePort = port.nodePort ? ` node:${port.nodePort}` : '';
return `${port.port}${target}${protocol}${nodePort}`;
});
- return summarizeValues(labels, 2);
+ return summarizePlatformTableValues(labels);
};
const selectorSummary = (resource: Resource): { label: string; title: string } => {
@@ -65,11 +53,11 @@ const selectorSummary = (resource: Resource): { label: string; title: string } =
const pairs = Object.entries(selector)
.sort(([left], [right]) => left.localeCompare(right))
.map(([key, value]) => `${key}=${value}`);
- return summarizeValues(pairs, 2);
+ return summarizePlatformTableValues(pairs);
};
const externalIpSummary = (resource: Resource): { label: string; title: string } =>
- summarizeValues(resource.kubernetes?.externalIps);
+ summarizePlatformTableValues(resource.kubernetes?.externalIps);
export const KubernetesServicesTable: Component<{
resources: Resource[];