[v9.4.x] Alerting: Fix available labels in the alert panel groupby dropdown (#63799)

Alerting: Fix available labels in the alert panel groupby dropdown (#63573)

(cherry picked from commit 5f35995cd4)

Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2023-02-27 17:58:52 +01:00
committed by GitHub
co-authored by Konrad Lalik
parent 53b5cf5288
commit 194dbead83
2 changed files with 10 additions and 2 deletions
@@ -157,6 +157,14 @@ export function messageFromError(e: Error | FetchError | SerializedError): strin
return (e as Error)?.message || String(e);
}
export function isAsyncRequestMapSliceSettled<T>(slice: AsyncRequestMapSlice<T>): boolean {
return Object.values(slice).every(isAsyncRequestStateSettled);
}
export function isAsyncRequestStateSettled<T>(state: AsyncRequestState<T>): boolean {
return state.dispatched && !state.loading;
}
export function isAsyncRequestMapSliceFulfilled<T>(slice: AsyncRequestMapSlice<T>): boolean {
return Object.values(slice).every(isAsyncRequestStateFulfilled);
}
@@ -7,8 +7,8 @@ import { useUnifiedAlertingSelector } from 'app/features/alerting/unified/hooks/
import { fetchAllPromRulesAction } from 'app/features/alerting/unified/state/actions';
import { getAllRulesSourceNames } from 'app/features/alerting/unified/utils/datasource';
import {
isAsyncRequestMapSliceFulfilled,
isAsyncRequestMapSlicePending,
isAsyncRequestMapSliceSettled,
} from 'app/features/alerting/unified/utils/redux';
import { useDispatch } from 'app/types';
import { AlertingRule } from 'app/types/unified-alerting';
@@ -33,7 +33,7 @@ export const GroupBy: FC<Props> = (props) => {
const promRulesByDatasource = useUnifiedAlertingSelector((state) => state.promRules);
const rulesDataSourceNames = useMemo(getAllRulesSourceNames, []);
const allRequestsReady = isAsyncRequestMapSliceFulfilled(promRulesByDatasource);
const allRequestsReady = isAsyncRequestMapSliceSettled(promRulesByDatasource);
const loading = isAsyncRequestMapSlicePending(promRulesByDatasource);
const labels = useMemo(() => {