2020-11-16 05:01:01 -05:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import Icon from '../../../shared/components/icon'
|
2020-11-26 04:58:42 -05:00
|
|
|
import PreviewLogsPaneEntry from './preview-logs-pane-entry'
|
2021-01-21 07:21:22 -05:00
|
|
|
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
|
2020-11-16 05:01:01 -05:00
|
|
|
|
|
|
|
function PreviewFirstErrorPopUp({
|
|
|
|
logEntry,
|
|
|
|
onGoToErrorLocation,
|
|
|
|
onViewLogs,
|
2021-04-27 03:52:58 -04:00
|
|
|
onClose,
|
2020-11-16 05:01:01 -05:00
|
|
|
}) {
|
|
|
|
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')}
|
|
|
|
>
|
2020-11-26 04:58:42 -05:00
|
|
|
<PreviewLogsPaneEntry
|
|
|
|
headerTitle={logEntry.message}
|
2021-04-12 05:23:25 -04:00
|
|
|
headerIcon={<FirstErrorPopUpInfoBadge />}
|
2020-11-26 04:58:42 -05:00
|
|
|
rawContent={logEntry.content}
|
|
|
|
formattedContent={logEntry.humanReadableHintComponent}
|
|
|
|
extraInfoURL={logEntry.extraInfoURL}
|
|
|
|
level={logEntry.level}
|
2020-11-16 05:01:01 -05:00
|
|
|
showLineAndNoLink={false}
|
|
|
|
showCloseButton
|
2020-12-02 05:03:03 -05:00
|
|
|
customClass="log-entry-first-error-popup"
|
2020-11-16 05:01:01 -05:00
|
|
|
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>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-04-12 05:23:25 -04:00
|
|
|
function FirstErrorPopUpInfoBadge() {
|
2021-01-21 07:21:22 -05:00
|
|
|
const { t } = useTranslation()
|
2021-04-12 05:23:25 -04:00
|
|
|
const logsPaneInfoMessage = t('logs_pane_info_message_popup')
|
2021-01-21 07:21:22 -05:00
|
|
|
const tooltip = (
|
2021-04-12 05:23:25 -04:00
|
|
|
<Tooltip id="file-tree-badge-tooltip">{logsPaneInfoMessage}</Tooltip>
|
2021-01-21 07:21:22 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<OverlayTrigger placement="bottom" overlay={tooltip} delayHide={100}>
|
|
|
|
<a
|
2021-04-12 05:23:25 -04:00
|
|
|
href="https://forms.gle/AUbDDRvroQ7KFwHR9"
|
2021-01-21 07:21:22 -05:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
2021-04-12 05:23:25 -04:00
|
|
|
className="info-badge-fade-bg"
|
2021-01-21 07:21:22 -05:00
|
|
|
>
|
2021-04-12 05:23:25 -04:00
|
|
|
<span className="sr-only">{logsPaneInfoMessage}</span>
|
2021-01-21 07:21:22 -05:00
|
|
|
</a>
|
|
|
|
</OverlayTrigger>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-11-16 05:01:01 -05:00
|
|
|
PreviewFirstErrorPopUp.propTypes = {
|
|
|
|
logEntry: PropTypes.object.isRequired,
|
|
|
|
onGoToErrorLocation: PropTypes.func.isRequired,
|
|
|
|
onViewLogs: PropTypes.func.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
onClose: PropTypes.func.isRequired,
|
2020-11-16 05:01:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default PreviewFirstErrorPopUp
|