The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Render `WorkflowActionMenuItems` as a proper component (#14223)
Baptiste Devessierd94e984a80e3
diff --git a/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/CommandMenuWorkflowSelectActionContent.tsx b/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/CommandMenuWorkflowSelectActionContent.tsxindex 3cc6cf0eb99..711b4562664 100644--- a/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/CommandMenuWorkflowSelectActionContent.tsx+++ b/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/CommandMenuWorkflowSelectActionContent.tsx@@ -20,7 +20,6 @@ import { OTHER_ACTIONS } from '@/workflow/workflow-steps/workflow-actions/constaimport { RECORD_ACTIONS } from '@/workflow/workflow-steps/workflow-actions/constants/RecordActions';import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';-import { useTheme } from '@emotion/react';import { useLingui } from '@lingui/react/macro';import { useSetRecoilState } from 'recoil';import { isDefined } from 'twenty-shared/utils';@@ -89,8 +88,6 @@ export const CommandMenuWorkflowSelectActionContent = ({);};- const theme = useTheme();-const isAiEnabled = useIsFeatureEnabled(FeatureFlagKey.IS_AI_ENABLED);const isIteratorEnabled = useIsFeatureEnabled(FeatureFlagKey.IS_WORKFLOW_ITERATOR_ENABLED,@@ -103,29 +100,48 @@ export const CommandMenuWorkflowSelectActionContent = ({<RightDrawerWorkflowSelectStepTitle>{t`Data`}</RightDrawerWorkflowSelectStepTitle>- {WorkflowActionMenuItems(RECORD_ACTIONS, theme, handleCreateStep)}+ <WorkflowActionMenuItems+ actions={RECORD_ACTIONS}+ onClick={handleCreateStep}+ />+{isAiEnabled && (<><RightDrawerWorkflowSelectStepTitle>{t`AI`}</RightDrawerWorkflowSelectStepTitle>- {WorkflowActionMenuItems(AI_ACTIONS, theme, handleCreateStep)}+ <WorkflowActionMenuItems+ actions={AI_ACTIONS}+ onClick={handleCreateStep}+ /></>)}+<RightDrawerWorkflowSelectStepTitle>{t`Core`}</RightDrawerWorkflowSelectStepTitle>- {WorkflowActionMenuItems(CORE_ACTIONS, theme, handleCreateStep)}+ <WorkflowActionMenuItems+ actions={CORE_ACTIONS}+ onClick={handleCreateStep}+ />+<RightDrawerWorkflowSelectStepTitle>{t`Human Input`}</RightDrawerWorkflowSelectStepTitle>- {WorkflowActionMenuItems(HUMAN_INPUT_ACTIONS, theme, handleCreateStep)}+ <WorkflowActionMenuItems+ actions={HUMAN_INPUT_ACTIONS}+ onClick={handleCreateStep}+ />+{isIteratorEnabled && (<><RightDrawerWorkflowSelectStepTitle>{t`Others`}</RightDrawerWorkflowSelectStepTitle>- {WorkflowActionMenuItems(OTHER_ACTIONS, theme, handleCreateStep)}+ <WorkflowActionMenuItems+ actions={OTHER_ACTIONS}+ onClick={handleCreateStep}+ /></>)}</RightDrawerStepListContainer>diff --git a/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/WorkflowActionMenuItems.tsx b/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/WorkflowActionMenuItems.tsxindex ea006188f8a..9a7174eb736 100644--- a/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/WorkflowActionMenuItems.tsx+++ b/packages/twenty-front/src/modules/command-menu/pages/workflow/action/components/WorkflowActionMenuItems.tsx@@ -1,32 +1,42 @@import { type WorkflowActionType } from '@/workflow/types/Workflow';import { getActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIconColorOrThrow';+import { useTheme } from '@emotion/react';import { useIcons } from 'twenty-ui/display';import { MenuItemCommand } from 'twenty-ui/navigation';type Action = { type: WorkflowActionType; label: string; icon: string };-export const WorkflowActionMenuItems = (- actions: Action[],- theme: any,- onClick: (actionType: WorkflowActionType) => void,-) => {+export const WorkflowActionMenuItems = ({+ actions,+ onClick,+}: {+ actions: Action[];+ onClick: (actionType: WorkflowActionType) => void;+}) => {+ const theme = useTheme();const { getIcon } = useIcons();- return actions.map((action) => {- const Icon = getIcon(action.icon);- return (- <MenuItemCommand- key={action.type}- LeftIcon={() => (- <Icon- color={getActionIconColorOrThrow({- theme,- actionType: action.type,- })}++ return (+ <>+ {actions.map((action) => {+ const Icon = getIcon(action.icon);++ return (+ <MenuItemCommand+ key={action.type}+ LeftIcon={() => (+ <Icon+ color={getActionIconColorOrThrow({+ theme,+ actionType: action.type,+ })}+ />+ )}+ text={action.label}+ onClick={() => onClick(action.type)}/>- )}- text={action.label}- onClick={() => onClick(action.type)}- />- );- });+ );+ })}+ </>+ );};