2025-06-19 17:17:14 +05:30
|
|
|
"use client";
|
|
|
|
|
|
2025-10-14 16:45:07 +05:30
|
|
|
import type { FC } from "react";
|
2025-06-19 17:17:14 +05:30
|
|
|
import { observer } from "mobx-react";
|
2025-08-15 13:10:26 +05:30
|
|
|
// plane imports
|
2025-06-19 17:17:14 +05:30
|
|
|
import { EProjectFeatureKey } from "@plane/constants";
|
2025-10-14 16:45:07 +05:30
|
|
|
import type { ISvgIcons } from "@plane/propel/icons";
|
2025-09-04 14:44:53 +05:30
|
|
|
import { BreadcrumbNavigationDropdown, Breadcrumbs } from "@plane/ui";
|
2025-06-19 17:17:14 +05:30
|
|
|
// components
|
2025-08-15 13:10:26 +05:30
|
|
|
import { SwitcherLabel } from "@/components/common/switcher-label";
|
|
|
|
|
import type { TNavigationItem } from "@/components/workspace/sidebar/project-navigation";
|
2025-06-19 17:17:14 +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-08-15 13:10:26 +05:30
|
|
|
// local imports
|
2025-08-25 02:13:20 +05:30
|
|
|
import { getProjectFeatureNavigation } from "../projects/navigation/helper";
|
2025-06-19 17:17:14 +05:30
|
|
|
|
|
|
|
|
type TProjectFeatureBreadcrumbProps = {
|
|
|
|
|
workspaceSlug: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
featureKey: EProjectFeatureKey;
|
|
|
|
|
isLast?: boolean;
|
|
|
|
|
additionalNavigationItems?: TNavigationItem[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ProjectFeatureBreadcrumb = observer((props: TProjectFeatureBreadcrumbProps) => {
|
|
|
|
|
const { workspaceSlug, projectId, featureKey, isLast = false, additionalNavigationItems } = props;
|
|
|
|
|
// router
|
|
|
|
|
const router = useAppRouter();
|
|
|
|
|
// store hooks
|
|
|
|
|
const { getPartialProjectById } = useProject();
|
|
|
|
|
// derived values
|
|
|
|
|
const project = getPartialProjectById(projectId);
|
|
|
|
|
|
|
|
|
|
if (!project) return null;
|
|
|
|
|
|
|
|
|
|
const navigationItems = getProjectFeatureNavigation(workspaceSlug, projectId, project);
|
|
|
|
|
|
|
|
|
|
// if additional navigation items are provided, add them to the navigation items
|
|
|
|
|
const allNavigationItems = [...(additionalNavigationItems || []), ...navigationItems];
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Breadcrumbs.Item
|
|
|
|
|
component={
|
|
|
|
|
<BreadcrumbNavigationDropdown
|
|
|
|
|
selectedItemKey={featureKey}
|
|
|
|
|
navigationItems={allNavigationItems
|
|
|
|
|
.filter((item) => item.shouldRender)
|
|
|
|
|
.map((item) => ({
|
|
|
|
|
key: item.key,
|
|
|
|
|
title: item.name,
|
|
|
|
|
customContent: <SwitcherLabel name={item.name} LabelIcon={item.icon as FC<ISvgIcons>} />,
|
|
|
|
|
action: () => router.push(item.href),
|
|
|
|
|
icon: item.icon as FC<ISvgIcons>,
|
|
|
|
|
}))}
|
|
|
|
|
handleOnClick={() => {
|
|
|
|
|
router.push(
|
|
|
|
|
`/${workspaceSlug}/projects/${projectId}/${featureKey === EProjectFeatureKey.WORK_ITEMS ? "issues" : featureKey}/`
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
isLast={isLast}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
showSeparator={false}
|
|
|
|
|
isLast={isLast}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
});
|