2023-05-15 05:18:30 -04:00
|
|
|
import { memo } from 'react'
|
2021-09-30 07:29:25 -04:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
2021-10-08 05:42:49 -04:00
|
|
|
import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
|
2021-10-15 05:45:06 -04:00
|
|
|
import PdfLogEntry from './pdf-log-entry'
|
2023-05-15 05:18:30 -04:00
|
|
|
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
|
2021-10-08 05:42:49 -04:00
|
|
|
|
|
|
|
const LOG_PREVIEW_LIMIT = 100
|
2021-09-30 07:29:25 -04:00
|
|
|
|
2021-11-25 05:24:25 -05:00
|
|
|
function PdfLogsEntries({ entries, hasErrors }) {
|
2021-09-30 07:29:25 -04:00
|
|
|
const { t } = useTranslation()
|
2023-05-15 05:18:30 -04:00
|
|
|
const { syncToEntry } = useDetachCompileContext()
|
2021-10-08 05:42:49 -04:00
|
|
|
const logEntries = entries.slice(0, LOG_PREVIEW_LIMIT)
|
|
|
|
|
2021-09-30 07:29:25 -04:00
|
|
|
return (
|
|
|
|
<>
|
2021-10-08 05:42:49 -04:00
|
|
|
{entries.length > LOG_PREVIEW_LIMIT && (
|
|
|
|
<PreviewLogsPaneMaxEntries
|
|
|
|
totalEntries={entries.length}
|
|
|
|
entriesShown={LOG_PREVIEW_LIMIT}
|
2021-11-25 05:24:25 -05:00
|
|
|
hasErrors={hasErrors}
|
2021-10-08 05:42:49 -04:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{logEntries.map(logEntry => (
|
2021-10-15 05:45:06 -04:00
|
|
|
<PdfLogEntry
|
2021-09-30 07:29:25 -04:00
|
|
|
key={logEntry.key}
|
2022-03-31 07:22:36 -04:00
|
|
|
ruleId={logEntry.ruleId}
|
2021-09-30 07:29:25 -04:00
|
|
|
headerTitle={logEntry.message}
|
|
|
|
rawContent={logEntry.content}
|
|
|
|
logType={logEntry.type}
|
|
|
|
level={logEntry.level}
|
2023-02-20 08:45:22 -05:00
|
|
|
contentDetails={logEntry.contentDetails}
|
2021-09-30 07:29:25 -04:00
|
|
|
entryAriaLabel={t('log_entry_description', {
|
|
|
|
level: logEntry.level,
|
|
|
|
})}
|
|
|
|
sourceLocation={{
|
|
|
|
file: logEntry.file,
|
|
|
|
line: logEntry.line,
|
|
|
|
column: logEntry.column,
|
|
|
|
}}
|
|
|
|
onSourceLocationClick={syncToEntry}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
PdfLogsEntries.propTypes = {
|
|
|
|
entries: PropTypes.arrayOf(PropTypes.object),
|
2021-11-25 05:24:25 -05:00
|
|
|
hasErrors: PropTypes.bool,
|
2021-09-30 07:29:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default memo(PdfLogsEntries)
|