Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Put workflow run actions behind feature flag #8798

Merged
merged 6 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down Expand Up @@ -34,6 +36,8 @@ const ActionEffects = ({
contextStoreNumberOfSelectedRecordsComponentState,
);

const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED');

return (
<>
{contextStoreNumberOfSelectedRecords === 0 && (
Expand All @@ -46,6 +50,11 @@ const ActionEffects = ({
objectMetadataItem={objectMetadataItem}
/>
)}
{contextStoreNumberOfSelectedRecords === 1 && isWorkflowEnabled && (
<WorkflowRunRecordActionMenuEntrySetterEffect
objectMetadataItem={objectMetadataItem}
/>
)}
{contextStoreNumberOfSelectedRecords > 1 && (
<MultipleRecordsActionMenuEntrySetterEffect
objectMetadataItem={objectMetadataItem}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = ({
Expand All @@ -24,23 +23,14 @@ export const useSingleRecordActions = ({
objectMetadataItem,
});

const {
registerWorkflowRunRecordActions,
unregisterWorkflowRunRecordActions,
} = useWorkflowRunRecordActions({
objectMetadataItem,
});

const registerSingleRecordActions = () => {
registerManageFavoritesSingleRecordAction();
registerDeleteSingleRecordAction();
registerWorkflowRunRecordActions();
};

const unregisterSingleRecordActions = () => {
unregisterManageFavoritesSingleRecordAction();
unregisterDeleteSingleRecordAction();
unregisterWorkflowRunRecordActions();
};

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -75,6 +76,8 @@ export const DefaultLayout = () => {
const windowsWidth = useScreenSize().width;
const showAuthModal = useShowAuthModal();

const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED');

return (
<>
<Global
Expand All @@ -92,7 +95,7 @@ export const DefaultLayout = () => {
value={{ instanceId: 'command-menu' }}
>
<RecordActionMenuEntriesSetter />
<RecordAgnosticActionsSetterEffect />
{isWorkflowEnabled && <RecordAgnosticActionsSetterEffect />}
<ActionMenuConfirmationModals />
<CommandMenu />
</ActionMenuComponentInstanceContext.Provider>
Expand Down
Loading