summaryrefslogtreecommitdiff
path: root/frontend/components/drive
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-08-14 18:13:32 +0100
committerdiogo464 <[email protected]>2025-08-14 18:13:32 +0100
commit753754a0981ee57f1ceca3738bbcd9956510cb5c (patch)
tree96440ddc44dc46498992a353e9f7421249c280d7 /frontend/components/drive
parent432656702032c49e80f34434f30e97e1c8259b45 (diff)
feat: implement file/directory move functionality
Replace fake move implementation with actual functionality using the existing rename API. The move feature now properly moves selected files/directories to chosen destinations. - Use existing /api/rename endpoint to move files by renaming paths - Handle multiple file selection with sequential move operations - Add comprehensive error handling for partial failures - Show detailed success/failure toast notifications - Refresh page after successful moves to display changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'frontend/components/drive')
-rw-r--r--frontend/components/drive/DriveDirectoryClient.tsx92
1 files changed, 80 insertions, 12 deletions
diff --git a/frontend/components/drive/DriveDirectoryClient.tsx b/frontend/components/drive/DriveDirectoryClient.tsx
index 7c5827b..f523e4f 100644
--- a/frontend/components/drive/DriveDirectoryClient.tsx
+++ b/frontend/components/drive/DriveDirectoryClient.tsx
@@ -310,18 +310,86 @@ export function DriveDirectoryClient({ path, files, breadcrumbs, storageData, us
310 310
311 311
312 const handleMove = async (destinationPath: string) => { 312 const handleMove = async (destinationPath: string) => {
313 // TODO: Implement actual move API calls 313 const filesToMove = Array.from(selectedFiles)
314 console.log('Moving files:', Array.from(selectedFiles), 'to:', destinationPath) 314 let successCount = 0
315 setSelectedFiles(new Set()) 315 let errorCount = 0
316 setMoveDialogOpen(false) 316 const errors: string[] = []
317 317
318 toast({ 318 try {
319 title: "Moved successfully", 319 // Move files sequentially using the rename API
320 description: `${selectedFiles.size} item(s) moved to ${destinationPath}`, 320 for (const filePath of filesToMove) {
321 }) 321 try {
322 322 // Extract filename from the full path
323 // Refresh page to show changes 323 const fileName = filePath.split('/').pop() || ''
324 window.location.reload() 324 // Construct new path: destination + filename
325 const newPath = destinationPath.endsWith('/')
326 ? `${destinationPath}${fileName}`
327 : `${destinationPath}/${fileName}`
328
329 const response = await fetch('/api/rename', {
330 method: 'POST',
331 headers: {
332 'Content-Type': 'application/json',
333 },
334 body: JSON.stringify({
335 oldPath: filePath,
336 newPath: newPath
337 })
338 })
339
340 if (!response.ok) {
341 const result = await response.json()
342 throw new Error(result.error || `Move failed with status ${response.status}`)
343 }
344
345 successCount++
346 } catch (error) {
347 console.error(`Failed to move ${filePath}:`, error)
348 errorCount++
349 errors.push(`${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`)
350 }
351 }
352
353 // Clear selection and close dialog
354 setSelectedFiles(new Set())
355 setMoveDialogOpen(false)
356
357 // Show results
358 if (successCount > 0) {
359 toast({
360 title: "Move completed",
361 description: `${successCount} item(s) moved successfully${errorCount > 0 ? `, ${errorCount} failed` : ''}`,
362 })
363
364 // Refresh page to show changes
365 window.location.reload()
366 }
367
368 if (errorCount > 0 && successCount === 0) {
369 toast({
370 title: "Move failed",
371 description: `All ${errorCount} item(s) failed to move. ${errors[0] || ''}`,
372 variant: "destructive"
373 })
374 } else if (errorCount > 0) {
375 toast({
376 title: "Partial move failure",
377 description: `${errorCount} item(s) failed to move. Check console for details.`,
378 variant: "destructive"
379 })
380 console.error('Move errors:', errors)
381 }
382
383 } catch (error) {
384 console.error('Move error:', error)
385 setSelectedFiles(new Set())
386 setMoveDialogOpen(false)
387 toast({
388 title: "Move failed",
389 description: error instanceof Error ? error.message : 'Unknown error occurred',
390 variant: "destructive"
391 })
392 }
325 } 393 }
326 394
327 const handleCreateFolder = async () => { 395 const handleCreateFolder = async () => {