diff --git a/src/components/CreateDirButton.tsx b/src/components/CreateDirButton.tsx new file mode 100644 index 0000000..5f1d409 --- /dev/null +++ b/src/components/CreateDirButton.tsx @@ -0,0 +1,38 @@ +import React from "react" +import { useState } from "react" + +interface Props { + onPressed?: (dirName: string)=>void +} + +const CreateDirButton: React.FC = (props) => { + + const [name,setName] = useState("") + + return ( +
+ +
+ { + setName(e.target.value) + }} + value={name} + /> + +
+
+ ) +} + +export default CreateDirButton diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index b3190d9..40e51c2 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -2,8 +2,9 @@ import React from "react" import { useState } from "react" import { useContextMenu } from "react-contexify" 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 CreateDirButton from "./CreateDirButton" import DragAndDrop from "./DragAndDrop" import FileBrowserContextMenu, { Action, CONTEXT_MENU_DIR, CONTEXT_MENU_FILE } from "./FileBrowserContextMenu" import FileBrowserElement from "./FileBrowserElement" @@ -21,6 +22,7 @@ const FileBrowser: React.FC = () => { const [deleteMutation] = useDeleteFileMutation() const [copyMutation] = useCopyMutation() const [moveMutation] = useMoveMutation() + const [createDirMutation] = useCreateDirMutation() const { show: showFileContext } = useContextMenu({ id: CONTEXT_MENU_FILE, @@ -106,6 +108,12 @@ const FileBrowser: React.FC = () => { handleDrop(files)} /> + { + await createDirMutation({variables:{path:dirName}}) + refetchDir() + }} + /> { setPath(newPath) }}/>