From a7e9efd218f249cc63fda06b086d25f7f966a9a4 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 16 Aug 2021 22:17:43 +0200 Subject: [PATCH] simple implemetation for create dir --- src/components/CreateDirButton.tsx | 38 ++++++++++++++++++++++++++++++ src/components/FileBrowser.tsx | 10 +++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/components/CreateDirButton.tsx 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) }}/>