mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-22 20:21:53 +03:00
Add see executions action
This commit is contained in:
parent
d1740cd36e
commit
d9eb528abe
@ -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(
|
||||
|
@ -44,7 +44,7 @@ export const ActivateWorkflowActionEffect = ({
|
||||
|
||||
addActionMenuEntry({
|
||||
key: 'activate-workflow',
|
||||
label: 'Activate workflow',
|
||||
label: 'Activate',
|
||||
position,
|
||||
Icon: IconPower,
|
||||
onClick: () => {
|
||||
|
@ -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;
|
||||
};
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user