Skip to content

The open alternative to Salesforce, designed for AI.

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

Raphaël Bosi541bbb93cb6a
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 b35bf397233..88f849fc8c7 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
@@ -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}
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useSingleRecordActions.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useSingleRecordActions.tsx
index 58248f1dc39..4b6a3763c67 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useSingleRecordActions.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useSingleRecordActions.tsx
@@ -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 {
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionMenuEntrySetter.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionMenuEntrySetter.tsx
new file mode 100644
index 00000000000..c2287493fb9
--- /dev/null
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionMenuEntrySetter.tsx
@@ -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;
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx
index 2e3c99c77c3..d815d600e91 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx
@@ -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>