diff --git a/packages/builder/assets/n8n.png b/packages/builder/assets/n8n.png new file mode 100644 index 0000000000..b9dad93e5a Binary files /dev/null and b/packages/builder/assets/n8n.png differ 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} + + +