Skip to content

Commit f7c7eb9

Browse files
authored
Only show NamespacePicker on certain pages (#2522)
* Only show NamespacePicker on certain pages * Update integration tests
1 parent 03f1eb9 commit f7c7eb9

File tree

4 files changed

+77
-33
lines changed

4 files changed

+77
-33
lines changed

Diff for: src/lib/components/bottom-nav.svelte

+21-18
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
export let namespaceList: NamespaceListItem[] | undefined = [];
2323
export let linkList: NavLinkListItem[];
2424
export let isCloud = false;
25+
export let showNamespacePicker = true;
2526
2627
let viewLinks = false;
2728
let viewNamespaces = writable(false);
@@ -120,24 +121,26 @@
120121
<Logo height={32} width={32} />
121122
{/if}
122123
</button>
123-
<div class="namespace-wrapper">
124-
<Button
125-
variant="ghost"
126-
data-testid="namespace-switcher"
127-
leadingIcon="namespace-switcher"
128-
size="xs"
129-
class="grow text-white"
130-
on:click={onNamespaceClick}>{truncateNamespace(namespace)}</Button
131-
>
132-
<div class="ml-1 h-full w-1 border-l border-subtle" />
133-
<Button
134-
variant="ghost"
135-
size="xs"
136-
href={routeForNamespace({ namespace })}
137-
disabled={!namespaceExists}
138-
><Icon class="text-white" name="external-link" /></Button
139-
>
140-
</div>
124+
{#if showNamespacePicker}
125+
<div class="namespace-wrapper">
126+
<Button
127+
variant="ghost"
128+
data-testid="namespace-switcher"
129+
leadingIcon="namespace-switcher"
130+
size="xs"
131+
class="grow text-white"
132+
on:click={onNamespaceClick}>{truncateNamespace(namespace)}</Button
133+
>
134+
<div class="ml-1 h-full w-1 border-l border-subtle" />
135+
<Button
136+
variant="ghost"
137+
size="xs"
138+
href={routeForNamespace({ namespace })}
139+
disabled={!namespaceExists}
140+
><Icon class="text-white" name="external-link" /></Button
141+
>
142+
</div>
143+
{/if}
141144
<button
142145
class="nav-button"
143146
data-testid="nav-profile-button"

Diff for: src/routes/(app)/+layout.svelte

+52-12
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,50 @@
5454
};
5555
});
5656
57-
$: linkList = getLinkList(activeNamespaceName, !!$inProgressBatchOperation);
57+
$: routes = getRoutes(activeNamespaceName);
58+
$: linkList = getLinkList(routes, !!$inProgressBatchOperation);
59+
60+
const getRoutes = (namespace: string) => {
61+
return {
62+
workflowsRoute: routeForWorkflows({ namespace }),
63+
schedulesRoute: routeForSchedules({ namespace }),
64+
batchOperationsRoute: routeForBatchOperations({ namespace }),
65+
archivalRoute: routeForArchivalWorkfows({ namespace }),
66+
namespacesRoute: routeForNamespaces(),
67+
nexusRoute: routeForNexus(),
68+
historyImportRoute: routeForEventHistoryImport(),
69+
};
70+
};
71+
72+
$: ({ workflowsRoute, schedulesRoute, batchOperationsRoute, archivalRoute } =
73+
routes);
74+
$: showNamespacePicker = [
75+
workflowsRoute,
76+
schedulesRoute,
77+
batchOperationsRoute,
78+
archivalRoute,
79+
].some((route) => $page.url.href.includes(route));
5880
5981
const getLinkList = (
60-
namespace: string,
82+
{
83+
workflowsRoute,
84+
schedulesRoute,
85+
batchOperationsRoute,
86+
archivalRoute,
87+
namespacesRoute,
88+
nexusRoute,
89+
historyImportRoute,
90+
}: {
91+
workflowsRoute: string;
92+
schedulesRoute: string;
93+
batchOperationsRoute: string;
94+
archivalRoute: string;
95+
namespacesRoute: string;
96+
nexusRoute: string;
97+
historyImportRoute: string;
98+
},
6199
inProgressBatch: boolean,
62100
): NavLinkListItem[] => {
63-
const workflowsRoute = routeForWorkflows({ namespace });
64-
const schedulesRoute = routeForSchedules({ namespace });
65-
const batchOperationsRoute = routeForBatchOperations({ namespace });
66-
const archivalRoute = routeForArchivalWorkfows({ namespace });
67-
const namespacesRoute = routeForNamespaces();
68-
const nexusRoute = routeForNexus();
69-
const historyImportRoute = routeForEventHistoryImport();
70-
71101
return [
72102
{
73103
href: workflowsRoute,
@@ -190,7 +220,11 @@
190220
<MainContentContainer>
191221
<DataEncoderSettings class="hidden md:flex" />
192222
<TopNavigation>
193-
<NamespacePicker {namespaceList} slot="left" />
223+
<svelte:fragment slot="left">
224+
{#if showNamespacePicker}
225+
<NamespacePicker {namespaceList} />
226+
{/if}
227+
</svelte:fragment>
194228
<UserMenu {logout} />
195229
</TopNavigation>
196230
<CodecServerErrorBanner>
@@ -210,7 +244,13 @@
210244
<slot />
211245
</ErrorBoundary>
212246
</div>
213-
<BottomNavigation slot="footer" {linkList} {namespaceList} {isCloud}>
247+
<BottomNavigation
248+
slot="footer"
249+
{linkList}
250+
{namespaceList}
251+
{isCloud}
252+
{showNamespacePicker}
253+
>
214254
<UserMenuMobile {logout} />
215255
</BottomNavigation>
216256
</MainContentContainer>

Diff for: tests/integration/workflow-navigation.desktop.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test('Top Navigation current namespace is present and has other namespaces to se
6767
).toBeHidden();
6868
});
6969

70-
test('Top Navigation current namespace is present on non-namespace specific pages', async ({
70+
test('Top Navigation current namespace is NOT present on non-namespace specific pages', async ({
7171
page,
7272
}) => {
7373
const switcher = page
@@ -76,6 +76,7 @@ test('Top Navigation current namespace is present on non-namespace specific page
7676

7777
await expect(switcher).toBeVisible();
7878
await page.getByRole('link', { name: 'Namespaces' }).click();
79+
await expect(switcher).toBeHidden();
7980
await page.getByRole('link', { name: 'Workflows' }).first().click();
8081
await expect(switcher).toBeVisible();
8182
});

Diff for: tests/integration/workflow-navigation.mobile.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ test('Top Navigation current namespace is present and has other namespaces to se
9494
).toBeHidden();
9595
});
9696

97-
test('Top Navigation current namespace is present on non-namespace specific pages', async ({
97+
test('Top Navigation current namespace is NOT present on non-namespace specific pages', async ({
9898
page,
9999
}) => {
100100
const switcher = page
@@ -103,7 +103,7 @@ test('Top Navigation current namespace is present on non-namespace specific page
103103
await expect(switcher).toBeVisible();
104104
await page.getByTestId('nav-menu-button').click();
105105
await page.getByRole('link', { name: 'Namespaces' }).click();
106-
await expect(switcher).toBeVisible();
106+
await expect(switcher).toBeHidden();
107107
await page.getByTestId('nav-menu-button').click();
108108
await page.getByRole('link', { name: 'Workflows' }).click();
109109
await expect(switcher).toBeVisible();

0 commit comments

Comments
 (0)