Skip to content

Commit eebe5fc

Browse files
Omolola-Akinleyecqliu1
authored andcommitted
[Cloud Security] fix the alert severity order (elastic#215813)
## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. Alert status Order was showing Low to High rather the showing the highest status of severity to the lowest severity. This PR removes the reverse and shows severity from Critical to Low. I applied ranking order for critical to low to address the sort order <img width="664" alt="image" src="https://github.com/user-attachments/assets/2e0f4974-ea08-4bc4-ae1c-53b0c0f53561" /> <img width="408" alt="image" src="https://github.com/user-attachments/assets/77db4442-53eb-44b5-a2d1-8dbbf1858dff" /> <img width="628" alt="image" src="https://github.com/user-attachments/assets/947e8cc2-989b-4b9c-bffe-97ab2e15309d" />
1 parent 29cac1f commit eebe5fc

File tree

1 file changed

+10
-3
lines changed
  • x-pack/solutions/security/plugins/security_solution/public/cloud_security_posture/components/alerts

1 file changed

+10
-3
lines changed

x-pack/solutions/security/plugins/security_solution/public/cloud_security_posture/components/alerts/alerts_preview.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export const AlertsPreview = ({
7474
const { euiTheme } = useEuiTheme();
7575

7676
const severityMap = new Map<string, number>();
77+
const severityRank: Record<string, number> = {
78+
critical: 4,
79+
high: 3,
80+
medium: 2,
81+
low: 1,
82+
};
7783

7884
(Object.keys(alertsData || {}) as AlertsByStatus[]).forEach((status) => {
7985
if (alertsData?.[status]?.severities) {
@@ -84,11 +90,12 @@ export const AlertsPreview = ({
8490
}
8591
});
8692

87-
const alertStats = Array.from(severityMap, ([key, count]) => ({
93+
const alertStats = Array.from(severityMap, ([key, count]: [string, number]) => ({
8894
key: capitalize(key),
8995
count,
9096
color: getSeverityColor(key, euiTheme),
91-
}));
97+
sort: severityRank[key.toLowerCase()] || 0,
98+
})).sort((a, b) => b.sort - a.sort);
9299

93100
const totalAlertsCount = alertStats.reduce((total, item) => total + item.count, 0);
94101

@@ -145,7 +152,7 @@ export const AlertsPreview = ({
145152
<EuiFlexItem>
146153
<EuiSpacer />
147154
<DistributionBar
148-
stats={alertStats.reverse()}
155+
stats={alertStats}
149156
data-test-subj="AlertsPreviewDistributionBarTestId"
150157
/>
151158
</EuiFlexItem>

0 commit comments

Comments
 (0)