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 TrueNAS table title-case fallbacks

rcourtman8e1a55c03cca
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 14069c2177..973cb1af27 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2591,6 +2591,11 @@ 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 table title-case fallback formatting follows the same rule.
+`formatPlatformTableTitleCaseValue` owns the repeated trimmed-string plus
+`Unknown` fallback behavior for state/status labels that need simple title
+case. TrueNAS platform tables must compose that helper instead of declaring
+local `titleCase` helpers.
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 ff9338d785..527fc72a10 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -229,6 +229,10 @@ 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.
+Simple title-case state/status label fallback follows that boundary too:
+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.
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 fcd960c8eb..9b66a9d2ce 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1192,6 +1192,49 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-title-case-value-fallback",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must use the shared title-case fallback helper for status/state labels instead of recreating local titleCase helpers.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableTitleCaseValue"
+ },
+ "requiredConsumers": [
+ { "path": "src/features/truenas/TrueNASAppsTable.tsx" },
+ { "path": "src/features/truenas/TrueNASNetworkSharesTable.tsx" },
+ { "path": "src/features/truenas/TrueNASServicesTable.tsx" },
+ { "path": "src/features/truenas/TrueNASStorageTopologyTable.tsx" },
+ { "path": "src/features/truenas/TrueNASVirtualMachinesTable.tsx" }
+ ],
+ "forbiddenPatterns": [
+ {
+ "path": "src/features/truenas/TrueNASAppsTable.tsx",
+ "patterns": ["const titleCase"]
+ },
+ {
+ "path": "src/features/truenas/TrueNASNetworkSharesTable.tsx",
+ "patterns": ["const titleCase"]
+ },
+ {
+ "path": "src/features/truenas/TrueNASServicesTable.tsx",
+ "patterns": ["const titleCase"]
+ },
+ {
+ "path": "src/features/truenas/TrueNASStorageTopologyTable.tsx",
+ "patterns": ["const titleCase"]
+ },
+ {
+ "path": "src/features/truenas/TrueNASVirtualMachinesTable.tsx",
+ "patterns": ["const titleCase"]
+ }
+ ],
+ "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",
@@ -1614,6 +1657,26 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "truenas-platform-table-local-title-case-helper",
+ "category": "platform-table-text-value",
+ "summary": "TrueNAS platform tables must not recreate local titleCase helpers for status/state label fallback.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableTitleCaseValue"
+ },
+ "scopes": ["src/features/truenas"],
+ "extensions": [".tsx"],
+ "allPatterns": ["const titleCase", "asTrimmedString(value)", "return 'Unknown'"],
+ "legacyReason": "Retired migration debt. TrueNAS platform table status/state labels must use formatPlatformTableTitleCaseValue for the shared title-case fallback.",
+ "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 52d1c0edb8..ba79f544f7 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -254,8 +254,12 @@ import dockerAlertsTableSource from '@/features/docker/DockerAlertsTable.tsx?raw
import kubernetesAlertsTableSource from '@/features/kubernetes/KubernetesAlertsTable.tsx?raw';
import proxmoxBackupsTableSharedSource from '@/features/proxmox/proxmoxBackupsTableShared.tsx?raw';
import truenasAlertsTableSource from '@/features/truenas/TrueNASAlertsTable.tsx?raw';
+import truenasAppsTableSource from '@/features/truenas/TrueNASAppsTable.tsx?raw';
+import truenasNetworkSharesTableSource from '@/features/truenas/TrueNASNetworkSharesTable.tsx?raw';
import truenasServicesTableSource from '@/features/truenas/TrueNASServicesTable.tsx?raw';
+import truenasStorageTopologyTableSource from '@/features/truenas/TrueNASStorageTopologyTable.tsx?raw';
import truenasSystemsTableSource from '@/features/truenas/TrueNASSystemsTable.tsx?raw';
+import truenasVirtualMachinesTableSource from '@/features/truenas/TrueNASVirtualMachinesTable.tsx?raw';
import vsphereActivityTableSource from '@/features/vmware/VsphereActivityTable.tsx?raw';
import vsphereAlertsTableSource from '@/features/vmware/VsphereAlertsTable.tsx?raw';
@@ -3517,6 +3521,73 @@ describe('shared primitive guardrails', () => {
}
});
+ it('keeps TrueNAS platform table title-case 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-title-case-value-fallback',
+ );
+ const localHelperGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'truenas-platform-table-local-title-case-helper',
+ );
+ const truenasTitleCaseConsumers: Array<[string, string]> = [
+ ['src/features/truenas/TrueNASAppsTable.tsx', truenasAppsTableSource],
+ ['src/features/truenas/TrueNASNetworkSharesTable.tsx', truenasNetworkSharesTableSource],
+ ['src/features/truenas/TrueNASServicesTable.tsx', truenasServicesTableSource],
+ ['src/features/truenas/TrueNASStorageTopologyTable.tsx', truenasStorageTopologyTableSource],
+ ['src/features/truenas/TrueNASVirtualMachinesTable.tsx', truenasVirtualMachinesTableSource],
+ ];
+ const truenasTitleCaseConsumerPaths = truenasTitleCaseConsumers.map(([path]) => path);
+
+ expect(registeredRule?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(registeredRule?.canonical?.export).toBe('formatPlatformTableTitleCaseValue');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(
+ truenasTitleCaseConsumerPaths,
+ );
+ expect(registeredRule?.forbiddenPatterns).toEqual(
+ truenasTitleCaseConsumerPaths.map((path) => ({
+ path,
+ patterns: ['const titleCase'],
+ })),
+ );
+ expect(localHelperGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localHelperGuard?.canonical?.export).toBe('formatPlatformTableTitleCaseValue');
+ expect(localHelperGuard?.allPatterns).toEqual([
+ 'const titleCase',
+ 'asTrimmedString(value)',
+ "return 'Unknown'",
+ ]);
+ expect(localHelperGuard?.scopes).toEqual(['src/features/truenas']);
+ expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
+
+ expect(sharedPlatformPageSource).toContain('export const formatPlatformTableTitleCaseValue');
+ expect(sharedPlatformPageSource).toContain("if (!normalized) return emptyText");
+
+ for (const [, source] of truenasTitleCaseConsumers) {
+ expect(source).toContain('formatPlatformTableTitleCaseValue');
+ expect(source).not.toContain('const titleCase');
+ }
+ });
+
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/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 7f3187d1e0..79880dd026 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -3,6 +3,7 @@ import { createRoot, createSignal } from 'solid-js';
import type { Resource } from '@/types/resource';
import {
createPlatformTableFilterState,
+ formatPlatformTableTitleCaseValue,
filterPlatformResources,
formatPlatformTableTextValue,
type PlatformResourceStatusFilter,
@@ -223,3 +224,13 @@ describe('formatPlatformTableTextValue', () => {
expect(formatPlatformTableTextValue(' ', 'n/a')).toBe('n/a');
});
});
+
+describe('formatPlatformTableTitleCaseValue', () => {
+ it('formats table status labels with the canonical title-case fallback', () => {
+ expect(formatPlatformTableTitleCaseValue(' RUNNING ')).toBe('Running');
+ expect(formatPlatformTableTitleCaseValue('degraded')).toBe('Degraded');
+ expect(formatPlatformTableTitleCaseValue('')).toBe('Unknown');
+ expect(formatPlatformTableTitleCaseValue(undefined)).toBe('Unknown');
+ expect(formatPlatformTableTitleCaseValue(' ', 'Unavailable')).toBe('Unavailable');
+ });
+});
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index fc751eafca..7ae40ed628 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -144,6 +144,15 @@ export const getPlatformTableCellClassForKind = (kind: PlatformTableColumnKind):
export const formatPlatformTableTextValue = (value: unknown, emptyText = '—'): string =>
asTrimmedString(value) || emptyText;
+export const formatPlatformTableTitleCaseValue = (
+ value: unknown,
+ emptyText = 'Unknown',
+): string => {
+ const normalized = asTrimmedString(value);
+ if (!normalized) return emptyText;
+ return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
+};
+
export function PlatformErrorState(props: {
title: string;
description: string;
diff --git a/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx b/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx
index dba2c637fd..c5028037d3 100644
--- a/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx
@@ -11,6 +11,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTitleCaseValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformTableFilterOption,
@@ -48,12 +49,6 @@ const metricFallback = () => (
const finiteMetric = (value: number | undefined): number | undefined =>
typeof value === 'number' && Number.isFinite(value) ? value : undefined;
-const titleCase = (value: string | undefined): string => {
- const normalized = asTrimmedString(value);
- if (!normalized) return 'Unknown';
- return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
-};
-
const appMeta = (resource: Resource): ResourceTrueNASAppMeta | undefined => resource.truenas?.app;
const appVersionLabel = (app: ResourceTrueNASAppMeta | undefined): string => {
@@ -280,7 +275,8 @@ export const TrueNASAppsTable: Component<{
{name()}
</div>
<div class="truncate text-[10px] text-muted">
- {titleCase(app()?.state)} on {resource.parentName || 'TrueNAS'}
+ {formatPlatformTableTitleCaseValue(app()?.state)} on{' '}
+ {resource.parentName || 'TrueNAS'}
<Show when={app()?.customApp}> - Custom</Show>
</div>
</div>
diff --git a/frontend-modern/src/features/truenas/TrueNASNetworkSharesTable.tsx b/frontend-modern/src/features/truenas/TrueNASNetworkSharesTable.tsx
index ba613c4e9b..8adacc6595 100644
--- a/frontend-modern/src/features/truenas/TrueNASNetworkSharesTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASNetworkSharesTable.tsx
@@ -7,6 +7,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTitleCaseValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformTableFilterOption,
@@ -37,12 +38,6 @@ const TRUENAS_SHARE_STATUS_OPTIONS: PlatformTableFilterOption<TrueNASShareStatus
const shareMeta = (resource: Resource): ResourceTrueNASShareMeta | undefined =>
resource.truenas?.share;
-const titleCase = (value: string | undefined): string => {
- const normalized = asTrimmedString(value);
- if (!normalized) return 'Unknown';
- return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
-};
-
const formatProtocol = (share: ResourceTrueNASShareMeta | undefined): string =>
asTrimmedString(share?.protocol)?.toUpperCase() || '-';
@@ -198,7 +193,8 @@ export const TrueNASNetworkSharesTable: Component<{
const access = createMemo(() => formatAccess(share()));
const clients = createMemo(() => formatClients(share()));
const security = createMemo(() => formatSecurity(share()));
- const stateLabel = () => titleCase(mapTrueNASShareStatus(resource));
+ const stateLabel = () =>
+ formatPlatformTableTitleCaseValue(mapTrueNASShareStatus(resource));
const detailRowId = () => drawer.detailRowId(resource);
const isExpanded = () => drawer.isExpanded(resource);
return (
diff --git a/frontend-modern/src/features/truenas/TrueNASServicesTable.tsx b/frontend-modern/src/features/truenas/TrueNASServicesTable.tsx
index ab257e7b81..fa406d1908 100644
--- a/frontend-modern/src/features/truenas/TrueNASServicesTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASServicesTable.tsx
@@ -7,6 +7,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTitleCaseValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformTableFilterOption,
@@ -52,12 +53,6 @@ const SERVICE_NAME_LABELS: Record<string, string> = {
ups: 'UPS',
};
-const titleCase = (value: string | undefined): string => {
- const normalized = asTrimmedString(value);
- if (!normalized) return 'Unknown';
- return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
-};
-
const formatServiceName = (value: string | undefined): string => {
const normalized = asTrimmedString(value);
if (!normalized) return 'Unknown';
@@ -122,7 +117,7 @@ const buildServiceDetailSections = (row: TrueNASServiceRow): ServiceDetailSectio
{
label: 'Runtime',
rows: compactDetailRows([
- detailRow('State', titleCase(asTrimmedString(row.service.state) || undefined), {
+ detailRow('State', formatPlatformTableTitleCaseValue(row.service.state), {
tone: serviceTone(row),
}),
detailRow('Boot', detailBool(row.service.enabled), {
@@ -147,7 +142,7 @@ const ServiceDetailTable: Component<{ row: TrueNASServiceRow; onClose: () => voi
testId="truenas-service-detail"
detailFor={props.row.id}
title="Service detail"
- summary={`${formatServiceName(props.row.service.service)} · ${titleCase(
+ summary={`${formatServiceName(props.row.service.service)} · ${formatPlatformTableTitleCaseValue(
mapTrueNASServiceStatus(props.row),
)}`}
sections={buildServiceDetailSections(props.row)}
@@ -261,7 +256,7 @@ export const TrueNASServicesTable: Component<{
<StatusDot
size="sm"
variant={serviceStatusVariant(status())}
- title={titleCase(status())}
+ title={formatPlatformTableTitleCaseValue(status())}
/>
<div class="min-w-0 truncate font-medium text-base-content">
{formatServiceName(row.service.service)}
@@ -270,7 +265,7 @@ export const TrueNASServicesTable: Component<{
</TableCell>
<TableCell class={getPlatformTableCellClassForKind('badge')}>
<span class="inline-flex rounded-full border border-border px-2 py-0.5 text-[11px] font-medium text-base-content">
- {titleCase(rawState())}
+ {formatPlatformTableTitleCaseValue(rawState())}
</span>
</TableCell>
<TableCell class={getPlatformTableCellClassForKind('badge')}>
diff --git a/frontend-modern/src/features/truenas/TrueNASStorageTopologyTable.tsx b/frontend-modern/src/features/truenas/TrueNASStorageTopologyTable.tsx
index 6cfac028b6..6f8656cb77 100644
--- a/frontend-modern/src/features/truenas/TrueNASStorageTopologyTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASStorageTopologyTable.tsx
@@ -11,6 +11,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTitleCaseValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformTableFilterOption,
@@ -56,12 +57,6 @@ const TRUENAS_STORAGE_STATUS_OPTIONS: PlatformTableFilterOption<TrueNASStorageSt
},
];
-const titleCase = (value: string | undefined): string => {
- const normalized = asTrimmedString(value);
- if (!normalized) return 'Unknown';
- return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
-};
-
const resourceName = (resource: Resource): string =>
asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
@@ -131,7 +126,7 @@ const riskLabel = (row: TrueNASStorageTopologyRow): string => {
const risk =
asTrimmedString(row.resource.storage?.risk?.level) ||
asTrimmedString(row.resource.physicalDisk?.risk?.level);
- if (risk) return titleCase(risk);
+ if (risk) return formatPlatformTableTitleCaseValue(risk);
const incidentCount = row.resource.incidentCount ?? row.resource.incidents?.length ?? 0;
if (incidentCount > 0) return `${incidentCount} alert${incidentCount === 1 ? '' : 's'}`;
const mapped = mapTrueNASStorageStatus(row.resource);
diff --git a/frontend-modern/src/features/truenas/TrueNASVirtualMachinesTable.tsx b/frontend-modern/src/features/truenas/TrueNASVirtualMachinesTable.tsx
index 1c07b7c047..89d06877e6 100644
--- a/frontend-modern/src/features/truenas/TrueNASVirtualMachinesTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASVirtualMachinesTable.tsx
@@ -7,6 +7,7 @@ import {
PlatformTableEmptyState,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableTitleCaseValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformTableFilterOption,
@@ -35,12 +36,6 @@ const TRUENAS_VM_STATUS_OPTIONS: PlatformTableFilterOption<TrueNASVMStatusFilter
const vmMeta = (resource: Resource): ResourceTrueNASVMMeta | undefined => resource.truenas?.vm;
-const titleCase = (value: string | undefined): string => {
- const normalized = asTrimmedString(value);
- if (!normalized) return 'Unknown';
- return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
-};
-
const formatBytes = (bytes: number | undefined): string => {
if (!bytes || bytes <= 0) return '-';
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
@@ -203,7 +198,8 @@ export const TrueNASVirtualMachinesTable: Component<{
resource.id;
const displayStatus = () => getTrueNASResourceDisplayStatus(resource);
const indicator = () => getSimpleStatusIndicator(displayStatus());
- const stateLabel = () => titleCase(vm()?.state || vm()?.domainState);
+ const stateLabel = () =>
+ formatPlatformTableTitleCaseValue(vm()?.state || vm()?.domainState);
const devices = createMemo(() => formatDevices(vm()));
const flags = createMemo(() => flagLabels(vm()));
const detailRowId = () => drawer.detailRowId(resource);