mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix NoRulesSplash being rendered for some seconds, fater creating a rule (#77048)
* Fix NoRulesSplash being rendered for some seconds, fater creating a rule * Add ruler response/loading,dispatched,error to the logic in hasNoAlertRulesCreatedYet expression
This commit is contained in:
parent
b0b033584e
commit
f1ce73dc2c
@ -61,11 +61,23 @@ const RuleList = withErrorBoundary(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const promRequests = Object.entries(promRuleRequests);
|
const promRequests = Object.entries(promRuleRequests);
|
||||||
|
const rulerRequests = Object.entries(rulerRuleRequests);
|
||||||
|
|
||||||
const allPromLoaded = promRequests.every(
|
const allPromLoaded = promRequests.every(
|
||||||
([_, state]) => state.dispatched && (state?.result !== undefined || state?.error !== undefined)
|
([_, state]) => state.dispatched && (state?.result !== undefined || state?.error !== undefined)
|
||||||
);
|
);
|
||||||
|
const allRulerLoaded = rulerRequests.every(
|
||||||
|
([_, state]) => state.dispatched && (state?.result !== undefined || state?.error !== undefined)
|
||||||
|
);
|
||||||
|
|
||||||
const allPromEmpty = promRequests.every(([_, state]) => state.dispatched && state?.result?.length === 0);
|
const allPromEmpty = promRequests.every(([_, state]) => state.dispatched && state?.result?.length === 0);
|
||||||
|
|
||||||
|
const allRulerEmpty = rulerRequests.every(([_, state]) => {
|
||||||
|
const rulerRules = Object.entries(state?.result ?? {});
|
||||||
|
const noRules = rulerRules.every(([_, result]) => result?.length === 0);
|
||||||
|
return noRules && state.dispatched;
|
||||||
|
});
|
||||||
|
|
||||||
const limitAlerts = hasActiveFilters ? undefined : LIMIT_ALERTS;
|
const limitAlerts = hasActiveFilters ? undefined : LIMIT_ALERTS;
|
||||||
// Trigger data refresh only when the RULE_LIST_POLL_INTERVAL_MS elapsed since the previous load FINISHED
|
// Trigger data refresh only when the RULE_LIST_POLL_INTERVAL_MS elapsed since the previous load FINISHED
|
||||||
const [_, fetchRules] = useAsyncFn(async () => {
|
const [_, fetchRules] = useAsyncFn(async () => {
|
||||||
@ -85,7 +97,8 @@ const RuleList = withErrorBoundary(
|
|||||||
useInterval(fetchRules, RULE_LIST_POLL_INTERVAL_MS);
|
useInterval(fetchRules, RULE_LIST_POLL_INTERVAL_MS);
|
||||||
|
|
||||||
// Show splash only when we loaded all of the data sources and none of them has alerts
|
// Show splash only when we loaded all of the data sources and none of them has alerts
|
||||||
const hasNoAlertRulesCreatedYet = allPromLoaded && allPromEmpty && promRequests.length > 0;
|
const hasNoAlertRulesCreatedYet =
|
||||||
|
allPromLoaded && allPromEmpty && promRequests.length > 0 && allRulerEmpty && allRulerLoaded;
|
||||||
|
|
||||||
const combinedNamespaces: CombinedRuleNamespace[] = useCombinedRuleNamespaces();
|
const combinedNamespaces: CombinedRuleNamespace[] = useCombinedRuleNamespaces();
|
||||||
const filteredNamespaces = useFilteredRules(combinedNamespaces, filterState);
|
const filteredNamespaces = useFilteredRules(combinedNamespaces, filterState);
|
||||||
|
Loading…
Reference in New Issue
Block a user