From 541bbb93cb6ac404d07114bc591591347e37ed71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?=
<71827178+bosiraphael@users.noreply.github.com>
Date: Thu, 28 Nov 2024 17:21:46 +0100
Subject: [PATCH] Fix: Put workflow run actions behind feature flag (#8798)
Fix: Put workflow run actions behind feature flag
---
.../RecordActionMenuEntriesSetter.tsx | 9 +++++++
.../hooks/useSingleRecordActions.tsx | 10 -------
...WorkflowRunRecordActionMenuEntrySetter.tsx | 26 +++++++++++++++++++
.../layout/page/components/DefaultLayout.tsx | 5 +++-
4 files changed, 39 insertions(+), 11 deletions(-)
create mode 100644 packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionMenuEntrySetter.tsx
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 b35bf3972..88f849fc8 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 && (
+
+ )}
{contextStoreNumberOfSelectedRecords > 1 && (
{
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 000000000..c2287493f
--- /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 2e3c99c77..d815d600e 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 (
<>
{
value={{ instanceId: 'command-menu' }}
>
-
+ {isWorkflowEnabled && }