deleteDir

This commit is contained in:
Niklas 2021-08-20 21:39:36 +02:00
parent 8789fee962
commit 2747a833dd
2 changed files with 9 additions and 3 deletions

View File

@ -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
}

View File

@ -9,7 +9,8 @@ export enum Action {
FileDelete,
FileCopy,
FilePaste,
FileMove
FileMove,
DirDelete
}
interface Props {
@ -35,7 +36,7 @@ const FileBrowserContextMenu: React.FC<Props> = (props) => {
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
</Menu>
<Menu id={CONTEXT_MENU_DIR} animation={false}>
<Item onClick={onClick} >Item 1</Item>
<Item onClick={onClick} data={Action.DirDelete} >Delete</Item>
<Item onClick={onClick} >Item 2</Item>
<Separator />
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>