From a94c3d63ccea0b1713ba6611db5122fc9a33ca08 Mon Sep 17 00:00:00 2001 From: Tom Ratcliffe Date: Mon, 25 Mar 2024 18:26:56 +0000 Subject: [PATCH] Update utils for determining paused state of a rule --- .../alerting/unified/components/rules/RulesTable.tsx | 2 +- public/app/features/alerting/unified/utils/rules.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/public/app/features/alerting/unified/components/rules/RulesTable.tsx b/public/app/features/alerting/unified/components/rules/RulesTable.tsx index d5a3453da7c..a65d4e69874 100644 --- a/public/app/features/alerting/unified/components/rules/RulesTable.tsx +++ b/public/app/features/alerting/unified/components/rules/RulesTable.tsx @@ -157,7 +157,7 @@ function useColumns(showSummaryColumn: boolean, showGroupColumn: boolean, showNe const isDeleting = !!(hasRuler(rulesSource) && rulerRulesLoaded(rulesSource) && promRule && !rulerRule); const isCreating = !!(hasRuler(rulesSource) && rulerRulesLoaded(rulesSource) && rulerRule && !promRule); - const isPaused = isGrafanaRulerRulePaused(rule); + const isPaused = isGrafanaRulerRule(rule.rulerRule) && isGrafanaRulerRulePaused(rule.rulerRule); return ; }, diff --git a/public/app/features/alerting/unified/utils/rules.ts b/public/app/features/alerting/unified/utils/rules.ts index 3885db0d20d..ca45ba028d4 100644 --- a/public/app/features/alerting/unified/utils/rules.ts +++ b/public/app/features/alerting/unified/utils/rules.ts @@ -5,7 +5,6 @@ import { Alert, AlertingRule, CloudRuleIdentifier, - CombinedRule, CombinedRuleGroup, CombinedRuleWithLocation, GrafanaRuleIdentifier, @@ -57,8 +56,8 @@ export function isGrafanaRulerRule(rule?: RulerRuleDTO): rule is RulerGrafanaRul return typeof rule === 'object' && 'grafana_alert' in rule; } -export function isGrafanaRulerRulePaused(rule: CombinedRule) { - return rule.rulerRule && isGrafanaRulerRule(rule.rulerRule) && Boolean(rule.rulerRule.grafana_alert.is_paused); +export function isGrafanaRulerRulePaused(rule: RulerGrafanaRuleDTO) { + return rule && isGrafanaRulerRule(rule) && Boolean(rule.grafana_alert.is_paused); } export function alertInstanceKey(alert: Alert): string {