diff --git a/frontend/src/lib/components/flows/pickers/PickHubApp.svelte b/frontend/src/lib/components/flows/pickers/PickHubApp.svelte index 234f053f7b..6118c5dd9e 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubApp.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubApp.svelte @@ -15,14 +15,26 @@ syncQuery?: boolean children?: import('svelte').Snippet size?: ButtonType.UnifiedSize + hideSearchbar?: boolean + appFilter?: string | undefined + summaryFilter?: string + pathFilter?: string } - let { filter = $bindable(''), syncQuery = false, children, size = 'md' }: Props = $props() + let { + filter = $bindable(''), + syncQuery = false, + children, + size = 'md', + hideSearchbar = false, + appFilter = $bindable(undefined), + summaryFilter, + pathFilter + }: Props = $props() type Item = { apps: string[]; summary: string; path: string } let hubApps: any[] | undefined = $state(undefined) let filteredItems: (Item & { marked?: string })[] = $state([]) - let appFilter: string | undefined = $state(undefined) const prefilteredItems = $derived( appFilter ? (hubApps ?? []).filter((i: Item) => i.apps.includes(appFilter!)) : (hubApps ?? []) @@ -30,6 +42,20 @@ const apps = $derived(Array.from(new Set(filteredItems?.flatMap((x) => x.apps) ?? [])).sort()) + // Apply summary/path post-filters + let displayItems = $derived.by(() => { + let result = filteredItems + if (summaryFilter) { + const s = summaryFilter.toLowerCase() + result = result.filter((x) => x.summary.toLowerCase().includes(s)) + } + if (pathFilter) { + const p = pathFilter.toLowerCase() + result = result.filter((x) => x.path.toLowerCase().includes(p)) + } + return result + }) + const dispatch = createEventDispatcher() let hubNotAvailable = $state(false) @@ -54,6 +80,7 @@ bind:filteredItems f={(x) => x.summary + ' (' + x.apps.join(', ') + ')'} /> +{#if !hideSearchbar}
{@render children?.()}
+{/if} {#if hubNotAvailable} @@ -72,11 +100,11 @@ Could not connect to the Windmill Hub. If you are in a closed environment, you can disable the Hub in the instance settings. {:else if hubApps} - {#if filteredItems.length == 0} + {#if displayItems.length == 0} {:else}