From bc6752a51c3114f403368bd4301b3bb3c785eab1 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 27 Sep 2024 15:20:45 +0100 Subject: [PATCH] SingleTopNav: Add "Grafana" header to MegaMenu (#93798) * add "Grafana" header to MegaMenu * add truncation for really long custom app titles * revert padding change since paddingLeft will handle it --- .../components/AppChrome/AppChromeMenu.tsx | 4 +- .../AppChrome/MegaMenu/MegaMenu.tsx | 31 ++++--- .../AppChrome/MegaMenu/MegaMenuHeader.tsx | 85 +++++++++++++++++++ .../AppChrome/TopBar/SingleTopBar.tsx | 17 ++-- 4 files changed, 119 insertions(+), 18 deletions(-) create mode 100644 public/app/core/components/AppChrome/MegaMenu/MegaMenuHeader.tsx diff --git a/public/app/core/components/AppChrome/AppChromeMenu.tsx b/public/app/core/components/AppChrome/AppChromeMenu.tsx index 7926e41aae9..cf02b6a7c48 100644 --- a/public/app/core/components/AppChrome/AppChromeMenu.tsx +++ b/public/app/core/components/AppChrome/AppChromeMenu.tsx @@ -91,7 +91,7 @@ const getStyles = (theme: GrafanaTheme2, searchBarHidden?: boolean) => { left: 0, position: 'fixed', right: 0, - top: searchBarHidden ? 0 : TOP_BAR_LEVEL_HEIGHT, + top: searchBarHidden || config.featureToggles.singleTopNav ? 0 : TOP_BAR_LEVEL_HEIGHT, zIndex: theme.zIndex.modalBackdrop, [theme.breakpoints.up('md')]: { @@ -107,7 +107,7 @@ const getStyles = (theme: GrafanaTheme2, searchBarHidden?: boolean) => { // Needs to below navbar should we change the navbarFixed? add add a new level? zIndex: theme.zIndex.modal, position: 'fixed', - top: searchBarHidden ? 0 : TOP_BAR_LEVEL_HEIGHT, + top: searchBarHidden || config.featureToggles.singleTopNav ? 0 : TOP_BAR_LEVEL_HEIGHT, backgroundColor: theme.colors.background.primary, flex: '1 1 0', diff --git a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx index d7deaaeb3cd..b2be2f189b1 100644 --- a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx +++ b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx @@ -13,6 +13,7 @@ import { setBookmark } from 'app/core/reducers/navBarTree'; import { usePatchUserPreferencesMutation } from 'app/features/preferences/api/index'; import { useDispatch, useSelector } from 'app/types'; +import { MegaMenuHeader } from './MegaMenuHeader'; import { MegaMenuItem } from './MegaMenuItem'; import { usePinnedItems } from './hooks'; import { enrichWithInteractionTracking, findByUrl, getActiveItem } from './utils'; @@ -62,6 +63,10 @@ export const MegaMenu = memo( const activeItem = getActiveItem(navItems, state.sectionNav.node, location.pathname); + const handleMegaMenu = () => { + chrome.setMegaMenuOpen(!state.megaMenuOpen); + }; + const handleDockedMenu = () => { chrome.setMegaMenuDocked(!state.megaMenuDocked); if (state.megaMenuDocked) { @@ -109,22 +114,26 @@ export const MegaMenu = memo( return (
-
- - -
+ {config.featureToggles.singleTopNav ? ( + + ) : ( +
+ + +
+ )}