Alerting: Fix cloud rules edit url (#92853)
Update cloud rule edit page url after successful update
This commit is contained in:
+6
-1
@@ -14,6 +14,7 @@ import InfoPausedRule from 'app/features/alerting/unified/components/InfoPausedR
|
|||||||
import {
|
import {
|
||||||
getRuleGroupLocationFromFormValues,
|
getRuleGroupLocationFromFormValues,
|
||||||
getRuleGroupLocationFromRuleWithLocation,
|
getRuleGroupLocationFromRuleWithLocation,
|
||||||
|
isCloudRulerRule,
|
||||||
isGrafanaManagedRuleByType,
|
isGrafanaManagedRuleByType,
|
||||||
isGrafanaRulerRule,
|
isGrafanaRulerRule,
|
||||||
isGrafanaRulerRulePaused,
|
isGrafanaRulerRulePaused,
|
||||||
@@ -42,7 +43,7 @@ import {
|
|||||||
formValuesToRulerGrafanaRuleDTO,
|
formValuesToRulerGrafanaRuleDTO,
|
||||||
formValuesToRulerRuleDTO,
|
formValuesToRulerRuleDTO,
|
||||||
} from '../../../utils/rule-form';
|
} from '../../../utils/rule-form';
|
||||||
import { fromRulerRuleAndRuleGroupIdentifier } from '../../../utils/rule-id';
|
import { fromRulerRule, fromRulerRuleAndRuleGroupIdentifier, stringifyIdentifier } from '../../../utils/rule-id';
|
||||||
import { GrafanaRuleExporter } from '../../export/GrafanaRuleExporter';
|
import { GrafanaRuleExporter } from '../../export/GrafanaRuleExporter';
|
||||||
import { AlertRuleNameAndMetric } from '../AlertRuleNameInput';
|
import { AlertRuleNameAndMetric } from '../AlertRuleNameInput';
|
||||||
import AnnotationsStep from '../AnnotationsStep';
|
import AnnotationsStep from '../AnnotationsStep';
|
||||||
@@ -167,6 +168,10 @@ export const AlertRuleForm = ({ existing, prefill }: Props) => {
|
|||||||
|
|
||||||
if (exitOnSave && returnTo) {
|
if (exitOnSave && returnTo) {
|
||||||
locationService.push(returnTo);
|
locationService.push(returnTo);
|
||||||
|
} else if (isCloudRulerRule(ruleDefinition)) {
|
||||||
|
const { dataSourceName, namespaceName, groupName } = getRuleGroupLocationFromFormValues(values);
|
||||||
|
const updatedRuleIdentifier = fromRulerRule(dataSourceName, namespaceName, groupName, ruleDefinition);
|
||||||
|
locationService.replace(`/alerting/${encodeURIComponent(stringifyIdentifier(updatedRuleIdentifier))}/edit`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user