2025-01-06 19:00:05 +05:30
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { observer } from "mobx-react";
|
2025-10-13 19:43:24 +05:30
|
|
|
import { ProjectIcon } from "@plane/propel/icons";
|
2025-06-19 17:17:14 +05:30
|
|
|
// plane imports
|
2025-10-14 16:45:07 +05:30
|
|
|
import type { ICustomSearchSelectOption } from "@plane/types";
|
2025-09-02 19:00:15 +05:30
|
|
|
import { BreadcrumbNavigationSearchDropdown, Breadcrumbs } from "@plane/ui";
|
2025-01-06 19:00:05 +05:30
|
|
|
// components
|
2025-09-02 19:00:15 +05:30
|
|
|
import { Logo } from "@/components/common/logo";
|
2025-08-15 13:10:26 +05:30
|
|
|
import { SwitcherLabel } from "@/components/common/switcher-label";
|
2025-01-06 19:00:05 +05:30
|
|
|
// hooks
|
2025-08-15 13:10:26 +05:30
|
|
|
import { useProject } from "@/hooks/store/use-project";
|
2025-06-19 17:17:14 +05:30
|
|
|
import { useAppRouter } from "@/hooks/use-app-router";
|
2025-10-14 16:45:07 +05:30
|
|
|
import type { TProject } from "@/plane-web/types";
|
2025-06-19 17:17:14 +05:30
|
|
|
|
|
|
|
|
type TProjectBreadcrumbProps = {
|
|
|
|
|
workspaceSlug: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
handleOnClick?: () => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ProjectBreadcrumb = observer((props: TProjectBreadcrumbProps) => {
|
|
|
|
|
const { workspaceSlug, projectId, handleOnClick } = props;
|
|
|
|
|
// router
|
|
|
|
|
const router = useAppRouter();
|
|
|
|
|
// store hooks
|
|
|
|
|
const { joinedProjectIds, getPartialProjectById } = useProject();
|
|
|
|
|
const currentProjectDetails = getPartialProjectById(projectId);
|
2025-01-06 19:00:05 +05:30
|
|
|
|
|
|
|
|
// store hooks
|
2025-06-19 17:17:14 +05:30
|
|
|
|
|
|
|
|
if (!currentProjectDetails) return null;
|
|
|
|
|
|
|
|
|
|
// derived values
|
|
|
|
|
const switcherOptions = joinedProjectIds
|
|
|
|
|
.map((projectId) => {
|
|
|
|
|
const project = getPartialProjectById(projectId);
|
|
|
|
|
return {
|
|
|
|
|
value: projectId,
|
|
|
|
|
query: project?.name,
|
2025-07-30 17:18:18 +05:30
|
|
|
content: (
|
2025-10-13 19:43:24 +05:30
|
|
|
<SwitcherLabel
|
|
|
|
|
name={project?.name}
|
|
|
|
|
logo_props={project?.logo_props}
|
|
|
|
|
LabelIcon={ProjectIcon}
|
|
|
|
|
type="material"
|
|
|
|
|
/>
|
2025-07-30 17:18:18 +05:30
|
|
|
),
|
2025-06-19 17:17:14 +05:30
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.filter((option) => option !== undefined) as ICustomSearchSelectOption[];
|
|
|
|
|
|
|
|
|
|
// helpers
|
|
|
|
|
const renderIcon = (projectDetails: TProject) => (
|
|
|
|
|
<span className="grid place-items-center flex-shrink-0 h-4 w-4">
|
|
|
|
|
<Logo logo={projectDetails.logo_props} size={14} />
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2025-01-06 19:00:05 +05:30
|
|
|
|
|
|
|
|
return (
|
2025-06-19 17:17:14 +05:30
|
|
|
<>
|
|
|
|
|
<Breadcrumbs.Item
|
|
|
|
|
component={
|
|
|
|
|
<BreadcrumbNavigationSearchDropdown
|
|
|
|
|
selectedItem={currentProjectDetails.id}
|
|
|
|
|
navigationItems={switcherOptions}
|
|
|
|
|
onChange={(value: string) => {
|
|
|
|
|
router.push(`/${workspaceSlug}/projects/${value}/issues`);
|
|
|
|
|
}}
|
|
|
|
|
title={currentProjectDetails?.name}
|
|
|
|
|
icon={renderIcon(currentProjectDetails)}
|
|
|
|
|
handleOnClick={() => {
|
|
|
|
|
if (handleOnClick) handleOnClick();
|
|
|
|
|
else router.push(`/${workspaceSlug}/projects/${currentProjectDetails.id}/issues/`);
|
|
|
|
|
}}
|
2025-07-22 16:47:14 +05:30
|
|
|
shouldTruncate
|
2025-06-19 17:17:14 +05:30
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
showSeparator={false}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
2025-01-06 19:00:05 +05:30
|
|
|
);
|
|
|
|
|
});
|