diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index 0f27269..d1e450c 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -2,10 +2,10 @@ import React from "react" import { useState } from "react" import { useContextMenu } from "react-contexify" import uploadFile from "../functions/uploadFile" -import { useOpenDirQuery } from "../generated/graphql" +import { useDeleteFileMutation, useOpenDirQuery } from "../generated/graphql" import Breadcrum from "./Breadcrum" import DragAndDrop from "./DragAndDrop" -import FileBrowserContextMenu, { CONTEXT_MENU_DIR, CONTEXT_MENU_FILE } from "./FileBrowserContextMenu" +import FileBrowserContextMenu, { Action, CONTEXT_MENU_DIR, CONTEXT_MENU_FILE } from "./FileBrowserContextMenu" import FileBrowserElement from "./FileBrowserElement" import FileOpen from "./FileOpen" @@ -14,6 +14,8 @@ const FileBrowser: React.FC = () => { const [openFileId, setOpenFileId] = useState("") const [showFile, setShowFile] = useState(false) + const [deleteMutation] = useDeleteFileMutation() + const { show: showFileContext } = useContextMenu({ id: CONTEXT_MENU_FILE, }) @@ -56,9 +58,23 @@ const FileBrowser: React.FC = () => { }) } + function onContextSelect(action:Action, id: string) { + console.debug(action) + switch (action) { + case Action.FileDelete: + deleteMutation({variables:{id}}) + break + + default: + break + } + } + return (