overleaf/services/web/frontend/js/features/preview/components/preview-first-error-pop-up.js
Paulo Jorge Reis 081f4212a8 Add error and validation issues (#3400)
* Remove references to the duplicatePaths validation

* Make the log entries more generic, to support validation and CLSI errors

* Add validation issues to the new logs UI

* Add CLSI errors to the new logs UI

* Update tests; accessibility fixes

* Disable PDF viewing when compile fails; address PR feedback.

* Add accessible description for error and validation failed compiles

GitOrigin-RevId: 8b0597af8857712d47c20e4915470e8e745bb315
2020-11-27 03:04:38 +00:00

67 lines
1.7 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'
import Icon from '../../../shared/components/icon'
import PreviewLogsPaneEntry from './preview-logs-pane-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')}
>
<PreviewLogsPaneEntry
headerTitle={logEntry.message}
rawContent={logEntry.content}
formattedContent={logEntry.humanReadableHintComponent}
extraInfoURL={logEntry.extraInfoURL}
level={logEntry.level}
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" />
&nbsp;
{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" />
&nbsp;
{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