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

View File

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

View File

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