From 4b609f1121867ee0570b20f50e7703cc66efd282 Mon Sep 17 00:00:00 2001 From: Matthew Jacobson Date: Wed, 7 Feb 2024 16:14:56 -0500 Subject: [PATCH] Alerting: upgrade preview enable folder alert tab and dashboard alert panel (#81992) * Alerting: upgrade preview enable folder alert tab and dashboard alert panel Enable the folder alert tab and the dashboard alert panel when the alertingPreviewUpgrade feature flag is enabled * Link directly to folder alerts in upgrade page --- public/app/features/alerting/Upgrade.tsx | 6 +++--- public/app/features/alerting/unified/initAlerting.tsx | 2 +- public/app/features/alerting/unified/utils/misc.ts | 4 ++++ public/app/features/folders/state/navModel.ts | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/public/app/features/alerting/Upgrade.tsx b/public/app/features/alerting/Upgrade.tsx index 9b3af9f2696..4e116224000 100644 --- a/public/app/features/alerting/Upgrade.tsx +++ b/public/app/features/alerting/Upgrade.tsx @@ -42,7 +42,7 @@ import { DynamicTable, DynamicTableColumnProps, DynamicTableItemProps } from './ import { DynamicTableWithGuidelines } from './unified/components/DynamicTableWithGuidelines'; import { Matchers } from './unified/components/notification-policies/Matchers'; import { ActionIcon } from './unified/components/rules/ActionIcon'; -import { createContactPointLink, makeDashboardLink, makeFolderLink } from './unified/utils/misc'; +import { createContactPointLink, makeDashboardLink, makeFolderAlertsLink } from './unified/utils/misc'; import { createUrl } from './unified/utils/url'; export const UpgradePage = () => { @@ -1011,7 +1011,7 @@ const useAlertColumns = (): Array> => rel="noreferrer" target="_blank" className={styles.textLink} - href={makeFolderLink(dashUpgrade.folderUid)} + href={makeFolderAlertsLink(dashUpgrade.folderUid, dashUpgrade.folderName)} > {dashUpgrade.folderName} @@ -1075,7 +1075,7 @@ const useAlertColumns = (): Array> => rel="noreferrer" target="_blank" className={styles.textLink} - href={makeFolderLink(migratedFolderUid)} + href={makeFolderAlertsLink(migratedFolderUid, dashUpgrade.newFolderName)} > {dashUpgrade.newFolderName} diff --git a/public/app/features/alerting/unified/initAlerting.tsx b/public/app/features/alerting/unified/initAlerting.tsx index fecd56dd3e6..7ae82186e5f 100644 --- a/public/app/features/alerting/unified/initAlerting.tsx +++ b/public/app/features/alerting/unified/initAlerting.tsx @@ -10,7 +10,7 @@ const AlertRulesToolbarButton = React.lazy( export function initAlerting() { addCustomRightAction({ - show: () => config.unifiedAlertingEnabled, + show: () => config.unifiedAlertingEnabled || (config.featureToggles.alertingPreviewUpgrade ?? false), component: ({ dashboard }) => ( {dashboard && } diff --git a/public/app/features/alerting/unified/utils/misc.ts b/public/app/features/alerting/unified/utils/misc.ts index f8deef67b00..cb41bea1e15 100644 --- a/public/app/features/alerting/unified/utils/misc.ts +++ b/public/app/features/alerting/unified/utils/misc.ts @@ -145,6 +145,10 @@ export function makeFolderLink(folderUID: string): string { return createUrl(`/dashboards/f/${folderUID}`); } +export function makeFolderAlertsLink(folderUID: string, title: string): string { + return createUrl(`/dashboards/f/${folderUID}/${title}/alerting`); +} + export function makeFolderSettingsLink(folder: FolderDTO): string { return createUrl(`/dashboards/f/${folder.uid}/${folder.title}/settings`); } diff --git a/public/app/features/folders/state/navModel.ts b/public/app/features/folders/state/navModel.ts index 5c7e0d4ffb4..ecd0336ca05 100644 --- a/public/app/features/folders/state/navModel.ts +++ b/public/app/features/folders/state/navModel.ts @@ -45,7 +45,10 @@ export function buildNavModel(folder: FolderDTO, parents = folder.parents): NavM url: `${folder.url}/library-panels`, }); - if (contextSrv.hasPermission(AccessControlAction.AlertingRuleRead) && config.unifiedAlertingEnabled) { + if ( + contextSrv.hasPermission(AccessControlAction.AlertingRuleRead) && + (config.unifiedAlertingEnabled || config.featureToggles.alertingPreviewUpgrade) + ) { model.children!.push({ active: false, icon: 'bell',