From 2a7f698c4c0743b61a14ac12e0e59236aba987e5 Mon Sep 17 00:00:00 2001 From: Alejandro Fraenkel Date: Fri, 9 Jan 2026 11:53:36 +0100 Subject: [PATCH] Flatten Alerting V2 navigation sidebar while keeping tabs in page content - Modified MegaMenu to filter out nested children for Alerting V2 navigation items - Sidebar now shows only top-level items: Alert Activity, Alert Rules, Notification Configuration, Insights, Settings - Tabs are still available in page content (handled by frontend navigation hooks) - Breadcrumbs still work correctly (children available in navIndex) - Only applies when alertingNavigationV2 feature flag is enabled --- .../AppChrome/MegaMenu/MegaMenu.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx index f4ec7598fa2..e1b69963d67 100644 --- a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx +++ b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx @@ -11,6 +11,7 @@ import { reportInteraction } from '@grafana/runtime'; import { ScrollContainer, useStyles2 } from '@grafana/ui'; import { useGrafana } from 'app/core/context/GrafanaContext'; import { setBookmark } from 'app/core/reducers/navBarTree'; +import { shouldUseAlertingNavigationV2 } from 'app/features/alerting/unified/featureToggles'; import { useDispatch, useSelector } from 'app/types/store'; import { MegaMenuExtensionPoint } from './MegaMenuExtensionPoint'; @@ -37,9 +38,25 @@ export const MegaMenu = memo( const pinnedItems = usePinnedItems(); // Remove profile + help from tree + // For Alerting V2 navigation, flatten the sidebar to show only top-level items (hide nested children/tabs) + const useV2Nav = shouldUseAlertingNavigationV2(); const navItems = navTree .filter((item) => item.id !== 'profile' && item.id !== 'help') - .map((item) => enrichWithInteractionTracking(item, state.megaMenuDocked)); + .map((item) => { + const enriched = enrichWithInteractionTracking(item, state.megaMenuDocked); + // If this is Alerting section and V2 navigation is enabled, flatten children for sidebar display + // Children are still available in navIndex for breadcrumbs and page navigation + if (useV2Nav && item.id === 'alerting' && enriched.children) { + return { + ...enriched, + children: enriched.children.map((child) => ({ + ...child, + children: undefined, // Remove nested children from sidebar, but keep them for page navigation + })), + }; + } + return enriched; + }); const bookmarksItem = navItems.find((item) => item.id === 'bookmarks'); if (bookmarksItem) {