mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
b2e74464a2
editor events GitOrigin-RevId: 8d74576d4f8117ecca47402afcc9cee229dd0dca
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import { useTranslation } from 'react-i18next'
|
|
import * as eventTracking from '../../../../infrastructure/event-tracking'
|
|
|
|
import { MenuItem } from 'react-bootstrap'
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
|
|
|
function FileTreeItemMenuItems() {
|
|
const { t } = useTranslation()
|
|
|
|
const {
|
|
canRename,
|
|
canDelete,
|
|
canCreate,
|
|
startRenaming,
|
|
startDeleting,
|
|
startCreatingFolder,
|
|
startCreatingDocOrFile,
|
|
startUploadingDocOrFile,
|
|
downloadPath,
|
|
} = useFileTreeActionable()
|
|
|
|
const createWithAnalytics = () => {
|
|
eventTracking.sendMB('new-file-click', { location: 'file-menu' })
|
|
startCreatingDocOrFile()
|
|
}
|
|
|
|
const uploadWithAnalytics = () => {
|
|
eventTracking.sendMB('upload-click', { location: 'file-menu' })
|
|
startUploadingDocOrFile()
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{canRename ? (
|
|
<MenuItem onClick={startRenaming}>{t('rename')}</MenuItem>
|
|
) : null}
|
|
{downloadPath ? (
|
|
<MenuItem href={downloadPath} download>
|
|
{t('download')}
|
|
</MenuItem>
|
|
) : null}
|
|
{canDelete ? (
|
|
<MenuItem onClick={startDeleting}>{t('delete')}</MenuItem>
|
|
) : null}
|
|
{canCreate ? (
|
|
<>
|
|
<MenuItem divider />
|
|
<MenuItem onClick={createWithAnalytics}>{t('new_file')}</MenuItem>
|
|
<MenuItem onClick={startCreatingFolder}>{t('new_folder')}</MenuItem>
|
|
<MenuItem onClick={uploadWithAnalytics}>{t('upload')}</MenuItem>
|
|
</>
|
|
) : null}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default FileTreeItemMenuItems
|