Skip to content

Commit

Permalink
fix alert flyout insights color order
Browse files Browse the repository at this point in the history
  • Loading branch information
christineweng committed Mar 3, 2025
1 parent d291339 commit 1869921
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ describe('AlertCountInsight', () => {
closed: {
total: 6,
severities: [
{ key: 'high', value: 1, label: 'High' },
{ key: 'low', value: 1, label: 'Low' },
{ key: 'medium', value: 2, label: 'Medium' },
{ key: 'high', value: 1, label: 'High' },
{ key: 'critical', value: 2, label: 'Critical' },
],
},
Expand All @@ -173,9 +173,9 @@ describe('getFormattedAlertStats', () => {
it('should return alert stats', () => {
const alertStats = getFormattedAlertStats(mockAlertData, euiTheme);
expect(alertStats).toEqual([
{ key: 'High', count: 2, color: '#DA8B45' },
{ key: 'Low', count: 2, color: '#54B399' },
{ key: 'Medium', count: 2, color: '#D6BF57' },
{ key: 'High', count: 2, color: '#DA8B45' },
{ key: 'Critical', count: 2, color: '#E7664C' },
]);
});
Expand All @@ -186,8 +186,8 @@ describe('getFormattedAlertStats', () => {
closed: {
total: 2,
severities: [
{ key: 'high', value: 1, label: 'High' },
{ key: 'low', value: 1, label: 'Low' },
{ key: 'high', value: 1, label: 'High' },
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import {
EntityDetailsLeftPanelTab,
} from '../../../entity_details/shared/components/left_panel/left_panel_header';

const ORDER = ['Low', 'Medium', 'High', 'Critical'];

interface AlertCountInsightProps {
/**
* The name of the entity to filter the alerts by.
Expand Down Expand Up @@ -97,7 +99,12 @@ export const getFormattedAlertStats = (
key: capitalize(key),
count,
color: getSeverityColor(key, euiTheme),
}));
})).sort((a, b) => {
const aIndex = ORDER.indexOf(a.key);
const bIndex = ORDER.indexOf(b.key);
return aIndex - bIndex;
});

return alertStats;
};

Expand Down

0 comments on commit 1869921

Please sign in to comment.