import { observer } from "mobx-react"; import Link from "next/link"; import { ExternalLink, LinkIcon } from "lucide-react"; // ui import { TStaticViewTypes } from "@plane/types"; import { ContextMenu, CustomMenu, TContextMenuItem, TOAST_TYPE, setToast } from "@plane/ui"; // helpers import { cn } from "@/helpers/common.helper"; import { copyUrlToClipboard } from "@/helpers/string.helper"; type Props = { parentRef: React.RefObject; workspaceSlug: string; globalViewId: string | undefined; view: { key: TStaticViewTypes; label: string; }; }; export const DefaultWorkspaceViewQuickActions: React.FC = observer((props) => { const { parentRef, globalViewId, view, workspaceSlug } = props; const viewLink = `${workspaceSlug}/workspace-views/${view.key}`; const handleCopyText = () => copyUrlToClipboard(viewLink).then(() => { setToast({ type: TOAST_TYPE.SUCCESS, title: "Link Copied!", message: "View link copied to clipboard.", }); }); const handleOpenInNewTab = () => window.open(`/${viewLink}`, "_blank"); const MENU_ITEMS: TContextMenuItem[] = [ { key: "open-new-tab", action: handleOpenInNewTab, title: "Open in new tab", icon: ExternalLink, }, { key: "copy-link", action: handleCopyText, title: "Copy link", icon: LinkIcon, }, ]; return ( <> {view.key === globalViewId ? ( {view.label} ) : ( {view.label} )} } placement="bottom-end" menuItemsClassName="z-20" closeOnSelect > {MENU_ITEMS.map((item) => { if (item.shouldRender === false) return null; return ( { e.preventDefault(); e.stopPropagation(); item.action(); }} className={cn( "flex items-center gap-2", { "text-custom-text-400": item.disabled, }, item.className )} disabled={item.disabled} > {item.icon && }
{item.title}
{item.description && (

{item.description}

)}
); })}
); });