From fd4c1c992972284a5bcce09a4453cfa21704b386 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 2 Sep 2021 14:25:01 +0100 Subject: [PATCH] Add triggers to setup modal --- .../AutomationPanel/AutomationPanel.svelte | 3 +- .../CreateAutomationModal.svelte | 91 ++++++++++++++----- .../app/[application]/automate/_layout.svelte | 9 +- 3 files changed, 77 insertions(+), 26 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationPanel/AutomationPanel.svelte b/packages/builder/src/components/automation/AutomationPanel/AutomationPanel.svelte index b2773ae455..0c975eab18 100644 --- a/packages/builder/src/components/automation/AutomationPanel/AutomationPanel.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/AutomationPanel.svelte @@ -4,6 +4,7 @@ import { Icon, Modal, Tabs, Tab } from "@budibase/bbui" export let modal + export let webhookModal
@@ -12,7 +13,7 @@
- +
diff --git a/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte b/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte index dfcfc2ab95..43bb2ff777 100644 --- a/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte @@ -3,12 +3,14 @@ import { database } from "stores/backend" import { automationStore } from "builderStore" import { notifications } from "@budibase/bbui" - import { Icon, Input, ModalContent } from "@budibase/bbui" + import { Input, ModalContent, Layout, Body } from "@budibase/bbui" import analytics from "analytics" let name + let selectedTrigger + let triggerVal + export let webhookModal - $: valid = !!name $: instanceId = $database._id async function createAutomation() { @@ -16,41 +18,84 @@ name, instanceId, }) + const newBlock = await $automationStore.selectedAutomation.constructBlock( + "TRIGGER", + triggerVal.stepId, + triggerVal + ) + automationStore.actions.addBlockToAutomation(newBlock) + if (triggerVal.stepId === "WEBHOOK") { + webhookModal.show() + } + notifications.success(`Automation ${name} created.`) $goto(`./${$automationStore.selectedAutomation.automation._id}`) analytics.captureEvent("Automation Created", { name }) } + $: triggers = Object.entries($automationStore.blockDefinitions.TRIGGER) + + const selectTrigger = trigger => { + triggerVal = trigger + selectedTrigger = trigger.name + } + Please name your automation, then select a trigger. Every automation must + start with a trigger. + - - - Learn about automations - + + + Triggers + +
+ {#each triggers as [idx, trigger]} +
selectTrigger(trigger)} + > +
+ + + {trigger.name} +
+
+ {/each} +
+
diff --git a/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte index bc04548d8f..0d0582a34e 100644 --- a/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte @@ -4,14 +4,16 @@ import AutomationPanel from "components/automation/AutomationPanel/AutomationPanel.svelte" import SetupPanel from "components/automation/SetupPanel/SetupPanel.svelte" import CreateAutomationModal from "components/automation/AutomationPanel/CreateAutomationModal.svelte" + import CreateWebhookModal from "components/automation/shared/CreateWebhookModal.svelte" $: automation = $automationStore.selectedAutomation?.automation let modal + let webhookModal
{#if automation} @@ -44,7 +46,10 @@
{/if} - + + + +