diff --git a/cli/apps.ts b/cli/apps.ts index 1330c3ba80..de513b28c6 100644 --- a/cli/apps.ts +++ b/cli/apps.ts @@ -25,7 +25,7 @@ export async function pushApp( return; } alreadySynced.push(localPath); - remotePath.replaceAll(SEP, "/"); + remotePath = remotePath.replaceAll(SEP, "/"); let app: any = undefined; // deleting old app if it exists in raw mode try { diff --git a/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte b/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte index 15817edd25..b87326ff65 100644 --- a/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte +++ b/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte @@ -366,7 +366,7 @@ } dispatch('new', { - kind: 'script', + kind: selectedKind, inlineScript: { language: lang == 'docker' ? 'bash' : lang, kind: selectedKind, diff --git a/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte b/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte index 00e098e9c2..5994d0fdb0 100644 --- a/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte +++ b/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte @@ -91,14 +91,7 @@ ;[module, state] = await createBranchAll(module.id) } $flowStateStore[module.id] = state - if (kind == 'trigger') { - module.summary = 'Trigger' - } else if (kind == 'approval') { - module.summary = 'Approval' - } else if (kind == 'end') { - module.summary = 'Terminate flow' - module.stop_after_if = { skip_if_stopped: false, expr: 'true' } - } + if (inlineScript) { const { language, kind, subkind } = inlineScript ;[module, state] = await createInlineScriptModule( @@ -109,7 +102,22 @@ module.summary ) $flowStateStore[module.id] = state + if (kind == 'trigger') { + module.summary = 'Trigger' + } else if (kind == 'approval') { + module.summary = 'Approval' + } } + + if (kind == 'approval') { + module.suspend = { required_events: 1 } + } else if (kind == 'trigger') { + module.stop_after_if = { + expr: '!result || (Array.isArray(result) && result.length == 0)', + skip_if_stopped: true + } + } + if (!modules) return [module] modules.splice(index, 0, module) return modules @@ -254,6 +262,13 @@ } } } + + function setExpr(module: FlowModule, expr: string) { + if (module.value.type == 'forloopflow') { + module.value.iterator = { type: 'javascript', expr } + module.value.parallel = true + } + } @@ -349,7 +364,7 @@ } else if (shouldRunTutorial('branchall', detail.detail, 3)) { flowTutorials?.runTutorialById('branchall') } else { - if (detail.modules) { + if (detail.modules && Array.isArray(detail.modules)) { await tick() if ($moving) { push(history, $flowStore) @@ -363,19 +378,33 @@ insertNewPreprocessorModule(detail.inlineScript, detail.script) $selectedId = 'preprocessor' } else { + const index = detail.index ?? 0 await insertNewModuleAtIndex( detail.modules, - detail.index ?? 0, + index, detail.kind, detail.script, detail.flow, detail.inlineScript ) - $selectedId = detail.modules[detail.index ?? 0].id + const id = detail.modules[detail.index ?? 0].id + $selectedId = id + + if (detail.kind == 'trigger') { + await insertNewModuleAtIndex( + detail.modules, + index + 1, + 'forloop', + undefined, + undefined, + undefined + ) + setExpr(detail.modules[index + 1], `results.${id}`) + } } } - if (['branchone', 'branchall'].includes(detail.detail)) { + if (['branchone', 'branchall'].includes(detail.kind)) { await addBranch(detail.modules[detail.index ?? 0]) } $flowStateStore = $flowStateStore diff --git a/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte b/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte index 67988e8005..21da7ecb04 100644 --- a/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte +++ b/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte @@ -82,7 +82,7 @@ if (kind == 'flow') { dispatch('pickFlow', { path: item.path }) } else { - dispatch('pickScript', { path: item.path, hash: lockHash ? item.hash : undefined }) + dispatch('pickScript', { path: item.path, hash: lockHash ? item.hash : undefined, kind }) } } } @@ -114,7 +114,7 @@ if (kind == 'flow') { dispatch('pickFlow', { path: path }) } else { - dispatch('pickScript', { path: path, hash: lockHash ? hash : undefined }) + dispatch('pickScript', { path: path, hash: lockHash ? hash : undefined, kind }) } }} > diff --git a/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte b/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte index 584fb44b25..8dbe9d3ad5 100644 --- a/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte +++ b/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte @@ -60,7 +60,6 @@ allowTrigger={data.enableTrigger} modules={data?.modules ?? []} on:new={(e) => { - // console.log('new', e) data?.eventHandlers.insert({ modules: data.modules, index: data.index, @@ -73,7 +72,8 @@ data?.eventHandlers.insert({ modules: data.modules, index: data.index, - script: e.detail + script: e.detail, + kind: e.detail.kind }) }} on:pickFlow={(e) => { @@ -107,7 +107,8 @@ data?.eventHandlers.insert({ modules: data.modules, index: data.index, - script: e.detail + script: e.detail, + kind: e.detail.kind }) }} on:pickFlow={(e) => {