overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.js
Timothée Alby 3c01402bbd Merge pull request #7034 from overleaf/ta-pdf-detach-full
PDF Detach v2

GitOrigin-RevId: 3deb76474185f9176cde23ab32ef51b90df6e8e9
2022-04-05 12:19:23 +00:00

37 lines
1,012 B
JavaScript

import { useTranslation } from 'react-i18next'
import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap'
import Icon from '../../../shared/components/icon'
import { memo } from 'react'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
function PdfHybridDownloadButton() {
const { pdfDownloadUrl } = useCompileContext()
const { t } = useTranslation()
return (
<OverlayTrigger
placement="bottom"
overlay={
<Tooltip id="tooltip-logs-toggle">
{pdfDownloadUrl
? t('download_pdf')
: t('please_compile_pdf_before_download')}
</Tooltip>
}
>
<Button
bsStyle="link"
disabled={!pdfDownloadUrl}
download
href={pdfDownloadUrl || '#'}
target="_blank"
style={{ pointerEvents: 'auto' }}
>
<Icon type="download" fw />
</Button>
</OverlayTrigger>
)
}
export default memo(PdfHybridDownloadButton)