diff options
| author | diogo464 <[email protected]> | 2025-08-13 11:08:48 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-13 11:08:48 +0100 |
| commit | 74069a896a3b831a19baefc0d9487060b34760b3 (patch) | |
| tree | 8398b24dd884d0b2e50dd1dcc7e7c758a5ba05fc /frontend/components | |
| parent | d3f54389f2ba0e70fef9b44a947cc0d9a8bb61e2 (diff) | |
Implement rename functionality using fctdrive CLI
- Add Drive_rename function to drive_server.ts for backend integration
- Create /api/rename endpoint with proper authentication and error handling
- Update handleRename function to call API instead of placeholder TODO
- Test rename functionality for both files and directories
- Update CLAUDE.md to note fctdrive is available in PATH
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/drive/DriveDirectoryClient.tsx | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/frontend/components/drive/DriveDirectoryClient.tsx b/frontend/components/drive/DriveDirectoryClient.tsx index 8a53123..6089ec2 100644 --- a/frontend/components/drive/DriveDirectoryClient.tsx +++ b/frontend/components/drive/DriveDirectoryClient.tsx | |||
| @@ -134,18 +134,49 @@ export function DriveDirectoryClient({ path, files, breadcrumbs }: DriveDirector | |||
| 134 | }) | 134 | }) |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | const handleRename = () => { | 137 | const handleRename = async () => { |
| 138 | if (currentItem && newName.trim()) { | 138 | if (!currentItem || !newName.trim()) return |
| 139 | // TODO: Implement actual rename API call | 139 | |
| 140 | setRenameDialogOpen(false) | 140 | try { |
| 141 | setCurrentItem(null) | 141 | // Calculate the new full path by replacing the filename |
| 142 | setNewName("") | 142 | const pathParts = currentItem.path.split('/') |
| 143 | pathParts[pathParts.length - 1] = newName.trim() | ||
| 144 | const newPath = pathParts.join('/') | ||
| 145 | |||
| 146 | const response = await fetch('/api/rename', { | ||
| 147 | method: 'POST', | ||
| 148 | headers: { | ||
| 149 | 'Content-Type': 'application/json', | ||
| 150 | }, | ||
| 151 | body: JSON.stringify({ | ||
| 152 | oldPath: currentItem.path, | ||
| 153 | newPath: newPath | ||
| 154 | }) | ||
| 155 | }) | ||
| 156 | |||
| 157 | const result = await response.json() | ||
| 158 | |||
| 159 | if (response.ok) { | ||
| 160 | setRenameDialogOpen(false) | ||
| 161 | setCurrentItem(null) | ||
| 162 | setNewName("") | ||
| 163 | toast({ | ||
| 164 | title: "Renamed successfully", | ||
| 165 | description: result.message, | ||
| 166 | }) | ||
| 167 | |||
| 168 | // Refresh page to show changes | ||
| 169 | window.location.reload() | ||
| 170 | } else { | ||
| 171 | throw new Error(result.error || `Rename failed with status ${response.status}`) | ||
| 172 | } | ||
| 173 | } catch (error) { | ||
| 174 | console.error('Rename error:', error) | ||
| 143 | toast({ | 175 | toast({ |
| 144 | title: "Renamed successfully", | 176 | title: "Rename failed", |
| 145 | description: `Item renamed to "${newName.trim()}"`, | 177 | description: error instanceof Error ? error.message : 'Unknown error occurred', |
| 178 | variant: "destructive" | ||
| 146 | }) | 179 | }) |
| 147 | // Refresh page to show changes | ||
| 148 | window.location.reload() | ||
| 149 | } | 180 | } |
| 150 | } | 181 | } |
| 151 | 182 | ||
