Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/file-tree/hooks/useFileTreeUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ export const useFileTreeUpload = ({
);

const handleFileSelect = useCallback(
async (fileList: FileList | File[]) => {
await uploadFiles(Array.from(fileList), '');
async (fileList: FileList | File[], targetPath = '') => {
await uploadFiles(Array.from(fileList), targetPath);
},
[uploadFiles],
);
Expand Down
22 changes: 21 additions & 1 deletion src/components/file-tree/view/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ export default function FileTree({ selectedProject, onFileOpen }: FileTreeProps)
return <Icon className={cn(ICON_SIZE_CLASS, color)} />;
}, []);

const [selectedUploadDir, setSelectedUploadDir] = useState<string>('');

// Centralized click behavior keeps file actions identical across all presentation modes.
const handleItemClick = useCallback(
(item: FileTreeNode) => {
if (item.type === 'directory') {
setSelectedUploadDir(item.path);
toggleDirectory(item.path);
return;
}
Expand Down Expand Up @@ -150,7 +153,7 @@ export default function FileTree({ selectedProject, onFileOpen }: FileTreeProps)
onViewModeChange={changeViewMode}
searchQuery={searchQuery}
onSearchQueryChange={setSearchQuery}
onUploadFiles={upload.handleFileSelect}
onUploadFiles={(files) => upload.handleFileSelect(files, selectedUploadDir)}
onNewFile={() => operations.handleStartCreate('', 'file')}
onNewFolder={() => operations.handleStartCreate('', 'directory')}
onRefresh={refreshFiles}
Expand All @@ -161,6 +164,23 @@ export default function FileTree({ selectedProject, onFileOpen }: FileTreeProps)
uploadProgress={upload.uploadProgress?.progress ?? null}
/>

{selectedUploadDir && (
<div className="flex items-center gap-1.5 px-3 py-0.5 text-xs text-muted-foreground">
<span className="truncate">
{t('fileTree.uploadTarget', 'Upload target')}: {selectedUploadDir}
</span>
<button
type="button"
onClick={() => setSelectedUploadDir('')}
className="shrink-0 rounded p-0.5 hover:text-foreground"
title={t('fileTree.uploadTargetReset', 'Reset upload target to project root')}
aria-label={t('fileTree.uploadTargetReset', 'Reset upload target to project root')}
>
<X className="h-3 w-3" />
</button>
</div>
)}

<FileTreeUploadProgress upload={upload.uploadProgress} />

{viewMode === 'detailed' && filteredFiles.length > 0 && <FileTreeDetailedColumns />}
Expand Down