feat(alerts/ui): add severityToAccent helper for DataTable rowAccent
Pure function mapping the 3-value AlertDto.severity enum to the 2-value DataTable rowAccent prop. INFO maps to undefined (no tint) because the DS DataTable rowAccent only supports error|warning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
ui/src/pages/Alerts/severity-utils.test.ts
Normal file
16
ui/src/pages/Alerts/severity-utils.test.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { severityToAccent } from './severity-utils';
|
||||||
|
|
||||||
|
describe('severityToAccent', () => {
|
||||||
|
it('maps CRITICAL → error', () => {
|
||||||
|
expect(severityToAccent('CRITICAL')).toBe('error');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('maps WARNING → warning', () => {
|
||||||
|
expect(severityToAccent('WARNING')).toBe('warning');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('maps INFO → undefined (no row tint)', () => {
|
||||||
|
expect(severityToAccent('INFO')).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
12
ui/src/pages/Alerts/severity-utils.ts
Normal file
12
ui/src/pages/Alerts/severity-utils.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import type { AlertDto } from '../../api/queries/alerts';
|
||||||
|
|
||||||
|
type Severity = NonNullable<AlertDto['severity']>;
|
||||||
|
export type RowAccent = 'error' | 'warning' | undefined;
|
||||||
|
|
||||||
|
export function severityToAccent(severity: Severity): RowAccent {
|
||||||
|
switch (severity) {
|
||||||
|
case 'CRITICAL': return 'error';
|
||||||
|
case 'WARNING': return 'warning';
|
||||||
|
case 'INFO': return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user