overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-code-check-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

36 lines
955 B
JavaScript

import { memo, useCallback } from 'react'
import { Button } from 'react-bootstrap'
import Icon from '../../../shared/components/icon'
import { useTranslation } from 'react-i18next'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
function PdfHybridCodeCheckButton() {
const { codeCheckFailed, error, toggleLogs } = useCompileContext()
const { t } = useTranslation()
const handleClick = useCallback(() => {
toggleLogs()
}, [toggleLogs])
if (!codeCheckFailed) {
return null
}
return (
<Button
bsSize="xsmall"
bsStyle="danger"
disabled={Boolean(error)}
className="btn-toggle-logs toolbar-item"
onClick={handleClick}
>
<Icon type="exclamation-triangle" />
<span className="toolbar-text toolbar-hide-small">
{t('code_check_failed')}
</span>
</Button>
)
}
export default memo(PdfHybridCodeCheckButton)