mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
12eab99990
* Migrate log entry component to new PDF preview * Add a test for expandable log content GitOrigin-RevId: 3e2154983c1ea03b5db44c87822e7043c4aa2cfe
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import { memo, useCallback } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { useTranslation } from 'react-i18next'
|
|
import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
|
|
import PdfLogEntry from './pdf-log-entry'
|
|
|
|
const LOG_PREVIEW_LIMIT = 100
|
|
|
|
function PdfLogsEntries({ entries }) {
|
|
const { t } = useTranslation()
|
|
|
|
const syncToEntry = useCallback(entry => {
|
|
window.dispatchEvent(
|
|
new CustomEvent('synctex:sync-to-entry', {
|
|
detail: entry,
|
|
})
|
|
)
|
|
}, [])
|
|
|
|
const logEntries = entries.slice(0, LOG_PREVIEW_LIMIT)
|
|
|
|
return (
|
|
<>
|
|
{entries.length > LOG_PREVIEW_LIMIT && (
|
|
<PreviewLogsPaneMaxEntries
|
|
totalEntries={entries.length}
|
|
entriesShown={LOG_PREVIEW_LIMIT}
|
|
/>
|
|
)}
|
|
{logEntries.map(logEntry => (
|
|
<PdfLogEntry
|
|
key={logEntry.key}
|
|
headerTitle={logEntry.message}
|
|
rawContent={logEntry.content}
|
|
logType={logEntry.type}
|
|
formattedContent={logEntry.humanReadableHintComponent}
|
|
extraInfoURL={logEntry.extraInfoURL}
|
|
level={logEntry.level}
|
|
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),
|
|
}
|
|
|
|
export default memo(PdfLogsEntries)
|