mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix UI crashing when selecting custom grouping in alert panel (#64124)
Fix UI crashing when selecting custom grouping in alert panel
This commit is contained in:
parent
c840f6fb9d
commit
9765c98b3d
@ -5,7 +5,6 @@ import { SelectableValue } from '@grafana/data';
|
||||
import { Icon, MultiSelect } from '@grafana/ui';
|
||||
import { useUnifiedAlertingSelector } from 'app/features/alerting/unified/hooks/useUnifiedAlertingSelector';
|
||||
import { fetchAllPromRulesAction } from 'app/features/alerting/unified/state/actions';
|
||||
import { getAllRulesSourceNames } from 'app/features/alerting/unified/utils/datasource';
|
||||
import {
|
||||
isAsyncRequestMapSlicePending,
|
||||
isAsyncRequestMapSliceSettled,
|
||||
@ -31,7 +30,6 @@ export const GroupBy: FC<Props> = (props) => {
|
||||
}, [dispatch]);
|
||||
|
||||
const promRulesByDatasource = useUnifiedAlertingSelector((state) => state.promRules);
|
||||
const rulesDataSourceNames = useMemo(getAllRulesSourceNames, []);
|
||||
|
||||
const allRequestsReady = isAsyncRequestMapSliceSettled(promRulesByDatasource);
|
||||
const loading = isAsyncRequestMapSlicePending(promRulesByDatasource);
|
||||
@ -45,7 +43,7 @@ export const GroupBy: FC<Props> = (props) => {
|
||||
return [];
|
||||
}
|
||||
|
||||
const allLabels = rulesDataSourceNames
|
||||
const allLabels = Object.keys(promRulesByDatasource)
|
||||
.flatMap((datasource) => promRulesByDatasource[datasource].result ?? [])
|
||||
.flatMap((rules) => rules.groups)
|
||||
.flatMap((group) => group.rules.filter((rule): rule is AlertingRule => rule.type === PromRuleType.Alerting))
|
||||
@ -54,7 +52,7 @@ export const GroupBy: FC<Props> = (props) => {
|
||||
.flatMap((labels) => labels.filter(isPrivateLabel));
|
||||
|
||||
return uniq(allLabels);
|
||||
}, [allRequestsReady, promRulesByDatasource, rulesDataSourceNames]);
|
||||
}, [allRequestsReady, promRulesByDatasource]);
|
||||
|
||||
return (
|
||||
<MultiSelect<string>
|
||||
|
Loading…
Reference in New Issue
Block a user