mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-05 16:03:47 +00:00
* (frontend) add quick access menu in flow editor * (frontend) add quick access menu in flow editor * improve UI * make design prettier * add scroll effects * improve loading preview * change no items found * prevent scroll using menu * change user folder button * set default integration icon * reduce column width * ajust font * add defaults script button * add shadow divider * fix scroll * add chevron * Change toogle bar * Add preprocessor menu * add handler * simplify scroll * fix display * fix minor issues * delete useless log * revert node tree changes * merge main * fix z-index issues * iterate * fix: improve allowed domains setting for sso * chore(main): release 1.402.3 (#4458) * chore(main): release 1.402.3 * Apply automatic changes --------- Co-authored-by: rubenfiszel <rubenfiszel@users.noreply.github.com> * improve allowed domains change handling * send stats when renewing key if last >24h (#4430) * feat: send stats when renewing key if last >24h * nits * fix: sqlx * nit * renewal reason * stats reason * update ee ref * Update ee-repo-ref.txt --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev> * fix: skip one migration to avoid using md5 for azure support * all * all * Apply automatic changes * all * done? * nit * nit * nit * nit * nit noAi if prefilter is not all * fix shadow * fix error handler * fix error handler * Polishing default script settings * all * all * full * all * add deno_core as features * all * remove warnings * all * npm check * npm check * new script script * nits * nits item 0 * nits item 0 --------- Co-authored-by: Guilhem Le Mouel <guilhem.le-mouel.ext@altran.com> Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev> Co-authored-by: rubenfiszel <rubenfiszel@users.noreply.github.com> Co-authored-by: HugoCasa <hugo@casademont.ch> Co-authored-by: Guilhem <guilhem@mbp-de-windmill.home>
176 lines
4.3 KiB
Svelte
176 lines
4.3 KiB
Svelte
<script lang="ts">
|
|
import { createEventDispatcher } from 'svelte'
|
|
import { Skeleton } from '$lib/components/common'
|
|
import { classNames } from '$lib/utils'
|
|
import { APP_TO_ICON_COMPONENT } from '$lib/components/icons'
|
|
import { IntegrationService, ScriptService, type HubScriptKind } from '$lib/gen'
|
|
import { Circle } from 'lucide-svelte'
|
|
|
|
export let kind: HubScriptKind & string = 'script'
|
|
export let filter = ''
|
|
|
|
export let loading = false
|
|
export let selected: number | undefined = undefined
|
|
let hubNotAvailable = false
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
export let appFilter: string | undefined = undefined
|
|
export let items: {
|
|
path: string
|
|
summary: string
|
|
id: number
|
|
version_id: number
|
|
ask_id: number
|
|
app: string
|
|
kind: HubScriptKind
|
|
}[] = []
|
|
|
|
export let apps: string[] = []
|
|
let allApps: string[] = []
|
|
$: applyFilter(filter, kind, appFilter)
|
|
$: getAllApps(kind)
|
|
|
|
async function getAllApps(filterKind: typeof kind) {
|
|
try {
|
|
hubNotAvailable = false
|
|
allApps = (
|
|
await IntegrationService.listHubIntegrations({
|
|
kind: filterKind
|
|
})
|
|
).map((x) => x.name)
|
|
apps = allApps
|
|
} catch (err) {
|
|
console.error('Hub is not available')
|
|
allApps = []
|
|
apps = []
|
|
hubNotAvailable = true
|
|
}
|
|
}
|
|
|
|
let startTs = 0
|
|
async function applyFilter(
|
|
filter: string,
|
|
filterKind: typeof kind,
|
|
appFilter: string | undefined
|
|
) {
|
|
try {
|
|
loading = true
|
|
hubNotAvailable = false
|
|
const ts = Date.now()
|
|
startTs = ts
|
|
await new Promise((resolved, rejected) => setTimeout(resolved, 200))
|
|
if (ts < startTs) return
|
|
const scripts =
|
|
filter.length > 0
|
|
? await ScriptService.queryHubScripts({
|
|
text: `${filter}`,
|
|
limit: 40,
|
|
kind: filterKind
|
|
})
|
|
: (
|
|
await ScriptService.getTopHubScripts({
|
|
limit: 40,
|
|
kind: filterKind,
|
|
app: appFilter
|
|
})
|
|
).asks ?? []
|
|
|
|
const mappedItems = scripts.map(
|
|
(x: {
|
|
summary: string
|
|
version_id: number
|
|
id: number
|
|
ask_id: number
|
|
app: string
|
|
kind: HubScriptKind
|
|
}) => ({
|
|
...x,
|
|
path: `hub/${x.version_id}/${x.app}/${x.summary.toLowerCase().replaceAll(/\s+/g, '_')}`,
|
|
summary: `${x.summary} (${x.app})`
|
|
})
|
|
)
|
|
if (filter.length > 0) {
|
|
apps = Array.from(new Set(mappedItems?.map((x) => x.app) ?? [])).sort()
|
|
} else {
|
|
apps = allApps
|
|
}
|
|
|
|
items = appFilter ? mappedItems.filter((x) => x.app === appFilter) : mappedItems
|
|
|
|
if (ts === startTs) {
|
|
loading = false
|
|
}
|
|
|
|
hubNotAvailable = false
|
|
} catch (err) {
|
|
hubNotAvailable = true
|
|
console.error('Hub not available')
|
|
loading = false
|
|
}
|
|
}
|
|
|
|
function onKeyDown(e: KeyboardEvent) {
|
|
if (
|
|
selected != undefined &&
|
|
items &&
|
|
selected >= 0 &&
|
|
selected < items?.length! &&
|
|
e.key === 'Enter'
|
|
) {
|
|
e.preventDefault()
|
|
let item = items![selected]
|
|
dispatch('pickScript', item)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<svelte:window on:keydown={onKeyDown} />
|
|
{#if hubNotAvailable}
|
|
<div class="text-2xs text-red-400 ftext-2xs font-light text-center py-2 px-3 items-center">
|
|
Hub not available
|
|
</div>
|
|
{:else if loading}
|
|
{#each Array(15).fill(0) as _}
|
|
<Skeleton layout={[0.1, [1.5]]} />
|
|
{/each}
|
|
{:else if items.length > 0 && apps.length > 0}
|
|
<ul>
|
|
{#each items as item, index (item.path)}
|
|
<li class="w-full">
|
|
<button
|
|
class="px-3 py-2 gap-2 flex flex-row w-full hover:bg-surface-hover transition-all items-center rounded-md {index ===
|
|
selected
|
|
? 'bg-surface-hover'
|
|
: ''}"
|
|
on:click={() => dispatch('pickScript', item)}
|
|
>
|
|
<div class={classNames('flex justify-center items-center')}>
|
|
{#if item['app'] in APP_TO_ICON_COMPONENT}
|
|
<svelte:component this={APP_TO_ICON_COMPONENT[item['app']]} height={14} width={14} />
|
|
{:else}
|
|
<div
|
|
class="w-[14px] h-[14px] text-gray-400 flex flex-row items-center justify-center"
|
|
>
|
|
<Circle size="12" />
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<span class="grow truncate text-left text-2xs text-primary font-normal">
|
|
{item.summary ?? ''}
|
|
</span>
|
|
{#if index === selected}
|
|
<kbd class="!text-xs">↵</kbd>
|
|
{/if}
|
|
</button>
|
|
</li>
|
|
{/each}
|
|
</ul>
|
|
{#if items.length == 40}
|
|
<div class="text-2xs text-tercary font-extralight text-center py-2 px-3 items-center">
|
|
There are more items than being displayed. Refine your search.
|
|
</div>
|
|
{/if}
|
|
{/if}
|