fix app action trigger

This commit is contained in:
Peter Clement 2021-10-11 19:38:43 +01:00
parent eba9bd79f6
commit abebe5de12
3 changed files with 27 additions and 11 deletions

View File

@ -9,7 +9,10 @@
Label,
ActionButton,
Drawer,
Modal,
} from "@budibase/bbui"
import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte"
import { automationStore } from "builderStore"
import { tables } from "stores/backend"
import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
@ -27,13 +30,15 @@
import { buildLuceneQuery } from "helpers/lucene"
export let block
export let webhookModal
export let testData
export let schemaProperties
export let isTestModal = false
let webhookModal
let drawer
let tempFilters = lookForFilters(schemaProperties) || []
let fillWidth = true
$: stepId = block.stepId
$: bindings = getAvailableBindings(
block || $automationStore.selectedBlock,
@ -205,7 +210,10 @@
{bindings}
/>
{:else if value.customType === "webhookUrl"}
<WebhookDisplay value={inputData[key]} />
<WebhookDisplay
on:change={e => onChange(e, key)}
value={inputData[key]}
/>
{:else if value.customType === "triggerSchema"}
<SchemaSetup on:change={e => onChange(e, key)} value={inputData[key]} />
{:else if value.customType === "code"}
@ -247,6 +255,10 @@
</div>
{/each}
</div>
<Modal bind:this={webhookModal} width="30%">
<CreateWebhookModal />
</Modal>
{#if stepId === "WEBHOOK"}
<Button secondary on:click={() => webhookModal.show()}>Set Up Webhook</Button>
{/if}

View File

@ -22,6 +22,7 @@ exports.definition = {
fields: {
type: "object",
description: "Fields submitted from the app frontend",
customType: "triggerSchema",
},
},
required: ["fields"],

View File

@ -81,16 +81,19 @@ exports.externalTrigger = async function (
params,
{ getResponses } = {}
) {
if (automation.definition != null && automation.definition.trigger != null) {
if (automation.definition.trigger.stepId === "APP") {
// values are likely to be submitted as strings, so we shall convert to correct type
const coercedFields = {}
const fields = automation.definition.trigger.inputs.fields
for (let key of Object.keys(fields)) {
coercedFields[key] = coerce(params.fields[key], fields[key])
}
params.fields = coercedFields
if (
automation.definition != null &&
automation.definition.trigger != null &&
automation.definition.trigger.stepId === definitions.APP.stepId &&
!checkTestFlag(automation._id)
) {
// values are likely to be submitted as strings, so we shall convert to correct type
const coercedFields = {}
const fields = automation.definition.trigger.inputs.fields
for (let key of Object.keys(fields)) {
coercedFields[key] = coerce(params.fields[key], fields[key])
}
params.fields = coercedFields
}
const data = { automation, event: params }
if (getResponses) {