diff --git a/web/src/components/workspace/FileExplorerPanel.tsx b/web/src/components/workspace/FileExplorerPanel.tsx index 11c936f..5af9502 100644 --- a/web/src/components/workspace/FileExplorerPanel.tsx +++ b/web/src/components/workspace/FileExplorerPanel.tsx @@ -5,11 +5,16 @@ import { FilePlus, Folder, FolderPlus, - Pencil, RefreshCw, - Trash2, } from "lucide-react"; -import type { ReactNode } from "react"; +import { + useEffect, + useLayoutEffect, + useMemo, + useRef, + useState, + type ReactNode, +} from "react"; import { ScrollArea } from "@/components/ui/scroll-area"; import { @@ -28,42 +33,48 @@ interface FileExplorerPanelProps { workspaceId: string | null; } +type OnRowContextMenu = ( + entry: FileEntry, + point: { x: number; y: number }, +) => void; interface FileTreeDirectoryProps { workspaceId: string; entry: FileEntry; depth: number; onSelectFile: (path: string) => void; - onRename: (entry: FileEntry) => void; - onDelete: (entry: FileEntry) => void; + onContextMenu: OnRowContextMenu; } interface FileTreeFileProps { entry: FileEntry; depth: number; onSelectFile: (path: string) => void; - onRename: (entry: FileEntry) => void; - onDelete: (entry: FileEntry) => void; + onContextMenu: OnRowContextMenu; } function FileTreeFile({ entry, depth, onSelectFile, - onRename, - onDelete, + onContextMenu, }: FileTreeFileProps) { const selectedPath = useFileTreeStore((s) => s.selectedPath); const isSelected = selectedPath === entry.path; const paddingLeft = `${depth * 0.875 + 0.75}rem`; return ( -
  • +
  • -
    - - -
  • ); } @@ -105,8 +92,7 @@ function FileTreeDirectory({ entry, depth, onSelectFile, - onRename, - onDelete, + onContextMenu, }: FileTreeDirectoryProps) { const expanded = useFileTreeStore((s) => s.expandedPaths.has(entry.path)); const toggleExpanded = useFileTreeStore((s) => s.toggleExpanded); @@ -118,12 +104,17 @@ function FileTreeDirectory({ const paddingLeft = `${depth * 0.875 + 0.75}rem`; return ( -
  • +
  • -
    - - -
    {expanded && ( + {contextMenu && menuPos && ( +
    + + + {contextMenu.entry.isDir && ( + <> +
    + + + + )} +
    + )} ); }