From 5a55181561bca01059c11ebeb3324a7077bfc682 Mon Sep 17 00:00:00 2001 From: David Leek Date: Mon, 31 Mar 2025 08:37:15 +0200 Subject: [PATCH] feat: show only link to /admin in mobile menu (#9647) --- .../NavigationSidebar/NavigationSidebar.tsx | 16 +++++++++++----- .../menu/Header/DrawerMenu/DrawerMenu.tsx | 9 +++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/frontend/src/component/layout/MainLayout/NavigationSidebar/NavigationSidebar.tsx b/frontend/src/component/layout/MainLayout/NavigationSidebar/NavigationSidebar.tsx index d508221383..2ecf33090d 100644 --- a/frontend/src/component/layout/MainLayout/NavigationSidebar/NavigationSidebar.tsx +++ b/frontend/src/component/layout/MainLayout/NavigationSidebar/NavigationSidebar.tsx @@ -12,6 +12,7 @@ import { SecondaryNavigation, SecondaryNavigationList, AdminSettingsNavigation, + AdminSettingsLink, } from './NavigationList'; import { FullListItem, MiniListItem } from './ListItems'; import { useInitialPathname } from './useInitialPathname'; @@ -35,6 +36,7 @@ export const MobileNavigationSidebar: FC<{ NewInUnleash?: typeof NewInUnleash; }> = ({ onClick, NewInUnleash }) => { const { routes } = useRoutes(); + const newAdminUIEnabled = useUiFlag('adminNavUI'); return ( <> @@ -45,11 +47,15 @@ export const MobileNavigationSidebar: FC<{ mode='full' onClick={onClick} /> - + {newAdminUIEnabled ? ( + + ) : ( + + )} ); diff --git a/frontend/src/component/menu/Header/DrawerMenu/DrawerMenu.tsx b/frontend/src/component/menu/Header/DrawerMenu/DrawerMenu.tsx index a742a3daec..9e963d920d 100644 --- a/frontend/src/component/menu/Header/DrawerMenu/DrawerMenu.tsx +++ b/frontend/src/component/menu/Header/DrawerMenu/DrawerMenu.tsx @@ -1,5 +1,5 @@ import type { VFC } from 'react'; -import { Link, useLocation } from 'react-router-dom'; +import { Link } from 'react-router-dom'; import { Divider, Drawer, styled } from '@mui/material'; import { ReactComponent as UnleashLogo } from 'assets/img/logoDarkWithText.svg'; import { ReactComponent as UnleashLogoWhite } from 'assets/img/logoWithWhiteText.svg'; @@ -8,8 +8,8 @@ import theme from 'themes/theme'; import { ThemeMode } from 'component/common/ThemeMode/ThemeMode'; import { MobileNavigationSidebar } from 'component/layout/MainLayout/NavigationSidebar/NavigationSidebar'; import { NewInUnleash } from 'component/layout/MainLayout/NavigationSidebar/NewInUnleash/NewInUnleash'; -import { useUiFlag } from 'hooks/useUiFlag'; import { AdminMobileNavigation } from 'component/layout/MainLayout/AdminMenu/AdminNavigationItems'; +import { useNewAdminMenu } from 'hooks/useNewAdminMenu'; const StyledDrawerHeader = styled('div')(({ theme }) => ({ display: 'flex', @@ -33,10 +33,7 @@ export const DrawerMenu: VFC = ({ open = false, toggleDrawer, }) => { - const newAdminUIEnabled = useUiFlag('adminNavUI'); - const location = useLocation(); - const showOnlyAdminMenu = - newAdminUIEnabled && location.pathname.indexOf('/admin') === 0; + const showOnlyAdminMenu = useNewAdminMenu(); const onClick = () => { toggleDrawer(); };