From 9765c98b3dfb1f7a615ec78f409bc5ec4b0954cc Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:59:36 +0100 Subject: [PATCH] Alerting: Fix UI crashing when selecting custom grouping in alert panel (#64124) Fix UI crashing when selecting custom grouping in alert panel --- public/app/plugins/panel/alertlist/GroupByWithLoading.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/panel/alertlist/GroupByWithLoading.tsx b/public/app/plugins/panel/alertlist/GroupByWithLoading.tsx index 56696d237c0..6aecab8aaa3 100644 --- a/public/app/plugins/panel/alertlist/GroupByWithLoading.tsx +++ b/public/app/plugins/panel/alertlist/GroupByWithLoading.tsx @@ -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) => { }, [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) => { 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) => { .flatMap((labels) => labels.filter(isPrivateLabel)); return uniq(allLabels); - }, [allRequestsReady, promRulesByDatasource, rulesDataSourceNames]); + }, [allRequestsReady, promRulesByDatasource]); return (