import { FC, Fragment, useMemo } from "react"; import { observer } from "mobx-react-lite"; import { LucideIcon, List, Kanban, Calendar, Sheet, GanttChartSquare } from "lucide-react"; // hooks import { useViewDetail } from "hooks/store"; // ui import { Tooltip } from "@plane/ui"; // types import { TViewTypes } from "@plane/types"; // constants import { EViewLayouts, EViewPageType, viewPageDefaultLayoutsByPageType } from "constants/view"; type TViewLayoutRoot = { workspaceSlug: string; projectId: string | undefined; viewId: string; viewType: TViewTypes; viewPageType: EViewPageType; }; export const ViewLayoutRoot: FC = observer((props) => { const { workspaceSlug, projectId, viewId, viewType, viewPageType } = props; // hooks const viewDetailStore = useViewDetail(workspaceSlug, projectId, viewId, viewType); const LAYOUTS_DATA: { key: EViewLayouts; title: string; icon: LucideIcon }[] = useMemo( () => [ { key: EViewLayouts.LIST, title: "List Layout", icon: List }, { key: EViewLayouts.KANBAN, title: "Kanban Layout", icon: Kanban }, { key: EViewLayouts.CALENDAR, title: "Calendar Layout", icon: Calendar }, { key: EViewLayouts.SPREADSHEET, title: "Spreadsheet Layout", icon: Sheet }, { key: EViewLayouts.GANTT, title: "Gantt Chart layout", icon: GanttChartSquare }, ], [] ); const validLayouts = useMemo(() => viewPageDefaultLayoutsByPageType(viewPageType), [viewPageType]); if (!viewDetailStore || validLayouts.length <= 1) return <>; return (
{LAYOUTS_DATA.map((layout) => { if (!validLayouts.includes(layout.key)) return ; return (
viewDetailStore.setDisplayFilters({ layout: layout.key })} >
); })}
); });