diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml
index e2538774ef..c4a6c669b3 100644
--- a/hosting/docker-compose.yaml
+++ b/hosting/docker-compose.yaml
@@ -42,6 +42,7 @@ services:
environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
+ MINIO_BROWSER: "off"
command: server /data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
diff --git a/packages/builder/src/builderStore/store/automation/Automation.js b/packages/builder/src/builderStore/store/automation/Automation.js
index cbdcabeccc..a9dce88258 100644
--- a/packages/builder/src/builderStore/store/automation/Automation.js
+++ b/packages/builder/src/builderStore/store/automation/Automation.js
@@ -56,4 +56,13 @@ export default class Automation {
steps.splice(stepIdx, 1)
this.automation.definition.steps = steps
}
+
+ constructBlock(type, stepId, blockDefinition) {
+ return {
+ ...blockDefinition,
+ inputs: blockDefinition.inputs || {},
+ stepId,
+ type,
+ }
+ }
}
diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js
index 3f0743aa1e..7a01bccfab 100644
--- a/packages/builder/src/builderStore/store/automation/index.js
+++ b/packages/builder/src/builderStore/store/automation/index.js
@@ -2,6 +2,7 @@ import { writable } from "svelte/store"
import api from "../../api"
import Automation from "./Automation"
import { cloneDeep } from "lodash/fp"
+import analytics from "analytics"
const automationActions = store => ({
fetch: async () => {
@@ -93,6 +94,9 @@ const automationActions = store => ({
state.selectedBlock = newBlock
return state
})
+ analytics.captureEvent("Added Automation Block", {
+ name: block.name,
+ })
},
deleteAutomationBlock: block => {
store.update(state => {
diff --git a/packages/builder/src/components/automation/AutomationBuilder/BlockList.svelte b/packages/builder/src/components/automation/AutomationBuilder/BlockList.svelte
index de3e9660ad..5ea1d64e51 100644
--- a/packages/builder/src/components/automation/AutomationBuilder/BlockList.svelte
+++ b/packages/builder/src/components/automation/AutomationBuilder/BlockList.svelte
@@ -49,16 +49,9 @@
}
function addBlockToAutomation(stepId, blockDefinition) {
- const newBlock = {
- ...blockDefinition,
- inputs: blockDefinition.inputs || {},
- stepId,
- type: selectedTab,
- }
+ const newBlock = $automationStore.selectedAutomation.constructBlock(
+ selectedTab, stepId, blockDefinition)
automationStore.actions.addBlockToAutomation(newBlock)
- analytics.captureEvent("Added Automation Block", {
- name: blockDefinition.name,
- })
closePopover()
if (stepId === "WEBHOOK") {
webhookModal.show()
diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
index 7e26b2155e..5d3371ee7d 100644
--- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
+++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
@@ -1,6 +1,7 @@
+
+
+
+
+
+
+ {#each fieldsArray as field}
+
+
+
+
+ removeField(field.name)} />
+
+
+
+ {/each}
+
+
+
+
diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/TriggerAutomation.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/TriggerAutomation.svelte
new file mode 100644
index 0000000000..3e46f813fd
--- /dev/null
+++ b/packages/builder/src/components/userInterface/EventsEditor/actions/TriggerAutomation.svelte
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {#if newOrExisting=== "existing"}
+
+ {:else}
+
+ {/if}
+
+
+
+
+
+
diff --git a/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/EventEditorModal.svelte b/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/EventEditorModal.svelte
index 27e91cd29e..d92ebed33e 100644
--- a/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/EventEditorModal.svelte
+++ b/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/EventEditorModal.svelte
@@ -3,6 +3,7 @@
import { AddIcon, ArrowDownIcon } from "components/common/Icons/"
import actionTypes from "./actions"
import { createEventDispatcher } from "svelte"
+ import { automationStore } from "builderStore"
const dispatch = createEventDispatcher()
const eventTypeKey = "##eventHandlerType"
@@ -13,17 +14,11 @@
let addActionDropdown
let selectedAction
- let draftEventHandler = { parameters: [] }
-
$: actions = event || []
$: selectedActionComponent =
selectedAction &&
actionTypes.find(t => t.name === selectedAction[eventTypeKey]).component
- const updateEventHandler = (updatedHandler, index) => {
- actions[index] = updatedHandler
- }
-
const deleteAction = index => {
actions.splice(index, 1)
actions = actions
@@ -44,8 +39,43 @@
selectedAction = action
}
- const saveEventData = () => {
- dispatch("change", actions)
+ const saveEventData = async () => {
+ // e.g. The Trigger Automation action exposes beforeSave, so it can
+ // create any automations it needs to
+ for (let action of actions) {
+ if (action[eventTypeKey] === "Trigger Automation") {
+ await createAutomation(action.parameters)
+ }
+ }
+ dispatch("change", actions)
+ }
+
+ // called by the parent modal when actions are saved
+ const createAutomation = async parameters => {
+ if (parameters.automationId || !parameters.newAutomationName) return
+
+ await automationStore.actions.create({name: parameters.newAutomationName})
+
+ const appActionDefinition = $automationStore.blockDefinitions.TRIGGER.APP
+
+ const newBlock = $automationStore.selectedAutomation.constructBlock(
+ "TRIGGER", "APP", appActionDefinition)
+
+
+ newBlock.inputs = {
+ fields: Object.entries(parameters.fields).reduce((fields, [key, value]) => {
+ fields[key] = value.type
+ return fields
+ }, {})
+ }
+
+ automationStore.actions.addBlockToAutomation(newBlock)
+
+ await automationStore.actions.save(
+ $automationStore.selectedAutomation)
+
+ parameters.automationId = $automationStore.selectedAutomation.automation._id
+ delete parameters.newAutomationName
}
diff --git a/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/actions/SaveFields.svelte b/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/actions/SaveFields.svelte
index 3fe85cbfda..71d0ddf17f 100644
--- a/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/actions/SaveFields.svelte
+++ b/packages/builder/src/components/userInterface/PropertyPanelControls/EventsEditor/actions/SaveFields.svelte
@@ -1,6 +1,6 @@