File tree 5 files changed +456
-35
lines changed
shell-ui/src/alerts/services
5 files changed +456
-35
lines changed Original file line number Diff line number Diff line change 125
125
- Following to Alert Manager Bump the test email feature from the
126
126
UI wasn't working correctly.
127
127
(PR[ #4322 ] ( https://github.com/scality/metalk8s/pull/4322 ) )
128
+ - Alert filtering in the UI when both a critical and warning alert
129
+ wasn't working properly.
130
+ (PR[ #4334 ] ( https://github.com/scality/metalk8s/pull/4334 ) )
128
131
129
132
## Release 127.0.1
130
133
Original file line number Diff line number Diff line change @@ -56,24 +56,20 @@ const isSameAlertWithDiffSeverity = (
56
56
or where we resolve the promise with `react-query`
57
57
*/
58
58
export const removeWarningAlerts = ( alerts : Alert [ ] ) : Alert [ ] => {
59
- const len = alerts . length ;
60
- const removeIndex = [ ] ;
61
-
62
- for ( let i = 0 ; i < len - 1 ; i ++ ) {
63
- for ( let j = i + 1 ; j < len ; j ++ ) {
64
- if ( isSameAlertWithDiffSeverity ( alerts [ i ] . labels , alerts [ j ] . labels ) ) {
65
- if ( alerts [ i ] . labels . severity === STATUS_WARNING ) {
66
- removeIndex . push ( i ) ;
67
- } else if ( alerts [ j ] . labels . severity === STATUS_WARNING ) {
68
- removeIndex . push ( j ) ;
69
- }
70
- }
59
+ const criticalAlerts = alerts . filter ( ( alert ) => {
60
+ if ( alert . severity === STATUS_CRITICAL ) {
61
+ return true ;
71
62
}
72
- }
73
-
74
- let removedWarningAlerts = [ ...alerts ] ;
75
- removeIndex . forEach ( ( index ) => removedWarningAlerts . splice ( index , 1 ) ) ;
76
- return removedWarningAlerts ;
63
+ // check if there is a critical alert with the same labels
64
+ const isSameAlert = alerts . find ( ( a ) => {
65
+ return (
66
+ a . severity === STATUS_CRITICAL &&
67
+ isSameAlertWithDiffSeverity ( a . labels , alert . labels )
68
+ ) ;
69
+ } ) ;
70
+ return ! isSameAlert ;
71
+ } ) ;
72
+ return criticalAlerts ;
77
73
} ;
78
74
// Sort the alerts base on the `severity`
79
75
export const sortAlerts = ( alerts : Alert [ ] ) : Alert [ ] => {
You can’t perform that action at this time.
0 commit comments