import { BookOpen, Database, FileCode, FileText, Folder, Lock, Unlock, Upload, X, } from "lucide-react"; import type { ScriptItem, ScriptType } from "../../services/api"; type ContextMenuState = { x: number; y: number; kind: "root" | "directory" | "file"; path: string; script?: ScriptItem; }; type TreeContextMenuProps = { contextMenu: ContextMenuState | null; onOpenScript: (scriptId: string) => void; onRemoveScript: (script: ScriptItem) => void; onToggleLock: (script: ScriptItem) => void; onOpenCreateDialog: (parentPath: string, scriptType: ScriptType) => void; onOpenFolderDialog: (parentPath: string) => void; onChooseUpload: (parentPath: string) => void; onRemoveDirectory: (path: string) => void; onCopyResourcePath?: (jupyterPath: string) => void; onRemoveResource?: (resourceId: string) => void; onClose: () => void; }; const menuItemClass = "flex h-[34px] cursor-pointer items-center gap-[9px] rounded-[5px] border-0 bg-transparent px-[9px] text-left text-[11px] text-[#34475a] hover:bg-[#eef6fd] hover:text-[#136dbd]"; const dangerItemClass = "flex h-[34px] cursor-pointer items-center gap-[9px] rounded-[5px] border-0 bg-transparent px-[9px] text-left text-[11px] text-[#c74848] hover:bg-[#fff0f0]"; export function TreeContextMenu({ contextMenu, onOpenScript, onRemoveScript, onToggleLock, onOpenCreateDialog, onOpenFolderDialog, onChooseUpload, onRemoveDirectory, onCopyResourcePath, onRemoveResource, onClose, }: TreeContextMenuProps) { if (!contextMenu) return null; const isDataResource = !!contextMenu.script?.script_id.startsWith("data:"); const LockToggleIcon = contextMenu.script?.is_locked ? Unlock : Lock; return (
event.stopPropagation()} > {contextMenu.kind === "file" && contextMenu.script ? ( <> {isDataResource ? ( <> {onRemoveResource && ( )} ) : ( <> )} ) : ( <> {contextMenu.kind === "directory" && ( <> )} )}
); }