|
14 | 14 | const nav = [
|
15 | 15 | {
|
16 | 16 | tab: 'Overview',
|
17 |
| - routeId: '/team/[team]/(teamTabs)' |
| 17 | + routeId: '/team/[team]/(teamTabs)', |
| 18 | + withSubRoutes: false |
18 | 19 | },
|
19 | 20 | {
|
20 | 21 | tab: 'Apps',
|
21 |
| - routeId: '/team/[team]/(teamTabs)/applications' |
| 22 | + routeId: '/team/[team]/(teamTabs)/applications', |
| 23 | + withSubRoutes: true |
22 | 24 | },
|
23 | 25 | {
|
24 | 26 | tab: 'Jobs',
|
25 |
| - routeId: '/team/[team]/(teamTabs)/jobs' |
| 27 | + routeId: '/team/[team]/(teamTabs)/jobs', |
| 28 | + withSubRoutes: true |
26 | 29 | },
|
27 | 30 | {
|
28 | 31 | tab: 'Members',
|
29 |
| - routeId: '/team/[team]/(teamTabs)/members' |
| 32 | + routeId: '/team/[team]/(teamTabs)/members', |
| 33 | + withSubRoutes: true |
30 | 34 | },
|
31 | 35 | {
|
32 | 36 | tab: 'Deploys',
|
33 |
| - routeId: '/team/[team]/(teamTabs)/deploy' |
| 37 | + routeId: '/team/[team]/(teamTabs)/deploy', |
| 38 | + withSubRoutes: true |
34 | 39 | },
|
35 | 40 | {
|
36 | 41 | tab: 'Cost',
|
37 |
| - routeId: '/team/[team]/(teamTabs)/cost' |
| 42 | + routeId: '/team/[team]/(teamTabs)/cost', |
| 43 | + withSubRoutes: true |
38 | 44 | },
|
39 | 45 | {
|
40 | 46 | tab: 'Utilization',
|
41 |
| - routeId: '/team/[team]/(teamTabs)/utilization' |
| 47 | + routeId: '/team/[team]/(teamTabs)/utilization', |
| 48 | + withSubRoutes: true |
42 | 49 | },
|
43 | 50 | {
|
44 | 51 | tab: 'Vulnerabilities',
|
45 |
| - routeId: '/team/[team]/(teamTabs)/vulnerabilities' |
| 52 | + routeId: '/team/[team]/(teamTabs)/vulnerabilities', |
| 53 | + withSubRoutes: true |
46 | 54 | },
|
47 | 55 | {
|
48 | 56 | tab: 'Repositories',
|
49 |
| - routeId: '/team/[team]/(teamTabs)/repositories' |
| 57 | + routeId: '/team/[team]/(teamTabs)/repositories', |
| 58 | + withSubRoutes: true |
50 | 59 | }
|
51 | 60 | ];
|
| 61 | +
|
| 62 | + const isActive = (current: string | null, routeID: string, allWithPrefix = false) => { |
| 63 | + if (current === routeID) { |
| 64 | + return true; |
| 65 | + } |
| 66 | + if (current && allWithPrefix) { |
| 67 | + return current.startsWith(routeID); |
| 68 | + } |
| 69 | + return false; |
| 70 | + }; |
52 | 71 | </script>
|
53 | 72 |
|
54 | 73 | <svelte:head><title>{team} - Console</title></svelte:head>
|
|
57 | 76 | <h2>{team}</h2>
|
58 | 77 | </div>
|
59 | 78 | <Tabs>
|
60 |
| - {#each nav as { tab, routeId }} |
61 |
| - <Tab href={replacer(routeId, { team })} active={currentRoute == routeId} title={tab} /> |
| 79 | + {#each nav as { tab, routeId, withSubRoutes }} |
| 80 | + <Tab |
| 81 | + href={replacer(routeId, { team })} |
| 82 | + active={isActive(currentRoute, routeId, withSubRoutes)} |
| 83 | + title={tab} |
| 84 | + /> |
62 | 85 | {/each}
|
63 | 86 | {#if $TeamRoles.data}
|
64 | 87 | {#if $TeamRoles.data.team !== PendingValue && ($TeamRoles.data.team.viewerIsMember || $TeamRoles.data.team.viewerIsOwner)}
|
65 | 88 | <Tab
|
66 | 89 | href={replacer('/team/[team]/(teamTabs)/secrets', { team })}
|
67 |
| - active={currentRoute == '/team/[team]/(teamTabs)/secrets'} |
| 90 | + active={isActive(currentRoute, '/team/[team]/(teamTabs)/secrets', true)} |
68 | 91 | title="Secrets"
|
69 | 92 | />
|
70 | 93 | <Tab
|
71 | 94 | href={replacer('/team/[team]/(teamTabs)/settings', { team })}
|
72 |
| - active={currentRoute == '/team/[team]/(teamTabs)/settings'} |
| 95 | + active={isActive(currentRoute, '/team/[team]/(teamTabs)/settings', true)} |
73 | 96 | title="Settings"
|
74 | 97 | />
|
75 | 98 | {/if}
|
|
0 commit comments