diff --git a/frontend/src/components/FileExplorer.tsx b/frontend/src/components/FileExplorer.tsx index 0ad31fe..5276fee 100644 --- a/frontend/src/components/FileExplorer.tsx +++ b/frontend/src/components/FileExplorer.tsx @@ -899,6 +899,9 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { } function handleItemDragStart(e: React.DragEvent, path: string) { + if (selectedFiles.has(path) && selectedFiles.size > 1) { + e.dataTransfer.setData('application/json', JSON.stringify(Array.from(selectedFiles))); + } e.dataTransfer.setData('text/plain', path); setDraggedFile(path); } @@ -921,13 +924,40 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { async function handleItemDrop(e: React.DragEvent, file: FileItem) { if (!file.is_dir) return; setDragOverFolder(null); - const sourcePath = e.dataTransfer.getData('text/plain'); - if (!sourcePath || sourcePath === file.path) return; - e.preventDefault(); e.stopPropagation(); setDraggedFile(null); + + const jsonPaths = e.dataTransfer.getData('application/json'); + if (jsonPaths) { + try { + const paths = JSON.parse(jsonPaths); + const fileNames = paths.map((p: string) => p.split('/').pop() || p); + const res = await api.checkConflicts(file.path, fileNames); + if (res.conflicts?.length) { + setConflictState({ type: 'move', sourcePaths: paths, destPath: file.path, conflicts: res.conflicts }); + return; + } + await Promise.all(paths.map((p: string) => api.move(p, file.path))); + loadFiles(undefined, true); + setSelectedFiles(new Set()); + showToast(`Moved ${paths.length} items`); + } catch (err) { + console.error(err); + } + return; + } + + const sourcePath = e.dataTransfer.getData('text/plain'); + if (!sourcePath || sourcePath === file.path) return; + try { + const fileName = sourcePath.split('/').pop() || sourcePath; + const res = await api.checkConflicts(file.path, [fileName]); + if (res.conflicts?.length) { + setConflictState({ type: 'move', sourcePaths: [sourcePath], destPath: file.path, conflicts: res.conflicts }); + return; + } await api.move(sourcePath, file.path); loadFiles(undefined, true); showToast('Item moved');