mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
feat(frontend): prop picker for stop condition
This commit is contained in:
@@ -366,11 +366,13 @@
|
||||
|
||||
if (shouldBindKey) {
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, function () {
|
||||
code = getCode()
|
||||
format()
|
||||
})
|
||||
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, function () {
|
||||
if (cmdEnterAction) {
|
||||
code = getCode()
|
||||
cmdEnterAction()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
export let automaticLayout = true
|
||||
export let extraLib: string = ''
|
||||
export let extraLibPath: string = ''
|
||||
export let shouldBindKey: boolean = true
|
||||
export let shouldBindKey: boolean = false
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
|
||||
@@ -36,21 +36,21 @@
|
||||
</Tooltip>
|
||||
</span>
|
||||
|
||||
<PropPickerWrapper
|
||||
{pickableProperties}
|
||||
on:select={({ detail }) => {
|
||||
console.log(detail)
|
||||
console.log('test')
|
||||
editor?.insertAtCursor(detail)
|
||||
}}
|
||||
>
|
||||
<SimpleEditor
|
||||
bind:this={editor}
|
||||
lang="javascript"
|
||||
bind:code={$flowStore.value.modules[index].value.iterator.expr}
|
||||
class="small-editor"
|
||||
/>
|
||||
</PropPickerWrapper>
|
||||
<div class="border w-full">
|
||||
<PropPickerWrapper
|
||||
{pickableProperties}
|
||||
on:select={({ detail }) => {
|
||||
editor?.insertAtCursor(detail)
|
||||
}}
|
||||
>
|
||||
<SimpleEditor
|
||||
bind:this={editor}
|
||||
lang="javascript"
|
||||
bind:code={$flowStore.value.modules[index].value.iterator.expr}
|
||||
class="small-editor"
|
||||
/>
|
||||
</PropPickerWrapper>
|
||||
</div>
|
||||
<span class="mb-2 text-sm font-bold">Skip failures</span>
|
||||
|
||||
<Toggle
|
||||
|
||||
@@ -2,13 +2,44 @@
|
||||
import SimpleEditor from '$lib/components/SimpleEditor.svelte'
|
||||
|
||||
import Toggle from '$lib/components/Toggle.svelte'
|
||||
import PropPickerWrapper from '$lib/components/flows/propPicker/PropPickerWrapper.svelte'
|
||||
|
||||
import type { FlowModule } from '$lib/gen'
|
||||
import { getStepPropPicker } from '../flowStateUtils'
|
||||
import { flowStore } from '../flowStore'
|
||||
import { flowStateStore } from '../flowState'
|
||||
import type { FlowEditorContext } from '../types'
|
||||
import { getContext } from 'svelte'
|
||||
|
||||
const { selectedId, previewArgs } = getContext<FlowEditorContext>('FlowEditorContext')
|
||||
|
||||
export let flowModule: FlowModule
|
||||
|
||||
let editor: SimpleEditor | undefined = undefined
|
||||
|
||||
$: isSuspendEnabled = Boolean(flowModule.suspend)
|
||||
$: isStopAfterIfEnabled = Boolean(flowModule.stop_after_if)
|
||||
let pickableProperties: Object = {}
|
||||
|
||||
$: {
|
||||
let indices = $selectedId.split('-').map(Number)
|
||||
if (indices[1]) {
|
||||
indices[1] += 1
|
||||
} else {
|
||||
indices[0] += 1
|
||||
}
|
||||
const props = getStepPropPicker(
|
||||
indices,
|
||||
$flowStore.schema,
|
||||
$flowStateStore,
|
||||
$previewArgs
|
||||
).pickableProperties
|
||||
|
||||
props['result'] = props['previous_result']
|
||||
delete props['previous_result']
|
||||
props.step = props.step?.slice(0, props.step.length - 1)
|
||||
pickableProperties = props
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col items-start space-y-2">
|
||||
@@ -51,20 +82,31 @@
|
||||
/>
|
||||
|
||||
{#if flowModule.stop_after_if}
|
||||
<span class="text-xs font-bold">Stop condition expression</span>
|
||||
|
||||
<SimpleEditor
|
||||
lang="javascript"
|
||||
bind:code={flowModule.stop_after_if.expr}
|
||||
class="few-lines-editor border w-full"
|
||||
/>
|
||||
<span class="text-xs font-bold">Should skip if stopped</span>
|
||||
|
||||
<input type="checkbox" bind:checked={flowModule.stop_after_if.skip_if_stopped} />
|
||||
{:else}
|
||||
|
||||
<span class="text-xs font-bold">Stop condition expression</span>
|
||||
<textarea disabled rows="3" />
|
||||
|
||||
<div class="border w-full">
|
||||
<PropPickerWrapper
|
||||
{pickableProperties}
|
||||
on:select={({ detail }) => {
|
||||
editor?.insertAtCursor(detail)
|
||||
}}
|
||||
>
|
||||
<SimpleEditor
|
||||
bind:this={editor}
|
||||
lang="javascript"
|
||||
bind:code={flowModule.stop_after_if.expr}
|
||||
class="small-editor"
|
||||
/>
|
||||
</PropPickerWrapper>
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-xs font-bold">Should skip if stopped</span>
|
||||
<input type="checkbox" disabled />
|
||||
<span class="text-xs font-bold">Stop condition expression</span>
|
||||
<textarea disabled rows="3" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -206,7 +206,6 @@ export function getStepPropPicker(
|
||||
const flowInput = schemaToObject(flowInputSchema, args)
|
||||
const results = getPreviousResults(flowState.modules, parentIndex)
|
||||
|
||||
console.log(parentIndex)
|
||||
const lastResult =
|
||||
parentIndex == 0
|
||||
? flowInput
|
||||
@@ -228,7 +227,7 @@ export function getStepPropPicker(
|
||||
}
|
||||
|
||||
const innerResults = getPreviousResults(
|
||||
flowState.modules[parentIndex].childFlowModules,
|
||||
flowState.modules[parentIndex]?.childFlowModules,
|
||||
childIndex
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user