Fix: allow multi-select drag and drop for moving multiple files at once
All checks were successful
Automated Container Build / build-and-push (push) Successful in 38s

This commit is contained in:
Elijah 2026-05-25 16:31:02 -07:00
parent e9d1ef0ad6
commit 0bd42e5b47

View file

@ -899,6 +899,9 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
} }
function handleItemDragStart(e: React.DragEvent, path: string) { 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); e.dataTransfer.setData('text/plain', path);
setDraggedFile(path); setDraggedFile(path);
} }
@ -921,13 +924,40 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
async function handleItemDrop(e: React.DragEvent, file: FileItem) { async function handleItemDrop(e: React.DragEvent, file: FileItem) {
if (!file.is_dir) return; if (!file.is_dir) return;
setDragOverFolder(null); setDragOverFolder(null);
const sourcePath = e.dataTransfer.getData('text/plain');
if (!sourcePath || sourcePath === file.path) return;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
setDraggedFile(null); 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 { 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); await api.move(sourcePath, file.path);
loadFiles(undefined, true); loadFiles(undefined, true);
showToast('Item moved'); showToast('Item moved');