diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index dcb4534..ca43cda 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -2,7 +2,7 @@ import React from "react" import { useState } from "react" import { useContextMenu } from "react-contexify" import uploadFile from "../functions/uploadFile" -import { useDeleteFileMutation, useOpenDirQuery } from "../generated/graphql" +import { useCopyMutation, useDeleteFileMutation, useOpenDirQuery } from "../generated/graphql" import Breadcrum from "./Breadcrum" import DragAndDrop from "./DragAndDrop" import FileBrowserContextMenu, { Action, CONTEXT_MENU_DIR, CONTEXT_MENU_FILE } from "./FileBrowserContextMenu" @@ -15,7 +15,10 @@ const FileBrowser: React.FC = () => { const [openFileId, setOpenFileId] = useState("") const [showFile, setShowFile] = useState(false) + const [srcID,setSrcID] = useState("") + const [deleteMutation] = useDeleteFileMutation() + const [copyMutation] = useCopyMutation() const { show: showFileContext } = useContextMenu({ id: CONTEXT_MENU_FILE, @@ -60,12 +63,16 @@ const FileBrowser: React.FC = () => { } function onContextSelect(action:Action, id: string) { - console.debug(action) switch (action) { case Action.FileDelete: deleteMutation({variables:{id}}) break - + case Action.FileCopy: + setSrcID(id) + break + case Action.FilePaste: + copyMutation({variables:{src:srcID,dest:path}}) + break default: break } @@ -75,6 +82,7 @@ const FileBrowser: React.FC = () => {