mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
e26d47cb41
GitOrigin-RevId: 6266028091229c819aee3c8d4bd3bff2e2417125
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { memo, useCallback } from 'react'
|
|
import { usePdfPreviewContext } from '../contexts/pdf-preview-context'
|
|
import { sendMBOnce } from '../../../infrastructure/event-tracking'
|
|
import { Button } from 'react-bootstrap'
|
|
import Icon from '../../../shared/components/icon'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
function PdfHybridCodeCheckButton() {
|
|
const { codeCheckFailed, error, setShowLogs } = usePdfPreviewContext()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const handleClick = useCallback(() => {
|
|
setShowLogs(value => {
|
|
if (!value) {
|
|
sendMBOnce('ide-open-logs-once')
|
|
}
|
|
|
|
return !value
|
|
})
|
|
}, [setShowLogs])
|
|
|
|
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)
|