Alerting: Fix history tab visibility condition (#106262)
* Improve rule type discovery in the RuleViewer component * Fix lint errors
This commit is contained in:
@@ -23,6 +23,7 @@ import InfoPausedRule from 'app/features/alerting/unified/components/InfoPausedR
|
||||
import { RuleActionsButtons } from 'app/features/alerting/unified/components/rules/RuleActionsButtons';
|
||||
import {
|
||||
AlertInstanceTotalState,
|
||||
AlertInstanceTotals,
|
||||
CombinedRule,
|
||||
RuleGroupIdentifierV2,
|
||||
RuleHealth,
|
||||
@@ -95,7 +96,6 @@ const RuleViewer = () => {
|
||||
const { annotations, promRule, rulerRule } = rule;
|
||||
|
||||
const hasError = isErrorHealth(promRule?.health);
|
||||
const isAlertType = prometheusRuleType.alertingRule(promRule);
|
||||
|
||||
const isFederatedRule = isFederatedRuleGroup(rule.group);
|
||||
const isProvisioned = rulerRuleType.grafana.rule(rulerRule) && Boolean(rulerRule.grafana_alert.provenance);
|
||||
@@ -115,7 +115,7 @@ const RuleViewer = () => {
|
||||
<Title
|
||||
name={title}
|
||||
paused={isPaused}
|
||||
state={isAlertType ? promRule.state : undefined}
|
||||
state={prometheusRuleType.alertingRule(promRule) ? promRule.state : undefined}
|
||||
health={promRule?.health}
|
||||
ruleType={promRule?.type}
|
||||
ruleOrigin={ruleOrigin}
|
||||
@@ -406,8 +406,8 @@ function usePageNav(rule: CombinedRule) {
|
||||
const namespaceName = decodeGrafanaNamespace(rule.namespace).name;
|
||||
const groupName = rule.group.name;
|
||||
|
||||
const isGrafanaAlertRule = rulerRuleType.grafana.rule(rulerRule) && isAlertType;
|
||||
const grafanaRecordingRule = rulerRuleType.grafana.recordingRule(rulerRule);
|
||||
const isGrafanaAlertRule = rulerRuleType.grafana.alertingRule(rulerRule);
|
||||
const isGrafanaRecordingRule = rulerRuleType.grafana.recordingRule(rulerRule);
|
||||
const isRecordingRuleType = prometheusRuleType.recordingRule(promRule);
|
||||
|
||||
const pageNav: NavModelItem = {
|
||||
@@ -453,7 +453,7 @@ function usePageNav(rule: CombinedRule) {
|
||||
onClick: () => {
|
||||
setActiveTab(ActiveTab.VersionHistory);
|
||||
},
|
||||
hideFromTabs: !isGrafanaAlertRule && !grafanaRecordingRule,
|
||||
hideFromTabs: !isGrafanaAlertRule && !isGrafanaRecordingRule,
|
||||
},
|
||||
],
|
||||
parentItem: {
|
||||
@@ -476,7 +476,7 @@ function usePageNav(rule: CombinedRule) {
|
||||
};
|
||||
}
|
||||
|
||||
export const calculateTotalInstances = (stats: CombinedRule['instanceTotals']) => {
|
||||
export const calculateTotalInstances = (stats: AlertInstanceTotals) => {
|
||||
return chain(stats)
|
||||
.pick([
|
||||
AlertInstanceTotalState.Alerting,
|
||||
|
||||
Reference in New Issue
Block a user