diff --git a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx index cf8dfd3f589..4a01b9364a5 100644 --- a/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/alert-rule-form/AlertRuleForm.tsx @@ -319,7 +319,9 @@ function useRedirectToDetailsPage(existingUid?: string) { const newOrUpdatedRuleUid = (saveResult.created?.at(0) || saveResult.updated?.at(0)) ?? existingUid; if (newOrUpdatedRuleUid) { locationService.replace( - rulesNav.detailsPageLink('grafana', { uid: newOrUpdatedRuleUid, ruleSourceName: 'grafana' }) + rulesNav.detailsPageLink('grafana', { uid: newOrUpdatedRuleUid, ruleSourceName: 'grafana' }, undefined, { + skipSubPath: true, + }) ); } else { notifyApp.error( @@ -335,7 +337,11 @@ function useRedirectToDetailsPage(existingUid?: string) { const redirectCloudRulerRule = useCallback((rule: RulerRuleDTO, groupId: RuleGroupIdentifier) => { const { dataSourceName, namespaceName, groupName } = groupId; const updatedRuleIdentifier = fromRulerRule(dataSourceName, namespaceName, groupName, rule); - locationService.replace(rulesNav.detailsPageLink(updatedRuleIdentifier.ruleSourceName, updatedRuleIdentifier)); + locationService.replace( + rulesNav.detailsPageLink(updatedRuleIdentifier.ruleSourceName, updatedRuleIdentifier, undefined, { + skipSubPath: true, + }) + ); }, []); const redirectToDetailsPage = useCallback( diff --git a/public/app/features/alerting/unified/utils/navigation.ts b/public/app/features/alerting/unified/utils/navigation.ts index 0c72f7ae8c1..15081fb8b4e 100644 --- a/public/app/features/alerting/unified/utils/navigation.ts +++ b/public/app/features/alerting/unified/utils/navigation.ts @@ -51,9 +51,15 @@ export const rulesNav = { /** * Creates a link to the details page of a rule. Encodes the rules source name and rule identifier. */ - detailsPageLink: (rulesSourceName: string, ruleIdentifier: RuleIdentifier, params?: QueryParams) => + detailsPageLink: ( + rulesSourceName: string, + ruleIdentifier: RuleIdentifier, + params?: QueryParams, + options?: { skipSubPath?: boolean } + ) => createRelativeUrl( `/alerting/${encodeURIComponent(rulesSourceName)}/${encodeURIComponent(stringifyIdentifier(ruleIdentifier))}/view`, - params + params, + { skipSubPath: options?.skipSubPath } ), };