implmented moveDir

This commit is contained in:
Djeeberjr 2021-11-02 00:34:46 +01:00
parent 6bcb41820c
commit 615292ac24
3 changed files with 18 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import { RouteComponentProps } from "react-router-dom"
import downloadFile from "../functions/downloadFile" import downloadFile from "../functions/downloadFile"
import genDownloadLink from "../functions/genDownloadLink" import genDownloadLink from "../functions/genDownloadLink"
import uploadFile from "../functions/uploadFile" 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 Breadcrum from "./Breadcrum"
import CreateDirButton from "./CreateDirButton" import CreateDirButton from "./CreateDirButton"
import GlobalDragAndDrop from "./GlobalDragAndDrop" import GlobalDragAndDrop from "./GlobalDragAndDrop"
@ -32,6 +32,7 @@ const FileBrowser: React.FC<RouteComponentProps> = (props) => {
const [moveMutation] = useMoveMutation() const [moveMutation] = useMoveMutation()
const [createDirMutation] = useCreateDirMutation() const [createDirMutation] = useCreateDirMutation()
const [deleteDirMutation] = useDeleteDirMutation() const [deleteDirMutation] = useDeleteDirMutation()
const [moveDirMutation] = useMoveDirMutation()
const { show: showFileContext } = useContextMenu({ const { show: showFileContext } = useContextMenu({
id: CONTEXT_MENU_FILE, id: CONTEXT_MENU_FILE,
@ -66,6 +67,7 @@ const FileBrowser: React.FC<RouteComponentProps> = (props) => {
break break
case Action.FileCopy: case Action.FileCopy:
case Action.FileMove: case Action.FileMove:
case Action.DirMove:
setSrcID(id) setSrcID(id)
setPasteAction(action) setPasteAction(action)
break break
@ -80,6 +82,13 @@ const FileBrowser: React.FC<RouteComponentProps> = (props) => {
refetchDir() refetchDir()
setSrcID(null) setSrcID(null)
} }
if (pasteAction === Action.DirMove && srcID){
await moveDirMutation({variables:{src:srcID,dest:path}})
refetchDir()
setSrcID(null)
}
break break
case Action.DirDelete: case Action.DirDelete:
await deleteDirMutation({variables:{path:id}}) await deleteDirMutation({variables:{path:id}})

View File

@ -12,7 +12,8 @@ export enum Action {
FileMove, FileMove,
FileDownload, FileDownload,
FileRename, FileRename,
DirDelete DirDelete,
DirMove,
} }
interface Props { interface Props {
@ -40,7 +41,7 @@ const FileBrowserContextMenu: React.FC<Props> = (props) => {
</Menu> </Menu>
<Menu id={CONTEXT_MENU_DIR} animation={false} className="dark:bg-gray-400"> <Menu id={CONTEXT_MENU_DIR} animation={false} className="dark:bg-gray-400">
<Item onClick={onClick} data={Action.DirDelete} >Delete</Item> <Item onClick={onClick} data={Action.DirDelete} >Delete</Item>
<Item onClick={onClick} >Item 2</Item> <Item onClick={onClick} data={Action.DirMove} >Move</Item>
<Separator /> <Separator />
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item> <Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
</Menu> </Menu>

View File

@ -0,0 +1,5 @@
mutation moveDir($src: objID!, $dest: objID!) {
moveDir(src: $src,dest: $dest){
id
}
}