Files
twenty/packages/twenty-front/src/modules/page-layout/utils/getTabsByDisplayMode.ts
T
Baptiste Devessier b9bdb12b3c Hide page layout tab bar when there are less than two tabs to display (#15385)
- DIsplay the tab bar only if more than 1 tabs can be displayed
- Remove the selfDisplayMode feature: the first tab is now considered to
be the pinned tab on record pages


https://github.com/user-attachments/assets/3f61931d-fde4-4065-b646-5b3a7bdebcc0
2025-10-28 17:20:32 +05:30

35 lines
826 B
TypeScript

import { type DraftPageLayout } from '@/page-layout/types/draft-page-layout';
import { type PageLayout } from '@/page-layout/types/PageLayout';
import { PageLayoutType } from '~/generated/graphql';
type GetTabsByDisplayModeParams = {
pageLayout: PageLayout | DraftPageLayout;
isMobile: boolean;
isInRightDrawer: boolean;
};
export const getTabsByDisplayMode = ({
pageLayout,
isMobile,
isInRightDrawer,
}: GetTabsByDisplayModeParams) => {
if (
isMobile ||
isInRightDrawer ||
pageLayout.type !== PageLayoutType.RECORD_PAGE
) {
return {
tabsToRenderInTabList: pageLayout.tabs,
pinnedLeftTab: undefined,
};
}
const tabsToRenderInTabList = pageLayout.tabs.slice(1);
const pinnedLeftTab = pageLayout.tabs[0];
return {
tabsToRenderInTabList,
pinnedLeftTab,
};
};