Skip to content

Commit 99ecc6c

Browse files
committed
MK8S-197 - Display the alert status in Alert page
1 parent 2343fea commit 99ecc6c

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

ui/src/containers/AlertPage.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { STATUS_CRITICAL, STATUS_HEALTH, STATUS_WARNING } from '../constants';
2020
import { useUserAccessRight } from '../hooks';
2121
import { compareHealth } from '../services/utils';
2222
import { useAlerts } from './AlertProvider';
23+
import type { Alert } from '../services/alertUtils';
24+
import type { QueryStatus } from 'react-query';
2325
import { useBasenameRelativeNavigate } from '@scality/module-federation';
2426

2527
const AlertPageHeaderContainer = styled.div`
@@ -94,8 +96,8 @@ const getAlertStatus = (numbersOfCritical, numbersOfWarning) =>
9496
numbersOfCritical > 0
9597
? STATUS_CRITICAL
9698
: numbersOfWarning > 0
97-
? STATUS_WARNING
98-
: STATUS_HEALTH;
99+
? STATUS_WARNING
100+
: STATUS_HEALTH;
99101

100102
function AlertPageHeader({
101103
activeAlerts,
@@ -118,7 +120,7 @@ function AlertPageHeader({
118120
<Title>
119121
<AlertStatusIcon>
120122
<StatusWrapper status={alertStatus}>
121-
<StatusIcon status={alertStatus} name="Alert" entity='Alerts' />
123+
<StatusIcon status={alertStatus} name="Alert" entity="Alerts" />
122124
</StatusWrapper>
123125
</AlertStatusIcon>
124126
<>
@@ -163,9 +165,14 @@ function AlertPageHeader({
163165
);
164166
}
165167

168+
type ActiveAlertTabProps = {
169+
columns: Record<string, unknown>[];
170+
data: Alert[];
171+
status: QueryStatus;
172+
};
173+
166174
const ActiveAlertTab = React.memo(
167-
// @ts-expect-error - FIXME when you are working on it
168-
({ columns, data }) => {
175+
({ columns, data, status }: ActiveAlertTabProps) => {
169176
const sortTypes = React.useMemo(() => {
170177
return {
171178
severity: (row1, row2) => {
@@ -197,6 +204,7 @@ const ActiveAlertTab = React.memo(
197204
data={data}
198205
defaultSortingKey={DEFAULT_SORTING_KEY}
199206
sortTypes={sortTypes}
207+
status={status}
200208
entityName={{
201209
en: {
202210
singular: 'active alert',
@@ -219,10 +227,12 @@ const ActiveAlertTab = React.memo(
219227
</Table>
220228
);
221229
},
222-
(a, b) => {
223-
// compare the alert only on id and severity
224-
// @ts-expect-error - FIXME when you are working on it
225-
return isEqual(a.columns, b.columns) && isEqualAlert(a.data, b.data);
230+
(prevProps: ActiveAlertTabProps, nextProps: ActiveAlertTabProps) => {
231+
return (
232+
isEqual(prevProps.columns, nextProps.columns) &&
233+
isEqualAlert(prevProps.data, nextProps.data) &&
234+
prevProps.status === nextProps.status
235+
);
226236
},
227237
);
228238
export default function AlertPage() {
@@ -295,8 +305,11 @@ export default function AlertPage() {
295305
/>
296306
</AppContainer.OverallSummary>
297307
<AppContainer.MainContent>
298-
{/* @ts-expect-error - FIXME when you are working on it */}
299-
<ActiveAlertTab data={leafAlerts} columns={columns} />
308+
<ActiveAlertTab
309+
data={leafAlerts}
310+
columns={columns}
311+
status={alerts.status}
312+
/>
300313
</AppContainer.MainContent>
301314
</AppContainer>
302315
);

0 commit comments

Comments
 (0)