mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
619ec15309
* Add first error popup * Address PR feedback GitOrigin-RevId: e924b3e6096584de6f363aae70a62328cd3de83d
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { useTranslation } from 'react-i18next'
|
|
import Icon from '../../../shared/components/icon'
|
|
import PreviewLogEntry from './preview-log-entry'
|
|
|
|
function PreviewFirstErrorPopUp({
|
|
logEntry,
|
|
onGoToErrorLocation,
|
|
onViewLogs,
|
|
onClose
|
|
}) {
|
|
const { t } = useTranslation()
|
|
|
|
function handleGoToErrorLocation() {
|
|
const { file, line, column } = logEntry
|
|
onGoToErrorLocation({ file, line, column })
|
|
}
|
|
|
|
return (
|
|
<div
|
|
className="first-error-popup"
|
|
role="alertdialog"
|
|
aria-label={t('first_error_popup_label')}
|
|
>
|
|
<PreviewLogEntry
|
|
{...logEntry}
|
|
showLineAndNoLink={false}
|
|
showCloseButton
|
|
onClose={onClose}
|
|
/>
|
|
<div className="first-error-popup-actions">
|
|
<button
|
|
className="btn btn-info btn-xs first-error-btn"
|
|
type="button"
|
|
onClick={handleGoToErrorLocation}
|
|
>
|
|
<Icon type="chain" />
|
|
|
|
{t('go_to_error_location')}
|
|
</button>
|
|
<button
|
|
className="btn btn-info btn-xs first-error-btn"
|
|
type="button"
|
|
onClick={onViewLogs}
|
|
>
|
|
<Icon type="file-text-o" />
|
|
|
|
{t('view_all_errors')}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
PreviewFirstErrorPopUp.propTypes = {
|
|
logEntry: PropTypes.object.isRequired,
|
|
onGoToErrorLocation: PropTypes.func.isRequired,
|
|
onViewLogs: PropTypes.func.isRequired,
|
|
onClose: PropTypes.func.isRequired
|
|
}
|
|
|
|
export default PreviewFirstErrorPopUp
|