diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx index fc67453a0..2b4712cfc 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx @@ -9,7 +9,7 @@ import cn from 'classnames'; import Link from 'next/link'; import { signIn, useSession } from 'next-auth/react'; import { create } from 'zustand'; -import { useRouter } from 'next/navigation'; +import { usePathname, useRouter, useSearchParams } from 'next/navigation'; import { Environment } from '@/lib/data/environment-schema'; import UserAvatar from '@/components/user-avatar'; import { spaceURL } from '@/lib/utils'; @@ -46,6 +46,7 @@ const Layout: FC< }) => { const session = useSession(); const router = useRouter(); + const pathname = usePathname(); const mobileDrawerOpen = useLayoutMobileDrawer((state) => state.open); const setMobileDrawerOpen = useLayoutMobileDrawer((state) => state.set); @@ -59,7 +60,31 @@ const Layout: FC< (item) => !(breakpoint.xs && item && 'type' in item && item.type === 'divider'), ); - const menu = ; + let activeKey: string | undefined; + for (const layoutItem of layoutMenuItems) { + if ( + layoutItem === null || + !('type' in layoutItem) || + layoutItem.type !== 'group' || + !layoutItem.children + ) + continue; + + activeKey = layoutItem?.children.find((item) => { + return item?.key && pathname.includes(item.key as string); + })?.key as string; + + if (activeKey) break; + } + + const menu = ( + + ); return ( diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/layout.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/layout.tsx index 7ea628d20..a2eac7b2f 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/layout.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/layout.tsx @@ -62,14 +62,14 @@ const DashboardLayout = async ({ if (can('view', 'Process')) children.push({ - key: 'processes', + key: '/processes', label: Process List, icon: , }); if (can('view', 'Template')) children.push({ - key: 'templates', + key: '/templates', label: Templates, icon: , }); @@ -90,7 +90,7 @@ const DashboardLayout = async ({ const children: MenuProps['items'] = []; children.push({ - key: 'executions', + key: '/executions', label: Instances, icon: , }); @@ -110,7 +110,7 @@ const DashboardLayout = async ({ if (process.env.ENABLE_MACHINE_CONFIG) { layoutMenuItems.push({ - key: 'machine-config', + key: '/machine-config', label: Machine Config, icon: , }); @@ -130,14 +130,14 @@ const DashboardLayout = async ({ if (can('manage', 'User')) children.push({ - key: 'users', + key: '/users', label: Users, icon: , }); if (ability.can('manage', 'RoleMapping') || ability.can('manage', 'Role')) children.push({ - key: 'roles', + key: '/roles', label: Roles, icon: , }); @@ -162,7 +162,7 @@ const DashboardLayout = async ({ type: 'group', children: [ { - key: 'general-settings', + key: '/general-settings', label: ( General Settings ),