further work for triggering automations from other automations

This commit is contained in:
Peter Clement 2024-01-03 11:59:15 +00:00
parent 49676f2cae
commit 734ad2c1ae
9 changed files with 27 additions and 7 deletions

View File

@ -155,6 +155,7 @@ const automationActions = store => ({
await store.actions.save(newAutomation) await store.actions.save(newAutomation)
}, },
test: async (automation, testData) => { test: async (automation, testData) => {
console.log(testData)
const result = await API.testAutomation({ const result = await API.testAutomation({
automationId: automation?._id, automationId: automation?._id,
testData, testData,

View File

@ -19,6 +19,7 @@
export let lastStep export let lastStep
let syncAutomationsEnabled = $licensing.syncAutomationsEnabled let syncAutomationsEnabled = $licensing.syncAutomationsEnabled
let triggerAutomationsEnabled = $licensing.triggerAutomationsEnabled
let collectBlockAllowedSteps = [TriggerStepID.APP, TriggerStepID.WEBHOOK] let collectBlockAllowedSteps = [TriggerStepID.APP, TriggerStepID.WEBHOOK]
let selectedAction let selectedAction
let actionVal let actionVal
@ -35,6 +36,10 @@
disabled: !lastStep || !syncAutomationsEnabled || collectBlockExists, disabled: !lastStep || !syncAutomationsEnabled || collectBlockExists,
message: collectDisabledMessage(), message: collectDisabledMessage(),
}, },
TRIGGER: {
disabled: !triggerAutomationsEnabled,
message: collectDisabledMessage(),
},
} }
} }
@ -98,6 +103,9 @@
notifications.error("Error saving automation") notifications.error("Error saving automation")
} }
} }
let lockedFeatures = [ActionStepID.COLLECT, ActionStepID.TRIGGER]
$: console.log
</script> </script>
<ModalContent <ModalContent
@ -148,7 +156,7 @@
<div class="item-body"> <div class="item-body">
<Icon name={action.icon} /> <Icon name={action.icon} />
<Body size="XS">{action.name}</Body> <Body size="XS">{action.name}</Body>
{#if isDisabled && !syncAutomationsEnabled && action.stepId === ActionStepID.COLLECT} {#if isDisabled && !syncAutomationsEnabled && !triggerAutomationsEnabled && lockedFeatures.includes(action.stepId)}
<div class="tag-color"> <div class="tag-color">
<Tags> <Tags>
<Tag icon="LockClosed">Business</Tag> <Tag icon="LockClosed">Business</Tag>

View File

@ -46,6 +46,8 @@
} }
const testAutomation = async () => { const testAutomation = async () => {
console.log(testData)
console.log($selectedAutomation)
try { try {
await automationStore.actions.test($selectedAutomation, testData) await automationStore.actions.test($selectedAutomation, testData)
$automationStore.showTestPanel = true $automationStore.showTestPanel = true

View File

@ -21,6 +21,7 @@ export const ActionStepID = {
QUERY_ROWS: "QUERY_ROWS", QUERY_ROWS: "QUERY_ROWS",
LOOP: "LOOP", LOOP: "LOOP",
COLLECT: "COLLECT", COLLECT: "COLLECT",
TRIGGER: "TRIGGER",
// these used to be lowercase step IDs, maintain for backwards compat // these used to be lowercase step IDs, maintain for backwards compat
discord: "discord", discord: "discord",
slack: "slack", slack: "slack",

View File

@ -125,6 +125,10 @@ export const createLicensingStore = () => {
const syncAutomationsEnabled = license.features.includes( const syncAutomationsEnabled = license.features.includes(
Constants.Features.SYNC_AUTOMATIONS Constants.Features.SYNC_AUTOMATIONS
) )
const triggerAutomationsEnabled = license.features.includes(
Constants.Features.SYNC_AUTOMATIONS
)
const perAppBuildersEnabled = license.features.includes( const perAppBuildersEnabled = license.features.includes(
Constants.Features.APP_BUILDERS Constants.Features.APP_BUILDERS
) )
@ -147,6 +151,7 @@ export const createLicensingStore = () => {
auditLogsEnabled, auditLogsEnabled,
enforceableSSO, enforceableSSO,
syncAutomationsEnabled, syncAutomationsEnabled,
triggerAutomationsEnabled,
isViewPermissionsEnabled, isViewPermissionsEnabled,
perAppBuildersEnabled, perAppBuildersEnabled,
} }

@ -1 +1 @@
Subproject commit 992486c10044a7495496b97bdf5f454d4020bfba Subproject commit 82de3443fd03b272555d23c42ead3a611302277d

View File

@ -42,7 +42,7 @@ const ACTION_IMPLS: Record<
FILTER: filter.run, FILTER: filter.run,
QUERY_ROWS: queryRow.run, QUERY_ROWS: queryRow.run,
COLLECT: collect.run, COLLECT: collect.run,
TRIGGER_AUTOMATION: trigger.run, TRIGGER: trigger.run,
// these used to be lowercase step IDs, maintain for backwards compat // these used to be lowercase step IDs, maintain for backwards compat
discord: discord.run, discord: discord.run,
slack: slack.run, slack: slack.run,

View File

@ -26,7 +26,11 @@ export const definition: AutomationStepSchema = {
properties: { properties: {
automationId: { automationId: {
type: AutomationIOType.STRING, type: AutomationIOType.STRING,
title: "Automation ID to trigger", title: "Automation ID",
},
timeout: {
type: AutomationIOType.NUMBER,
title: "Timeout (ms)",
}, },
}, },
required: ["automationId"], required: ["automationId"],
@ -48,8 +52,6 @@ export const definition: AutomationStepSchema = {
} }
export async function run({ inputs }: AutomationStepInput) { export async function run({ inputs }: AutomationStepInput) {
console.log("??: " + inputs.automationId)
console.log("???DSAASDFAFSDFDSFDS")
if (!inputs.automationId) { if (!inputs.automationId) {
return { return {
success: false, success: false,
@ -62,7 +64,7 @@ export async function run({ inputs }: AutomationStepInput) {
automation, automation,
{ {
fields: {}, fields: {},
timeout: 120000, timeout: inputs.timeout * 1000 || 120000,
}, },
{ getResponses: true } { getResponses: true }
) )

View File

@ -9,6 +9,7 @@ export enum Feature {
BRANDING = "branding", BRANDING = "branding",
SCIM = "scim", SCIM = "scim",
SYNC_AUTOMATIONS = "syncAutomations", SYNC_AUTOMATIONS = "syncAutomations",
TRIGGER_AUTOMATION = "triggerAutomation",
APP_BUILDERS = "appBuilders", APP_BUILDERS = "appBuilders",
OFFLINE = "offline", OFFLINE = "offline",
EXPANDED_PUBLIC_API = "expandedPublicApi", EXPANDED_PUBLIC_API = "expandedPublicApi",