mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-22 21:50:43 +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 { ExportRecordsActionEffect } from '@/action-menu/actions/record-actions/components/ExportRecordsActionEffect';
|
||||||
import { ManageFavoritesActionEffect } from '@/action-menu/actions/record-actions/components/ManageFavoritesActionEffect';
|
import { ManageFavoritesActionEffect } from '@/action-menu/actions/record-actions/components/ManageFavoritesActionEffect';
|
||||||
import { ActivateWorkflowActionEffect } from '@/action-menu/actions/record-actions/workflow-actions/components/ActivateWorkflowActionEffect';
|
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 { contextStoreCurrentObjectMetadataIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdComponentState';
|
||||||
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
||||||
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
|
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
|
||||||
@ -19,7 +20,10 @@ const multipleRecordActionEffects = [
|
|||||||
DeleteRecordsActionEffect,
|
DeleteRecordsActionEffect,
|
||||||
];
|
];
|
||||||
|
|
||||||
const workflowSingleRecordActionEffects = [ActivateWorkflowActionEffect];
|
const workflowSingleRecordActionEffects = [
|
||||||
|
ActivateWorkflowActionEffect,
|
||||||
|
SeeWorkflowExecutionsActionEffect,
|
||||||
|
];
|
||||||
|
|
||||||
export const RecordActionMenuEntriesSetter = () => {
|
export const RecordActionMenuEntriesSetter = () => {
|
||||||
const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2(
|
const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2(
|
||||||
|
@ -44,7 +44,7 @@ export const ActivateWorkflowActionEffect = ({
|
|||||||
|
|
||||||
addActionMenuEntry({
|
addActionMenuEntry({
|
||||||
key: 'activate-workflow',
|
key: 'activate-workflow',
|
||||||
label: 'Activate workflow',
|
label: 'Activate',
|
||||||
position,
|
position,
|
||||||
Icon: IconPower,
|
Icon: IconPower,
|
||||||
onClick: () => {
|
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,
|
IconFileUpload,
|
||||||
IconFileZip,
|
IconFileZip,
|
||||||
IconFilter,
|
IconFilter,
|
||||||
IconFilterOff,
|
|
||||||
IconFilterCog,
|
IconFilterCog,
|
||||||
|
IconFilterOff,
|
||||||
IconFocusCentered,
|
IconFocusCentered,
|
||||||
IconForbid,
|
IconForbid,
|
||||||
IconFunction,
|
IconFunction,
|
||||||
@ -136,11 +136,13 @@ export {
|
|||||||
IconH2,
|
IconH2,
|
||||||
IconH3,
|
IconH3,
|
||||||
IconHandClick,
|
IconHandClick,
|
||||||
|
IconHandMove,
|
||||||
IconHeadphones,
|
IconHeadphones,
|
||||||
IconHeart,
|
IconHeart,
|
||||||
IconHeartOff,
|
IconHeartOff,
|
||||||
IconHelpCircle,
|
IconHelpCircle,
|
||||||
IconHierarchy2,
|
IconHierarchy2,
|
||||||
|
IconHistoryToggle,
|
||||||
IconHome,
|
IconHome,
|
||||||
IconInbox,
|
IconInbox,
|
||||||
IconInfoCircle,
|
IconInfoCircle,
|
||||||
@ -181,13 +183,12 @@ export {
|
|||||||
IconPlayerPlay,
|
IconPlayerPlay,
|
||||||
IconPlayerStop,
|
IconPlayerStop,
|
||||||
IconPlaylistAdd,
|
IconPlaylistAdd,
|
||||||
IconHandMove,
|
|
||||||
IconSquare,
|
|
||||||
IconPlaystationSquare,
|
IconPlaystationSquare,
|
||||||
IconPlug,
|
IconPlug,
|
||||||
IconPlus,
|
IconPlus,
|
||||||
IconPower,
|
IconPower,
|
||||||
IconPresentation,
|
IconPresentation,
|
||||||
|
IconPrinter,
|
||||||
IconProgressCheck,
|
IconProgressCheck,
|
||||||
IconPuzzle,
|
IconPuzzle,
|
||||||
IconQuestionMark,
|
IconQuestionMark,
|
||||||
@ -209,6 +210,7 @@ export {
|
|||||||
IconSortDescending,
|
IconSortDescending,
|
||||||
IconSparkles,
|
IconSparkles,
|
||||||
IconSql,
|
IconSql,
|
||||||
|
IconSquare,
|
||||||
IconSquareKey,
|
IconSquareKey,
|
||||||
IconSquareRoundedCheck,
|
IconSquareRoundedCheck,
|
||||||
IconTable,
|
IconTable,
|
||||||
@ -221,7 +223,6 @@ export {
|
|||||||
IconTimelineEvent,
|
IconTimelineEvent,
|
||||||
IconTool,
|
IconTool,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconPrinter,
|
|
||||||
IconUnlink,
|
IconUnlink,
|
||||||
IconUpload,
|
IconUpload,
|
||||||
IconUser,
|
IconUser,
|
||||||
|
Loading…
Reference in New Issue
Block a user