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 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<RouteComponentProps> = (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<RouteComponentProps> = (props) => {
break
case Action.FileCopy:
case Action.FileMove:
case Action.DirMove:
setSrcID(id)
setPasteAction(action)
break
@ -80,6 +82,13 @@ const FileBrowser: React.FC<RouteComponentProps> = (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}})

View File

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

View File

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