@@ -62,6 +62,7 @@ import { Incident, IncidentsPageFiltersExpandedState } from './model';
6262import { useAlertsPoller } from '../hooks/useAlertsPoller' ;
6363import { Rule } from '@openshift-console/dynamic-plugin-sdk' ;
6464import IncidentFilterToolbarItem , { severityOptions , stateOptions } from './ToolbarItemFilter' ;
65+ import { isEmpty } from 'lodash-es' ;
6566
6667const 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 >
0 commit comments