From 37a520375f512ea56c3e67e58cfb97e671e81eac Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 19 Mar 2026 17:33:04 +0000 Subject: [PATCH] Centralize alerts resource labels --- .../v6/internal/subsystems/alerts.md | 4 ++++ .../components/Alerts/ResourceTable.test.tsx | 22 +++++++++++++++++++ .../src/components/Alerts/ResourceTable.tsx | 12 +++++----- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md index 292b3106e..c8bca7ba0 100644 --- a/docs/release-control/v6/internal/subsystems/alerts.md +++ b/docs/release-control/v6/internal/subsystems/alerts.md @@ -103,6 +103,10 @@ presentation now also route through `frontend-modern/src/utils/alertIncidentPresentation.ts` instead of remaining duplicated inline across the alerts page and overview timeline surfaces. +Alert resource tables now route resource labels and row action labels through +the shared policy-aware resource identity helper so governed resources do not +fall back to raw names inside the alerts surface. + Alert incident timeline event cards now route through `frontend-modern/src/components/Alerts/IncidentTimelineEventCard.tsx`, while their meta-row, heading, detail, command, and output typography still diff --git a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx index ac3b0edd9..6adf0837c 100644 --- a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx +++ b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx @@ -192,6 +192,28 @@ describe('ResourceTable', () => { expect(screen.getByText('my-vm-100')).toBeInTheDocument(); }); + it('uses the governed label for policy-aware resources', () => { + const props = makeProps({ + resources: [ + makeResource({ + id: 'vm-1', + name: 'secret-vm-1', + rawName: 'secret-vm-1', + policy: { + sensitivity: 'restricted', + routing: { scope: 'local-only', redact: ['hostname'] }, + }, + aiSafeSummary: 'Production VM', + }), + ], + }); + render(() => ); + + expect(screen.getByText('Production VM')).toBeInTheDocument(); + expect(screen.getByLabelText('Edit thresholds for Production VM')).toBeInTheDocument(); + expect(screen.queryByText('secret-vm-1')).not.toBeInTheDocument(); + }); + it('renders multiple resources', () => { const props = makeProps({ resources: [ diff --git a/frontend-modern/src/components/Alerts/ResourceTable.tsx b/frontend-modern/src/components/Alerts/ResourceTable.tsx index f04ca5426..770b1b280 100644 --- a/frontend-modern/src/components/Alerts/ResourceTable.tsx +++ b/frontend-modern/src/components/Alerts/ResourceTable.tsx @@ -32,10 +32,12 @@ import { getAlertResourceTableResetFactoryDefaultsLabel, getAlertResourceTableRevertToDefaultsLabel, } from '@/utils/alertResourceTablePresentation'; +import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity'; import { ALERT_BULK_EDIT_CLEAR_LABEL, getAlertBulkEditOpenLabel, } from '@/utils/alertBulkEditPresentation'; +import type { Resource as UnifiedResource, ResourcePolicy } from '@/types/resource'; const COLUMN_TOOLTIP_LOOKUP: Record = { 'cpu %': 'Percent CPU utilization allowed before an alert fires.', @@ -87,6 +89,8 @@ export interface Resource { id: string; name: string; displayName?: string; + policy?: ResourcePolicy; + aiSafeSummary?: string; rawName?: string; node?: string; instance?: string; @@ -451,13 +455,7 @@ export function ResourceTable(props: ResourceTableProps) { }; const getResourceLabel = (resource: Resource): string => { - return ( - resource.displayName || - resource.name || - resource.rawName || - resource.clusterName || - resource.id - ); + return getPreferredResourceDisplayName(resource as unknown as UnifiedResource); }; const MetricValueWithHeat = (metricProps: {