simple implemetation for create dir

This commit is contained in:
Niklas 2021-08-16 22:17:43 +02:00
parent c448051838
commit a7e9efd218
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,38 @@
import React from "react"
import { useState } from "react"
interface Props {
onPressed?: (dirName: string)=>void
}
const CreateDirButton: React.FC<Props> = (props) => {
const [name,setName] = useState("")
return (
<div>
<button>
Create Dir
</button>
<div>
<input
type="text"
onChange={(e)=>{
setName(e.target.value)
}}
value={name}
/>
<button
onClick={()=>{
props.onPressed?.(name)
setName("")
}}
>
Create
</button>
</div>
</div>
)
}
export default CreateDirButton

View File

@ -2,8 +2,9 @@ import React from "react"
import { useState } from "react" import { useState } from "react"
import { useContextMenu } from "react-contexify" import { useContextMenu } from "react-contexify"
import uploadFile from "../functions/uploadFile" import uploadFile from "../functions/uploadFile"
import { useCopyMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" import { useCopyMutation, useCreateDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql"
import Breadcrum from "./Breadcrum" import Breadcrum from "./Breadcrum"
import CreateDirButton from "./CreateDirButton"
import DragAndDrop from "./DragAndDrop" import DragAndDrop from "./DragAndDrop"
import FileBrowserContextMenu, { Action, CONTEXT_MENU_DIR, CONTEXT_MENU_FILE } from "./FileBrowserContextMenu" import FileBrowserContextMenu, { Action, CONTEXT_MENU_DIR, CONTEXT_MENU_FILE } from "./FileBrowserContextMenu"
import FileBrowserElement from "./FileBrowserElement" import FileBrowserElement from "./FileBrowserElement"
@ -21,6 +22,7 @@ const FileBrowser: React.FC = () => {
const [deleteMutation] = useDeleteFileMutation() const [deleteMutation] = useDeleteFileMutation()
const [copyMutation] = useCopyMutation() const [copyMutation] = useCopyMutation()
const [moveMutation] = useMoveMutation() const [moveMutation] = useMoveMutation()
const [createDirMutation] = useCreateDirMutation()
const { show: showFileContext } = useContextMenu({ const { show: showFileContext } = useContextMenu({
id: CONTEXT_MENU_FILE, id: CONTEXT_MENU_FILE,
@ -106,6 +108,12 @@ const FileBrowser: React.FC = () => {
<FileUploadButton <FileUploadButton
onUpload={(files)=>handleDrop(files)} onUpload={(files)=>handleDrop(files)}
/> />
<CreateDirButton
onPressed={async (dirName)=>{
await createDirMutation({variables:{path:dirName}})
refetchDir()
}}
/>
<Breadcrum path={path} onDirClick={(newPath)=>{ <Breadcrum path={path} onDirClick={(newPath)=>{
setPath(newPath) setPath(newPath)
}}/> }}/>