1
0
Fork 0
mirror of synced 2024-10-01 09:38:55 +13:00

fix webhook issue in automations

This commit is contained in:
Peter Clement 2021-10-12 11:00:49 +01:00
parent b98fc5fc67
commit e479ced4c8
5 changed files with 21 additions and 10 deletions

View file

@ -14,7 +14,7 @@ export default class Automation {
}
addTestData(data) {
this.automation.testData = data
this.automation.testData = { ...this.automation.testData, ...data }
}
addBlock(block, idx) {

View file

@ -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 @@
><Tab icon="Form" title="Form">
<div class="tab-content-padding">
<AutomationBlockSetup
bind:testData
{testData}
{schemaProperties}
isTestModal
block={trigger}

View file

@ -55,6 +55,15 @@
const onChange = debounce(
async function (e, key) {
if (isTestModal) {
// Special case for webhook, as it requires a body, but the schema already brings back the body's contents
if (stepId === "WEBHOOK") {
automationStore.actions.addTestDataToAutomation({
body: { [key]: e.detail },
})
}
automationStore.actions.addTestDataToAutomation({
[key]: e.detail,
})
testData[key] = e.detail
} else {
block.inputs[key] = e.detail

View file

@ -1,7 +1,6 @@
<script>
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 () => {

View file

@ -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