Skip to content

Commit 54e7ea2

Browse files
committed
fix: reuse existing handler to set alerts table data
1 parent e305a86 commit 54e7ea2

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

web/src/components/Incidents/IncidentsPage.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ const IncidentsPage = () => {
131131
(state: MonitoringState) => state.plugins.mcp.incidentsData.incidentsActiveFilters,
132132
);
133133

134-
const alertsData = useSelector(
135-
(state: MonitoringState) => state.plugins.mcp.incidentsData?.alertsData,
136-
);
137134
const alertsAreLoading = useSelector(
138135
(state: MonitoringState) => state.plugins.mcp.incidentsData?.alertsAreLoading,
139136
);
@@ -239,15 +236,23 @@ const IncidentsPage = () => {
239236
)
240237
.then((results) => {
241238
const prometheusResults = results.flat();
239+
const alerts = convertToAlerts(
240+
prometheusResults,
241+
incidentForAlertProcessing,
242+
currentTime,
243+
);
242244
dispatch(
243245
setAlertsData({
244-
alertsData: convertToAlerts(
245-
prometheusResults,
246-
incidentForAlertProcessing,
247-
currentTime,
248-
),
246+
alertsData: alerts,
249247
}),
250248
);
249+
if (rules && alerts) {
250+
dispatch(
251+
setAlertsTableData({
252+
alertsTableData: groupAlertsForTable(alerts, rules),
253+
}),
254+
);
255+
}
251256
if (!isEmpty(filteredData)) {
252257
dispatch(setAlertsAreLoading({ alertsAreLoading: false }));
253258
} else {
@@ -261,16 +266,6 @@ const IncidentsPage = () => {
261266
})();
262267
}, [incidentForAlertProcessing]);
263268

264-
useEffect(() => {
265-
if (rules && alertsData) {
266-
dispatch(
267-
setAlertsTableData({
268-
alertsTableData: groupAlertsForTable(alertsData, rules),
269-
}),
270-
);
271-
}
272-
}, [alertsData, rules]);
273-
274269
useEffect(() => {
275270
if (!isInitialized) return;
276271

0 commit comments

Comments
 (0)