From e7e79bbaf7048d181b357dfb48c006a49a75fc20 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 4 Dec 2022 01:02:33 +0100 Subject: [PATCH] UX improvements --- backend/windmill-worker/src/worker_flow.rs | 8 +- .../src/lib/components/ScriptEditor.svelte | 90 ++++++++++--------- .../flows/content/FlowBranchesWrapper.svelte | 11 ++- .../components/flows/content/FlowLoop.svelte | 11 ++- .../flows/content/FlowModuleComponent.svelte | 12 ++- .../flows/content/FlowModuleSleep.svelte | 80 +++++++++++++++++ .../flows/content/FlowModuleSuspend.svelte | 71 +-------------- .../flows/propPicker/PropPickerWrapper.svelte | 11 ++- .../propertyPicker/PropPickerResult.svelte | 4 +- frontend/src/routes/index.svelte | 2 +- 10 files changed, 174 insertions(+), 126 deletions(-) create mode 100644 frontend/src/lib/components/flows/content/FlowModuleSleep.svelte diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index 7d6a7a5abd..10fd75bf76 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -818,7 +818,11 @@ async fn push_next_flow_job( InputTransform::Static { value } => value, InputTransform::Javascript { expr } => eval_timeout( expr.to_string(), - [("result".to_string(), last_result.clone())].into(), + [ + ("flow_input".to_string(), flow_input), + ("result".to_string(), last_result.clone()), + ] + .into(), None, None, "".to_string(), @@ -835,7 +839,7 @@ async fn push_next_flow_job( n.as_u64().map(|x| from_now(Duration::from_secs(x))) } _ => Err(Error::ExecutionErr(format!( - "Expected an array value, found: {json_value}" + "Expected a number value, found: {json_value}" )))?, } } else { diff --git a/frontend/src/lib/components/ScriptEditor.svelte b/frontend/src/lib/components/ScriptEditor.svelte index 7f3285621c..f7688fc818 100644 --- a/frontend/src/lib/components/ScriptEditor.svelte +++ b/frontend/src/lib/components/ScriptEditor.svelte @@ -165,50 +165,52 @@ - - -
Preview
-
-
- +
+
+ {#if testIsLoading} + + {:else} + + {/if} +
+ + +
+
+ +
-
- - -
- {#if testIsLoading} - - {:else} - - {/if} -
- -
- + + + + + +
diff --git a/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte b/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte index 6a4e2e0aa9..e6989e1067 100644 --- a/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte +++ b/frontend/src/lib/components/flows/content/FlowBranchesWrapper.svelte @@ -11,6 +11,7 @@ import FlowCard from '../common/FlowCard.svelte' import type { FlowEditorContext } from '../types' import FlowModuleEarlyStop from './FlowModuleEarlyStop.svelte' + import FlowModuleSleep from './FlowModuleSleep.svelte' import FlowModuleSuspend from './FlowModuleSuspend.svelte' // import FlowRetries from './FlowRetries.svelte' @@ -117,7 +118,8 @@ Early Stop - Sleep/Suspend + Suspend + Sleep
@@ -135,7 +137,12 @@
- + +
+
+ +
+
diff --git a/frontend/src/lib/components/flows/content/FlowLoop.svelte b/frontend/src/lib/components/flows/content/FlowLoop.svelte index eb52361ada..dc1eb23298 100644 --- a/frontend/src/lib/components/flows/content/FlowLoop.svelte +++ b/frontend/src/lib/components/flows/content/FlowLoop.svelte @@ -15,6 +15,7 @@ import { getStepPropPicker } from '../previousResults' import { flowStateStore } from '../flowState' import { flowStore } from '../flowStore' + import FlowModuleSleep from './FlowModuleSleep.svelte' const { previewArgs } = getContext('FlowEditorContext') @@ -98,7 +99,8 @@ Early Stop - Sleep/Suspend + Suspend + Sleep
@@ -116,7 +118,12 @@
- + +
+
+ +
+
diff --git a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte index 1286289e1f..b6499283ef 100644 --- a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte +++ b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte @@ -25,6 +25,7 @@ import Button from '$lib/components/common/button/Button.svelte' import Alert from '$lib/components/common/alert/Alert.svelte' + import FlowModuleSleep from './FlowModuleSleep.svelte' const { selectedId, previewArgs } = getContext('FlowEditorContext') @@ -56,7 +57,7 @@ $: stepPropPicker = failureModule ? { pickableProperties: { - flow_input: $flowStateStore.previewArgs, + flow_input: $previewArgs, priorIds: {}, previousId: undefined }, @@ -221,7 +222,8 @@ Retries {#if !$selectedId.includes('failure')} Early Stop - Sleep/Suspend + Suspend + Sleep Same Worker/Shared dir {/if}
@@ -231,7 +233,11 @@ {:else if selected === 'advanced-suspend'}
- + +
+ {:else if selected === 'advanced-sleep'} +
+
{:else if selected === 'advanced-same_worker'}
diff --git a/frontend/src/lib/components/flows/content/FlowModuleSleep.svelte b/frontend/src/lib/components/flows/content/FlowModuleSleep.svelte new file mode 100644 index 0000000000..d93c11a41e --- /dev/null +++ b/frontend/src/lib/components/flows/content/FlowModuleSleep.svelte @@ -0,0 +1,80 @@ + + +

Sleep + If defined, at the end of the step, the flow will sleep for a number of seconds before + scheduling the next job (if any, no effect if the step is the last one). Sleeping is passive and + does not consume any resources.

+ { + if (isSleepEnabled && flowModule.sleep != undefined) { + flowModule.sleep = undefined + } else { + flowModule.sleep = { + type: 'static', + value: 0 + } + } + }} + options={{ + right: 'Sleep after module successful execution' + }} +/> +
+ Sleep for duration (seconds) + + {#if flowModule.sleep && schema.properties['sleep']} +
+ { + editor?.insertAtCursor(detail) + }} + > + + +
+ {:else} + + {/if} +
diff --git a/frontend/src/lib/components/flows/content/FlowModuleSuspend.svelte b/frontend/src/lib/components/flows/content/FlowModuleSuspend.svelte index 36aa72910e..03e94cd4dc 100644 --- a/frontend/src/lib/components/flows/content/FlowModuleSuspend.svelte +++ b/frontend/src/lib/components/flows/content/FlowModuleSuspend.svelte @@ -1,20 +1,11 @@

Suspend If defined, at the end of the step, the flow will be suspended until it receives external requests to be resumed or canceled. This is most useful to implement approval steps but can be - used flexibly for other purpose. To get the resume urls, use `wmill.getResumeEndpoints`.

- Number of approvals required for resuming flow + Number of approvals/events required for resuming flow {#if flowModule.suspend} @@ -70,53 +57,3 @@ {/if}
- -

Sleep - If defined, at the end of the step, the flow will sleep for a number of seconds before - scheduling the next job (if any, no effect if the step is the last one). Sleeping is passive and - does not consume any resources.

- { - if (isSleepEnabled && flowModule.sleep != undefined) { - flowModule.sleep = undefined - } else { - flowModule.sleep = { - type: 'static', - value: 0 - } - } - }} - options={{ - right: 'Sleep after module successful execution' - }} -/> -
- Sleep for duration (seconds) - - {#if flowModule.sleep && schema.properties['sleep']} -
- { - editor?.insertAtCursor(detail) - }} - > - - -
- {:else} - - {/if} -
diff --git a/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte b/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte index dfad34f90f..cdf3423a72 100644 --- a/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte +++ b/frontend/src/lib/components/flows/propPicker/PropPickerWrapper.svelte @@ -9,7 +9,6 @@ onSelect: SelectCallback } - writable export type PropPickerWrapperContext = { propPickerConfig: Writable focusProp: (propName: string, insertionMode: InsertionMode, onSelect: SelectCallback) => void @@ -55,7 +54,15 @@ {#if result} - + { + dispatch('select', detail) + if ($propPickerConfig?.onSelect(detail)) { + propPickerConfig.set(undefined) + } + }} + /> {:else if pickableProperties} - import { createEventDispatcher } from 'svelte' - import ObjectViewer from './ObjectViewer.svelte' export let result: any -
+
Result
diff --git a/frontend/src/routes/index.svelte b/frontend/src/routes/index.svelte index f9afb49c5f..7aa66cb5eb 100644 --- a/frontend/src/routes/index.svelte +++ b/frontend/src/routes/index.svelte @@ -96,7 +96,7 @@ {#if $workspaceStore == 'demo'}
- All uers get an invitation to this workspace. + All users get an invitation to this workspace. {:else if $workspaceStore == 'starter'}