From aebb68c4791d3ebb18a8e98edc770b56fa63aa4c Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 9 May 2023 16:08:14 +0200 Subject: [PATCH] feat(frontend): add input library to flow builder --- .github/workflows/pypi_on_release.yml | 4 +- .../src/lib/components/FlowBuilder.svelte | 5 +- .../lib/components/FlowPreviewContent.svelte | 48 +++++++++++++------ .../lib/components/ModulePreviewForm.svelte | 13 ++++- .../lib/components/flows/FlowEditor.svelte | 3 +- .../flows/content/FlowEditorPanel.svelte | 4 +- .../flows/content/FlowSettings.svelte | 4 +- frontend/src/lib/components/flows/types.ts | 1 + frontend/src/lib/components/flows/utils.ts | 3 ++ 9 files changed, 57 insertions(+), 28 deletions(-) diff --git a/.github/workflows/pypi_on_release.yml b/.github/workflows/pypi_on_release.yml index c49fd2e9f0..9ceb695214 100644 --- a/.github/workflows/pypi_on_release.yml +++ b/.github/workflows/pypi_on_release.yml @@ -28,8 +28,8 @@ jobs: needs: [publish_pypi] runs-on: [self-hosted, new] steps: - - name: Sleep for 30 seconds waiting for pypi to update index - run: sleep 30s + - name: Sleep for 120 seconds waiting for pypi to update index + run: sleep 120 shell: bash - uses: actions/checkout@v3 with: diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index 15921bc7f4..0a3723f209 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -217,7 +217,8 @@ flowStateStore, flowStore, testStepStore, - saveDraft + saveDraft, + initialPath }) async function loadSchedule() { @@ -419,7 +420,7 @@ {#if $flowStateStore} - + {:else} Loading... {/if} diff --git a/frontend/src/lib/components/FlowPreviewContent.svelte b/frontend/src/lib/components/FlowPreviewContent.svelte index 2255246b64..c631eadae7 100644 --- a/frontend/src/lib/components/FlowPreviewContent.svelte +++ b/frontend/src/lib/components/FlowPreviewContent.svelte @@ -2,7 +2,7 @@ import { Job, JobService, type Flow, type FlowModule } from '$lib/gen' import { workspaceStore } from '$lib/stores' import { faClose, faPlay, faRefresh } from '@fortawesome/free-solid-svg-icons' - import { Button, Kbd } from './common' + import { Button, Drawer, Kbd } from './common' import { createEventDispatcher, getContext } from 'svelte' import Icon from 'svelte-awesome' import { dfs } from './flows/flowStore' @@ -14,6 +14,8 @@ import CapturePayload from './flows/content/CapturePayload.svelte' import { Loader2 } from 'lucide-svelte' import { getModifierKey } from '$lib/utils' + import DrawerContent from './common/drawer/DrawerContent.svelte' + import SavedInputs from './SavedInputs.svelte' let capturePayload: CapturePayload export let previewMode: 'upTo' | 'whole' @@ -24,7 +26,7 @@ let isRunning: boolean = false let jobProgressReset: () => void - const { selectedId, previewArgs, flowStateStore, flowStore } = + const { selectedId, previewArgs, flowStateStore, flowStore, initialPath } = getContext('FlowEditorContext') const dispatch = createEventDispatcher() @@ -88,12 +90,28 @@ $: if (job?.type === 'CompletedJob') { isRunning = false } + + let inputLibraryDrawer: Drawer + + + { + $previewArgs = JSON.parse(JSON.stringify(e.detail)) + inputLibraryDrawer?.closeDrawer() + }} + /> + + +
@@ -139,25 +157,27 @@ {/if} - - - +
diff --git a/frontend/src/lib/components/ModulePreviewForm.svelte b/frontend/src/lib/components/ModulePreviewForm.svelte index c7fcdd1a2e..17d9c26952 100644 --- a/frontend/src/lib/components/ModulePreviewForm.svelte +++ b/frontend/src/lib/components/ModulePreviewForm.svelte @@ -2,7 +2,7 @@ import type { Schema } from '$lib/common' import { allTrue } from '$lib/utils' - import { Plug } from 'lucide-svelte' + import { RefreshCw } from 'lucide-svelte' import ArgInput from './ArgInput.svelte' import { Button } from './common' import { getContext } from 'svelte' @@ -10,6 +10,7 @@ import { evalValue } from './flows/utils' import type { FlowModule } from '$lib/gen' import type { PickableProperties } from './flows/previousResults' + import type SimpleEditor from './SimpleEditor.svelte' export let schema: Schema export let args: Record = {} @@ -49,7 +50,14 @@ function plugIt(argName: string) { args[argName] = evalValue(argName, mod, testStepStore, pickableProperties, true) + try { + editor?.[argName]?.setCode(JSON.stringify(args[argName], null, 4)) + } catch { + //ignore + } } + + let editor: Record = {}
@@ -67,6 +75,7 @@ type={schema.properties[argName].type} required={schema.required.includes(argName)} pattern={schema.properties[argName].pattern} + bind:editor={editor[argName]} bind:valid={inputCheck[argName]} defaultValue={schema.properties[argName].default} enum_={schema.properties[argName].enum} @@ -83,7 +92,7 @@ size="sm" variant="border" color="light" - title="Eval input component">
diff --git a/frontend/src/lib/components/flows/FlowEditor.svelte b/frontend/src/lib/components/flows/FlowEditor.svelte index 8465fe0537..458743da3c 100644 --- a/frontend/src/lib/components/flows/FlowEditor.svelte +++ b/frontend/src/lib/components/flows/FlowEditor.svelte @@ -7,7 +7,6 @@ import { getContext } from 'svelte' import type { FlowEditorContext } from './types' - export let initialPath: string export let loading: boolean const { flowStore } = getContext('FlowEditorContext') @@ -38,7 +37,7 @@ {:else} - + {/if} diff --git a/frontend/src/lib/components/flows/content/FlowEditorPanel.svelte b/frontend/src/lib/components/flows/content/FlowEditorPanel.svelte index 7987bfa08b..78219e21ee 100644 --- a/frontend/src/lib/components/flows/content/FlowEditorPanel.svelte +++ b/frontend/src/lib/components/flows/content/FlowEditorPanel.svelte @@ -8,13 +8,11 @@ import FlowFailureModule from './FlowFailureModule.svelte' import FlowConstants from './FlowConstants.svelte' - export let initialPath: string - const { selectedId, flowStore } = getContext('FlowEditorContext') {#if $selectedId?.startsWith('settings')} - + {:else if $selectedId === 'Input'} {:else if $selectedId === 'Result'} diff --git a/frontend/src/lib/components/flows/content/FlowSettings.svelte b/frontend/src/lib/components/flows/content/FlowSettings.svelte index 12b5793b7e..1a2dc8b127 100644 --- a/frontend/src/lib/components/flows/content/FlowSettings.svelte +++ b/frontend/src/lib/components/flows/content/FlowSettings.svelte @@ -20,9 +20,7 @@ import { faClipboard } from '@fortawesome/free-solid-svg-icons' import Tooltip from '$lib/components/Tooltip.svelte' - const { selectedId, flowStore } = getContext('FlowEditorContext') - - export let initialPath: string + const { selectedId, flowStore, initialPath } = getContext('FlowEditorContext') $: url = `${$page.url.hostname}/api/w/${$workspaceStore}/jobs/run/f/${$flowStore?.path}` $: syncedUrl = `${$page.url.hostname}/api/w/${$workspaceStore}/jobs/run_wait_result/f/${$flowStore?.path}` diff --git a/frontend/src/lib/components/flows/types.ts b/frontend/src/lib/components/flows/types.ts index 8bc475e5e2..6e9b3b4d7c 100644 --- a/frontend/src/lib/components/flows/types.ts +++ b/frontend/src/lib/components/flows/types.ts @@ -16,4 +16,5 @@ export type FlowEditorContext = { flowStateStore: Writable testStepStore: Writable> saveDraft: () => void + initialPath: string } diff --git a/frontend/src/lib/components/flows/utils.ts b/frontend/src/lib/components/flows/utils.ts index 516ad7c516..cb8187b0ac 100644 --- a/frontend/src/lib/components/flows/utils.ts +++ b/frontend/src/lib/components/flows/utils.ts @@ -62,6 +62,9 @@ export function evalValue( } } } + if (v == NEVER_TESTED_THIS_FAR) { + return undefined + } return v }