import { useEffect, useState } from "react"; import { Folder, File as FileIcon, ArrowUp, CornerDownLeft } from "lucide-react"; import { volumesApi } from "@/api/volumes"; import { apiErrorMessage } from "@/api/client"; import { Button } from "@/components/ui"; import type { HostPathResult } from "@/types"; export function HostPathBrowser({ onPick, }: { onPick: (path: string) => void; }) { const [data, setData] = useState(null); const [path, setPath] = useState("/"); const [error, setError] = useState(null); const load = (p: string) => { volumesApi .hostPaths(p) .then((d) => { setData(d); setPath(d.path); setError(null); }) .catch((e) => setError(apiErrorMessage(e))); }; useEffect(() => { load("/"); }, []); return (
{data?.roots.map((r) => ( ))} {path}
{error &&

{error}

}
{data?.entries.length === 0 && (

Empty directory.

)} {data?.entries.map((e) => ( ))}
); }