From d86c238d53097130d7d30ebb421642d24ea7e43b Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 13 Sep 2021 13:14:03 +0100 Subject: [PATCH] Improve test automation modal and handling of data --- packages/builder/assets/n8n.png | Bin 0 -> 3078 bytes .../store/automation/Automation.js | 4 + .../builderStore/store/automation/index.js | 11 +- .../AutomationBuilder.svelte | 2 - .../FlowChart/ActionModal.svelte | 13 +- .../FlowChart/FlowChart.svelte | 20 ++- .../FlowChart/FlowItem.svelte | 40 +++--- .../FlowChart/TestDataModal.svelte | 69 ++++++++-- .../SetupPanel/AutomationBlockSetup.svelte | 126 +++++++++++------- .../automation/SetupPanel/RowSelector.svelte | 50 ++++--- .../automation/SetupPanel/SchemaSetup.svelte | 11 +- .../automation/SetupPanel/SetupPanel.svelte | 4 +- .../automate/[automation]/_layout.svelte | 1 + .../app/[application]/automate/_layout.svelte | 3 +- 14 files changed, 241 insertions(+), 113 deletions(-) create mode 100644 packages/builder/assets/n8n.png diff --git a/packages/builder/assets/n8n.png b/packages/builder/assets/n8n.png new file mode 100644 index 0000000000000000000000000000000000000000..b9dad93e5a916f7af5a3648108cab859fcec4909 GIT binary patch literal 3078 zcmbuB`9BkmAICLGIVu#nq78)*%RNb0sG0l7ku+DbxoyKJa*QyyB=>#nV@R&al{=Da zGkj3y_Q{od-#&lB_wji>Uhl{I{dhedujkM2Xd}aioNNMYOiWCi`g%GhOiX7I{+;v8 zf0FuVUrzrlu+d{PUB(}IJo&%uXXJYOPyMp5iJ>Xe<@=tY#MW%1I}Wq)qMJjm{Yt`2 zOzhtJI$CDv_v_OWuUFJK?tjz2aUqMrpazDjvxrerP0u?M>5@0_nZQh<+#k|^R%pG^ z7;FmJScRH;cC-?6;5$||`}Df6j20$idNGe85=SJH;AVA!ibBenhhu5Kz5H*g3)NS} zSda?VRfXcp_r~}Rw5Vv6Q&n)YT>eVpyjR0}e{xApfAqE|E-|KbY6j zS+r1H@M;jU5AM}17h336hVJq2o}z6H2XHQ6MCZa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eY445RKWeON(N?E_dkEXe*pM@M64rS6Zsx!$p4Ge*EQ6sdf@Q-e}J#b Ae*gdg literal 0 HcmV?d00001 diff --git a/packages/builder/src/builderStore/store/automation/Automation.js b/packages/builder/src/builderStore/store/automation/Automation.js index a9dce88258..dcbb747e38 100644 --- a/packages/builder/src/builderStore/store/automation/Automation.js +++ b/packages/builder/src/builderStore/store/automation/Automation.js @@ -13,6 +13,10 @@ export default class Automation { return this.automation.definition.trigger } + addTestData(data) { + this.automation.testData = data + } + addBlock(block) { // Make sure to add trigger if doesn't exist if (!this.hasTrigger() && block.type === "TRIGGER") { diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index f8e7db04a0..36afe6aa08 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -80,9 +80,9 @@ const automationActions = store => ({ const { _id } = automation return await api.post(`/api/automations/${_id}/trigger`) }, - test: async ({ automation }) => { + test: async ({ automation }, testData) => { const { _id } = automation - return await api.post(`/api/automations/${_id}/test`) + return await api.post(`/api/automations/${_id}/test`, testData) }, select: automation => { store.update(state => { @@ -91,6 +91,13 @@ const automationActions = store => ({ return state }) }, + addTestDataToAutomation: data => { + store.update(state => { + state.selectedAutomation.addTestData(data) + console.log(state) + return state + }) + }, addBlockToAutomation: block => { store.update(state => { const newBlock = state.selectedAutomation.addBlock(cloneDeep(block)) diff --git a/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte b/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte index 46440a68f6..7ce77a58e3 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte @@ -1,7 +1,6 @@ {#if automation} - {/if} diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte index 0cd4f147be..052d319181 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte @@ -4,7 +4,11 @@ import DiscordLogo from "assets/discord.svg" import ZapierLogo from "assets/zapier.png" import IntegromatLogo from "assets/integromat.png" - import SlackLogo from "assets/integromat.png" + import SlackLogo from "assets/slack.svg" + import n8nlogo from "assets/n8nlogo.png" + + import { database } from "stores/backend" + $: instanceId = $database._id let selectedAction let actionVal @@ -15,6 +19,7 @@ { name: "discord", logo: DiscordLogo }, { name: "slack", logo: SlackLogo }, { name: "integromat", logo: IntegromatLogo }, + { name: "n8n", logo: n8nlogo }, ] let actions = Object.entries($automationStore.blockDefinitions.ACTION) @@ -39,13 +44,17 @@ selectedAction = action.name } - function addBlockToAutomation() { + async function addBlockToAutomation() { const newBlock = $automationStore.selectedAutomation.constructBlock( "ACTION", actionVal.stepId, actionVal ) automationStore.actions.addBlockToAutomation(newBlock) + await automationStore.actions.save({ + instanceId, + automation: $automationStore.selectedAutomation?.automation, + }) } diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte index 2398d2754a..b87f1009b7 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte @@ -2,14 +2,23 @@ import { automationStore } from "builderStore" import FlowItem from "./FlowItem.svelte" + import TestDataModal from "./TestDataModal.svelte" + import Arrow from "./Arrow.svelte" import { flip } from "svelte/animate" import { fade, fly } from "svelte/transition" - import { Detail, Icon, ActionButton, notifications } from "@budibase/bbui" + import { + Detail, + Icon, + ActionButton, + notifications, + Modal, + } from "@budibase/bbui" import { database } from "stores/backend" export let automation export let onSelect + let testDataModal let blocks $: instanceId = $database._id @@ -61,7 +70,7 @@ testAutomation()} + on:click={() => testDataModal.show()} icon="MultipleCheck" size="S">Run test @@ -75,21 +84,24 @@ in:fade|local out:fly|local={{ x: 500 }} > - + {#if idx !== blocks.length - 1} {/if} {/each} + + +