diff --git a/packages/backend-core/tests/core/utilities/mocks/licenses.ts b/packages/backend-core/tests/core/utilities/mocks/licenses.ts index 839b22e5f9..4272e78eb8 100644 --- a/packages/backend-core/tests/core/utilities/mocks/licenses.ts +++ b/packages/backend-core/tests/core/utilities/mocks/licenses.ts @@ -90,6 +90,10 @@ export const useScimIntegration = () => { return useFeature(Feature.SCIM) } +export const useSyncAutomations = () => { + return useFeature(Feature.SYNC_AUTOMATIONS) +} + // QUOTAS export const setAutomationLogsQuota = (value: number) => { diff --git a/packages/builder/src/builderStore/utils.js b/packages/builder/src/builderStore/utils.js index 3ddf6fb667..86c63f20ee 100644 --- a/packages/builder/src/builderStore/utils.js +++ b/packages/builder/src/builderStore/utils.js @@ -1,3 +1,4 @@ +import { ActionStepID } from "constants/backend/automations" import { TableNames } from "../constants" import { AUTO_COLUMN_DISPLAY_NAMES, @@ -53,3 +54,9 @@ export function buildAutoColumn(tableName, name, subtype) { } return base } + +export function checkForCollectStep(automation) { + return automation.definition.steps.some( + step => step.stepId === ActionStepID.COLLECT + ) +} diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte index 7c9f31352f..c5e4eaf61f 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/ActionModal.svelte @@ -6,24 +6,48 @@ Body, Icon, notifications, + Tags, + Tag, } from "@budibase/bbui" - import { automationStore } from "builderStore" - import { admin } from "stores/portal" + import { automationStore, selectedAutomation } from "builderStore" + import { admin, licensing } from "stores/portal" import { externalActions } from "./ExternalActions" + import { TriggerStepID } from "constants/backend/automations" + import { checkForCollectStep } from "builderStore/utils" export let blockIdx + export let lastStep - const disabled = { - SEND_EMAIL_SMTP: { - disabled: !$admin.checklist.smtp.checked, - message: "Please configure SMTP", - }, - } - + let syncAutomationsEnabled = $licensing.syncAutomationsEnabled + let collectBlockAllowedSteps = [TriggerStepID.APP, TriggerStepID.WEBHOOK] let selectedAction let actionVal let actions = Object.entries($automationStore.blockDefinitions.ACTION) + $: collectBlockExists = checkForCollectStep($selectedAutomation) + + const disabled = () => { + return { + SEND_EMAIL_SMTP: { + disabled: !$admin.checklist.smtp.checked, + message: "Please configure SMTP", + }, + COLLECT: { + disabled: !lastStep || !syncAutomationsEnabled || collectBlockExists, + message: collectDisabledMessage(), + }, + } + } + + const collectDisabledMessage = () => { + if (collectBlockExists) { + return "Only one Collect step allowed" + } + if (!lastStep) { + return "Only available as the last step" + } + } + const external = actions.reduce((acc, elm) => { const [k, v] = elm if (!v.internal && !v.custom) { @@ -38,6 +62,15 @@ acc[k] = v } delete acc.LOOP + + // Filter out Collect block if not App Action or Webhook + if ( + !collectBlockAllowedSteps.includes( + $selectedAutomation.definition.trigger.stepId + ) + ) { + delete acc.COLLECT + } return acc }, {}) @@ -48,7 +81,6 @@ } return acc }, {}) - console.log(plugins) const selectAction = action => { actionVal = action @@ -72,7 +104,7 @@ @@ -107,7 +139,7 @@ Actions
{#each Object.entries(internal) as [idx, action]} - {@const isDisabled = disabled[idx] && disabled[idx].disabled} + {@const isDisabled = disabled()[idx] && disabled()[idx].disabled}
{action.name} - {#if isDisabled} - + {#if isDisabled && !syncAutomationsEnabled} +
+ + Business + +
+ {:else if isDisabled} + {/if}
@@ -152,6 +190,7 @@ display: flex; margin-left: var(--spacing-m); gap: var(--spacing-m); + align-items: center; } .item-list { display: grid; @@ -181,4 +220,8 @@ .disabled :global(.spectrum-Body) { color: var(--spectrum-global-color-gray-600); } + + .tag-color :global(.spectrum-Tags-item) { + background: var(--spectrum-global-color-gray-200); + } diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 7484a60502..092138170f 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -17,7 +17,11 @@ import ActionModal from "./ActionModal.svelte" import FlowItemHeader from "./FlowItemHeader.svelte" import RoleSelect from "components/design/settings/controls/RoleSelect.svelte" - import { ActionStepID, TriggerStepID } from "constants/backend/automations" + import { + ActionStepID, + TriggerStepID, + Features, + } from "constants/backend/automations" import { permissions } from "stores/backend" export let block @@ -31,6 +35,9 @@ let showLooping = false let role + $: collectBlockExists = $selectedAutomation.definition.steps.some( + step => step.stepId === ActionStepID.COLLECT + ) $: automationId = $selectedAutomation?._id $: showBindingPicker = block.stepId === ActionStepID.CREATE_ROW || @@ -184,7 +191,7 @@ {#if !isTrigger}
- {#if !loopBlock} + {#if block?.features?.[Features.LOOPING] || !block.features} addLooping()} icon="Reuse"> Add Looping @@ -224,21 +231,28 @@
{/if} - - - - - - - -
-
- actionModal.show()} hoverable name="AddCircle" size="S" /> -{#if isTrigger ? totalBlocks > 1 : blockIdx !== totalBlocks - 2} +{#if !collectBlockExists || !lastStep}
+ actionModal.show()} + hoverable + name="AddCircle" + size="S" + /> + {#if isTrigger ? totalBlocks > 1 : blockIdx !== totalBlocks - 2} +
+ {/if} {/if} + + + + + + + +