diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index a382a3a..118fb6e 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -5,7 +5,7 @@ import { RouteComponentProps } from "react-router-dom" import downloadFile from "../functions/downloadFile" import genDownloadLink from "../functions/genDownloadLink" import uploadFile from "../functions/uploadFile" -import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" +import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveDirMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" import Breadcrum from "./Breadcrum" import CreateDirButton from "./CreateDirButton" import GlobalDragAndDrop from "./GlobalDragAndDrop" @@ -32,6 +32,7 @@ const FileBrowser: React.FC = (props) => { const [moveMutation] = useMoveMutation() const [createDirMutation] = useCreateDirMutation() const [deleteDirMutation] = useDeleteDirMutation() + const [moveDirMutation] = useMoveDirMutation() const { show: showFileContext } = useContextMenu({ id: CONTEXT_MENU_FILE, @@ -66,6 +67,7 @@ const FileBrowser: React.FC = (props) => { break case Action.FileCopy: case Action.FileMove: + case Action.DirMove: setSrcID(id) setPasteAction(action) break @@ -80,6 +82,13 @@ const FileBrowser: React.FC = (props) => { refetchDir() setSrcID(null) } + + if (pasteAction === Action.DirMove && srcID){ + await moveDirMutation({variables:{src:srcID,dest:path}}) + refetchDir() + setSrcID(null) + } + break case Action.DirDelete: await deleteDirMutation({variables:{path:id}}) diff --git a/src/components/FileBrowserContextMenu.tsx b/src/components/FileBrowserContextMenu.tsx index 05856d7..327bfb3 100644 --- a/src/components/FileBrowserContextMenu.tsx +++ b/src/components/FileBrowserContextMenu.tsx @@ -12,7 +12,8 @@ export enum Action { FileMove, FileDownload, FileRename, - DirDelete + DirDelete, + DirMove, } interface Props { @@ -40,7 +41,7 @@ const FileBrowserContextMenu: React.FC = (props) => { Delete - Item 2 + Move Paste diff --git a/src/graphql/moveDir.graphql b/src/graphql/moveDir.graphql new file mode 100644 index 0000000..4d2e5ef --- /dev/null +++ b/src/graphql/moveDir.graphql @@ -0,0 +1,5 @@ +mutation moveDir($src: objID!, $dest: objID!) { + moveDir(src: $src,dest: $dest){ + id + } +} \ No newline at end of file