import { useEffect } from "react"; import { observer } from "mobx-react-lite"; import Link from "next/link"; import { useRouter } from "next/router"; // components import { Briefcase } from "lucide-react"; import { Avatar, Button } from "@plane/ui"; import { ProjectLogo } from "@/components/common"; import { IssueFiltersDropdown } from "@/components/issues/filters"; // hooks import { useUser } from "@/hooks/store"; import { useMobxStore } from "@/lib/mobx/store-provider"; // store import { RootStore } from "@/store/root.store"; import { TIssueBoardKeys } from "@/types/issue"; import { NavbarIssueBoardView } from "./issue-board-view"; import { NavbarTheme } from "./theme"; const IssueNavbar = observer(() => { const { project: projectStore, issuesFilter: { updateFilters }, }: RootStore = useMobxStore(); const { data: user } = useUser(); // router const router = useRouter(); const { workspace_slug, project_slug, board, peekId, states, priorities, labels } = router.query as { workspace_slug: string; project_slug: string; peekId: string; board: string; states: string; priorities: string; labels: string; }; useEffect(() => { if (workspace_slug && project_slug) { projectStore.fetchProjectSettings(workspace_slug.toString(), project_slug.toString()); } }, [projectStore, workspace_slug, project_slug]); useEffect(() => { if (workspace_slug && project_slug && projectStore?.deploySettings) { const viewsAcceptable: string[] = []; let currentBoard: TIssueBoardKeys | null = null; if (projectStore?.deploySettings?.views?.list) viewsAcceptable.push("list"); if (projectStore?.deploySettings?.views?.kanban) viewsAcceptable.push("kanban"); if (projectStore?.deploySettings?.views?.calendar) viewsAcceptable.push("calendar"); if (projectStore?.deploySettings?.views?.gantt) viewsAcceptable.push("gantt"); if (projectStore?.deploySettings?.views?.spreadsheet) viewsAcceptable.push("spreadsheet"); if (board) { if (viewsAcceptable.includes(board.toString())) { currentBoard = board.toString() as TIssueBoardKeys; } else { if (viewsAcceptable && viewsAcceptable.length > 0) { currentBoard = viewsAcceptable[0] as TIssueBoardKeys; } } } else { if (viewsAcceptable && viewsAcceptable.length > 0) { currentBoard = viewsAcceptable[0] as TIssueBoardKeys; } } if (currentBoard) { if (projectStore?.activeBoard === null || projectStore?.activeBoard !== currentBoard) { let params: any = { board: currentBoard }; if (peekId && peekId.length > 0) params = { ...params, peekId: peekId }; if (priorities && priorities.length > 0) params = { ...params, priorities: priorities }; if (states && states.length > 0) params = { ...params, states: states }; if (labels && labels.length > 0) params = { ...params, labels: labels }; let storeParams: any = {}; if (priorities && priorities.length > 0) storeParams = { ...storeParams, priority: priorities.split(",") }; if (states && states.length > 0) storeParams = { ...storeParams, state: states.split(",") }; if (labels && labels.length > 0) storeParams = { ...storeParams, labels: labels.split(",") }; if (storeParams) updateFilters(project_slug, storeParams); projectStore.setActiveBoard(currentBoard); router.push({ pathname: `/${workspace_slug}/${project_slug}`, query: { ...params }, }); } } } }, [ board, workspace_slug, project_slug, router, projectStore, projectStore?.deploySettings, updateFilters, labels, states, priorities, peekId, ]); return (
{/* project detail */}
{projectStore.project ? ( ) : ( )}
{projectStore?.project?.name || `...`}
{/* issue search bar */}
{/* */}
{/* issue views */}
{/* issue filters */}
{/* theming */}
{user ? (
{user.display_name}
) : (
)}
); }); export default IssueNavbar;