From e479ced4c88291dc574521ad1b321968084a1010 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 12 Oct 2021 11:00:49 +0100 Subject: [PATCH] fix webhook issue in automations --- .../builderStore/store/automation/Automation.js | 2 +- .../FlowChart/TestDataModal.svelte | 17 ++++++++++------- .../SetupPanel/AutomationBlockSetup.svelte | 9 +++++++++ .../automation/Shared/CreateWebhookModal.svelte | 2 -- packages/server/src/automations/triggers.js | 1 + 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/Automation.js b/packages/builder/src/builderStore/store/automation/Automation.js index 49928c69a9..af0c03cb5a 100644 --- a/packages/builder/src/builderStore/store/automation/Automation.js +++ b/packages/builder/src/builderStore/store/automation/Automation.js @@ -14,7 +14,7 @@ export default class Automation { } addTestData(data) { - this.automation.testData = data + this.automation.testData = { ...this.automation.testData, ...data } } addBlock(block, idx) { diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte index 8caba9d351..3c75c9963d 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte @@ -5,20 +5,24 @@ import { cloneDeep } from "lodash/fp" let failedParse = null + let trigger = {} + let schemaProperties = {} + // clone the trigger so we're not mutating the reference - let trigger = cloneDeep( + $: trigger = cloneDeep( $automationStore.selectedAutomation.automation.definition.trigger ) - let schemaProperties = Object.entries(trigger.schema.outputs.properties || {}) + + // get the outputs so we can define the fields + $: schemaProperties = Object.entries(trigger?.schema?.outputs?.properties) if (!$automationStore.selectedAutomation.automation.testData) { $automationStore.selectedAutomation.automation.testData = {} } - // get the outputs so we can define the fields - // check to see if there is existing test data in the store - $: testData = $automationStore.selectedAutomation.automation.testData + $: testData = $automationStore.selectedAutomation.automation.testData || {} + // Check the schema to see if required fields have been entered $: isError = !trigger.schema.outputs.required.every( required => testData[required] @@ -41,7 +45,6 @@ showConfirmButton={true} disabled={isError} onConfirm={() => { - automationStore.actions.addTestDataToAutomation(testData) automationStore.actions.test( $automationStore.selectedAutomation?.automation, testData @@ -53,7 +56,7 @@ >
import { Icon } from "@budibase/bbui" import { automationStore } from "builderStore" - import { database } from "stores/backend" import WebhookDisplay from "./WebhookDisplay.svelte" import { ModalContent } from "@budibase/bbui" import { onMount, onDestroy } from "svelte" @@ -12,7 +11,6 @@ let schemaURL let propCount = 0 - $: instanceId = $database._id $: automation = $automationStore.selectedAutomation?.automation onMount(async () => { diff --git a/packages/server/src/automations/triggers.js b/packages/server/src/automations/triggers.js index f774c23123..e6c722ce3e 100644 --- a/packages/server/src/automations/triggers.js +++ b/packages/server/src/automations/triggers.js @@ -85,6 +85,7 @@ exports.externalTrigger = async function ( automation.definition != null && automation.definition.trigger != null && automation.definition.trigger.stepId === definitions.APP.stepId && + automation.definition.trigger.stepId === "APP" && !checkTestFlag(automation._id) ) { // values are likely to be submitted as strings, so we shall convert to correct type