overleaf/services/web/frontend/js/features/preview/components/preview-log-entry.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
function PreviewLogEntry({ file, line, message, content, raw, level }) {
const logEntryClasses = classNames('alert', {
'alert-danger': level === 'error',
'alert-warning': level === 'warning',
'alert-info': level === 'typesetting'
})
return (
<div className={logEntryClasses}>
<span className="line-no">
<i className="fa fa-link" aria-hidden="true" />
{file ? <span>{file}</span> : null}
{line ? <span>, {line}</span> : null}
</span>
{message ? (
<p className="entry-message">
{level} {message}
</p>
) : null}
{content ? <p className="entry-content">{content.trim()}</p> : null}
</div>
)
}
PreviewLogEntry.propTypes = {
file: PropTypes.string,
// `line should be either a number or null (i.e. not required), but currently sometimes we get
// an empty string (from BibTeX errors), which is why we're using `any` here. We should revert
// to PropTypes.number (not required) once we fix that.
line: PropTypes.any,
message: PropTypes.string,
content: PropTypes.string,
raw: PropTypes.string,
level: PropTypes.string.isRequired
}
export default PreviewLogEntry