{file.isDirectory && (
)}
{getFileIcon()}
{editing ? (
setEditName(e.target.value)}
onBlur={handleRenameSubmit}
onKeyDown={(e) => {
if (e.key === 'Enter') handleRenameSubmit()
if (e.key === 'Escape') handleRenameCancel()
}}
onClick={(e) => e.stopPropagation()}
className="h-10"
autoFocus
/>
) : (
{file.name}
)}
{!file.isDirectory && (
Download
)}
Rename
Delete
{file.isDirectory && expanded && file.children && (
{file.children.map((child) => (
))}
)}
)
}
export const FileTree = memo(function FileTree({ files, onFileSelect, onDirectoryClick, selectedFile, onDelete, onRename, currentPath = '', basePath = '' }: FileTreeProps) {
const handleGoUp = () => {
// If currentPath has content and is different from basePath, go up
if (currentPath !== basePath) {
const pathParts = currentPath.split('/').filter(p => p)
pathParts.pop()
const parentPath = pathParts.join('/')
onDirectoryClick(parentPath)
}
}
// Show ".." if we're not at the base path (empty string means root)
const showGoUp = currentPath && currentPath !== basePath
return (
{showGoUp && (
âŠī¸
..
)}
{files.length === 0 ? (
No files in this directory
) : (
files.map((file) => (
))
)}
)
})