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.

Centralize title-case label formatting

rcourtman92ba5c775721
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 40b9a43f69..a37aa91621 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -37,6 +37,8 @@ querying, and the operator-facing storage health presentation layer.
12. `frontend-modern/src/pages/DashboardPanels/RecoveryStatusPanel.tsx`
13. `frontend-modern/src/pages/DashboardPanels/StoragePanel.tsx`
14. `frontend-modern/src/types/recovery.ts`
+15. `frontend-modern/src/utils/recoveryTablePresentation.ts`
+16. `frontend-modern/src/utils/textPresentation.ts`
## Shared Boundaries
@@ -174,6 +176,11 @@ points. `frontend-modern/src/components/Storage/` plus
storage health model and presentation, while
`frontend-modern/src/components/Recovery/` and the recovery hooks define the
timeline, protected-item, and recovery-summary UX.
+The recovery table presentation helper now owns the canonical subject-type
+label fallback for recovery rows and delegates its title-casing to the shared
+`frontend-modern/src/utils/textPresentation.ts` helper rather than keeping a
+local recovery-only formatter, so subject and outcome labels stay aligned with
+the shared frontend label contract.
Those transport hooks are direct governed runtime surfaces, not just page
implementation detail: `frontend-modern/src/hooks/useRecoveryPoints.ts`,
`frontend-modern/src/hooks/useRecoveryPointsFacets.ts`,
diff --git a/frontend-modern/src/components/Recovery/Recovery.tsx b/frontend-modern/src/components/Recovery/Recovery.tsx
index b76fec142e..1c0e89a887 100644
--- a/frontend-modern/src/components/Recovery/Recovery.tsx
+++ b/frontend-modern/src/components/Recovery/Recovery.tsx
@@ -97,6 +97,7 @@ import {
getRecoveryRollupStatusPillLabel,
getRecoverySpecialOutcomeTextClass,
} from '@/utils/recoveryStatusPresentation';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
import {
getRecoveryGroupNoTimestampLabel,
getRecoveryHistorySearchPlaceholder,
@@ -138,13 +139,6 @@ import { createHiddenCanonicalTypeColumn } from '@/utils/typeColumnDefinition';
type ArtifactMode = RecoveryArtifactMode;
type VerificationFilter = 'all' | 'verified' | 'unverified' | 'unknown';
-const titleize = (value: string): string =>
- (value || '')
- .split('-')
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(' ');
-
const isRecoveryDateKey = (value: string): boolean => /^\d{4}-\d{2}-\d{2}$/.test(value);
const isRecoveryRangeDays = (value: string): value is '7' | '30' | '90' | '365' =>
value === '7' || value === '30' || value === '90' || value === '365';
@@ -1009,7 +1003,7 @@ const Recovery: Component = () => {
<For each={availableOutcomes}>
{(outcome) => (
<option value={outcome}>
- {outcome === 'all' ? 'Any status' : titleize(outcome)}
+ {outcome === 'all' ? 'Any status' : titleCaseDelimitedLabel(outcome)}
</option>
)}
</For>
@@ -1190,7 +1184,7 @@ const Recovery: Component = () => {
<span
class={`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${getRecoveryOutcomeBadgeClass(outcome)}`}
>
- {titleize(outcome)}
+ {titleCaseDelimitedLabel(outcome)}
</span>
</TableCell>
</TableRow>
@@ -1874,7 +1868,7 @@ const Recovery: Component = () => {
<For each={availableOutcomes}>
{(outcome) => (
<option value={outcome}>
- {outcome === 'all' ? 'Any status' : titleize(outcome)}
+ {outcome === 'all' ? 'Any status' : titleCaseDelimitedLabel(outcome)}
</option>
)}
</For>
@@ -2189,7 +2183,7 @@ const Recovery: Component = () => {
outcome,
)}`}
>
- {titleize(outcome)}
+ {titleCaseDelimitedLabel(outcome)}
</span>
</TableCell>
);
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 79bd216142..2983f8b144 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -14,6 +14,7 @@ import emptyStateSource from '@/components/shared/EmptyState.tsx?raw';
import webInterfaceUrlFieldSource from '@/components/shared/WebInterfaceUrlField.tsx?raw';
import workloadTypePresentationSource from '@/utils/workloadTypePresentation.ts?raw';
import sourcePlatformsSource from '@/utils/sourcePlatforms.ts?raw';
+import storageSourcesSource from '@/utils/storageSources.ts?raw';
import rbacPermissionsSource from '@/utils/rbacPermissions.ts?raw';
import systemSettingsPresentationSource from '@/utils/systemSettingsPresentation.ts?raw';
import updatesSettingsPanelSource from '@/components/Settings/UpdatesSettingsPanel.tsx?raw';
@@ -228,6 +229,7 @@ import rbacPresentationSource from '@/utils/rbacPresentation.ts?raw';
import upgradePresentationSource from '@/utils/upgradePresentation.ts?raw';
import agentProfilesPanelSource from '@/components/Settings/AgentProfilesPanel.tsx?raw';
import agentProfilesPresentationSource from '@/utils/agentProfilesPresentation.ts?raw';
+import agentProfileSuggestionPresentationSource from '@/utils/agentProfileSuggestionPresentation.ts?raw';
import organizationAccessPanelSource from '@/components/Settings/OrganizationAccessPanel.tsx?raw';
import billingAdminPanelSource from '@/components/Settings/BillingAdminPanel.tsx?raw';
import organizationBillingPanelSource from '@/components/Settings/OrganizationBillingPanel.tsx?raw';
@@ -322,8 +324,13 @@ describe('frontend resource type boundaries', () => {
expect(resourceBadgePresentationSource).toContain('getResourceTypePresentation');
expect(resourceBadgesSource).not.toContain('function formatType(');
expect(workloadTypePresentationSource).toContain('canonicalizeFrontendResourceType');
+ expect(workloadTypePresentationSource).toContain('titleCaseDelimitedLabel');
expect(workloadTypeBadgesSource).not.toContain('canonicalizeFrontendResourceType');
expect(workloadTypeBadgesSource).toContain('getWorkloadTypePresentation');
+ expect(sourcePlatformsSource).toContain('titleCaseDelimitedLabel');
+ expect(sourcePlatformsSource).not.toContain('const titleize =');
+ expect(storageSourcesSource).toContain('titleCaseDelimitedLabel');
+ expect(storageSourcesSource).not.toContain('const titleCaseLabel =');
expect(workloadsSource).toContain('export const normalizeWorkloadViewModeParam');
expect(dashboardSource).toContain('normalizeWorkloadViewModeParam');
expect(dashboardSource).not.toContain('function normalizeViewModeParam');
@@ -369,6 +376,7 @@ describe('frontend resource type boundaries', () => {
);
expect(recoveryIssuePresentationSource).toContain('export function getRecoveryIssueRailClass');
expect(recoverySource).toContain('getRecoveryFilterChipPresentation');
+ expect(recoverySource).not.toContain('const titleize =');
expect(recoverySource).toContain("segmentedButtonClass(chartRangeDays() === range, false, 'accent')");
expect(recoverySource).not.toContain('border-blue-200 bg-blue-50 px-2 py-0.5');
expect(recoverySource).not.toContain('border-cyan-200 bg-cyan-50 px-2 py-0.5');
@@ -489,6 +497,8 @@ describe('frontend resource type boundaries', () => {
expect(recoveryTablePresentationSource).toContain(
'export function getRecoveryArtifactColumnHeaderClass',
);
+ expect(recoveryTablePresentationSource).toContain('titleCaseDelimitedLabel');
+ expect(recoveryTablePresentationSource).not.toContain('const titleize =');
expect(recoveryDatePresentationSource).toContain(
'export function recoveryDateKeyFromTimestamp',
);
@@ -803,6 +813,8 @@ describe('frontend resource type boundaries', () => {
expect(agentProfilesPresentationSource).toContain(
'export function getAgentProfileAssignmentsEmptyState',
);
+ expect(agentProfileSuggestionPresentationSource).toContain('titleCaseDelimitedLabel');
+ expect(agentProfileSuggestionPresentationSource).not.toContain('const titleize =');
expect(trendChartsSource).toContain("segmentedButtonClass(active(), false, 'accent')");
expect(trendChartsSource).not.toContain(
"'px-2 py-0.5 rounded bg-blue-600 text-white text-[11px] font-medium'",
@@ -817,6 +829,8 @@ describe('frontend resource type boundaries', () => {
expect(dashboardCompositionPresentationSource).toContain(
'export const DASHBOARD_COMPOSITION_EMPTY_STATE',
);
+ expect(dashboardCompositionPresentationSource).toContain('titleCaseDelimitedLabel');
+ expect(dashboardCompositionPresentationSource).not.toContain('const titleize =');
expect(problemResourcesTableSource).toContain('getProblemResourceStatusVariant');
expect(problemResourcesTableSource).not.toContain(
'function statusVariant(pr: ProblemResource)',
@@ -1708,6 +1722,7 @@ describe('frontend resource type boundaries', () => {
);
expect(licensePresentationSource).toContain('export const BILLING_ADMIN_EMPTY_STATE');
expect(licensePresentationSource).toContain('export const formatLicensePlanVersion');
+ expect(licensePresentationSource).toContain('titleCaseDelimitedLabel');
expect(licensePresentationSource).toContain('export const getCommercialMigrationNotice');
expect(licensePresentationSource).toContain('export const getTrialActivationNotice');
expect(securityPostureSummarySource).toContain('getSecurityScorePresentation');
diff --git a/frontend-modern/src/utils/__tests__/textPresentation.test.ts b/frontend-modern/src/utils/__tests__/textPresentation.test.ts
index 84c3c0b98b..8f9b5180ce 100644
--- a/frontend-modern/src/utils/__tests__/textPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/textPresentation.test.ts
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest';
-import { formatIdentifierLabel, humanizeToken } from '@/utils/textPresentation';
+import {
+ formatIdentifierLabel,
+ humanizeToken,
+ titleCaseDelimitedLabel,
+} from '@/utils/textPresentation';
describe('textPresentation', () => {
it('humanizes underscore-separated tokens with a fallback', () => {
@@ -25,4 +29,18 @@ describe('textPresentation', () => {
})).toBe('very long un');
expect(formatIdentifierLabel(undefined, { fallback: 'Unknown' })).toBe('Unknown');
});
+
+ it('title-cases delimited labels with configurable separators', () => {
+ expect(titleCaseDelimitedLabel('docker_host')).toBe('Docker Host');
+ expect(titleCaseDelimitedLabel('IP_address', { preserveShortAllCaps: true })).toBe(
+ 'IP Address',
+ );
+ expect(titleCaseDelimitedLabel('k8s-node', { preserveShortAllCaps: true })).toBe('K8s Node');
+ expect(
+ titleCaseDelimitedLabel('agent.profile.suggestion', {
+ separators: /[._]+/,
+ }),
+ ).toBe('Agent Profile Suggestion');
+ expect(titleCaseDelimitedLabel('', { fallback: 'Unknown' })).toBe('Unknown');
+ });
});
diff --git a/frontend-modern/src/utils/agentProfileSuggestionPresentation.ts b/frontend-modern/src/utils/agentProfileSuggestionPresentation.ts
index cdbe0acc69..8c45e3f7bc 100644
--- a/frontend-modern/src/utils/agentProfileSuggestionPresentation.ts
+++ b/frontend-modern/src/utils/agentProfileSuggestionPresentation.ts
@@ -1,3 +1,5 @@
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
+
export function getAgentProfileSuggestionValueBadgeClass(value: unknown): string {
if (typeof value === 'boolean') {
return value
@@ -15,11 +17,7 @@ export const AGENT_PROFILE_SUGGESTION_EXAMPLE_PROMPTS = [
] as const;
export function getAgentProfileSuggestionKeyLabel(value: string): string {
- return value
- .split('_')
- .filter(Boolean)
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(' ');
+ return titleCaseDelimitedLabel(value);
}
export function formatAgentProfileSuggestionValue(value: unknown): string {
diff --git a/frontend-modern/src/utils/dashboardCompositionPresentation.ts b/frontend-modern/src/utils/dashboardCompositionPresentation.ts
index d1a4fe67f5..949436e589 100644
--- a/frontend-modern/src/utils/dashboardCompositionPresentation.ts
+++ b/frontend-modern/src/utils/dashboardCompositionPresentation.ts
@@ -5,6 +5,7 @@ import Box from 'lucide-solid/icons/box';
import Container from 'lucide-solid/icons/container';
import type { ValidComponent } from 'solid-js';
import { getResourceTypeLabel } from '@/utils/resourceTypePresentation';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
const COMPOSITION_ICONS: Record<string, ValidComponent> = {
vm: Server,
@@ -23,13 +24,6 @@ const COMPOSITION_LABELS: Record<string, string> = {
database: 'Databases',
};
-const titleize = (value: string): string =>
- value
- .split(/[\s_-]+/)
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(' ');
-
export const DASHBOARD_COMPOSITION_EMPTY_STATE = 'No resources detected';
export const getDashboardCompositionLabel = (resourceType: string): string => {
@@ -38,7 +32,7 @@ export const getDashboardCompositionLabel = (resourceType: string): string => {
if (COMPOSITION_LABELS[normalized]) return COMPOSITION_LABELS[normalized];
const sharedLabel = getResourceTypeLabel(normalized);
if (sharedLabel && sharedLabel !== normalized) return sharedLabel;
- return titleize(normalized);
+ return titleCaseDelimitedLabel(normalized);
};
export const getDashboardCompositionIcon = (resourceType: string): ValidComponent => {
diff --git a/frontend-modern/src/utils/licensePresentation.ts b/frontend-modern/src/utils/licensePresentation.ts
index fc331ad47f..eb3ea0cce1 100644
--- a/frontend-modern/src/utils/licensePresentation.ts
+++ b/frontend-modern/src/utils/licensePresentation.ts
@@ -1,6 +1,7 @@
import type { BillingState, HostedOrganizationSummary } from '@/api/billingAdmin';
import type { CommercialMigrationStatus, LicenseStatus } from '@/api/license';
import { CLOUD_PLAN_LABELS } from '@/utils/cloudPlans';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
const TIER_LABELS: Record<string, string> = {
free: 'Community',
@@ -69,19 +70,16 @@ const GRANDFATHERED_V5_PLAN_LABELS: Record<string, string> = {
v5_pro_annual_grandfathered: 'V5 Pro Annual (Grandfathered)',
};
-const formatTitleCase = (value: string) =>
- value.replace(/[_-]/g, ' ').replace(/\b\w/g, (match) => match.toUpperCase());
-
export const getLicenseTierLabel = (tier?: string | null): string => {
const normalized = (tier || '').trim().toLowerCase();
if (!normalized) return 'Unknown';
- return TIER_LABELS[normalized] || formatTitleCase(normalized);
+ return TIER_LABELS[normalized] || titleCaseDelimitedLabel(normalized);
};
export const getLicenseFeatureLabel = (feature?: string | null): string => {
const normalized = (feature || '').trim().toLowerCase();
if (!normalized) return 'Unknown';
- return FEATURE_LABELS[normalized] || formatTitleCase(normalized);
+ return FEATURE_LABELS[normalized] || titleCaseDelimitedLabel(normalized);
};
export const getFeatureMinTierLabel = (feature?: string | null): string => {
@@ -97,7 +95,7 @@ export const formatLicensePlanVersion = (value?: string | null): string | null =
if (grandfathered) return grandfathered;
const canonical = CLOUD_PLAN_LABELS[normalized.toLowerCase()];
if (canonical) return canonical;
- return formatTitleCase(normalized);
+ return titleCaseDelimitedLabel(normalized);
};
export const getGrandfatheredPriceContinuityNotice = (
diff --git a/frontend-modern/src/utils/recoveryTablePresentation.ts b/frontend-modern/src/utils/recoveryTablePresentation.ts
index bf293fc49d..2922016495 100644
--- a/frontend-modern/src/utils/recoveryTablePresentation.ts
+++ b/frontend-modern/src/utils/recoveryTablePresentation.ts
@@ -6,6 +6,7 @@ import {
} from '@/utils/workloadTypePresentation';
import { normalizeRecoveryOutcome } from '@/utils/recoveryOutcomePresentation';
import type { RecoveryIssueTone } from '@/utils/recoveryIssuePresentation';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
export const STALE_ISSUE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000;
export const AGING_THRESHOLD_MS = 2 * 24 * 60 * 60 * 1000;
@@ -21,13 +22,6 @@ export const RECOVERY_PROTECTED_SEARCH_PLACEHOLDER = 'Search protected items...'
export const RECOVERY_HISTORY_SEARCH_PLACEHOLDER = 'Search recovery history...';
export const RECOVERY_SEARCH_HISTORY_EMPTY_MESSAGE = 'Recent searches appear here.';
-const titleize = (value: string): string =>
- (value || '')
- .split('-')
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(' ');
-
export function getRecoveryEventTimeTextClass(
timestamp: number,
nowMs: number = Date.now(),
@@ -115,11 +109,11 @@ export function getRecoverySubjectTypeLabel(point: RecoveryPoint): string {
presentation.label === normalizeRecoverySubjectTypeKey(raw) &&
presentation.badgeClasses === 'bg-surface-alt text-base-content'
) {
- return titleize(normalizeRecoverySubjectTypeKey(raw));
+ return titleCaseDelimitedLabel(normalizeRecoverySubjectTypeKey(raw));
}
return presentation.label;
}
- return titleize(normalizeRecoverySubjectTypeKey(raw));
+ return titleCaseDelimitedLabel(normalizeRecoverySubjectTypeKey(raw));
}
export function getRecoveryArtifactColumnHeaderClass(id: string): string {
diff --git a/frontend-modern/src/utils/sourcePlatforms.ts b/frontend-modern/src/utils/sourcePlatforms.ts
index ba354461af..07621592a2 100644
--- a/frontend-modern/src/utils/sourcePlatforms.ts
+++ b/frontend-modern/src/utils/sourcePlatforms.ts
@@ -1,4 +1,5 @@
import type { PlatformType, SourceType } from '@/types/resource';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
export type KnownSourcePlatform =
| 'proxmox-pve'
@@ -103,13 +104,6 @@ const PLATFORM_ALIASES: Record<string, KnownSourcePlatform> = {
k8s: 'kubernetes',
};
-const titleize = (value: string): string =>
- value
- .split(/[\s_-]+/)
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(' ');
-
export const normalizeSourcePlatformKey = (
value: string | null | undefined,
): KnownSourcePlatform | null => {
@@ -128,7 +122,9 @@ export const getSourcePlatformPresentation = (
};
export const getSourcePlatformLabel = (value: string | null | undefined): string =>
- getSourcePlatformPresentation(value)?.label || titleize((value || '').toString()) || 'Unknown';
+ getSourcePlatformPresentation(value)?.label ||
+ titleCaseDelimitedLabel((value || '').toString()) ||
+ 'Unknown';
export const normalizeSourcePlatformQueryValue = (value: string | null | undefined): string => {
const normalized = (value || '').trim().toLowerCase();
diff --git a/frontend-modern/src/utils/storageSources.ts b/frontend-modern/src/utils/storageSources.ts
index 19f140c6f7..5d169f1b8e 100644
--- a/frontend-modern/src/utils/storageSources.ts
+++ b/frontend-modern/src/utils/storageSources.ts
@@ -1,5 +1,6 @@
import type { Storage } from '@/types/api';
import { getSourcePlatformLabel, normalizeSourcePlatformKey } from '@/utils/sourcePlatforms';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
export type StorageSourceTone = 'slate' | 'orange' | 'indigo' | 'rose' | 'violet' | 'cyan';
@@ -47,13 +48,6 @@ const slugifySource = (value: string): string =>
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
-const titleCaseLabel = (value: string): string =>
- value
- .split('-')
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(' ');
-
export const normalizeStorageSourceKey = (value: string | null | undefined): string => {
const normalized = slugifySource(value || '');
const canonicalPlatform = normalizeSourcePlatformKey(normalized);
@@ -108,7 +102,9 @@ export const getStorageSourceOption = (value: string | null | undefined): Storag
return {
key,
label:
- (key === 'ceph' ? 'Ceph' : getSourcePlatformLabel(key)) || titleCaseLabel(key) || 'Other',
+ (key === 'ceph' ? 'Ceph' : getSourcePlatformLabel(key)) ||
+ titleCaseDelimitedLabel(key) ||
+ 'Other',
tone: STORAGE_SOURCE_TONES[key] || 'slate',
};
};
diff --git a/frontend-modern/src/utils/textPresentation.ts b/frontend-modern/src/utils/textPresentation.ts
index 7f2f1bcb16..7960e13e91 100644
--- a/frontend-modern/src/utils/textPresentation.ts
+++ b/frontend-modern/src/utils/textPresentation.ts
@@ -9,6 +9,12 @@ export interface IdentifierLabelOptions {
stripPrefix?: string;
}
+export interface TitleCaseLabelOptions {
+ fallback?: string;
+ preserveShortAllCaps?: boolean;
+ separators?: RegExp;
+}
+
export function humanizeToken(value?: string, options?: HumanizeTokenOptions): string {
const normalized = (value || '').trim();
if (!normalized) {
@@ -48,3 +54,31 @@ export function formatIdentifierLabel(
return label;
}
+
+export function titleCaseDelimitedLabel(
+ value?: string,
+ options?: TitleCaseLabelOptions,
+): string {
+ const normalized = (value || '').trim();
+ if (!normalized) {
+ return options?.fallback ?? '';
+ }
+
+ const tokens = normalized
+ .split(options?.separators ?? /[\s_-]+/)
+ .map((part) => part.trim())
+ .filter(Boolean);
+
+ if (!tokens.length) {
+ return options?.fallback ?? '';
+ }
+
+ return tokens
+ .map((part) => {
+ if (options?.preserveShortAllCaps && part === part.toUpperCase() && part.length <= 4) {
+ return part;
+ }
+ return part.charAt(0).toUpperCase() + part.slice(1);
+ })
+ .join(' ');
+}
diff --git a/frontend-modern/src/utils/workloadTypePresentation.ts b/frontend-modern/src/utils/workloadTypePresentation.ts
index 5229048fd8..7e21dfe4b5 100644
--- a/frontend-modern/src/utils/workloadTypePresentation.ts
+++ b/frontend-modern/src/utils/workloadTypePresentation.ts
@@ -1,5 +1,6 @@
import type { WorkloadType } from '@/types/workloads';
import { canonicalizeFrontendResourceType } from '@/utils/resourceTypeCompat';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
export interface WorkloadTypePresentation {
label: string;
@@ -54,13 +55,6 @@ const DEFAULT_PRESENTATION: WorkloadTypePresentation = {
className: 'bg-surface-alt text-base-content',
};
-const toTitleCase = (value: string): string =>
- value
- .split(/[\s_-]+/)
- .filter(Boolean)
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
- .join(' ');
-
export const normalizeWorkloadTypePresentationKey = (
value: string | null | undefined,
): WorkloadTypePresentationKey | null => {
@@ -85,7 +79,9 @@ export const getWorkloadTypePresentation = (
): WorkloadTypePresentation => {
const normalized = normalizeWorkloadTypePresentationKey(rawType);
const fallbackLabel =
- overrides?.label || toTitleCase((rawType || '').toString()) || DEFAULT_PRESENTATION.label;
+ overrides?.label ||
+ titleCaseDelimitedLabel((rawType || '').toString()) ||
+ DEFAULT_PRESENTATION.label;
if (!normalized) {
return {