diff --git a/src/routes/console/project-[project]/authentication/header.svelte b/src/routes/console/project-[project]/authentication/header.svelte index 5879bca3d..c5251c825 100644 --- a/src/routes/console/project-[project]/authentication/header.svelte +++ b/src/routes/console/project-[project]/authentication/header.svelte @@ -5,14 +5,17 @@ const projectId = $page.params.project; const path = `/console/project-${projectId}/authentication`; - const tabs = [ + type TabElement = { href: string; title: string; hasChildren?: boolean }; + const tabs: TabElement[] = [ { href: path, - title: 'Users' + title: 'Users', + hasChildren: true }, { href: `${path}/teams`, - title: 'Teams' + title: 'Teams', + hasChildren: true }, { href: `${path}/usage`, @@ -27,6 +30,22 @@ title: 'Settings' } ]; + + function isSelected(tab: TabElement, pathname: string, basePath: string) { + if (!tab.hasChildren) { + return tab.href === pathname; + } else { + if (tab.href === pathname) return true; + + if (tab.href === basePath) { + if (!tabs.some((t) => pathname.includes(t.href) && t.href !== tab.href)) { + return pathname.includes(tab.href); + } + } else { + return pathname.includes(tab.href); + } + } + } @@ -35,7 +54,7 @@ {#each tabs as tab} - + {tab.title} {/each}