overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-code-check-button.js
Alf Eaton f7ef2532e0 Handle PDF preview on toggle between split and full-width views (#5470)
* Only hide the compile logs pane when toggled off
* Handle PDF preview on toggle between split and full-width views

GitOrigin-RevId: 9ceca8a06a22abfa78f245e1ae5d24af98215906
2021-10-18 08:03:26 +00:00

43 lines
1.1 KiB
JavaScript

import { memo, useCallback } from 'react'
import { sendMBOnce } from '../../../infrastructure/event-tracking'
import { Button } from 'react-bootstrap'
import Icon from '../../../shared/components/icon'
import { useTranslation } from 'react-i18next'
import { useCompileContext } from '../../../shared/context/compile-context'
function PdfHybridCodeCheckButton() {
const { codeCheckFailed, error, setShowLogs } = useCompileContext()
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)