fix webhook issue in automations
This commit is contained in:
parent
b98fc5fc67
commit
e479ced4c8
|
@ -14,7 +14,7 @@ export default class Automation {
|
||||||
}
|
}
|
||||||
|
|
||||||
addTestData(data) {
|
addTestData(data) {
|
||||||
this.automation.testData = data
|
this.automation.testData = { ...this.automation.testData, ...data }
|
||||||
}
|
}
|
||||||
|
|
||||||
addBlock(block, idx) {
|
addBlock(block, idx) {
|
||||||
|
|
|
@ -5,20 +5,24 @@
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
|
||||||
let failedParse = null
|
let failedParse = null
|
||||||
|
let trigger = {}
|
||||||
|
let schemaProperties = {}
|
||||||
|
|
||||||
// clone the trigger so we're not mutating the reference
|
// clone the trigger so we're not mutating the reference
|
||||||
let trigger = cloneDeep(
|
$: trigger = cloneDeep(
|
||||||
$automationStore.selectedAutomation.automation.definition.trigger
|
$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) {
|
if (!$automationStore.selectedAutomation.automation.testData) {
|
||||||
$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
|
// 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
|
// Check the schema to see if required fields have been entered
|
||||||
$: isError = !trigger.schema.outputs.required.every(
|
$: isError = !trigger.schema.outputs.required.every(
|
||||||
required => testData[required]
|
required => testData[required]
|
||||||
|
@ -41,7 +45,6 @@
|
||||||
showConfirmButton={true}
|
showConfirmButton={true}
|
||||||
disabled={isError}
|
disabled={isError}
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
automationStore.actions.addTestDataToAutomation(testData)
|
|
||||||
automationStore.actions.test(
|
automationStore.actions.test(
|
||||||
$automationStore.selectedAutomation?.automation,
|
$automationStore.selectedAutomation?.automation,
|
||||||
testData
|
testData
|
||||||
|
@ -53,7 +56,7 @@
|
||||||
><Tab icon="Form" title="Form">
|
><Tab icon="Form" title="Form">
|
||||||
<div class="tab-content-padding">
|
<div class="tab-content-padding">
|
||||||
<AutomationBlockSetup
|
<AutomationBlockSetup
|
||||||
bind:testData
|
{testData}
|
||||||
{schemaProperties}
|
{schemaProperties}
|
||||||
isTestModal
|
isTestModal
|
||||||
block={trigger}
|
block={trigger}
|
||||||
|
|
|
@ -55,6 +55,15 @@
|
||||||
const onChange = debounce(
|
const onChange = debounce(
|
||||||
async function (e, key) {
|
async function (e, key) {
|
||||||
if (isTestModal) {
|
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
|
testData[key] = e.detail
|
||||||
} else {
|
} else {
|
||||||
block.inputs[key] = e.detail
|
block.inputs[key] = e.detail
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { Icon } from "@budibase/bbui"
|
import { Icon } from "@budibase/bbui"
|
||||||
import { automationStore } from "builderStore"
|
import { automationStore } from "builderStore"
|
||||||
import { database } from "stores/backend"
|
|
||||||
import WebhookDisplay from "./WebhookDisplay.svelte"
|
import WebhookDisplay from "./WebhookDisplay.svelte"
|
||||||
import { ModalContent } from "@budibase/bbui"
|
import { ModalContent } from "@budibase/bbui"
|
||||||
import { onMount, onDestroy } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
|
@ -12,7 +11,6 @@
|
||||||
let schemaURL
|
let schemaURL
|
||||||
let propCount = 0
|
let propCount = 0
|
||||||
|
|
||||||
$: instanceId = $database._id
|
|
||||||
$: automation = $automationStore.selectedAutomation?.automation
|
$: automation = $automationStore.selectedAutomation?.automation
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
|
|
@ -85,6 +85,7 @@ exports.externalTrigger = async function (
|
||||||
automation.definition != null &&
|
automation.definition != null &&
|
||||||
automation.definition.trigger != null &&
|
automation.definition.trigger != null &&
|
||||||
automation.definition.trigger.stepId === definitions.APP.stepId &&
|
automation.definition.trigger.stepId === definitions.APP.stepId &&
|
||||||
|
automation.definition.trigger.stepId === "APP" &&
|
||||||
!checkTestFlag(automation._id)
|
!checkTestFlag(automation._id)
|
||||||
) {
|
) {
|
||||||
// values are likely to be submitted as strings, so we shall convert to correct type
|
// values are likely to be submitted as strings, so we shall convert to correct type
|
||||||
|
|
Loading…
Reference in New Issue