download button
This commit is contained in:
parent
37840ece32
commit
6dcd9cf81e
@ -2,6 +2,8 @@ import React from "react"
|
||||
import { useState } from "react"
|
||||
import { useContextMenu } from "react-contexify"
|
||||
import { RouteComponentProps } from "react-router-dom"
|
||||
import downloadFile from "../functions/downloadFile"
|
||||
import genDownloadLink from "../functions/genDownloadLink"
|
||||
import normalizeDirPath from "../functions/normalizeDirPath"
|
||||
import uploadFile from "../functions/uploadFile"
|
||||
import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql"
|
||||
@ -106,6 +108,9 @@ const FileBrowser: React.FC<RouteComponentProps> = (props) => {
|
||||
await deleteDirMutation({variables:{path:id}})
|
||||
refetchDir()
|
||||
break
|
||||
case Action.FileDownload:
|
||||
downloadFile(genDownloadLink(id))
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ export enum Action {
|
||||
FileCopy,
|
||||
FilePaste,
|
||||
FileMove,
|
||||
FileDownload,
|
||||
DirDelete
|
||||
}
|
||||
|
||||
@ -32,6 +33,7 @@ const FileBrowserContextMenu: React.FC<Props> = (props) => {
|
||||
<Item onClick={onClick} data={Action.FileDelete} >Delete</Item>
|
||||
<Item onClick={onClick} data={Action.FileCopy} >Copy</Item>
|
||||
<Item onClick={onClick} data={Action.FileMove} >Move</Item>
|
||||
<Item onClick={onClick} data={Action.FileDownload} >Download</Item>
|
||||
<Separator />
|
||||
<Item onClick={onClick} data={Action.FilePaste} disabled={!props.pasteActive}>Paste</Item>
|
||||
</Menu>
|
||||
|
9
src/functions/downloadFile.ts
Normal file
9
src/functions/downloadFile.ts
Normal file
@ -0,0 +1,9 @@
|
||||
function downloadFile(uri:string): void {
|
||||
const link = document.createElement("a")
|
||||
link.download = ""
|
||||
link.href = uri
|
||||
link.click()
|
||||
link.remove()
|
||||
}
|
||||
|
||||
export default downloadFile
|
Loading…
Reference in New Issue
Block a user