mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 01:16:51 -05:00
420aa4a657
React File Tree GitOrigin-RevId: fb3141ba8cd9ca0d68e87edb74764a360144c8fe
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import React, { useState } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { useTranslation } from 'react-i18next'
|
|
import withoutPropagation from '../../../../infrastructure/without-propagation'
|
|
|
|
import { Dropdown } from 'react-bootstrap'
|
|
import Icon from '../../../../shared/components/icon'
|
|
|
|
import FileTreeItemMenuItems from './file-tree-item-menu-items'
|
|
|
|
function FileTreeItemMenu({ id }) {
|
|
const { t } = useTranslation()
|
|
|
|
const [dropdownOpen, setDropdownOpen] = useState(false)
|
|
|
|
function handleToggle(wantOpen) {
|
|
setDropdownOpen(wantOpen)
|
|
}
|
|
|
|
function handleClick() {
|
|
handleToggle(false)
|
|
}
|
|
|
|
return (
|
|
<Dropdown
|
|
onClick={withoutPropagation(handleClick)}
|
|
pullRight
|
|
open={dropdownOpen}
|
|
id={`dropdown-${id}`}
|
|
onToggle={handleToggle}
|
|
>
|
|
<Dropdown.Toggle
|
|
noCaret
|
|
className="dropdown-toggle-no-background entity-menu-toggle"
|
|
onClick={withoutPropagation()}
|
|
>
|
|
<Icon type="ellipsis-v" accessibilityLabel={t('menu')} />
|
|
</Dropdown.Toggle>
|
|
<Dropdown.Menu>
|
|
<FileTreeItemMenuItems />
|
|
</Dropdown.Menu>
|
|
</Dropdown>
|
|
)
|
|
}
|
|
|
|
FileTreeItemMenu.propTypes = {
|
|
id: PropTypes.string.isRequired
|
|
}
|
|
|
|
export default FileTreeItemMenu
|