The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add 'Add a node' button to command menu for workflow node insertion (#14805)
Willy Douhard062fbe90ea5f
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 4660a12823e..20a2db8841a 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@@ -4,6 +4,7 @@ import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actionimport { NoSelectionWorkflowRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/workflow-actions/types/NoSelectionWorkflowRecordActionKeys';import { SingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/types/SingleRecordActionsKey';import { ActivateWorkflowSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-actions/components/ActivateWorkflowSingleRecordAction';+import { AddNodeWorkflowSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-actions/components/AddNodeWorkflowSingleRecordAction';import { DeactivateWorkflowSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-actions/components/DeactivateWorkflowSingleRecordAction';import { DiscardDraftWorkflowSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-actions/components/DiscardDraftWorkflowSingleRecordAction';import { SeeActiveVersionWorkflowSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-actions/components/SeeActiveVersionWorkflowSingleRecordAction';@@ -29,6 +30,7 @@ import {IconNoteOff,IconPlayerPause,IconPlayerPlay,+ IconPlus,IconPower,IconVersions,} from 'twenty-ui/display';@@ -192,6 +194,21 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({],component: <TestWorkflowSingleRecordAction />,},+ [WorkflowSingleRecordActionKeys.ADD_NODE]: {+ key: WorkflowSingleRecordActionKeys.ADD_NODE,+ label: msg`Add a node`,+ shortLabel: msg`Add a node`,+ isPinned: false,+ position: 8,+ Icon: IconPlus,+ type: ActionType.Standard,+ scope: ActionScope.RecordSelection,+ shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>+ areWorkflowTriggerAndStepsDefined(workflowWithCurrentVersion) &&+ !isDefined(selectedRecord?.deletedAt),+ availableOn: [ActionViewType.SHOW_PAGE],+ component: <AddNodeWorkflowSingleRecordAction />,+ },[NoSelectionWorkflowRecordActionKeys.GO_TO_RUNS]: {type: ActionType.Navigation,scope: ActionScope.Global,@@ -243,82 +260,82 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({label: msg`Create new workflow`,},[SingleRecordActionKeys.ADD_TO_FAVORITES]: {- position: 8,+ position: 9,},[SingleRecordActionKeys.REMOVE_FROM_FAVORITES]: {- position: 9,+ position: 10,},[SingleRecordActionKeys.DELETE]: {- position: 10,+ position: 11,label: msg`Delete workflow`,},[MultipleRecordsActionKeys.DELETE]: {- position: 11,+ position: 12,label: msg`Delete workflows`,},[SingleRecordActionKeys.DESTROY]: {- position: 12,+ position: 13,label: msg`Permanently destroy workflow`,},[SingleRecordActionKeys.EXPORT_FROM_RECORD_INDEX]: {- position: 13,+ position: 14,label: msg`Export workflow`,shouldBeRegistered: ({ selectedRecord }) =>!isDefined(selectedRecord?.deletedAt),},[SingleRecordActionKeys.EXPORT_FROM_RECORD_SHOW]: {- position: 14,+ position: 15,label: msg`Export workflow`,},[MultipleRecordsActionKeys.EXPORT]: {- position: 15,+ position: 16,label: msg`Export workflows`,},[NoSelectionRecordActionKeys.EXPORT_VIEW]: {- position: 15,+ position: 16,label: msg`Export view`,},[MultipleRecordsActionKeys.DESTROY]: {- position: 16,+ position: 17,label: msg`Permanently destroy workflows`,},[SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD]: {- position: 17,+ position: 18,label: msg`Navigate to previous workflow`,},[SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD]: {- position: 18,+ position: 19,label: msg`Navigate to next workflow`,},[NoSelectionRecordActionKeys.SEE_DELETED_RECORDS]: {- position: 19,+ position: 20,label: msg`See deleted workflows`,},[NoSelectionRecordActionKeys.HIDE_DELETED_RECORDS]: {- position: 20,+ position: 21,label: msg`Hide deleted workflows`,},[NoSelectionRecordActionKeys.IMPORT_RECORDS]: {- position: 21,+ position: 22,label: msg`Import workflows`,},[NoSelectionRecordActionKeys.GO_TO_PEOPLE]: {- position: 22,+ position: 23,},[NoSelectionRecordActionKeys.GO_TO_COMPANIES]: {- position: 23,+ position: 24,},[NoSelectionRecordActionKeys.GO_TO_OPPORTUNITIES]: {- position: 24,+ position: 25,},[NoSelectionRecordActionKeys.GO_TO_SETTINGS]: {- position: 25,+ position: 26,},[NoSelectionRecordActionKeys.GO_TO_TASKS]: {- position: 26,+ position: 27,},[NoSelectionRecordActionKeys.GO_TO_NOTES]: {- position: 27,+ position: 28,},},});diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/components/AddNodeWorkflowSingleRecordAction.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/components/AddNodeWorkflowSingleRecordAction.tsxnew file mode 100644index 00000000000..df359e37f41--- /dev/null+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/components/AddNodeWorkflowSingleRecordAction.tsx@@ -0,0 +1,21 @@+import { Action } from '@/action-menu/actions/components/Action';+import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow';+import { useWorkflowCommandMenu } from '@/command-menu/hooks/useWorkflowCommandMenu';+import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';+import { isDefined } from 'twenty-shared/utils';++export const AddNodeWorkflowSingleRecordAction = () => {+ const recordId = useSelectedRecordIdOrThrow();+ const workflowWithCurrentVersion = useWorkflowWithCurrentVersion(recordId);+ const { openWorkflowCreateStepInCommandMenu } = useWorkflowCommandMenu();++ const onClick = () => {+ if (!isDefined(workflowWithCurrentVersion)) {+ return;+ }++ openWorkflowCreateStepInCommandMenu(workflowWithCurrentVersion.id);+ };++ return <Action onClick={onClick} />;+};diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/types/WorkflowSingleRecordActionsKeys.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/types/WorkflowSingleRecordActionsKeys.tsindex 2464985343c..25863b2e24e 100644--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/types/WorkflowSingleRecordActionsKeys.ts+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-actions/types/WorkflowSingleRecordActionsKeys.ts@@ -6,4 +6,5 @@ export enum WorkflowSingleRecordActionKeys {SEE_RUNS = 'see-runs-workflow-single-record',SEE_VERSIONS = 'see-versions-workflow-single-record',TEST = 'test-workflow-single-record',+ ADD_NODE = 'add-node-workflow-single-record',}