mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 22:12:23 +00:00
Centralize alerts resource labels
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(() => <ResourceTable {...props} />);
|
||||
|
||||
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: [
|
||||
|
||||
@@ -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<string, string> = {
|
||||
'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: {
|
||||
|
||||
Reference in New Issue
Block a user