From 0571eb2cf6ef29803dc1686ff805db0b8ad78372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?= <71827178+bosiraphael@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:29:41 +0100 Subject: [PATCH] Only display record actions inside the RecordIndexActionMenuDropdown (#10384) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the action menu dropdown, we only want to display the actions for the selected records, so we need to filter available actions according to their type and scope. Note: the `Search record` action was appearing twice because one is a standard action and one is a fallback action and both are registered in the available actions. We don't want to display this action because it isn't related to the selected records, it is a global action. Before: Capture d’écran 2025-02-21 à 12 12 53 After: Capture d’écran 2025-02-21 à 12 10 34 --- .../components/RecordIndexActionMenuDropdown.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuDropdown.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuDropdown.tsx index 60c4fc7a6..65f38b64d 100644 --- a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuDropdown.tsx +++ b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuDropdown.tsx @@ -2,6 +2,10 @@ import { actionMenuEntriesComponentSelector } from '@/action-menu/states/actionM import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext'; import { recordIndexActionMenuDropdownPositionComponentState } from '@/action-menu/states/recordIndexActionMenuDropdownPositionComponentState'; import { ActionMenuDropdownHotkeyScope } from '@/action-menu/types/ActionMenuDropdownHotKeyScope'; +import { + ActionMenuEntryScope, + ActionMenuEntryType, +} from '@/action-menu/types/ActionMenuEntry'; import { getActionMenuDropdownIdFromActionMenuId } from '@/action-menu/utils/getActionMenuDropdownIdFromActionMenuId'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; @@ -29,6 +33,12 @@ export const RecordIndexActionMenuDropdown = () => { actionMenuEntriesComponentSelector, ); + const recordIndexActions = actionMenuEntries.filter( + (actionMenuEntry) => + actionMenuEntry.type === ActionMenuEntryType.Standard && + actionMenuEntry.scope === ActionMenuEntryScope.RecordSelection, + ); + const actionMenuId = useAvailableComponentInstanceIdOrThrow( ActionMenuComponentInstanceContext, ); @@ -44,7 +54,7 @@ export const RecordIndexActionMenuDropdown = () => { ); //TODO: remove this - const width = actionMenuEntries.some( + const width = recordIndexActions.some( (actionMenuEntry) => i18n._(actionMenuEntry.label) === 'Remove from favorites', ) @@ -68,7 +78,7 @@ export const RecordIndexActionMenuDropdown = () => { dropdownComponents={ - {actionMenuEntries.map((item) => ( + {recordIndexActions.map((item) => (