From 5bf9ee38a037fec271577548b170522576b594c0 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Tue, 26 Jul 2022 16:33:27 +0100 Subject: [PATCH 1/2] fixed automation app:trigger not mapping test modal form --- .../FlowChart/TestDataModal.svelte | 22 ++-- .../SetupPanel/AutomationBlockSetup.svelte | 46 +++++-- .../SetupPanel/FieldSelector.svelte | 116 ++++++++++++++++++ 3 files changed, 164 insertions(+), 20 deletions(-) create mode 100644 packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte index b86cffb1f9..86eec36094 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte @@ -15,16 +15,22 @@ let trigger = {} let schemaProperties = {} - // clone the trigger so we're not mutating the reference - $: trigger = cloneDeep( - $automationStore.selectedAutomation.automation.definition.trigger - ) + $: trigger + $: schemaProperties + $: { + // clone the trigger so we're not mutating the reference + trigger = cloneDeep( + $automationStore.selectedAutomation.automation.definition.trigger + ) - // get the outputs so we can define the fields - $: schemaProperties = Object.entries(trigger?.schema?.outputs?.properties) + // get the outputs so we can define the fields + let schema = Object.entries(trigger.schema?.outputs?.properties || {}) - if (!$automationStore.selectedAutomation.automation.testData) { - $automationStore.selectedAutomation.automation.testData = {} + if (trigger?.event === "app:trigger") { + schema = Object.entries({ fields: { customType: "fields" } }) + } + + schemaProperties = schema } // check to see if there is existing test data in the store diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 8b34cf8cd2..b8f403b452 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -1,6 +1,7 @@ + +FieldSelector + +{#if schemaFields.length && isTestModal} +
+ {#each schemaFields as [field, schema]} + + {/each} +
+{/if} + + From 1b3062dfcf03ed63086c11cb0ac61d5444f1b548 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Tue, 26 Jul 2022 17:22:42 +0100 Subject: [PATCH 2/2] amended code following recommendations in PR comments --- .../AutomationBuilder/FlowChart/TestDataModal.svelte | 4 +--- .../automation/SetupPanel/AutomationBlockSetup.svelte | 2 +- .../src/components/automation/SetupPanel/FieldSelector.svelte | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte index 86eec36094..9bbca16802 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte @@ -15,8 +15,6 @@ let trigger = {} let schemaProperties = {} - $: trigger - $: schemaProperties $: { // clone the trigger so we're not mutating the reference trigger = cloneDeep( @@ -27,7 +25,7 @@ let schema = Object.entries(trigger.schema?.outputs?.properties || {}) if (trigger?.event === "app:trigger") { - schema = Object.entries({ fields: { customType: "fields" } }) + schema = [["fields", { customType: "fields" }]] } schemaProperties = schema diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index b8f403b452..fd0b82a8a6 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -53,7 +53,7 @@ $: getInputData(testData, block.inputs) const getInputData = (testData, blockInputs) => { - let newInputData = testData ? testData : blockInputs + let newInputData = testData || blockInputs if (block.event === "app:trigger" && !newInputData?.fields) { newInputData = cloneDeep(blockInputs) diff --git a/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte b/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte index 4ac7b16fa1..f510d961fb 100644 --- a/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte @@ -87,8 +87,6 @@ } -FieldSelector - {#if schemaFields.length && isTestModal}
{#each schemaFields as [field, schema]}