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 arrow-delimited label formatting

rcourtman40ccf03845a2
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 6166b020a6..b7af4ffae0 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -1916,6 +1916,7 @@ describe('frontend resource type boundaries', () => {
);
expect(resourceRelationshipPresentationSource).toContain('formatConfidencePercentage');
expect(resourceCorrelationPresentationSource).toContain('formatConfidencePercentage');
+ expect(resourceCorrelationPresentationSource).toContain('humanizeArrowDelimitedLabel');
expect(confidencePresentationSource).toContain('formatConfidencePercentage');
expect(confidencePresentationSource).toContain('formatConfidenceLabel');
expect(approvalPresentationSource).toContain('getResourceApprovalLevelLabel');
@@ -1923,7 +1924,10 @@ describe('frontend resource type boundaries', () => {
expect(resourceDetailDrawerSource).toContain('formatIdentifierLabel');
expect(resourceChangePresentationSource).toContain('humanizeToken');
expect(resourceRelationshipPresentationSource).toContain('humanizeToken');
- expect(resourceCorrelationPresentationSource).toContain('humanizeToken');
+ expect(textPresentationSource).toContain('humanizeArrowDelimitedLabel');
+ expect(resourceCorrelationPresentationSource).not.toContain(
+ "replace(/\\s*->\\s*/g, ' → ')",
+ );
expect(resourceDetailDrawerSource).toContain('humanizeToken');
expect(textPresentationSource).toContain('humanizeToken');
expect(textPresentationSource).toContain('formatIdentifierLabel');
diff --git a/frontend-modern/src/utils/__tests__/textPresentation.test.ts b/frontend-modern/src/utils/__tests__/textPresentation.test.ts
index 8f9b5180ce..df255f237e 100644
--- a/frontend-modern/src/utils/__tests__/textPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/textPresentation.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import {
formatIdentifierLabel,
+ humanizeArrowDelimitedLabel,
humanizeToken,
titleCaseDelimitedLabel,
} from '@/utils/textPresentation';
@@ -43,4 +44,11 @@ describe('textPresentation', () => {
).toBe('Agent Profile Suggestion');
expect(titleCaseDelimitedLabel('', { fallback: 'Unknown' })).toBe('Unknown');
});
+
+ it('humanizes arrow-delimited labels', () => {
+ expect(humanizeArrowDelimitedLabel('disk_full -> restart', { fallback: 'Correlation' })).toBe(
+ 'Disk Full → Restart',
+ );
+ expect(humanizeArrowDelimitedLabel('', { fallback: 'Correlation' })).toBe('Correlation');
+ });
});
diff --git a/frontend-modern/src/utils/resourceCorrelationPresentation.ts b/frontend-modern/src/utils/resourceCorrelationPresentation.ts
index 4ed11cf159..ba89b235a8 100644
--- a/frontend-modern/src/utils/resourceCorrelationPresentation.ts
+++ b/frontend-modern/src/utils/resourceCorrelationPresentation.ts
@@ -1,7 +1,7 @@
import type { ResourceCorrelation } from '@/types/aiIntelligence';
import { formatDurationMs } from '@/utils/patrolFormat';
import { formatConfidencePercentage } from '@/utils/confidencePresentation';
-import { humanizeToken } from '@/utils/textPresentation';
+import { humanizeArrowDelimitedLabel } from '@/utils/textPresentation';
const parseGoDurationMs = (value: string): number | null => {
const normalized = value.trim();
@@ -28,7 +28,7 @@ const parseGoDurationMs = (value: string): number | null => {
};
const humanizeCorrelationToken = (value?: string): string => {
- return humanizeToken((value || '').replace(/\s*->\s*/g, ' → '), { fallback: 'Correlation' });
+ return humanizeArrowDelimitedLabel(value, { fallback: 'Correlation' });
};
const formatResourceCorrelationEndpointLabel = (value?: string): string => {
diff --git a/frontend-modern/src/utils/textPresentation.ts b/frontend-modern/src/utils/textPresentation.ts
index 7960e13e91..76141e4cee 100644
--- a/frontend-modern/src/utils/textPresentation.ts
+++ b/frontend-modern/src/utils/textPresentation.ts
@@ -82,3 +82,10 @@ export function titleCaseDelimitedLabel(
})
.join(' ');
}
+
+export function humanizeArrowDelimitedLabel(
+ value?: string,
+ options?: HumanizeTokenOptions,
+): string {
+ return humanizeToken((value || '').replace(/\s*->\s*/g, ' → '), options);
+}