From d91b53281614d10b43dd22c65b520cd095e660c6 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 3 Oct 2022 04:39:34 +0200 Subject: [PATCH] fix(frontend): split early stop + fix highlight code --- .../src/lib/components/HighlightCode.svelte | 8 +++-- .../flows/content/FlowModule.svelte | 19 ++++++++---- ...ings.svelte => FlowModuleEarlyStop.svelte} | 24 +-------------- .../flows/content/FlowModuleHeader.svelte | 16 +++++++++- .../flows/content/FlowModuleSuspend.svelte | 30 +++++++++++++++++++ 5 files changed, 65 insertions(+), 32 deletions(-) rename frontend/src/lib/components/flows/content/{FlowModuleAdvancedSettings.svelte => FlowModuleEarlyStop.svelte} (79%) create mode 100644 frontend/src/lib/components/flows/content/FlowModuleSuspend.svelte diff --git a/frontend/src/lib/components/HighlightCode.svelte b/frontend/src/lib/components/HighlightCode.svelte index 8638e97058..9245c6b18c 100644 --- a/frontend/src/lib/components/HighlightCode.svelte +++ b/frontend/src/lib/components/HighlightCode.svelte @@ -7,8 +7,8 @@ export let code: string = '' export let language: 'python3' | 'deno' | 'go' | undefined - function getLang() { - switch (language) { + function getLang(lang: string | undefined) { + switch (lang) { case 'python3': return python case 'deno': @@ -19,6 +19,8 @@ return python } } + + $: lang = getLang(language) - + diff --git a/frontend/src/lib/components/flows/content/FlowModule.svelte b/frontend/src/lib/components/flows/content/FlowModule.svelte index dda06dfd65..7765e61047 100644 --- a/frontend/src/lib/components/flows/content/FlowModule.svelte +++ b/frontend/src/lib/components/flows/content/FlowModule.svelte @@ -27,7 +27,7 @@ import { flowStore } from '$lib/components/flows/flowStore' import SchemaForm from '$lib/components/SchemaForm.svelte' - import { RawScript, type Flow, type FlowModule } from '$lib/gen' + import { RawScript, type FlowModule } from '$lib/gen' import FlowCard from '../common/FlowCard.svelte' import FlowModuleHeader from './FlowModuleHeader.svelte' import { flowStateStore, type FlowModuleState } from '../flowState' @@ -35,10 +35,11 @@ import PropPickerWrapper from '../propPicker/PropPickerWrapper.svelte' import { getContext, setContext } from 'svelte' import type { FlowEditorContext } from '../types' - import FlowModuleAdvancedSettings from './FlowModuleAdvancedSettings.svelte' import { loadSchemaFromModule } from '../utils' import { writable, type Writable } from 'svelte/store' import FlowModuleScript from './FlowModuleScript.svelte' + import FlowModuleEarlyStop from './FlowModuleEarlyStop.svelte' + import FlowModuleSuspend from './FlowModuleSuspend.svelte' const { selectedId, select, previewArgs } = getContext('FlowEditorContext') @@ -111,6 +112,7 @@ (selected = 'early-stop')} on:fork={() => apply(fork, flowModule)} on:createScriptFromInlineScript={() => { apply(createScriptFromInlineScript, { @@ -187,7 +189,8 @@ Inputs Test {#if !$selectedId.includes('failure')} - Advanced + Early Stop + Suspend {/if} @@ -213,9 +216,15 @@ /> - +
- + +
+
+ + +
+
diff --git a/frontend/src/lib/components/flows/content/FlowModuleAdvancedSettings.svelte b/frontend/src/lib/components/flows/content/FlowModuleEarlyStop.svelte similarity index 79% rename from frontend/src/lib/components/flows/content/FlowModuleAdvancedSettings.svelte rename to frontend/src/lib/components/flows/content/FlowModuleEarlyStop.svelte index a1aeec9063..9613af1ae4 100644 --- a/frontend/src/lib/components/flows/content/FlowModuleAdvancedSettings.svelte +++ b/frontend/src/lib/components/flows/content/FlowModuleEarlyStop.svelte @@ -17,7 +17,6 @@ let editor: SimpleEditor | undefined = undefined - $: isSuspendEnabled = Boolean(flowModule.suspend) $: isStopAfterIfEnabled = Boolean(flowModule.stop_after_if) let pickableProperties: Object = {} @@ -43,27 +42,6 @@
- { - if (isSuspendEnabled && flowModule.suspend != undefined) { - flowModule.suspend = undefined - } else { - flowModule.suspend = 1 - } - }} - options={{ - right: 'Suspend flow execution until events received enabled' - }} - /> - Number of events to wait for - - {#if flowModule.suspend} - - {:else} - - {/if} - { @@ -77,7 +55,7 @@ } }} options={{ - right: 'Early stop if condition met enabled' + right: 'Early stop if condition met' }} /> diff --git a/frontend/src/lib/components/flows/content/FlowModuleHeader.svelte b/frontend/src/lib/components/flows/content/FlowModuleHeader.svelte index 319b8b8c3d..1a196757ac 100644 --- a/frontend/src/lib/components/flows/content/FlowModuleHeader.svelte +++ b/frontend/src/lib/components/flows/content/FlowModuleHeader.svelte @@ -3,9 +3,11 @@ import { isEmptyFlowModule } from '$lib/components/flows/flowStateUtils' import type { FlowModule } from '$lib/gen' + import { classNames } from '$lib/utils' - import { faCodeBranch, faSave, faTrashAlt } from '@fortawesome/free-solid-svg-icons' + import { faCodeBranch, faSave, faStop, faTrashAlt } from '@fortawesome/free-solid-svg-icons' import { createEventDispatcher, getContext } from 'svelte' + import Icon from 'svelte-awesome' import type { FlowEditorContext } from '../types' import type { FlowModuleWidthContext } from './FlowModule.svelte' import RemoveStepConfirmationModal from './RemoveStepConfirmationModal.svelte' @@ -23,6 +25,18 @@
+ dispatch('toggleStopAfterIf')} + > + + {module.stop_after_if ? `Early stop` : 'Early stop'} + {#if module.value.type === 'script' && !shouldPick}