From b2a5860cc3e75bc49b4f3690959854544b47620f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Bj=C3=B8rnstad?= Date: Mon, 25 Sep 2023 16:08:11 +0200 Subject: [PATCH] show helpText when someone tries unsupported filter --- src/routes/Header.svelte | 15 +++++++++++++-- .../team/[team]/[env]/job/[job]/logs/+page.ts | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index 69ecb6b6..a6722a5b 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -51,6 +51,7 @@ let selected = -1; let showSearch = false; let showHelpText = false; + let unsupportedFilter = false; let timeout: ReturnType | null = null; $: { @@ -65,18 +66,26 @@ fetch(query); logEvent('search'); }, 500); + } else { + showHelpText = true; } } function fetch(query: string) { if (query.startsWith('app:')) { store.fetch({ variables: { query: query.slice(4), type: 'APP' } }); + unsupportedFilter = false; } else if (query.startsWith('team:')) { store.fetch({ variables: { query: query.slice(5), type: 'TEAM' } }); + unsupportedFilter = false; } else if (query.startsWith('job:')) { store.fetch({ variables: { query: query.slice(4), type: 'NAISJOB' } }); + unsupportedFilter = false; + } else if (query.lastIndexOf(':') >= 0) { + unsupportedFilter = true; } else { store.fetch({ variables: { query, type: null } }); + unsupportedFilter = false; } } @@ -116,6 +125,8 @@ break; case 'Escape': showHelpText = false; + showSearch = false; + query = ''; break; } } @@ -163,9 +174,9 @@ }} on:keyup={on_key_up} /> - {#if $store.data && showSearch} + {#if $store.data && showSearch && !unsupportedFilter} - {:else if showHelpText} + {:else if showHelpText || unsupportedFilter}
  • diff --git a/src/routes/team/[team]/[env]/job/[job]/logs/+page.ts b/src/routes/team/[team]/[env]/job/[job]/logs/+page.ts index a421c4b1..9e986713 100644 --- a/src/routes/team/[team]/[env]/job/[job]/logs/+page.ts +++ b/src/routes/team/[team]/[env]/job/[job]/logs/+page.ts @@ -4,7 +4,6 @@ export function _houdini_afterLoad({ data, event: { url } }: AfterLoadEvent) { const name = url.searchParams.get('name'); if (name) { - console.log('name set to ', name); const selected = data.RunsWithPodNames.naisjob.runs.find((run) => run.name === name)?.name; if (selected) { return { selected: selected, unknownName: false };