Skip to content

Commit

Permalink
show helpText when someone tries unsupported filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rbjornstad committed Sep 25, 2023
1 parent 38e3ddc commit b2a5860
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/routes/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
let selected = -1;
let showSearch = false;
let showHelpText = false;
let unsupportedFilter = false;
let timeout: ReturnType<typeof setTimeout> | null = null;
$: {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -116,6 +125,8 @@
break;
case 'Escape':
showHelpText = false;
showSearch = false;
query = '';
break;
}
}
Expand Down Expand Up @@ -163,9 +174,9 @@
}}
on:keyup={on_key_up}
/>
{#if $store.data && showSearch}
{#if $store.data && showSearch && !unsupportedFilter}
<SearchResults {showSearch} data={$store.data} bind:query {selected} />
{:else if showHelpText}
{:else if showHelpText || unsupportedFilter}
<ul class="helpText">
<li>
<div class="typeIcon">
Expand Down
1 change: 0 additions & 1 deletion src/routes/team/[team]/[env]/job/[job]/logs/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit b2a5860

Please sign in to comment.