diff --git a/frontend/src/lib/components/flows/flowStateUtils.ts b/frontend/src/lib/components/flows/flowStateUtils.ts index c0106b7ce5..65d4b83f82 100644 --- a/frontend/src/lib/components/flows/flowStateUtils.ts +++ b/frontend/src/lib/components/flows/flowStateUtils.ts @@ -45,12 +45,14 @@ export async function pickScript( path: string, summary: string, id: string, - hash?: string + hash?: string, + kind?: string ): Promise<[FlowModule & { value: PathScript }, FlowModuleState]> { const flowModule: FlowModule & { value: PathScript } = { id, value: { type: 'script', path, hash, input_transforms: {} }, - summary + summary, + isTrigger: kind === 'trigger' } return [flowModule, await loadFlowModuleState(flowModule)] diff --git a/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte b/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte index b854e517f0..daae2f61c5 100644 --- a/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte +++ b/frontend/src/lib/components/flows/map/FlowModuleSchemaMap.svelte @@ -74,10 +74,17 @@ push(history, $flowStore) var module = emptyModule($flowStateStore, $flowStore, kind == 'flow') var state = emptyFlowModuleState() + $flowStateStore[module.id] = state if (wsFlow) { ;[module, state] = await pickFlow(wsFlow.path, wsFlow.summary, module.id) } else if (wsScript) { - ;[module, state] = await pickScript(wsScript.path, wsScript.summary, module.id, wsScript.hash) + ;[module, state] = await pickScript( + wsScript.path, + wsScript.summary, + module.id, + wsScript.hash, + kind + ) } else if (kind == 'forloop') { ;[module, state] = await createLoop( module.id, @@ -89,18 +96,7 @@ ;[module, state] = await createBranches(module.id) } else if (kind == 'branchall') { ;[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) { - console.log('inlineScript', inlineScript) + } else if (inlineScript) { const { language, kind, subkind } = inlineScript ;[module, state] = await createInlineScriptModule( language, @@ -109,8 +105,18 @@ module.id, module.summary ) - $flowStateStore[module.id] = state } + $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 (!modules) return [module] modules.splice(index, 0, module) return modules diff --git a/frontend/src/lib/components/graph/renderers/nodes/TriggersNode.svelte b/frontend/src/lib/components/graph/renderers/nodes/TriggersNode.svelte index 6b135d2cfe..dc544ff38a 100644 --- a/frontend/src/lib/components/graph/renderers/nodes/TriggersNode.svelte +++ b/frontend/src/lib/components/graph/renderers/nodes/TriggersNode.svelte @@ -3,7 +3,6 @@ import TriggersWrapper from '../triggers/TriggersWrapper.svelte' import type { GraphEventHandlers } from '../../graphBuilder' import type { FlowModule } from '$lib/gen' - export let data: { path: string openSchedules: () => void @@ -42,6 +41,7 @@ data?.eventHandlers.insert({ modules: data.modules, index: 0, + kind: 'trigger', script: e.detail }) data?.eventHandlers.insert({