From 7e4aac997175bf2ba479021742e5aa8abab4ff41 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Wed, 17 Aug 2022 17:24:57 +0200 Subject: [PATCH] feat(frontend): Open/Close UI (#445) * feat(frontend): Properly open/close and highlight a flowbox * feat(frontend): Fix removing first step --- frontend/src/lib/components/ModuleStep.svelte | 152 +++++++++--------- .../src/lib/components/flows/FlowBox.svelte | 6 +- .../lib/components/flows/FlowBoxHeader.svelte | 2 +- .../src/lib/components/flows/FlowInput.svelte | 14 +- .../components/flows/FlowModuleHeader.svelte | 39 +++-- .../lib/components/flows/FlowSettings.svelte | 109 +++++++------ frontend/src/lib/components/flows/utils.ts | 17 +- 7 files changed, 177 insertions(+), 162 deletions(-) diff --git a/frontend/src/lib/components/ModuleStep.svelte b/frontend/src/lib/components/ModuleStep.svelte index 189070d323..93b61fcc23 100644 --- a/frontend/src/lib/components/ModuleStep.svelte +++ b/frontend/src/lib/components/ModuleStep.svelte @@ -15,7 +15,8 @@ fork, loadFlowModuleSchema, pickScript, - createScriptFromInlineScript + createScriptFromInlineScript, + isEmptyFlowModule } from './flows/flowStateUtils' import { jobsToResults } from './flows/utils' import SchemaForm from './SchemaForm.svelte' @@ -67,7 +68,7 @@ index: "iteration's index" } - if (hasElements(stepBeforeLoop.previewResults)) { + if (hasElements(stepBeforeLoop?.previewResults)) { const lastResults = getLast(stepBeforeLoop.previewResults) if (hasElements(lastResults)) { @@ -89,7 +90,7 @@ } } - $: shouldPick = 'path' in mod.value && mod.value.path === '' && !('language' in mod.value) + $: shouldPick = isEmptyFlowModule(mod) $: pickableProperties = getPickableProperties($flowStore, $flowStateStore) $: extraLib = buildExtraLib( schemaToTsType($flowStore?.schema), @@ -140,12 +141,11 @@ $: opened = $stepOpened === String(indexes.join('-')) - + apply(fork, mod)} on:createScriptFromInlineScript={() => { @@ -160,83 +160,75 @@
{#if opened} - {#if shouldPick} - 0} - shouldDisableLoopCreation={indexes.length > 1 || indexes[0] == 0} - on:pick={(e) => apply(pickScript, e.detail.path)} - on:new={(e) => - apply(createInlineScriptModule, { - language: e.detail.language, - isTrigger: e.detail.isTrigger - })} - on:loop={() => applyCreateLoop()} - /> - {/if} - {#if mod.value.type === 'rawscript'} -
- -
-
reload(mod)}> - reload(mod)} - formatAction={() => reload(mod)} +
+ {#if shouldPick} + 1 || i == 0} + on:pick={(e) => apply(pickScript, e.detail.path)} + on:new={(e) => + apply(createInlineScriptModule, { + language: e.detail.language, + isTrigger: e.detail.isTrigger + })} + on:loop={() => applyCreateLoop()} /> - -
-
-

- Move the focus outside of the text editor to recompute the input schema or press - Ctrl/Cmd+S -

-
- {/if} - {#if !shouldPick} -

Step inputs

- - {/if} - - {#if !shouldPick} -
-
- + +
+
reload(mod)}> + reload(mod)} + formatAction={() => reload(mod)} + /> + +
+
+

+ Move the focus outside of the text editor to recompute the input schema or press + Ctrl/Cmd+S +

+
+ {/if} + {#if !shouldPick} +

Step inputs

+ onPreview(e.detail)} + {extraLib} + inputTransform={true} + importPath={String(indexes.join('-'))} + bind:pickableProperties + bind:args={mod.input_transform} /> -
- {/if} - {:else} -
- + {/if} + + {#if !shouldPick} +
+
+ onPreview(e.detail)} + /> +
+ {/if}
{/if}
diff --git a/frontend/src/lib/components/flows/FlowBox.svelte b/frontend/src/lib/components/flows/FlowBox.svelte index 955fd22c3c..769457a624 100644 --- a/frontend/src/lib/components/flows/FlowBox.svelte +++ b/frontend/src/lib/components/flows/FlowBox.svelte @@ -4,13 +4,11 @@ let slots = $$props.$$slots -
+
{#if slots.content} -
- -
+ {/if}
diff --git a/frontend/src/lib/components/flows/FlowBoxHeader.svelte b/frontend/src/lib/components/flows/FlowBoxHeader.svelte index 5a6bf27810..7040e9c6b8 100644 --- a/frontend/src/lib/components/flows/FlowBoxHeader.svelte +++ b/frontend/src/lib/components/flows/FlowBoxHeader.svelte @@ -2,7 +2,7 @@ export let title: string | undefined = undefined -
+
{#if title}

{title}

{/if} diff --git a/frontend/src/lib/components/flows/FlowInput.svelte b/frontend/src/lib/components/flows/FlowInput.svelte index bf850cbc42..5dde2c63dd 100644 --- a/frontend/src/lib/components/flows/FlowInput.svelte +++ b/frontend/src/lib/components/flows/FlowInput.svelte @@ -10,11 +10,13 @@
- { - $flowStore = $flowStore - }} - schema={$flowStore.schema} - /> +
+ { + $flowStore = $flowStore + }} + schema={$flowStore.schema} + /> +
diff --git a/frontend/src/lib/components/flows/FlowModuleHeader.svelte b/frontend/src/lib/components/flows/FlowModuleHeader.svelte index 52ad6a00ea..bcb68fc7f2 100644 --- a/frontend/src/lib/components/flows/FlowModuleHeader.svelte +++ b/frontend/src/lib/components/flows/FlowModuleHeader.svelte @@ -1,7 +1,14 @@ - +
{#if mod.value.type === 'script' && !shouldPick} @@ -79,6 +83,19 @@ Remove step + {#if opened} + + {:else} + + {/if}
diff --git a/frontend/src/lib/components/flows/FlowSettings.svelte b/frontend/src/lib/components/flows/FlowSettings.svelte index 0debca80c4..dcfd121526 100644 --- a/frontend/src/lib/components/flows/FlowSettings.svelte +++ b/frontend/src/lib/components/flows/FlowSettings.svelte @@ -103,60 +103,63 @@
- -
- Flow permissions depend on their path. Select the group all - to share your flow, and user to keep it private. - docs -
-
+
+ +
+ Flow permissions depend on their path. Select the group all + to share your flow, and user to keep it private. + docs +
+
-