mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
f065a7a909
GitOrigin-RevId: fbb23b32c47edbe5a22badc627318accbd09e82a
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
import { useTranslation } from 'react-i18next'
|
|
import { Button, Dropdown } from 'react-bootstrap'
|
|
import Icon from '../../../shared/components/icon'
|
|
import ControlledDropdown from '../../../shared/components/controlled-dropdown'
|
|
import PdfFileList from './pdf-file-list'
|
|
import { memo } from 'react'
|
|
import { useCompileContext } from '../../../shared/context/compile-context'
|
|
|
|
function PdfDownloadButton() {
|
|
const { compiling, pdfDownloadUrl, fileList } = useCompileContext()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const disabled = compiling || !pdfDownloadUrl
|
|
|
|
return (
|
|
<ControlledDropdown
|
|
id="pdf-download-dropdown"
|
|
className="toolbar-item"
|
|
disabled={disabled}
|
|
>
|
|
<Button
|
|
bsSize="xsmall"
|
|
bsStyle="info"
|
|
disabled={compiling || !pdfDownloadUrl}
|
|
download
|
|
href={pdfDownloadUrl || '#'}
|
|
>
|
|
<Icon type="download" fw />
|
|
<span className="toolbar-text toolbar-hide-medium toolbar-hide-small">
|
|
{t('download_pdf')}
|
|
</span>
|
|
</Button>
|
|
|
|
<Dropdown.Toggle
|
|
bsSize="xsmall"
|
|
bsStyle="info"
|
|
className="dropdown-toggle"
|
|
aria-label={t('toggle_output_files_list')}
|
|
disabled={!fileList}
|
|
/>
|
|
|
|
<Dropdown.Menu id="download-dropdown-list">
|
|
<PdfFileList fileList={fileList} />
|
|
</Dropdown.Menu>
|
|
</ControlledDropdown>
|
|
)
|
|
}
|
|
|
|
export default memo(PdfDownloadButton)
|