|
|
@@ -1,30 +1,14 @@
|
|
|
-import { useCallback, useMemo } from 'react'
|
|
|
+import { useCallback } from 'react'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import * as eventTracking from '../../../../infrastructure/event-tracking'
|
|
|
import { useProjectContext } from '@/shared/context/project-context'
|
|
|
|
|
|
import { MenuItem } from 'react-bootstrap'
|
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
|
|
-import { useFileTreeData } from '@/shared/context/file-tree-data-context'
|
|
|
-import { useFileTreeSelectable } from '../../contexts/file-tree-selectable'
|
|
|
-import { findInTree } from '../../util/find-in-tree'
|
|
|
|
|
|
function FileTreeItemMenuItems() {
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
- const { fileTreeData } = useFileTreeData()
|
|
|
- const { selectedEntityIds } = useFileTreeSelectable()
|
|
|
-
|
|
|
- // return the name of the selected file or doc if there is only one selected
|
|
|
- const selectedFileName = useMemo(() => {
|
|
|
- if (selectedEntityIds.size === 1) {
|
|
|
- const [selectedEntityId] = selectedEntityIds
|
|
|
- const selectedEntity = findInTree(fileTreeData, selectedEntityId)
|
|
|
- return selectedEntity?.entity?.name
|
|
|
- }
|
|
|
- return null
|
|
|
- }, [fileTreeData, selectedEntityIds])
|
|
|
-
|
|
|
const {
|
|
|
canRename,
|
|
|
canDelete,
|
|
|
@@ -35,6 +19,7 @@ function FileTreeItemMenuItems() {
|
|
|
startCreatingDocOrFile,
|
|
|
startUploadingDocOrFile,
|
|
|
downloadPath,
|
|
|
+ selectedFileName,
|
|
|
} = useFileTreeActionable()
|
|
|
|
|
|
const { owner } = useProjectContext()
|