/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { CheckIcon } from "lucide-react"; import * as React from "react"; // ui import { Tooltip } from "@plane/propel/tooltip"; import type { TContextMenuItem } from "../dropdowns"; import { ActionDropdown } from "../dropdowns"; import { cn } from "../utils"; import { Breadcrumbs } from "./breadcrumbs"; type TBreadcrumbNavigationDropdownProps = { selectedItemKey: string; navigationItems: TContextMenuItem[]; navigationDisabled?: boolean; handleOnClick?: () => void; isLast?: boolean; }; export function BreadcrumbNavigationDropdown(props: TBreadcrumbNavigationDropdownProps) { const { selectedItemKey, navigationItems, navigationDisabled = false, handleOnClick, isLast = false } = props; const [isOpen, setIsOpen] = React.useState(false); // derived values const selectedItem = navigationItems.find((item) => item.key === selectedItemKey); const selectedItemIcon = selectedItem?.icon ? ( ) : undefined; // if no selected item, return null if (!selectedItem) return null; function NavigationButton() { return ( { if (!isLast) { e.preventDefault(); e.stopPropagation(); handleOnClick?.(); } }} className={cn( "group flex h-full cursor-pointer items-center gap-2 rounded-sm rounded-r-none px-1.5 py-1 text-13 font-medium text-tertiary", { "hover:bg-layer-1 hover:text-primary": !isLast, } )} > ... {selectedItemIcon && {selectedItemIcon}} {selectedItem?.title} ); } if (navigationDisabled) { return ; } return ( > } placement="bottom-start" className="h-full rounded-sm" buttonClassName={cn( "group flex h-full cursor-pointer items-center gap-0.5 rounded-sm outline-none hover:bg-surface-2", { "bg-surface-2": isOpen, } )} onOpenChange={setIsOpen} items={navigationItems.map((item) => ({ ...item, action: () => { if (item.key === selectedItemKey) return; item.action(); }, customContent: ( {item.icon && } {item.title} {item.description && ( {item.description} )} {item.key === selectedItemKey && } ), }))} /> ); }
{item.description}