mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
Add "Download" item to file tree context menu (#9190)
GitOrigin-RevId: af55d782aeaab3acd516a1581d59dd3332109cb8
This commit is contained in:
@@ -15,6 +15,7 @@ function FileTreeItemMenuItems() {
|
||||
startCreatingFolder,
|
||||
startCreatingDocOrFile,
|
||||
startUploadingDocOrFile,
|
||||
downloadPath,
|
||||
} = useFileTreeActionable()
|
||||
|
||||
return (
|
||||
@@ -22,6 +23,9 @@ function FileTreeItemMenuItems() {
|
||||
{canRename ? (
|
||||
<MenuItem onClick={startRenaming}>{t('rename')}</MenuItem>
|
||||
) : null}
|
||||
{downloadPath ? (
|
||||
<MenuItem href={downloadPath}>{t('download')}</MenuItem>
|
||||
) : null}
|
||||
{canDelete ? (
|
||||
<MenuItem onClick={startDeleting}>{t('delete')}</MenuItem>
|
||||
) : null}
|
||||
|
||||
@@ -346,6 +346,17 @@ export function FileTreeActionableProvider({ children }) {
|
||||
}
|
||||
}, [])
|
||||
|
||||
// build the path for downloading a single file
|
||||
const downloadPath = useMemo(() => {
|
||||
if (selectedEntityIds.size === 1) {
|
||||
const [selectedEntityId] = selectedEntityIds
|
||||
const selectedEntity = findInTree(fileTreeData, selectedEntityId)
|
||||
if (selectedEntity?.type === 'fileRef') {
|
||||
return `/project/${projectId}/file/${selectedEntityId}`
|
||||
}
|
||||
}
|
||||
}, [fileTreeData, projectId, selectedEntityIds])
|
||||
|
||||
const value = {
|
||||
canDelete: selectedEntityIds.size > 0,
|
||||
canRename: selectedEntityIds.size === 1,
|
||||
@@ -368,6 +379,7 @@ export function FileTreeActionableProvider({ children }) {
|
||||
cancel,
|
||||
droppedFiles,
|
||||
setDroppedFiles,
|
||||
downloadPath,
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user