fix: flow picker of flows

This commit is contained in:
Ruben Fiszel
2024-10-03 15:09:58 +02:00
parent 544e6ace0a
commit fbd196ca5f
3 changed files with 31 additions and 15 deletions
@@ -256,7 +256,14 @@
{#if preFilter == 'all'}
<div class="pb-0 text-2xs font-light text-secondary ml-2 pt-0.5">Integrations</div>
{/if}
<ListFiltersQuick filters={integrations} bind:selectedFilter={selected} resourceType />
<ListFiltersQuick
on:selected={() => {
selectedByKeyboard = 0
}}
filters={integrations}
bind:selectedFilter={selected}
resourceType
/>
{/if}
{:else if selectedKind === 'flow'}
{#if owners.length > 0}
@@ -415,6 +422,7 @@
kind={selectedKind}
selected={selectedByKeyboard - inlineScripts?.length - aiLength - topLevelNodes.length}
on:pickScript
on:pickFlow
/>
{/if}
@@ -64,24 +64,28 @@
const dispatch = createEventDispatcher()
let lockHash = false
function onKeyDown(e: KeyboardEvent) {
if (
selected != undefined &&
filteredItems &&
selected >= 0 &&
selected < filteredItems.length &&
e.key === 'Enter'
) {
e.preventDefault()
let item = filteredItems[selected]
dispatch('pickScript', { path: item.path, hash: lockHash ? item.hash : undefined })
}
}
$: filteredWithOwner =
ownerFilter != undefined
? filteredItems?.filter((x) => x.path.startsWith(ownerFilter?.name!))
: filteredItems
function onKeyDown(e: KeyboardEvent) {
if (
selected != undefined &&
filteredWithOwner &&
selected >= 0 &&
selected < filteredWithOwner.length &&
e.key === 'Enter'
) {
e.preventDefault()
let item = filteredWithOwner[selected]
if (kind == 'flow') {
dispatch('pickFlow', { path: item.path })
} else {
dispatch('pickScript', { path: item.path, hash: lockHash ? item.hash : undefined })
}
}
}
</script>
<SearchItems
@@ -2,6 +2,7 @@
import { Folder, User, Circle } from 'lucide-svelte'
import { APP_TO_ICON_COMPONENT } from '../icons'
import { twMerge } from 'tailwind-merge'
import { createEventDispatcher } from 'svelte'
export let filters: string[]
export let selectedFilter:
@@ -14,6 +15,8 @@
function getIconComponent(name: string) {
return APP_TO_ICON_COMPONENT[name] || APP_TO_ICON_COMPONENT[name.split('_')[0]]
}
const dispatch = createEventDispatcher()
</script>
{#if Array.isArray(filters) && filters.length > 0}
@@ -27,6 +30,7 @@
on:click={() => {
selectedFilter =
selectedAppFilter == filter ? undefined : { kind: 'integrations', name: filter }
dispatch('selected')
}}
>
<div class="flex justify-center flex-row items-center gap-2">