diff --git a/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx
index 0929ffc81..424b339af 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/global-actions/workflow-run-actions/components/WorkflowRunActionEffect.tsx
@@ -1,4 +1,8 @@
import { useActionMenuEntries } from '@/action-menu/hooks/useActionMenuEntries';
+import {
+ ActionMenuEntryScope,
+ ActionMenuEntryType,
+} from '@/action-menu/types/ActionMenuEntry';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useAllActiveWorkflowVersions } from '@/workflow/hooks/useAllActiveWorkflowVersions';
@@ -28,9 +32,9 @@ export const WorkflowRunActionEffect = () => {
activeWorkflowVersion,
] of activeWorkflowVersions.entries()) {
addActionMenuEntry({
- type: 'workflow-run',
+ type: ActionMenuEntryType.WorkflowRun,
key: `workflow-run-${activeWorkflowVersion.id}`,
- scope: 'global',
+ scope: ActionMenuEntryScope.Global,
label: capitalize(activeWorkflowVersion.workflow.name),
position: index,
Icon: IconSettingsAutomation,
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/DeleteRecordsActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/DeleteRecordsActionEffect.tsx
index 4f6d4f914..629d74f27 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/DeleteRecordsActionEffect.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/DeleteRecordsActionEffect.tsx
@@ -1,5 +1,9 @@
import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext';
import { useActionMenuEntries } from '@/action-menu/hooks/useActionMenuEntries';
+import {
+ ActionMenuEntryScope,
+ ActionMenuEntryType,
+} from '@/action-menu/types/ActionMenuEntry';
import { contextStoreFiltersComponentState } from '@/context-store/states/contextStoreFiltersComponentState';
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
@@ -105,8 +109,8 @@ export const DeleteRecordsActionEffect = ({
useEffect(() => {
if (canDelete) {
addActionMenuEntry({
- type: 'standard',
- scope: 'record-selection',
+ type: ActionMenuEntryType.Standard,
+ scope: ActionMenuEntryScope.RecordSelection,
key: 'delete',
label: 'Delete',
position,
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ExportRecordsActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ExportRecordsActionEffect.tsx
index 602aa9623..b4636a1d3 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ExportRecordsActionEffect.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ExportRecordsActionEffect.tsx
@@ -4,6 +4,10 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { IconDatabaseExport } from 'twenty-ui';
+import {
+ ActionMenuEntryScope,
+ ActionMenuEntryType,
+} from '@/action-menu/types/ActionMenuEntry';
import {
displayedExportProgress,
useExportRecords,
@@ -31,8 +35,11 @@ export const ExportRecordsActionEffect = ({
useEffect(() => {
addActionMenuEntry({
- type: 'standard',
- scope: 'record-selection',
+ type: ActionMenuEntryType.Standard,
+ scope:
+ contextStoreNumberOfSelectedRecords > 0
+ ? ActionMenuEntryScope.RecordSelection
+ : ActionMenuEntryScope.Global,
key: 'export',
position,
label: displayedExportProgress(progress),
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ManageFavoritesActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ManageFavoritesActionEffect.tsx
index ecb31f197..f1423b922 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ManageFavoritesActionEffect.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/components/ManageFavoritesActionEffect.tsx
@@ -1,4 +1,8 @@
import { useActionMenuEntries } from '@/action-menu/hooks/useActionMenuEntries';
+import {
+ ActionMenuEntryScope,
+ ActionMenuEntryType,
+} from '@/action-menu/types/ActionMenuEntry';
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
import { useCreateFavorite } from '@/favorites/hooks/useCreateFavorite';
import { useDeleteFavorite } from '@/favorites/hooks/useDeleteFavorite';
@@ -50,8 +54,8 @@ export const ManageFavoritesActionEffect = ({
}
addActionMenuEntry({
- type: 'standard',
- scope: 'record-selection',
+ type: ActionMenuEntryType.Standard,
+ scope: ActionMenuEntryScope.RecordSelection,
key: 'manage-favorites',
label: isFavorite ? 'Remove from favorites' : 'Add to favorites',
position,
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 7d64ec72c..417fa1dd1 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
@@ -7,6 +7,7 @@ import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-sto
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';
const noSelectionRecordActionEffects = [ExportRecordsActionEffect];
@@ -21,25 +22,33 @@ const multipleRecordActionEffects = [
];
export const RecordActionMenuEntriesSetter = () => {
- const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2(
- contextStoreNumberOfSelectedRecordsComponentState,
- );
-
const contextStoreCurrentObjectMetadataId = useRecoilComponentValueV2(
contextStoreCurrentObjectMetadataIdComponentState,
);
+ if (!isDefined(contextStoreCurrentObjectMetadataId)) {
+ return null;
+ }
+
+ return (
+
+ );
+};
+
+const ActionEffects = ({
+ objectMetadataItemId,
+}: {
+ objectMetadataItemId: string;
+}) => {
const { objectMetadataItem } = useObjectMetadataItemById({
- objectId: contextStoreCurrentObjectMetadataId ?? '',
+ objectId: objectMetadataItemId,
});
- const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED');
+ const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2(
+ contextStoreNumberOfSelectedRecordsComponentState,
+ );
- if (!objectMetadataItem) {
- throw new Error(
- `Object metadata item not found for id ${contextStoreCurrentObjectMetadataId}`,
- );
- }
+ const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED');
const actions =
contextStoreNumberOfSelectedRecords === 0
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx
index 8f7b1a85f..9535571eb 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/workflow-run-record-actions/components/WorkflowRunRecordActionEffect.tsx
@@ -1,4 +1,8 @@
import { useActionMenuEntries } from '@/action-menu/hooks/useActionMenuEntries';
+import {
+ ActionMenuEntryScope,
+ ActionMenuEntryType,
+} from '@/action-menu/types/ActionMenuEntry';
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
@@ -55,9 +59,9 @@ export const WorkflowRunRecordActionEffect = ({
activeWorkflowVersion,
] of activeWorkflowVersions.entries()) {
addActionMenuEntry({
- type: 'workflow-run',
+ type: ActionMenuEntryType.WorkflowRun,
key: `workflow-run-${activeWorkflowVersion.id}`,
- scope: 'record-selection',
+ scope: ActionMenuEntryScope.RecordSelection,
label: capitalize(activeWorkflowVersion.workflow.name),
position: index,
Icon: IconSettingsAutomation,
diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuEffect.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuEffect.tsx
index 3306d9fb0..66d49da9a 100644
--- a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuEffect.tsx
+++ b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuEffect.tsx
@@ -43,7 +43,12 @@ export const RecordIndexActionMenuEffect = () => {
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
useEffect(() => {
- if (contextStoreNumberOfSelectedRecords > 0 && !isDropdownOpen) {
+ if (
+ contextStoreNumberOfSelectedRecords > 0 &&
+ !isDropdownOpen &&
+ !isRightDrawerOpen &&
+ !isCommandMenuOpened
+ ) {
// We only handle opening the ActionMenuBar here, not the Dropdown.
// The Dropdown is already managed by sync handlers for events like
// right-click to open and click outside to close.
@@ -57,6 +62,8 @@ export const RecordIndexActionMenuEffect = () => {
openActionBar,
closeActionBar,
isDropdownOpen,
+ isRightDrawerOpen,
+ isCommandMenuOpened,
]);
useEffect(() => {
diff --git a/packages/twenty-front/src/modules/action-menu/components/RightDrawerActionMenuDropdown.tsx b/packages/twenty-front/src/modules/action-menu/components/RightDrawerActionMenuDropdown.tsx
index 2eeba8190..86b028a73 100644
--- a/packages/twenty-front/src/modules/action-menu/components/RightDrawerActionMenuDropdown.tsx
+++ b/packages/twenty-front/src/modules/action-menu/components/RightDrawerActionMenuDropdown.tsx
@@ -1,5 +1,6 @@
import { actionMenuEntriesComponentSelector } from '@/action-menu/states/actionMenuEntriesComponentSelector';
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
+import { ActionMenuEntryScope } from '@/action-menu/types/ActionMenuEntry';
import { RightDrawerActionMenuDropdownHotkeyScope } from '@/action-menu/types/RightDrawerActionMenuDropdownHotkeyScope';
import { getRightDrawerActionMenuDropdownIdFromActionMenuId } from '@/action-menu/utils/getRightDrawerActionMenuDropdownIdFromActionMenuId';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
@@ -67,7 +68,8 @@ export const RightDrawerActionMenuDropdown = () => {
{actionMenuEntries
.filter(
- (actionMenuEntry) => actionMenuEntry.scope === 'record-selection',
+ (actionMenuEntry) =>
+ actionMenuEntry.scope === ActionMenuEntryScope.RecordSelection,
)
.map((actionMenuEntry, index) => (