/** * @file WorkspaceRowMenu — the sidebar workspace row's context menu, opened at * the pointer (right-click) or under the row's `⋯` button. Every item is an * existing call: Rename (the row's inline field), New workspace here (the * Add modal prefilled), Copy path, and Reset/Remove through `DestructiveLaneModal` — Reset only on a * managed lane. The server's guards are the real ones; the menu only hides * what the lane's kind or tool makes meaningless. The shell (position, * Escape / outside-click close) is `ContextMenu`. * @author Nguyễn Ngọc Trí Vĩ */ import { useTranslation } from "react-i18next"; import type { Lane } from "../../lib/types"; import { ContextMenu, MenuItem, MenuSeparator } from "../ContextMenu"; import { copyText } from "../../lib/clipboard"; export type WorkspaceMenuAction = "rename" | "new-here" | "reset" | "remove"; export function WorkspaceRowMenu({ lane, x, y, onClose, onAction, }: { lane: Lane; x: number; y: number; onClose: () => void; /** Items the tree itself carries out (rename field, modals). */ onAction: (action: WorkspaceMenuAction) => void; }) { const { t } = useTranslation("lanes"); return ( onAction("rename")}>{t("menu.rename")} onAction("new-here")}>{t("menu.newHere")} { onClose(); void copyText(lane.cwd); }} > {t("menu.copyPath")} {lane.kind === "managed" && ( onAction("reset")}> {t("menu.reset")} )} onAction("remove")}> {t("menu.remove")} ); }