diff --git a/public/app/features/alerting/unified/RuleList.tsx b/public/app/features/alerting/unified/RuleList.tsx index 655b52a9f3d..a36a7eccff3 100644 --- a/public/app/features/alerting/unified/RuleList.tsx +++ b/public/app/features/alerting/unified/RuleList.tsx @@ -61,11 +61,23 @@ const RuleList = withErrorBoundary( ); const promRequests = Object.entries(promRuleRequests); + const rulerRequests = Object.entries(rulerRuleRequests); + const allPromLoaded = promRequests.every( ([_, 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 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; // Trigger data refresh only when the RULE_LIST_POLL_INTERVAL_MS elapsed since the previous load FINISHED const [_, fetchRules] = useAsyncFn(async () => { @@ -85,7 +97,8 @@ const RuleList = withErrorBoundary( useInterval(fetchRules, RULE_LIST_POLL_INTERVAL_MS); // 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 filteredNamespaces = useFilteredRules(combinedNamespaces, filterState);