Update styling of FileTreeView

This commit is contained in:
grimsi
2025-04-05 22:06:33 +02:00
parent e45c7dca6d
commit 9babedeba4
2 changed files with 6 additions and 7 deletions
@@ -117,7 +117,7 @@ export default function FileTreeView({onPathChange}: { onPathChange: (file: stri
} }
return ( return (
<div className="flex flex-col gap-4 bg-contrast"> <div className="flex flex-col flex-1 w-full gap-4 overflow-hidden">
<TreeView <TreeView
data={flattenedFileTree} data={flattenedFileTree}
aria-label="directory tree" aria-label="directory tree"
@@ -133,7 +133,7 @@ export default function FileTreeView({onPathChange}: { onPathChange: (file: stri
<IconContext.Provider value={{size: 32, weight: "regular"}}> <IconContext.Provider value={{size: 32, weight: "regular"}}>
<div {...getNodeProps()} <div {...getNodeProps()}
className={` className={`
flex flex-row items-center gap-2 flex flex-row items-center gap-2 w-full
rounded-md cursor-pointer rounded-md cursor-pointer
${isSelected ? 'bg-primary' : 'hover:bg-primary/20'}` ${isSelected ? 'bg-primary' : 'hover:bg-primary/20'}`
} }
@@ -144,7 +144,6 @@ export default function FileTreeView({onPathChange}: { onPathChange: (file: stri
</IconContext.Provider> </IconContext.Provider>
)} )}
/> />
<pre>{JSON.stringify(flattenedFileTree, null, 2)}</pre>
</div> </div>
); );
} }
@@ -23,7 +23,7 @@ class FilesystemService {
if (path == null || path.isEmpty()) { if (path == null || path.isEmpty()) {
val roots = FileSystems.getDefault().rootDirectories.toList() val roots = FileSystems.getDefault().rootDirectories.toList()
if (roots.size > 1) return roots.map { if (getHostOperatingSystem() == OperatingSystemType.WINDOWS) return roots.map {
FileDto( FileDto(
it.root.toString(), it.root.toString(),
if (it.isDirectory()) FileType.DIRECTORY else FileType.FILE, if (it.isDirectory()) FileType.DIRECTORY else FileType.FILE,
@@ -31,7 +31,7 @@ class FilesystemService {
) )
} }
// If there is only one root, return its contents // UNIX file systems only have one root, so return its contents directly
return safeReadDirectoryContents(roots.first().toString()) return safeReadDirectoryContents(roots.first().toString())
} }
@@ -66,8 +66,8 @@ class FilesystemService {
Path(path).toFile().listFiles() Path(path).toFile().listFiles()
.filter { !it.isHidden } .filter { !it.isHidden }
.map { FileDto(it.name, if (it.isDirectory) FileType.DIRECTORY else FileType.FILE, it.hashCode()) } .map { FileDto(it.name, if (it.isDirectory) FileType.DIRECTORY else FileType.FILE, it.hashCode()) }
} catch (e: Exception) { } catch (_: Exception) {
log.error(e) { "Error reading directory contents of $path" } log.error { "Error reading directory contents of $path" }
emptyList() emptyList()
} }
} }