Fix: Put workflow run actions behind feature flag (#8798)
Fix: Put workflow run actions behind feature flag
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
import { MultipleRecordsActionMenuEntrySetterEffect } from '@/action-menu/actions/record-actions/multiple-records/components/MultipleRecordsActionMenuEntrySetterEffect';
|
||||
import { NoSelectionActionMenuEntrySetterEffect } from '@/action-menu/actions/record-actions/no-selection/components/NoSelectionActionMenuEntrySetterEffect';
|
||||
import { SingleRecordActionMenuEntrySetterEffect } from '@/action-menu/actions/record-actions/single-record/components/SingleRecordActionMenuEntrySetterEffect';
|
||||
import { WorkflowRunRecordActionMenuEntrySetterEffect } from '@/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionMenuEntrySetter';
|
||||
import { contextStoreCurrentObjectMetadataIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdComponentState';
|
||||
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
||||
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
|
||||
export const RecordActionMenuEntriesSetter = () => {
|
||||
@ -34,6 +36,8 @@ const ActionEffects = ({
|
||||
contextStoreNumberOfSelectedRecordsComponentState,
|
||||
);
|
||||
|
||||
const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED');
|
||||
|
||||
return (
|
||||
<>
|
||||
{contextStoreNumberOfSelectedRecords === 0 && (
|
||||
@ -46,6 +50,11 @@ const ActionEffects = ({
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
/>
|
||||
)}
|
||||
{contextStoreNumberOfSelectedRecords === 1 && isWorkflowEnabled && (
|
||||
<WorkflowRunRecordActionMenuEntrySetterEffect
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
/>
|
||||
)}
|
||||
{contextStoreNumberOfSelectedRecords > 1 && (
|
||||
<MultipleRecordsActionMenuEntrySetterEffect
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { useDeleteSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useDeleteSingleRecordAction';
|
||||
import { useManageFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useManageFavoritesSingleRecordAction';
|
||||
import { useWorkflowRunRecordActions } from '@/action-menu/actions/record-actions/workflow-run-record-actions/hooks/useWorkflowRunRecordActions';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
|
||||
export const useSingleRecordActions = ({
|
||||
@ -24,23 +23,14 @@ export const useSingleRecordActions = ({
|
||||
objectMetadataItem,
|
||||
});
|
||||
|
||||
const {
|
||||
registerWorkflowRunRecordActions,
|
||||
unregisterWorkflowRunRecordActions,
|
||||
} = useWorkflowRunRecordActions({
|
||||
objectMetadataItem,
|
||||
});
|
||||
|
||||
const registerSingleRecordActions = () => {
|
||||
registerManageFavoritesSingleRecordAction();
|
||||
registerDeleteSingleRecordAction();
|
||||
registerWorkflowRunRecordActions();
|
||||
};
|
||||
|
||||
const unregisterSingleRecordActions = () => {
|
||||
unregisterManageFavoritesSingleRecordAction();
|
||||
unregisterDeleteSingleRecordAction();
|
||||
unregisterWorkflowRunRecordActions();
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { useEffect } from 'react';
|
||||
import { useWorkflowRunRecordActions } from '../hooks/useWorkflowRunRecordActions';
|
||||
|
||||
export const WorkflowRunRecordActionMenuEntrySetterEffect = ({
|
||||
objectMetadataItem,
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
}) => {
|
||||
const {
|
||||
registerWorkflowRunRecordActions,
|
||||
unregisterWorkflowRunRecordActions,
|
||||
} = useWorkflowRunRecordActions({
|
||||
objectMetadataItem,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
registerWorkflowRunRecordActions();
|
||||
|
||||
return () => {
|
||||
unregisterWorkflowRunRecordActions();
|
||||
};
|
||||
}, [registerWorkflowRunRecordActions, unregisterWorkflowRunRecordActions]);
|
||||
|
||||
return null;
|
||||
};
|
||||
Reference in New Issue
Block a user