Skip to content

Commit c83cc49

Browse files
Merge pull request #527 from Fewwy/RHINENG-20424-4
RHINENG-20424: fix clear filter bug with incident selected
2 parents a21aab2 + 7ae4b8a commit c83cc49

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

web/src/components/Incidents/IncidentsPage.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { Incident, IncidentsPageFiltersExpandedState } from './model';
6262
import { useAlertsPoller } from '../hooks/useAlertsPoller';
6363
import { Rule } from '@openshift-console/dynamic-plugin-sdk';
6464
import IncidentFilterToolbarItem, { severityOptions, stateOptions } from './ToolbarItemFilter';
65+
import { isEmpty } from 'lodash-es';
6566

6667
const IncidentsPage = () => {
6768
const { t } = useTranslation(process.env.I18N_NAMESPACE);
@@ -221,7 +222,11 @@ const IncidentsPage = () => {
221222
alertsData: processAlerts(aggregatedData, incidentForAlertProcessing),
222223
}),
223224
);
224-
dispatch(setAlertsAreLoading({ alertsAreLoading: false }));
225+
if (!isEmpty(filteredData)) {
226+
dispatch(setAlertsAreLoading({ alertsAreLoading: false }));
227+
} else {
228+
dispatch(setAlertsAreLoading({ alertsAreLoading: true }));
229+
}
225230
})
226231
.catch((err) => {
227232
// eslint-disable-next-line no-console
@@ -317,6 +322,21 @@ const IncidentsPage = () => {
317322

318323
const incidentIdFilterOptions = incidents ? getIncidentIdOptions(incidents) : [];
319324

325+
//loading states
326+
useEffect(() => {
327+
//force a loading state for the alerts chart and table if we filtered out all of the incidents
328+
if (
329+
(!isEmpty(incidentsActiveFilters.severity) || !isEmpty(incidentsActiveFilters.state)) &&
330+
isEmpty(filteredData)
331+
) {
332+
dispatch(setAlertsAreLoading({ alertsAreLoading: true }));
333+
}
334+
335+
if (!isEmpty(filteredData) && !isEmpty(incidentsActiveFilters.groupId)) {
336+
dispatch(setAlertsAreLoading({ alertsAreLoading: false }));
337+
}
338+
}, [incidentsActiveFilters, filteredData, dispatch]);
339+
320340
return (
321341
<>
322342
<Helmet>

web/src/components/Incidents/ToolbarItemFilter.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Badge,
1010
} from '@patternfly/react-core';
1111
import { getFilterKey } from './utils';
12+
import { setAlertsAreLoading } from '../../actions/observe';
1213

1314
interface IncidentFilterToolbarItemProps {
1415
categoryName: string;
@@ -66,11 +67,17 @@ const IncidentFilterToolbarItem: React.FC<IncidentFilterToolbarItemProps> = ({
6667
deleteLabel={(category, chip) => {
6768
if (typeof category === 'string' && typeof chip === 'string') {
6869
onDeleteIncidentFilterChip(category, chip, incidentsActiveFilters, dispatch);
70+
if (categoryName === 'Incident ID') {
71+
dispatch(setAlertsAreLoading({ alertsAreLoading: true }));
72+
}
73+
}
74+
}}
75+
deleteLabelGroup={(category) => {
76+
onDeleteGroupIncidentFilterChip(incidentsActiveFilters, dispatch, category);
77+
if (categoryName === 'Incident ID') {
78+
dispatch(setAlertsAreLoading({ alertsAreLoading: true }));
6979
}
7080
}}
71-
deleteLabelGroup={(category) =>
72-
onDeleteGroupIncidentFilterChip(incidentsActiveFilters, dispatch, category)
73-
}
7481
categoryName={categoryName}
7582
>
7683
<Select

0 commit comments

Comments
 (0)