e0d1f74648
- Allow widgets to be hidden based on device's type conditions: desktop or mobile - Create two widgets for rich text fields on tasks and notes. One widget is displayed below fields on mobile (and in the right drawer); the other is displayed on a separate tab on desktop - In read mode, hide tabs if they contain no visible widgets. If there is no tab left to display, display at least the first one with no widgets. - In edit mode, display all tabs and all widgets. ## Demo https://github.com/user-attachments/assets/65ef1261-3902-4432-a420-48983b763b2c Closes https://github.com/twentyhq/core-team-issues/issues/1811
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { SummaryCard } from '@/object-record/record-show/components/SummaryCard';
|
|
import { PageLayoutContent } from '@/page-layout/components/PageLayoutContent';
|
|
import { PageLayoutContentProvider } from '@/page-layout/contexts/PageLayoutContentContext';
|
|
import { useCurrentPageLayout } from '@/page-layout/hooks/useCurrentPageLayout';
|
|
import { usePageLayoutTabWithVisibleWidgetsOrThrow } from '@/page-layout/hooks/usePageLayoutTabWithVisibleWidgetsOrThrow';
|
|
import { getTabLayoutMode } from '@/page-layout/utils/getTabLayoutMode';
|
|
import { useLayoutRenderingContext } from '@/ui/layout/contexts/LayoutRenderingContext';
|
|
import { useTargetRecord } from '@/ui/layout/contexts/useTargetRecord';
|
|
import { ShowPageLeftContainer } from '@/ui/layout/show-page/components/ShowPageLeftContainer';
|
|
import { PageLayoutType } from '~/generated/graphql';
|
|
|
|
type PageLayoutLeftPanelProps = {
|
|
pinnedLeftTabId: string;
|
|
};
|
|
|
|
export const PageLayoutLeftPanel = ({
|
|
pinnedLeftTabId,
|
|
}: PageLayoutLeftPanelProps) => {
|
|
const { currentPageLayout } = useCurrentPageLayout();
|
|
const targetRecordIdentifier = useTargetRecord();
|
|
const { isInRightDrawer } = useLayoutRenderingContext();
|
|
const pinnedTab = usePageLayoutTabWithVisibleWidgetsOrThrow(pinnedLeftTabId);
|
|
|
|
if (currentPageLayout?.type !== PageLayoutType.RECORD_PAGE) {
|
|
return null;
|
|
}
|
|
|
|
const layoutMode = getTabLayoutMode({
|
|
tab: pinnedTab,
|
|
pageLayoutType: currentPageLayout.type,
|
|
});
|
|
|
|
return (
|
|
<ShowPageLeftContainer>
|
|
<SummaryCard
|
|
objectNameSingular={targetRecordIdentifier.targetObjectNameSingular}
|
|
objectRecordId={targetRecordIdentifier.id}
|
|
isInRightDrawer={isInRightDrawer}
|
|
/>
|
|
|
|
<PageLayoutContentProvider
|
|
value={{
|
|
tabId: pinnedLeftTabId,
|
|
layoutMode,
|
|
}}
|
|
>
|
|
<PageLayoutContent />
|
|
</PageLayoutContentProvider>
|
|
</ShowPageLeftContainer>
|
|
);
|
|
};
|