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 { DropdownDivider, DropdownItem, } from '@/features/ui/components/bootstrap-5/dropdown-menu' import { useFileTreeActionable } from '../../contexts/file-tree-actionable' import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher' function FileTreeItemMenuItems() { const { t } = useTranslation() const { canRename, canDelete, canCreate, startRenaming, startDeleting, startCreatingFolder, startCreatingDocOrFile, startUploadingDocOrFile, downloadPath, selectedFileName, } = useFileTreeActionable() const { owner } = useProjectContext() const downloadWithAnalytics = useCallback(() => { // we are only interested in downloads of bib files WRT analytics, for the purposes of promoting the tpr integrations if (selectedFileName?.endsWith('.bib')) { eventTracking.sendMB('download-bib-file', { projectOwner: owner._id }) } }, [selectedFileName, owner]) const createWithAnalytics = useCallback(() => { eventTracking.sendMB('new-file-click', { location: 'file-menu' }) startCreatingDocOrFile() }, [startCreatingDocOrFile]) const uploadWithAnalytics = useCallback(() => { eventTracking.sendMB('upload-click', { location: 'file-menu' }) startUploadingDocOrFile() }, [startUploadingDocOrFile]) return ( {canRename ? ( {t('rename')} ) : null} {downloadPath ? ( {t('download')} ) : null} {canDelete ? ( {t('delete')} ) : null} {canCreate ? ( <>
  • {t('new_file')} {t('new_folder')} {t('upload')} ) : null} } bs5={ <> {canRename ? (
  • {t('rename')}
  • ) : null} {downloadPath ? (
  • {t('download')}
  • ) : null} {canDelete ? (
  • {t('delete')}
  • ) : null} {canCreate ? ( <>
  • {t('new_file')}
  • {t('new_folder')}
  • {t('upload')}
  • ) : null} } /> ) } export default FileTreeItemMenuItems