diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/RecordActionMenuEntriesSetter.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/RecordActionMenuEntriesSetter.tsx index 7e8f301912..6364de0443 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/RecordActionMenuEntriesSetter.tsx +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/RecordActionMenuEntriesSetter.tsx @@ -2,6 +2,7 @@ import { DeleteRecordsActionEffect } from '@/action-menu/actions/record-actions/ import { ExportRecordsActionEffect } from '@/action-menu/actions/record-actions/components/ExportRecordsActionEffect'; import { ManageFavoritesActionEffect } from '@/action-menu/actions/record-actions/components/ManageFavoritesActionEffect'; import { ActivateWorkflowActionEffect } from '@/action-menu/actions/record-actions/workflow-actions/components/ActivateWorkflowActionEffect'; +import { SeeWorkflowExecutionsActionEffect } from '@/action-menu/actions/record-actions/workflow-actions/components/SeeWorkflowExecutionsActionEffect'; import { contextStoreCurrentObjectMetadataIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdComponentState'; import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState'; import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById'; @@ -19,7 +20,10 @@ const multipleRecordActionEffects = [ DeleteRecordsActionEffect, ]; -const workflowSingleRecordActionEffects = [ActivateWorkflowActionEffect]; +const workflowSingleRecordActionEffects = [ + ActivateWorkflowActionEffect, + SeeWorkflowExecutionsActionEffect, +]; export const RecordActionMenuEntriesSetter = () => { const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2( diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/ActivateWorkflowActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/ActivateWorkflowActionEffect.tsx index 4e477d0fb8..23126b8da7 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/ActivateWorkflowActionEffect.tsx +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/ActivateWorkflowActionEffect.tsx @@ -44,7 +44,7 @@ export const ActivateWorkflowActionEffect = ({ addActionMenuEntry({ key: 'activate-workflow', - label: 'Activate workflow', + label: 'Activate', position, Icon: IconPower, onClick: () => { diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/SeeWorkflowExecutionsActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/SeeWorkflowExecutionsActionEffect.tsx new file mode 100644 index 0000000000..8c9958dc2d --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-actions/components/SeeWorkflowExecutionsActionEffect.tsx @@ -0,0 +1,73 @@ +import { useActionMenuEntries } from '@/action-menu/hooks/useActionMenuEntries'; +import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState'; +import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; +import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; +import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion'; +import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion'; +import { useEffect } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { useRecoilValue } from 'recoil'; +import { IconHistoryToggle, isDefined } from 'twenty-ui'; + +export const SeeWorkflowExecutionsActionEffect = ({ + position, + objectMetadataItem, +}: { + position: number; + objectMetadataItem: ObjectMetadataItem; +}) => { + const { addActionMenuEntry, removeActionMenuEntry } = useActionMenuEntries(); + + const contextStoreTargetedRecordsRule = useRecoilComponentValueV2( + contextStoreTargetedRecordsRuleComponentState, + ); + + const selectedRecordId = + contextStoreTargetedRecordsRule.mode === 'selection' + ? contextStoreTargetedRecordsRule.selectedRecordIds[0] + : undefined; + + const selectedRecord = useRecoilValue( + recordStoreFamilyState(selectedRecordId ?? ''), + ); + + const { activateWorkflowVersion } = useActivateWorkflowVersion(); + + const workflowWithCurrentVersion = useWorkflowWithCurrentVersion( + selectedRecord?.id, + ); + + const navigate = useNavigate(); + + useEffect(() => { + if (!isDefined(objectMetadataItem) || objectMetadataItem.isRemote) { + return; + } + + addActionMenuEntry({ + key: 'see-workflow-executions', + label: 'See executions', + position, + Icon: IconHistoryToggle, + onClick: () => { + //TODO: go to past executions page http://localhost:3001/objects/workflowRuns?filter%5Bworkflow%5D%5Bis%5D%5B0%5D=3323cf02-5b95-459d-b432-20714a3d9c77&view=f3da4217-24c6-414a-8214-81fbd6012c01 + navigate(`/object/workflow/${workflowWithCurrentVersion?.id}`); + }, + }); + + return () => { + removeActionMenuEntry('see-workflow-executions'); + }; + }, [ + activateWorkflowVersion, + addActionMenuEntry, + navigate, + objectMetadataItem, + position, + removeActionMenuEntry, + selectedRecord, + workflowWithCurrentVersion, + ]); + return null; +}; diff --git a/packages/twenty-ui/src/display/icon/components/TablerIcons.ts b/packages/twenty-ui/src/display/icon/components/TablerIcons.ts index 8f75e4ae14..cd917fd3da 100644 --- a/packages/twenty-ui/src/display/icon/components/TablerIcons.ts +++ b/packages/twenty-ui/src/display/icon/components/TablerIcons.ts @@ -125,8 +125,8 @@ export { IconFileUpload, IconFileZip, IconFilter, - IconFilterOff, IconFilterCog, + IconFilterOff, IconFocusCentered, IconForbid, IconFunction, @@ -136,11 +136,13 @@ export { IconH2, IconH3, IconHandClick, + IconHandMove, IconHeadphones, IconHeart, IconHeartOff, IconHelpCircle, IconHierarchy2, + IconHistoryToggle, IconHome, IconInbox, IconInfoCircle, @@ -181,13 +183,12 @@ export { IconPlayerPlay, IconPlayerStop, IconPlaylistAdd, - IconHandMove, - IconSquare, IconPlaystationSquare, IconPlug, IconPlus, IconPower, IconPresentation, + IconPrinter, IconProgressCheck, IconPuzzle, IconQuestionMark, @@ -209,6 +210,7 @@ export { IconSortDescending, IconSparkles, IconSql, + IconSquare, IconSquareKey, IconSquareRoundedCheck, IconTable, @@ -221,7 +223,6 @@ export { IconTimelineEvent, IconTool, IconTrash, - IconPrinter, IconUnlink, IconUpload, IconUser,