Compare commits
2 Commits
adeddc7994
...
2747a833dd
| Author | SHA1 | Date | |
|---|---|---|---|
| 2747a833dd | |||
| 8789fee962 |
@@ -2,7 +2,7 @@ import React from "react"
|
|||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { useContextMenu } from "react-contexify"
|
import { useContextMenu } from "react-contexify"
|
||||||
import uploadFile from "../functions/uploadFile"
|
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 Breadcrum from "./Breadcrum"
|
||||||
import CreateDirButton from "./CreateDirButton"
|
import CreateDirButton from "./CreateDirButton"
|
||||||
import DragAndDrop from "./DragAndDrop"
|
import DragAndDrop from "./DragAndDrop"
|
||||||
@@ -23,6 +23,7 @@ const FileBrowser: React.FC = () => {
|
|||||||
const [copyMutation] = useCopyMutation()
|
const [copyMutation] = useCopyMutation()
|
||||||
const [moveMutation] = useMoveMutation()
|
const [moveMutation] = useMoveMutation()
|
||||||
const [createDirMutation] = useCreateDirMutation()
|
const [createDirMutation] = useCreateDirMutation()
|
||||||
|
const [deleteDirMutation] = useDeleteDirMutation()
|
||||||
|
|
||||||
const { show: showFileContext } = useContextMenu({
|
const { show: showFileContext } = useContextMenu({
|
||||||
id: CONTEXT_MENU_FILE,
|
id: CONTEXT_MENU_FILE,
|
||||||
@@ -89,6 +90,10 @@ const FileBrowser: React.FC = () => {
|
|||||||
refetchDir()
|
refetchDir()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case Action.DirDelete:
|
||||||
|
await deleteDirMutation({variables:{path:id}})
|
||||||
|
refetchDir()
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export enum Action {
|
|||||||
FileDelete,
|
FileDelete,
|
||||||
FileCopy,
|
FileCopy,
|
||||||
FilePaste,
|
FilePaste,
|
||||||
FileMove
|
FileMove,
|
||||||
|
DirDelete
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -35,7 +36,7 @@ const FileBrowserContextMenu: React.FC<Props> = (props) => {
|
|||||||
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
|
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu id={CONTEXT_MENU_DIR} animation={false}>
|
<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>
|
<Item onClick={onClick} >Item 2</Item>
|
||||||
<Separator />
|
<Separator />
|
||||||
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
|
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export type RootMutation = {
|
|||||||
copy?: Maybe<File>;
|
copy?: Maybe<File>;
|
||||||
createDir: Directory;
|
createDir: Directory;
|
||||||
delete?: Maybe<Scalars["String"]>;
|
delete?: Maybe<Scalars["String"]>;
|
||||||
|
deleteDir: Scalars["String"];
|
||||||
move?: Maybe<File>;
|
move?: Maybe<File>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,6 +66,11 @@ export type RootMutationDeleteArgs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type RootMutationDeleteDirArgs = {
|
||||||
|
path: Scalars["ID"];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export type RootMutationMoveArgs = {
|
export type RootMutationMoveArgs = {
|
||||||
src: Scalars["ID"];
|
src: Scalars["ID"];
|
||||||
dest: Scalars["ID"];
|
dest: Scalars["ID"];
|
||||||
@@ -119,6 +125,16 @@ export type CreateDirMutation = (
|
|||||||
) }
|
) }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export type DeleteDirMutationVariables = Exact<{
|
||||||
|
path: Scalars["ID"];
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
export type DeleteDirMutation = (
|
||||||
|
{ __typename?: "RootMutation" }
|
||||||
|
& Pick<RootMutation, "deleteDir">
|
||||||
|
);
|
||||||
|
|
||||||
export type DeleteFileMutationVariables = Exact<{
|
export type DeleteFileMutationVariables = Exact<{
|
||||||
id: Scalars["ID"];
|
id: Scalars["ID"];
|
||||||
}>;
|
}>;
|
||||||
@@ -240,6 +256,37 @@ export function useCreateDirMutation(baseOptions?: Apollo.MutationHookOptions<Cr
|
|||||||
export type CreateDirMutationHookResult = ReturnType<typeof useCreateDirMutation>;
|
export type CreateDirMutationHookResult = ReturnType<typeof useCreateDirMutation>;
|
||||||
export type CreateDirMutationResult = Apollo.MutationResult<CreateDirMutation>;
|
export type CreateDirMutationResult = Apollo.MutationResult<CreateDirMutation>;
|
||||||
export type CreateDirMutationOptions = Apollo.BaseMutationOptions<CreateDirMutation, CreateDirMutationVariables>;
|
export type CreateDirMutationOptions = Apollo.BaseMutationOptions<CreateDirMutation, CreateDirMutationVariables>;
|
||||||
|
export const DeleteDirDocument = gql`
|
||||||
|
mutation deleteDir($path: ID!) {
|
||||||
|
deleteDir(path: $path)
|
||||||
|
}
|
||||||
|
`
|
||||||
|
export type DeleteDirMutationFn = Apollo.MutationFunction<DeleteDirMutation, DeleteDirMutationVariables>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __useDeleteDirMutation__
|
||||||
|
*
|
||||||
|
* To run a mutation, you first call `useDeleteDirMutation` within a React component and pass it any options that fit your needs.
|
||||||
|
* When your component renders, `useDeleteDirMutation` returns a tuple that includes:
|
||||||
|
* - A mutate function that you can call at any time to execute the mutation
|
||||||
|
* - An object with fields that represent the current status of the mutation's execution
|
||||||
|
*
|
||||||
|
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const [deleteDirMutation, { data, loading, error }] = useDeleteDirMutation({
|
||||||
|
* variables: {
|
||||||
|
* path: // value for 'path'
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
export function useDeleteDirMutation(baseOptions?: Apollo.MutationHookOptions<DeleteDirMutation, DeleteDirMutationVariables>) {
|
||||||
|
const options = {...defaultOptions, ...baseOptions}
|
||||||
|
return Apollo.useMutation<DeleteDirMutation, DeleteDirMutationVariables>(DeleteDirDocument, options)
|
||||||
|
}
|
||||||
|
export type DeleteDirMutationHookResult = ReturnType<typeof useDeleteDirMutation>;
|
||||||
|
export type DeleteDirMutationResult = Apollo.MutationResult<DeleteDirMutation>;
|
||||||
|
export type DeleteDirMutationOptions = Apollo.BaseMutationOptions<DeleteDirMutation, DeleteDirMutationVariables>;
|
||||||
export const DeleteFileDocument = gql`
|
export const DeleteFileDocument = gql`
|
||||||
mutation deleteFile($id: ID!) {
|
mutation deleteFile($id: ID!) {
|
||||||
delete(id: $id)
|
delete(id: $id)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
3
src/graphql/deleteDir.graphql
Normal file
3
src/graphql/deleteDir.graphql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
mutation deleteDir($path: ID!){
|
||||||
|
deleteDir(path:$path)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user