From 2747a833dd4c46500cf997819594158b81a1060e Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 20 Aug 2021 21:39:36 +0200 Subject: [PATCH] deleteDir --- src/components/FileBrowser.tsx | 7 ++++++- src/components/FileBrowserContextMenu.tsx | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index b601005..bbc883d 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 { useCopyMutation, useCreateDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" +import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" import Breadcrum from "./Breadcrum" import CreateDirButton from "./CreateDirButton" import DragAndDrop from "./DragAndDrop" @@ -23,6 +23,7 @@ const FileBrowser: React.FC = () => { const [copyMutation] = useCopyMutation() const [moveMutation] = useMoveMutation() const [createDirMutation] = useCreateDirMutation() + const [deleteDirMutation] = useDeleteDirMutation() const { show: showFileContext } = useContextMenu({ id: CONTEXT_MENU_FILE, @@ -89,6 +90,10 @@ const FileBrowser: React.FC = () => { refetchDir() } break + case Action.DirDelete: + await deleteDirMutation({variables:{path:id}}) + refetchDir() + break default: break } diff --git a/src/components/FileBrowserContextMenu.tsx b/src/components/FileBrowserContextMenu.tsx index 0ae4ccf..a86cf3f 100644 --- a/src/components/FileBrowserContextMenu.tsx +++ b/src/components/FileBrowserContextMenu.tsx @@ -9,7 +9,8 @@ export enum Action { FileDelete, FileCopy, FilePaste, - FileMove + FileMove, + DirDelete } interface Props { @@ -35,7 +36,7 @@ const FileBrowserContextMenu: React.FC = (props) => { Paste - Item 1 + Delete Item 2 Paste