s3browser-frontend/src/components/FileBrowser.tsx

52 lines
992 B
TypeScript
Raw Normal View History

2021-07-26 12:54:22 +00:00
import React from "react"
import { useState } from "react"
import { useOpenDirQuery } from "../generated/graphql"
2021-07-27 17:24:52 +00:00
import Breadcrum from "./Breadcrum"
2021-07-26 12:54:22 +00:00
import FileBrowserElement from "./FileBrowserElement"
const FileBrowser: React.FC = () => {
const [path,setPath] = useState("/")
const { data } = useOpenDirQuery({
variables:{
path
}
})
return (
<div>
2021-07-27 17:24:52 +00:00
<Breadcrum path={path} onDirClick={(newPath)=>{
console.debug(newPath)
setPath(newPath)
}}/>
2021-07-26 12:54:22 +00:00
<div>
2021-07-27 17:24:52 +00:00
<table className="table table-striped table-hover">
<thead>
<tr>
<th>Icon</th>
<th>Name</th>
</tr>
</thead>
<tbody>
2021-07-26 12:54:22 +00:00
2021-07-27 17:24:52 +00:00
{ data?.directorys.map(v => (<FileBrowserElement
key={v?.id}
dir={v}
onClick={(data)=>{
setPath(data.id)
}}
/>))}
{ data?.files.map(v => (<FileBrowserElement
key={v?.id}
file={v}
/>))}
</tbody>
</table>
2021-07-26 12:54:22 +00:00
</div>
</div>
)
}
export default FileBrowser