Fix: Put workflow run actions behind feature flag (#8798)

Fix: Put workflow run actions behind feature flag
This commit is contained in:
Raphaël Bosi
2024-11-28 17:21:46 +01:00
committed by GitHub
parent 33159e29b7
commit 541bbb93cb
4 changed files with 39 additions and 11 deletions

View File

@ -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}

View File

@ -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 {

View File

@ -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;
};

View File

@ -16,6 +16,7 @@ import { SignInBackgroundMockPage } from '@/sign-in-background-mock/components/S
import { useShowAuthModal } from '@/ui/layout/hooks/useShowAuthModal';
import { NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/NavDrawerWidths';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { css, Global, useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { AnimatePresence, LayoutGroup, motion } from 'framer-motion';
@ -75,6 +76,8 @@ export const DefaultLayout = () => {
const windowsWidth = useScreenSize().width;
const showAuthModal = useShowAuthModal();
const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED');
return (
<>
<Global
@ -92,7 +95,7 @@ export const DefaultLayout = () => {
value={{ instanceId: 'command-menu' }}
>
<RecordActionMenuEntriesSetter />
<RecordAgnosticActionsSetterEffect />
{isWorkflowEnabled && <RecordAgnosticActionsSetterEffect />}
<ActionMenuConfirmationModals />
<CommandMenu />
</ActionMenuComponentInstanceContext.Provider>