mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
Alerting: Fix available labels in the alert panel groupby dropdown (#63573)
This commit is contained in:
parent
2372b7c626
commit
5f35995cd4
@ -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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user