8929 move recordindexactionmenu menu inside the recordindexpageheader (#9007)
Closes #8929 Users with the feature flag `IS_PAGE_HEADER_V2_ENABLED` set to false will still have the old behavior with the action bar. To test the PR, test with and without the feature flag.
This commit is contained in:
@ -38,6 +38,7 @@ import { mapViewFieldsToColumnDefinitions } from '@/views/utils/mapViewFieldsToC
|
||||
import { mapViewFiltersToFilters } from '@/views/utils/mapViewFiltersToFilters';
|
||||
import { mapViewGroupsToRecordGroupDefinitions } from '@/views/utils/mapViewGroupsToRecordGroupDefinitions';
|
||||
import { mapViewSortsToSorts } from '@/views/utils/mapViewSortsToSorts';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useCallback, useContext } from 'react';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
|
||||
@ -158,6 +159,10 @@ export const RecordIndexContainer = () => {
|
||||
contextStoreTargetedRecordsRuleComponentState,
|
||||
);
|
||||
|
||||
const isPageHeaderV2Enabled = useIsFeatureEnabled(
|
||||
'IS_PAGE_HEADER_V2_ENABLED',
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<InformationBannerWrapper />
|
||||
@ -240,7 +245,7 @@ export const RecordIndexContainer = () => {
|
||||
<RecordIndexBoardDataLoaderEffect recordBoardId={recordIndexId} />
|
||||
</StyledContainerWithPadding>
|
||||
)}
|
||||
<RecordIndexActionMenu />
|
||||
{!isPageHeaderV2Enabled && <RecordIndexActionMenu />}
|
||||
</RecordFieldValueSelectorContextProvider>
|
||||
</StyledContainer>
|
||||
);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { RecordIndexActionMenu } from '@/action-menu/components/RecordIndexActionMenu';
|
||||
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
||||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
||||
import { isObjectMetadataReadOnly } from '@/object-metadata/utils/isObjectMetadataReadOnly';
|
||||
import { RecordIndexPageKanbanAddButton } from '@/object-record/record-index/components/RecordIndexPageKanbanAddButton';
|
||||
@ -7,11 +9,12 @@ import { PageHeaderOpenCommandMenuButton } from '@/ui/layout/page-header/compone
|
||||
import { PageAddButton } from '@/ui/layout/page/components/PageAddButton';
|
||||
import { PageHeader } from '@/ui/layout/page/components/PageHeader';
|
||||
import { PageHotkeysEffect } from '@/ui/layout/page/components/PageHotkeysEffect';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { ViewType } from '@/views/types/ViewType';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useContext } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useIcons } from 'twenty-ui';
|
||||
import { isDefined, useIcons } from 'twenty-ui';
|
||||
import { capitalize } from '~/utils/string/capitalize';
|
||||
|
||||
export const RecordIndexPageHeader = () => {
|
||||
@ -32,9 +35,21 @@ export const RecordIndexPageHeader = () => {
|
||||
|
||||
const recordIndexViewType = useRecoilValue(recordIndexViewTypeState);
|
||||
|
||||
const shouldDisplayAddButton = objectMetadataItem
|
||||
? !isObjectMetadataReadOnly(objectMetadataItem)
|
||||
: false;
|
||||
const numberOfSelectedRecords = useRecoilComponentValueV2(
|
||||
contextStoreNumberOfSelectedRecordsComponentState,
|
||||
);
|
||||
|
||||
const isPageHeaderV2Enabled = useIsFeatureEnabled(
|
||||
'IS_PAGE_HEADER_V2_ENABLED',
|
||||
);
|
||||
|
||||
const isObjectMetadataItemReadOnly =
|
||||
isDefined(objectMetadataItem) &&
|
||||
isObjectMetadataReadOnly(objectMetadataItem);
|
||||
|
||||
const shouldDisplayAddButton =
|
||||
(numberOfSelectedRecords === 0 || !isPageHeaderV2Enabled) &&
|
||||
!isObjectMetadataItemReadOnly;
|
||||
|
||||
const isTable = recordIndexViewType === ViewType.Table;
|
||||
|
||||
@ -45,20 +60,23 @@ export const RecordIndexPageHeader = () => {
|
||||
onCreateRecord();
|
||||
};
|
||||
|
||||
const isPageHeaderV2Enabled = useIsFeatureEnabled(
|
||||
'IS_PAGE_HEADER_V2_ENABLED',
|
||||
);
|
||||
|
||||
return (
|
||||
<PageHeader title={pageHeaderTitle} Icon={Icon}>
|
||||
<PageHotkeysEffect onAddButtonClick={handleAddButtonClick} />
|
||||
|
||||
{shouldDisplayAddButton &&
|
||||
(isTable ? (
|
||||
<PageAddButton onClick={handleAddButtonClick} />
|
||||
) : (
|
||||
<RecordIndexPageKanbanAddButton />
|
||||
))}
|
||||
{isPageHeaderV2Enabled && <PageHeaderOpenCommandMenuButton />}
|
||||
|
||||
{isPageHeaderV2Enabled && (
|
||||
<>
|
||||
<RecordIndexActionMenu />
|
||||
<PageHeaderOpenCommandMenuButton />
|
||||
</>
|
||||
)}
|
||||
</PageHeader>
|
||||
);
|
||||
};
|
||||
|
||||
@ -38,6 +38,7 @@ export const RecordTableBodyUnselectEffect = ({
|
||||
'action-menu-dropdown',
|
||||
'command-menu',
|
||||
'modal-backdrop',
|
||||
'page-action-container',
|
||||
],
|
||||
listenerId: RECORD_TABLE_CLICK_OUTSIDE_LISTENER_ID,
|
||||
refs: [tableBodyRef],
|
||||
|
||||
Reference in New Issue
Block a user