[v11.3.x] Alerting: Fix saving advanced mode toggle state in the alert rule editor (#95981)

Alerting: Fix saving advanced mode toggle state in the alert rule editor (#95924)

(cherry picked from commit 4ce1abc6f9)

Co-authored-by: Alexander Akhmetov <me@alx.cx>
This commit is contained in:
grafana-delivery-bot[bot]
2024-11-06 19:04:59 +01:00
committed by GitHub
co-authored by Alexander Akhmetov
parent 8273628550
commit 0e0a2c0371
4 changed files with 32 additions and 5 deletions
@@ -313,13 +313,16 @@ func ValidateRuleGroup(
uids[rule.UID] = idx
}
var hasPause, isPaused bool
var hasPause, isPaused, hasMetadata bool
original := ruleGroupConfig.Rules[idx]
if alert := original.GrafanaManagedAlert; alert != nil {
if alert.IsPaused != nil {
isPaused = *alert.IsPaused
hasPause = true
}
if alert.Metadata != nil {
hasMetadata = true
}
}
ruleWithOptionals := ngmodels.AlertRuleWithOptionals{}
@@ -327,6 +330,7 @@ func ValidateRuleGroup(
rule.RuleGroupIndex = idx + 1
ruleWithOptionals.AlertRule = *rule
ruleWithOptionals.HasPause = hasPause
ruleWithOptionals.HasMetadata = hasMetadata
result = append(result, &ruleWithOptionals)
}