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 1d1bfdf5beaf..a8982d3acfd0 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 @@ -5,16 +5,26 @@ import { WorkflowRunRecordActionMenuEntrySetterEffect } from '@/action-menu/acti import { contextStoreCurrentObjectMetadataIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdComponentState'; import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState'; import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById'; +import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; +import { useRecoilValue } from 'recoil'; import { isDefined } from 'twenty-ui'; export const RecordActionMenuEntriesSetter = () => { const contextStoreCurrentObjectMetadataId = useRecoilComponentValueV2( contextStoreCurrentObjectMetadataIdComponentState, ); + const objectMetadataItems = useRecoilValue(objectMetadataItemsState); - if (!isDefined(contextStoreCurrentObjectMetadataId)) { + const objectMetadataItem = objectMetadataItems.find( + (item) => item.id === contextStoreCurrentObjectMetadataId, + ); + + if ( + !isDefined(contextStoreCurrentObjectMetadataId) || + !isDefined(objectMetadataItem) + ) { return null; } diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useManageFavoritesSingleRecordAction.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useManageFavoritesSingleRecordAction.ts index 25a56d6fecef..12a81985a906 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useManageFavoritesSingleRecordAction.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/hooks/useManageFavoritesSingleRecordAction.ts @@ -8,6 +8,7 @@ import { useDeleteFavorite } from '@/favorites/hooks/useDeleteFavorite'; import { useFavorites } from '@/favorites/hooks/useFavorites'; import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; +import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useRecoilValue } from 'recoil'; import { IconHeart, IconHeartOff, isDefined } from 'twenty-ui'; @@ -34,6 +35,10 @@ export const useManageFavoritesSingleRecordAction = ({ const isFavorite = !!foundFavorite; + const isPageHeaderV2Enabled = useIsFeatureEnabled( + 'IS_PAGE_HEADER_V2_ENABLED', + ); + const registerManageFavoritesSingleRecordAction = ({ position, }: { @@ -47,6 +52,7 @@ export const useManageFavoritesSingleRecordAction = ({ type: ActionMenuEntryType.Standard, scope: ActionMenuEntryScope.RecordSelection, key: 'manage-favorites-single-record', + isPinned: isPageHeaderV2Enabled, label: isFavorite ? 'Remove from favorites' : 'Add to favorites', position, Icon: isFavorite ? IconHeartOff : IconHeart, diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenu.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenu.tsx index a20ff64c96a8..8eafd9040de5 100644 --- a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenu.tsx +++ b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenu.tsx @@ -2,6 +2,7 @@ import { RecordActionMenuEntriesSetter } from '@/action-menu/actions/record-acti import { RecordAgnosticActionsSetterEffect } from '@/action-menu/actions/record-agnostic-actions/components/RecordAgnosticActionsSetterEffect'; import { ActionMenuConfirmationModals } from '@/action-menu/components/ActionMenuConfirmationModals'; import { RecordIndexActionMenuBar } from '@/action-menu/components/RecordIndexActionMenuBar'; +import { RecordIndexActionMenuButtons } from '@/action-menu/components/RecordIndexActionMenuButtons'; import { RecordIndexActionMenuDropdown } from '@/action-menu/components/RecordIndexActionMenuDropdown'; import { RecordIndexActionMenuEffect } from '@/action-menu/components/RecordIndexActionMenuEffect'; import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext'; @@ -9,6 +10,7 @@ import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext'; import { contextStoreCurrentObjectMetadataIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdComponentState'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; +import { useIsMobile } from 'twenty-ui'; export const RecordIndexActionMenu = () => { const contextStoreCurrentObjectMetadataId = useRecoilComponentValueV2( @@ -17,6 +19,12 @@ export const RecordIndexActionMenu = () => { const isWorkflowEnabled = useIsFeatureEnabled('IS_WORKFLOW_ENABLED'); + const isPageHeaderV2Enabled = useIsFeatureEnabled( + 'IS_PAGE_HEADER_V2_ENABLED', + ); + + const isMobile = useIsMobile(); + return ( <> {contextStoreCurrentObjectMetadataId && ( @@ -26,7 +34,11 @@ export const RecordIndexActionMenu = () => { onActionExecutedCallback: () => {}, }} > - + {isPageHeaderV2Enabled ? ( + <>{!isMobile && } + ) : ( + + )} diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBar.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBar.tsx index fcc93f5bc50e..2800c622758c 100644 --- a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBar.tsx +++ b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBar.tsx @@ -1,5 +1,3 @@ -import styled from '@emotion/styled'; - import { RecordIndexActionMenuBarAllActionsButton } from '@/action-menu/components/RecordIndexActionMenuBarAllActionsButton'; import { RecordIndexActionMenuBarEntry } from '@/action-menu/components/RecordIndexActionMenuBarEntry'; import { actionMenuEntriesComponentSelector } from '@/action-menu/states/actionMenuEntriesComponentSelector'; @@ -10,6 +8,7 @@ import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-sto import { BottomBar } from '@/ui/layout/bottom-bar/components/BottomBar'; import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import styled from '@emotion/styled'; const StyledLabel = styled.div` color: ${({ theme }) => theme.font.color.tertiary}; @@ -33,7 +32,6 @@ export const RecordIndexActionMenuBar = () => { ); const pinnedEntries = actionMenuEntries.filter((entry) => entry.isPinned); - if (contextStoreNumberOfSelectedRecords === 0) { return null; } diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBarEntry.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBarEntry.tsx index ffa52d20590b..1c73010da1a2 100644 --- a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBarEntry.tsx +++ b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuBarEntry.tsx @@ -1,8 +1,7 @@ +import { ActionMenuEntry } from '@/action-menu/types/ActionMenuEntry'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { ActionMenuEntry } from '@/action-menu/types/ActionMenuEntry'; - type RecordIndexActionMenuBarEntryProps = { entry: ActionMenuEntry; }; @@ -13,11 +12,9 @@ const StyledButton = styled.div` cursor: pointer; display: flex; justify-content: center; - padding: ${({ theme }) => theme.spacing(2)}; transition: background ${({ theme }) => theme.animation.duration.fast} ease; user-select: none; - &:hover { background: ${({ theme }) => theme.background.tertiary}; } @@ -32,6 +29,7 @@ export const RecordIndexActionMenuBarEntry = ({ entry, }: RecordIndexActionMenuBarEntryProps) => { const theme = useTheme(); + return ( entry.onClick?.()}> {entry.Icon && } diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuButtons.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuButtons.tsx new file mode 100644 index 000000000000..34090f9922d4 --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/components/RecordIndexActionMenuButtons.tsx @@ -0,0 +1,37 @@ +import { actionMenuEntriesComponentSelector } from '@/action-menu/states/actionMenuEntriesComponentSelector'; +import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState'; +import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { Button } from 'twenty-ui'; + +export const RecordIndexActionMenuButtons = () => { + const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2( + contextStoreNumberOfSelectedRecordsComponentState, + ); + + const actionMenuEntries = useRecoilComponentValueV2( + actionMenuEntriesComponentSelector, + ); + + const pinnedEntries = actionMenuEntries.filter((entry) => entry.isPinned); + + if (contextStoreNumberOfSelectedRecords === 0) { + return null; + } + + return ( + <> + {pinnedEntries.map((entry, index) => ( +