The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Prevent testing malformed workflows and allow testing workflows with cron trigger (#13045)
Baptiste Devessier7a2b6bd4d6f0
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.tsxindex 3d3b77bb344..10144c61ac6 100644--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.tsx+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.tsx@@ -17,6 +17,11 @@ import { ActionType } from '@/action-menu/actions/types/ActionType';import { ActionViewType } from '@/action-menu/actions/types/ActionViewType';import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';import { AppPath } from '@/types/AppPath';+import {+ WorkflowStep,+ WorkflowTrigger,+ WorkflowWithCurrentVersion,+} from '@/workflow/types/Workflow';import { msg } from '@lingui/core/macro';import { isDefined } from 'twenty-shared/utils';import {@@ -28,6 +33,21 @@ import {IconVersions,} from 'twenty-ui/display';+const areWorkflowTriggerAndStepsDefined = (+ workflowWithCurrentVersion: WorkflowWithCurrentVersion | undefined,+): workflowWithCurrentVersion is WorkflowWithCurrentVersion & {+ currentVersion: {+ trigger: WorkflowTrigger;+ steps: Array<WorkflowStep>;+ };+} => {+ return (+ isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) &&+ isDefined(workflowWithCurrentVersion.currentVersion?.steps) &&+ workflowWithCurrentVersion.currentVersion.steps.length > 0+ );+};+export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({config: {[WorkflowSingleRecordActionKeys.ACTIVATE]: {@@ -40,9 +60,7 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({type: ActionType.Standard,scope: ActionScope.RecordSelection,shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>- isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) &&- isDefined(workflowWithCurrentVersion.currentVersion?.steps) &&- workflowWithCurrentVersion.currentVersion.steps.length > 0 &&+ areWorkflowTriggerAndStepsDefined(workflowWithCurrentVersion) &&(workflowWithCurrentVersion.currentVersion.status === 'DRAFT' ||!workflowWithCurrentVersion.versions?.some((version) => version.status === 'ACTIVE',@@ -158,14 +176,15 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({type: ActionType.Standard,scope: ActionScope.RecordSelection,shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>- isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) &&+ areWorkflowTriggerAndStepsDefined(workflowWithCurrentVersion) &&((workflowWithCurrentVersion.currentVersion.trigger.type === 'MANUAL' &&!isDefined(workflowWithCurrentVersion.currentVersion.trigger.settings.objectType,)) ||workflowWithCurrentVersion.currentVersion.trigger.type ===- 'WEBHOOK') &&+ 'WEBHOOK' ||+ workflowWithCurrentVersion.currentVersion.trigger.type === 'CRON') &&!isDefined(selectedRecord?.deletedAt),availableOn: [ActionViewType.SHOW_PAGE,