import { observer } from "mobx-react"; import Link from "next/link"; import { useParams, usePathname } from "next/navigation"; import { Files, FolderOpen } from "lucide-react"; // ui import { Tooltip } from "@plane/ui"; // helpers import { cn } from "@/helpers/common.helper"; // hooks import { useAppTheme } from "@/hooks/store"; // plane web hooks import { useFlag } from "@/plane-web/hooks/store/use-flag"; const APPS_LIST = [ { key: "projects", label: "Projects", icon: FolderOpen, color: "#5472e4", href: "/", }, { key: "pages", label: "Pages", icon: Files, color: "#17a68c", href: "/pages", }, ]; export const SidebarAppSwitcher = observer(() => { // params const { workspaceSlug } = useParams(); const pathname = usePathname(); // store hooks const { sidebarCollapsed } = useAppTheme(); const isWorkspacePagesEnabled = useFlag(workspaceSlug?.toString(), "WORKSPACE_PAGES"); const isPagesApp = pathname.includes(`/${workspaceSlug.toString()}/pages`); if (!isWorkspacePagesEnabled) return null; return (
{APPS_LIST.map((app) => { const isSelected = (app.key === "pages" && isPagesApp) || (app.key === "projects" && !isPagesApp); return ( {!sidebarCollapsed && {app.label}} ); })}
); });