From 7817d65eb30a24acd9cba5b4249335e2aafa28f8 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 25 Mar 2022 09:26:55 +0000 Subject: [PATCH 01/16] Automation foreach block --- .../FlowChart/ActionModal.svelte | 1 + .../FlowChart/FlowItem.svelte | 180 +++++++++++++----- .../SetupPanel/AutomationBlockSetup.svelte | 14 ++ packages/server/src/automations/actions.js | 3 + packages/server/src/automations/steps/loop.js | 47 +++++ packages/server/src/threads/automation.js | 103 ++++++---- 6 files changed, 270 insertions(+), 78 deletions(-) create mode 100644 packages/server/src/automations/steps/loop.js diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte index 4e1e5e1103..caf8835b86 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte @@ -39,6 +39,7 @@ if (v.internal) { acc[k] = v } + delete acc.LOOP return acc }, {}) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 69dd67724a..5bd250572e 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -9,8 +9,8 @@ Modal, Button, StatusLight, - ActionButton, Select, + Label, notifications, } from "@budibase/bbui" import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte" @@ -25,7 +25,6 @@ let webhookModal let actionModal let resultsModal - let setupToggled let blockComplete $: rowControl = $automationStore.selectedAutomation.automation.rowControl @@ -52,6 +51,8 @@ block.schema?.inputs?.properties || {} ).every(x => block?.inputs[x]) + $: loopingSelected = !!block.llop + $: showLooping = false async function deleteStep() { try { automationStore.actions.deleteAutomationBlock(block) @@ -76,6 +77,37 @@ ) } + /* + async function removeLooping() { + loopingSelected = false + const idx = + $automationStore.selectedAutomation.automation.definition.steps.findIndex( + x => x.id === block.id + ) + + delete $automationStore.selectedAutomation.automation.definition.steps[idx] + .loop + + await automationStore.actions.save( + $automationStore.selectedAutomation?.automation + ) + }*/ + async function addLooping() { + loopingSelected = true + const loopDefinition = $automationStore.blockDefinitions.ACTION.LOOP + + const loopBlock = $automationStore.selectedAutomation.constructBlock( + "ACTION", + "LOOP", + loopDefinition + ) + loopBlock.blockToLoop = block.id + automationStore.actions.addBlockToAutomation(loopBlock, blockIdx - 1) + await automationStore.actions.save( + $automationStore.selectedAutomation?.automation + ) + } + async function onSelect(block) { await automationStore.update(state => { state.selectedBlock = block @@ -84,13 +116,61 @@ } -
{ - onSelect(block) - }} -> +
{}}> + {#if loopingSelected} +
+
{ + showLooping = !showLooping + }} + class="splitHeader" + > +
+ + + +
+ Looping +
+
+ +
+
{ + onSelect(block) + }} + > + +
+
+
+
+ + {#if !showLooping} +
+ + + +
+ + {/if} + {/if} +
{ @@ -127,34 +207,42 @@ {block?.name?.toUpperCase() || ""}
- {#if testResult && testResult[0]} - resultsModal.show()}> - View response - - {/if} +
+ {#if testResult && testResult[0]} +
resultsModal.show()}> + View response +
+ {/if} +
{ + onSelect(block) + }} + > + +
+
{#if !blockComplete}
-
- { - onSelect(block) - setupToggled = !setupToggled - }} - quiet - icon={setupToggled ? "ChevronDown" : "ChevronRight"} - > - Setup - - {#if !isTrigger} + {#if !isTrigger} +
+ {#if !loopingSelected} +
addLooping()}> + +
+ +
+
+ {/if} {#if showBindingPicker}
onChange(e, key)} + autoWidth + value={inputData[key]} + options={["Array", "String"]} + defaultValue={"Array"} + /> {:else if value.type === "string" || value.type === "number" || value.type === "integer"} {#if isTestModal} { - return stepFn({ - inputs: step.inputs, - appId: this._appId, - emitter: this._emitter, - context: this._context, - }) - }) - this._context.steps.push(outputs) - // if filter causes us to stop execution don't break the loop, set a var - // so that we can finish iterating through the steps and record that it stopped - if (step.stepId === FILTER_STEP_ID && !outputs.success) { - stopped = true - this.updateExecutionOutput(step.id, step.stepId, step.inputs, { - ...outputs, - ...STOPPED_STATUS, - }) + + let iterations = loopStep ? loopStep.inputs.iterations : 1 + for (let index = 0; index < iterations; index++) { + // execution stopped, record state for that + if (stopped) { + this.updateExecutionOutput(step.id, step.stepId, {}, STOPPED_STATUS) continue } - this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs) - } catch (err) { - console.error(`Automation error - ${step.stepId} - ${err}`) - return err + + // If it's a loop step, we need to manually add the bindings to the context + if (loopStep) { + this._context.steps[loopStepNumber] = { + currentItem: loopStep.inputs.binding.split(",")[index], + } + } + + let stepFn = await this.getStepFunctionality(step.stepId) + console.log(step.inputs) + + step.inputs = await processObject(step.inputs, this._context) + step.inputs = automationUtils.cleanInputValues( + step.inputs, + step.schema.inputs + ) + console.log(step.inputs) + try { + // appId is always passed + let tenantId = app.tenantId || DEFAULT_TENANT_ID + const outputs = await doInTenant(tenantId, () => { + return stepFn({ + inputs: step.inputs, + appId: this._appId, + emitter: this._emitter, + context: this._context, + }) + }) + this._context.steps[stepCount] = outputs + // if filter causes us to stop execution don't break the loop, set a var + // so that we can finish iterating through the steps and record that it stopped + if (step.stepId === FILTER_STEP_ID && !outputs.success) { + stopped = true + this.updateExecutionOutput(step.id, step.stepId, step.inputs, { + ...outputs, + ...STOPPED_STATUS, + }) + continue + } + // THE OUTPUTS GET SET IN THE CONSTRUCTOR SO WE NEED TO RESET THEM + + this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs) + console.log(this.executionOutput.input) + } catch (err) { + console.error(`Automation error - ${step.stepId} - ${err}`) + return err + } + if (index === iterations - 1) { + loopStep = null + break + } } } - // Increment quota for automation runs if (!env.SELF_HOSTED && !isDevAppID(this._appId)) { await usage.update(usage.Properties.AUTOMATION, 1) } + // make that we don't loop the next step if we have already been looping (loop block only has one step) + return this.executionOutput } } From 25258ba055e405cd7e1d8484453e8bc88cb52c39 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 25 Mar 2022 10:52:22 +0000 Subject: [PATCH 02/16] improve context handling --- packages/server/src/threads/automation.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index bfa3966863..64d68ab66b 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -16,6 +16,7 @@ const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId const CRON_STEP_ID = triggerDefs.CRON.stepId const STOPPED_STATUS = { success: false, status: "STOPPED" } +const { cloneDeep } = require("lodash/fp") /** * The automation orchestrator is a class responsible for executing automations. @@ -96,6 +97,7 @@ class Orchestrator { let iterations = loopStep ? loopStep.inputs.iterations : 1 for (let index = 0; index < iterations; index++) { + let originalStepInput = cloneDeep(step.inputs) // execution stopped, record state for that if (stopped) { this.updateExecutionOutput(step.id, step.stepId, {}, STOPPED_STATUS) @@ -108,22 +110,15 @@ class Orchestrator { currentItem: loopStep.inputs.binding.split(",")[index], } } - let stepFn = await this.getStepFunctionality(step.stepId) - console.log(step.inputs) - - step.inputs = await processObject(step.inputs, this._context) - step.inputs = automationUtils.cleanInputValues( - step.inputs, - step.schema.inputs - ) - console.log(step.inputs) + let inputs = await processObject(originalStepInput, this._context) + inputs = automationUtils.cleanInputValues(inputs, step.schema.inputs) try { // appId is always passed let tenantId = app.tenantId || DEFAULT_TENANT_ID const outputs = await doInTenant(tenantId, () => { return stepFn({ - inputs: step.inputs, + inputs: inputs, appId: this._appId, emitter: this._emitter, context: this._context, @@ -143,7 +138,6 @@ class Orchestrator { // THE OUTPUTS GET SET IN THE CONSTRUCTOR SO WE NEED TO RESET THEM this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs) - console.log(this.executionOutput.input) } catch (err) { console.error(`Automation error - ${step.stepId} - ${err}`) return err From 73151722ec106af00bd40bdae6dc206658a9fb5c Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 28 Mar 2022 10:01:56 +0100 Subject: [PATCH 03/16] update bindings to support looping --- .../builderStore/store/automation/index.js | 1 + .../FlowChart/FlowChart.svelte | 4 +- .../FlowChart/FlowItem.svelte | 28 ++++++---- .../SetupPanel/AutomationBlockSetup.svelte | 6 --- packages/server/src/automations/steps/loop.js | 12 ++++- packages/server/src/threads/automation.js | 51 +++++++++++++++++-- 6 files changed, 78 insertions(+), 24 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index 84e6033439..7e61b410e4 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -98,6 +98,7 @@ const automationActions = store => ({ automationId: automation?._id, testData, }) + console.log(result) store.update(state => { state.selectedAutomation.testResults = result return state diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte index ca04fed8df..505a0b9aca 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte @@ -72,7 +72,9 @@ animate:flip={{ duration: 500 }} in:fly|local={{ x: 500, duration: 1500 }} > - + {#if block.stepId !== "LOOP"} + + {/if}
{/each}
diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 5bd250572e..00b2366657 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -34,6 +34,7 @@ $: testResult = $automationStore.selectedAutomation.testResults?.steps.filter( step => (block.id ? step.id === block.id : step.stepId === block.stepId) ) + $: console.log(testResult) $: isTrigger = block.type === "TRIGGER" $: selected = $automationStore.selectedBlock?.id === block.id @@ -51,7 +52,10 @@ block.schema?.inputs?.properties || {} ).every(x => block?.inputs[x]) - $: loopingSelected = !!block.llop + $: loopingSelected = + $automationStore.selectedAutomation?.automation.definition.steps.find( + x => x.blockToLoop === block.id + ) $: showLooping = false async function deleteStep() { try { @@ -77,21 +81,18 @@ ) } - /* async function removeLooping() { loopingSelected = false - const idx = + const loopToDelete = $automationStore.selectedAutomation.automation.definition.steps.findIndex( - x => x.id === block.id + x => x.blockToLoop === block.id ) - delete $automationStore.selectedAutomation.automation.definition.steps[idx] - .loop - + automationStore.actions.deleteAutomationBlock(loopToDelete) await automationStore.actions.save( $automationStore.selectedAutomation?.automation ) - }*/ + } async function addLooping() { loopingSelected = true const loopDefinition = $automationStore.blockDefinitions.ACTION.LOOP @@ -152,18 +153,25 @@
+ {#if !showLooping}
+
+
deleteStep()}> + +
+
x.blockToLoop === block.id + )} {webhookModal} - isLoop={true} />
diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 19847a5196..2b4be4bb29 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -35,7 +35,6 @@ export let testData export let schemaProperties export let isTestModal = false - export let isLoop = false let webhookModal let drawer let tempFilters = lookForFilters(schemaProperties) || [] @@ -74,11 +73,6 @@ await automationStore.actions.save( $automationStore.selectedAutomation?.automation ) - } else if (isLoop) { - block.loop[key] = e.detail - await automationStore.actions.save( - $automationStore.selectedAutomation?.automation - ) } else { block.inputs[key] = e.detail await automationStore.actions.save( diff --git a/packages/server/src/automations/steps/loop.js b/packages/server/src/automations/steps/loop.js index 48b20ff277..1f53210269 100644 --- a/packages/server/src/automations/steps/loop.js +++ b/packages/server/src/automations/steps/loop.js @@ -11,7 +11,7 @@ exports.definition = { properties: { option: { customType: "loopOption", - title: "Whether it's an array or a string", + title: "Input type", }, binding: { type: "string", @@ -30,10 +30,18 @@ exports.definition = { }, outputs: { properties: { - currentItem: { + items: { customType: "item", description: "the item currently being executed", }, + success: { + type: "boolean", + description: "Whether the message sent successfully", + }, + iterations: { + type: "number", + descriptions: "The amount of times the block ran", + }, }, required: ["success"], }, diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index 64d68ab66b..666403d595 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -17,6 +17,7 @@ const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId const CRON_STEP_ID = triggerDefs.CRON.stepId const STOPPED_STATUS = { success: false, status: "STOPPED" } const { cloneDeep } = require("lodash/fp") +const { loop } = require("svelte/internal") /** * The automation orchestrator is a class responsible for executing automations. @@ -87,6 +88,7 @@ class Orchestrator { let stepCount = 0 let loopStepNumber + let loopSteps = [] for (let step of automation.definition.steps) { stepCount++ if (step.stepId === LOOP_STEP_ID) { @@ -94,10 +96,18 @@ class Orchestrator { loopStepNumber = stepCount continue } + let iterations = loopStep ? loopStep.inputs.binding.split(",").length : 1 - let iterations = loopStep ? loopStep.inputs.iterations : 1 for (let index = 0; index < iterations; index++) { let originalStepInput = cloneDeep(step.inputs) + + /* + if (step.stepId === LOOP_STEP_ID && index >= loopStep.inputs.iterations) { + this.executionOutput.steps[loopStepNumber].outputs.status = "Loop Broken" + break + } + + */ // execution stopped, record state for that if (stopped) { this.updateExecutionOutput(step.id, step.stepId, {}, STOPPED_STATUS) @@ -135,25 +145,56 @@ class Orchestrator { }) continue } - // THE OUTPUTS GET SET IN THE CONSTRUCTOR SO WE NEED TO RESET THEM - - this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs) + if (loopStep) { + loopSteps.push({ + id: step.id, + stepId: step.stepId, + inputs: step.inputs, + outputs, + }) + } else { + this.updateExecutionOutput( + step.id, + step.stepId, + step.inputs, + outputs + ) + } } catch (err) { console.error(`Automation error - ${step.stepId} - ${err}`) return err } + if (index === iterations - 1) { loopStep = null break } } + if (loopSteps) { + this.executionOutput.steps.splice(loopStepNumber, 0, { + id: step.id, + stepId: step.stepId, + outputs: { + success: true, + outputs: loopSteps, + iterations: iterations, + }, + }) + this._context.steps.splice(loopStepNumber, 0, { + id: step.id, + stepId: step.stepId, + steps: loopSteps, + iterations, + success: true, + }) + loopSteps = null + } } // Increment quota for automation runs if (!env.SELF_HOSTED && !isDevAppID(this._appId)) { await usage.update(usage.Properties.AUTOMATION, 1) } // make that we don't loop the next step if we have already been looping (loop block only has one step) - return this.executionOutput } } From 006bf368bba662dca90612596689096cd4affeff Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 29 Mar 2022 10:29:51 +0100 Subject: [PATCH 04/16] more parsing of output bindings --- .../builderStore/store/automation/index.js | 1 - .../FlowChart/FlowItem.svelte | 25 ++++++------ .../SetupPanel/AutomationBlockSetup.svelte | 9 ++++- packages/server/src/automations/steps/loop.js | 2 +- packages/server/src/threads/automation.js | 40 ++++++++----------- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index 7e61b410e4..84e6033439 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -98,7 +98,6 @@ const automationActions = store => ({ automationId: automation?._id, testData, }) - console.log(result) store.update(state => { state.selectedAutomation.testResults = result return state diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 00b2366657..5a00b3e790 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -34,7 +34,6 @@ $: testResult = $automationStore.selectedAutomation.testResults?.steps.filter( step => (block.id ? step.id === block.id : step.stepId === block.stepId) ) - $: console.log(testResult) $: isTrigger = block.type === "TRIGGER" $: selected = $automationStore.selectedBlock?.id === block.id @@ -57,6 +56,7 @@ x => x.blockToLoop === block.id ) $: showLooping = false + async function deleteStep() { try { automationStore.actions.deleteAutomationBlock(block) @@ -81,18 +81,6 @@ ) } - async function removeLooping() { - loopingSelected = false - const loopToDelete = - $automationStore.selectedAutomation.automation.definition.steps.findIndex( - x => x.blockToLoop === block.id - ) - - automationStore.actions.deleteAutomationBlock(loopToDelete) - await automationStore.actions.save( - $automationStore.selectedAutomation?.automation - ) - } async function addLooping() { loopingSelected = true const loopDefinition = $automationStore.blockDefinitions.ACTION.LOOP @@ -103,6 +91,7 @@ loopDefinition ) loopBlock.blockToLoop = block.id + block.loopBlock = loopBlock.id automationStore.actions.addBlockToAutomation(loopBlock, blockIdx - 1) await automationStore.actions.save( $automationStore.selectedAutomation?.automation @@ -142,6 +131,16 @@
+ {#if testResult && testResult[0]} +
resultsModal.show()}> + View response +
+ {/if} +
{ diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 2b4be4bb29..bd309d9809 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -104,7 +104,13 @@ ) bindings = bindings.concat( outputs.map(([name, value]) => { - const runtime = idx === 0 ? `trigger.${name}` : `steps.${idx}.${name}` + let runtimeName = + $automationStore.selectedAutomation.automation.definition.steps.find( + x => block.id === x.blockToLoop + ) + ? `loop.${name}` + : `steps.${idx}.${name}` + const runtime = idx === 0 ? `trigger.${name}` : runtimeName return { label: runtime, type: value.type, @@ -115,6 +121,7 @@ }) ) } + return bindings } diff --git a/packages/server/src/automations/steps/loop.js b/packages/server/src/automations/steps/loop.js index 1f53210269..543317f3be 100644 --- a/packages/server/src/automations/steps/loop.js +++ b/packages/server/src/automations/steps/loop.js @@ -36,7 +36,7 @@ exports.definition = { }, success: { type: "boolean", - description: "Whether the message sent successfully", + description: "Whether the message loop was successfully", }, iterations: { type: "number", diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index 666403d595..8ebad28f9a 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -17,7 +17,6 @@ const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId const CRON_STEP_ID = triggerDefs.CRON.stepId const STOPPED_STATUS = { success: false, status: "STOPPED" } const { cloneDeep } = require("lodash/fp") -const { loop } = require("svelte/internal") /** * The automation orchestrator is a class responsible for executing automations. @@ -89,6 +88,7 @@ class Orchestrator { let stepCount = 0 let loopStepNumber let loopSteps = [] + let lastLoopStep for (let step of automation.definition.steps) { stepCount++ if (step.stepId === LOOP_STEP_ID) { @@ -145,13 +145,9 @@ class Orchestrator { }) continue } - if (loopStep) { - loopSteps.push({ - id: step.id, - stepId: step.stepId, - inputs: step.inputs, - outputs, - }) + this._context.steps.splice(loopStepNumber, 1) + if (loopStep && loopSteps) { + loopSteps.push(outputs) } else { this.updateExecutionOutput( step.id, @@ -166,34 +162,30 @@ class Orchestrator { } if (index === iterations - 1) { + lastLoopStep = loopStep loopStep = null break } } - if (loopSteps) { - this.executionOutput.steps.splice(loopStepNumber, 0, { - id: step.id, - stepId: step.stepId, - outputs: { - success: true, - outputs: loopSteps, - iterations: iterations, - }, - }) - this._context.steps.splice(loopStepNumber, 0, { - id: step.id, - stepId: step.stepId, - steps: loopSteps, - iterations, - success: true, + + if (loopSteps && loopSteps.length) { + let tempOutput = { success: true, outputs: loopSteps } + this.executionOutput.steps.splice(loopStep, 0, { + id: lastLoopStep.id, + stepId: lastLoopStep.stepId, + outputs: tempOutput, + inputs: step.inputs, }) + this._context.steps.splice(loopStep, 0, tempOutput) loopSteps = null } } + // Increment quota for automation runs if (!env.SELF_HOSTED && !isDevAppID(this._appId)) { await usage.update(usage.Properties.AUTOMATION, 1) } + console.log(JSON.stringify(this._context, null, 2)) // make that we don't loop the next step if we have already been looping (loop block only has one step) return this.executionOutput } From 999199dcf6a895e01192015db54237112408cbf6 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 11 Apr 2022 10:26:59 +0100 Subject: [PATCH 05/16] Add handling for failure conditions --- .../FlowChart/FlowItem.svelte | 12 +- .../FlowChart/ResultsModal.svelte | 17 +- .../SetupPanel/AutomationBlockSetup.svelte | 54 ++++-- packages/server/src/automations/steps/loop.js | 5 - packages/server/src/threads/automation.js | 173 +++++++++++++++--- 5 files changed, 205 insertions(+), 56 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 5a00b3e790..d1659e51d1 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -92,7 +92,7 @@ ) loopBlock.blockToLoop = block.id block.loopBlock = loopBlock.id - automationStore.actions.addBlockToAutomation(loopBlock, blockIdx - 1) + automationStore.actions.addBlockToAutomation(loopBlock, blockIdx) await automationStore.actions.save( $automationStore.selectedAutomation?.automation ) @@ -131,16 +131,6 @@
- {#if testResult && testResult[0]} -
resultsModal.show()}> - View response -
- {/if} -
{ diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte index 7dfdff20a7..67c7f493e8 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ResultsModal.svelte @@ -1,5 +1,5 @@