2021-09-30 07:29:25 -04:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { useTranslation, Trans } from 'react-i18next'
|
2022-06-21 08:15:45 -04:00
|
|
|
import { memo, useCallback } from 'react'
|
2024-10-23 03:32:40 -04:00
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
2021-10-15 06:42:47 -04:00
|
|
|
import PdfLogEntry from './pdf-log-entry'
|
2022-06-09 10:47:53 -04:00
|
|
|
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
|
2022-06-13 08:08:38 -04:00
|
|
|
import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
|
2023-03-16 07:05:30 -04:00
|
|
|
import getMeta from '../../../utils/meta'
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
function PdfPreviewError({ error }) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
2022-11-07 09:23:53 -05:00
|
|
|
const { startCompile } = useCompileContext()
|
|
|
|
|
2021-09-30 07:29:25 -04:00
|
|
|
switch (error) {
|
2022-11-07 09:23:53 -05:00
|
|
|
case 'rendering-error-expected':
|
|
|
|
return (
|
|
|
|
<PdfLogEntry
|
|
|
|
headerTitle={t('pdf_rendering_error')}
|
|
|
|
formattedContent={
|
|
|
|
<>
|
2023-10-19 04:33:26 -04:00
|
|
|
<Trans
|
|
|
|
i18nKey="something_went_wrong_rendering_pdf_expected"
|
|
|
|
components={[
|
|
|
|
// eslint-disable-next-line react/jsx-key
|
2024-10-23 03:32:40 -04:00
|
|
|
<OLButton
|
|
|
|
variant="info"
|
|
|
|
size="sm"
|
|
|
|
bs3Props={{ bsSize: 'xsmall' }}
|
2023-10-19 04:33:26 -04:00
|
|
|
onClick={() => startCompile()}
|
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>
|
2022-11-07 09:23:53 -05:00
|
|
|
<br />
|
|
|
|
<br />
|
2023-02-03 06:17:52 -05:00
|
|
|
<Trans
|
|
|
|
i18nKey="last_resort_trouble_shooting_guide"
|
|
|
|
components={[
|
2022-11-07 09:23:53 -05:00
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
|
|
<a
|
|
|
|
href="/learn/how-to/Resolving_access%2C_loading%2C_and_display_problems"
|
|
|
|
target="_blank"
|
2023-02-03 06:17:52 -05:00
|
|
|
key="troubleshooting-link"
|
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>
|
2022-11-07 09:23:53 -05:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
level="warning"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
|
2021-09-30 07:29:25 -04:00
|
|
|
case 'rendering-error':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('pdf_rendering_error')}>
|
|
|
|
{t('something_went_wrong_rendering_pdf')}
|
2022-07-28 10:39:17 -04:00
|
|
|
|
|
|
|
<Trans
|
|
|
|
i18nKey="try_recompile_project_or_troubleshoot"
|
|
|
|
components={[
|
2023-02-03 06:17:52 -05:00
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
|
|
<a
|
|
|
|
href="/learn/how-to/Resolving_access%2C_loading%2C_and_display_problems"
|
|
|
|
target="_blank"
|
|
|
|
key="troubleshooting-link"
|
|
|
|
/>,
|
2022-07-28 10:39:17 -04:00
|
|
|
]}
|
|
|
|
/>
|
2023-06-27 09:37:53 -04:00
|
|
|
{getMeta('ol-compilesUserContentDomain') && (
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<Trans
|
|
|
|
i18nKey="new_compile_domain_notice"
|
|
|
|
values={{
|
|
|
|
compilesUserContentDomain: new URL(
|
|
|
|
getMeta('ol-compilesUserContentDomain')
|
|
|
|
).hostname,
|
|
|
|
}}
|
2023-10-19 04:27:45 -04:00
|
|
|
shouldUnescape
|
|
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
2023-06-27 09:37:53 -04:00
|
|
|
components={[
|
|
|
|
<code key="domain" />,
|
|
|
|
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
|
|
|
|
<a
|
|
|
|
href="/learn/how-to/Resolving_access%2C_loading%2C_and_display_problems"
|
|
|
|
target="_blank"
|
|
|
|
key="troubleshooting-link"
|
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2021-09-30 07:29:25 -04:00
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'clsi-maintenance':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('server_error')}>
|
|
|
|
{t('clsi_maintenance')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'clsi-unavailable':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('server_error')}>
|
|
|
|
{t('clsi_unavailable')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'too-recently-compiled':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('server_error')}>
|
|
|
|
{t('too_recently_compiled')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'terminated':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('terminated')}>
|
|
|
|
{t('compile_terminated_by_user')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'rate-limited':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('pdf_compile_rate_limit_hit')}>
|
|
|
|
{t('project_flagged_too_many_compiles')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'compile-in-progress':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('pdf_compile_in_progress_error')}>
|
|
|
|
{t('pdf_compile_try_again')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'auto-compile-disabled':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('autocompile_disabled')}>
|
|
|
|
{t('autocompile_disabled_reason')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'project-too-large':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('project_too_large')}>
|
|
|
|
{t('project_too_much_editable_text')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
2022-06-13 08:08:38 -04:00
|
|
|
case 'timedout':
|
|
|
|
return <TimedOutLogEntry />
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
case 'failure':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('no_pdf_error_title')}>
|
|
|
|
{t('no_pdf_error_explanation')}
|
|
|
|
|
2024-10-23 03:32:40 -04:00
|
|
|
<ul className="my-1 ps-3">
|
2021-09-30 07:29:25 -04:00
|
|
|
<li>{t('no_pdf_error_reason_unrecoverable_error')}</li>
|
|
|
|
<li>
|
|
|
|
<Trans
|
|
|
|
i18nKey="no_pdf_error_reason_no_content"
|
|
|
|
components={{ code: <code /> }}
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<Trans
|
|
|
|
i18nKey="no_pdf_error_reason_output_pdf_already_exists"
|
|
|
|
components={{ code: <code /> }}
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
|
|
|
case 'clear-cache':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('server_error')}>
|
|
|
|
{t('somthing_went_wrong_compiling')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
2022-05-23 07:57:30 -04:00
|
|
|
case 'pdf-viewer-loading-error':
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('pdf_rendering_error')}>
|
|
|
|
<Trans
|
|
|
|
i18nKey="something_went_wrong_loading_pdf_viewer"
|
|
|
|
components={[
|
|
|
|
<strong key="strong-" />,
|
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
|
|
<a
|
|
|
|
href="/learn/how-to/Resolving_access%2C_loading%2C_and_display_problems"
|
2023-02-03 06:17:52 -05:00
|
|
|
target="_blank"
|
|
|
|
key="troubleshooting-link"
|
2022-05-23 07:57:30 -04:00
|
|
|
/>,
|
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
|
|
<a key="contact-link" target="_blank" href="/contact" />,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
|
2021-09-30 07:29:25 -04:00
|
|
|
case 'validation-problems':
|
|
|
|
return null // handled elsewhere
|
|
|
|
|
|
|
|
case 'error':
|
|
|
|
default:
|
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('server_error')}>
|
|
|
|
{t('somthing_went_wrong_compiling')}
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PdfPreviewError.propTypes = {
|
|
|
|
error: PropTypes.string.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default memo(PdfPreviewError)
|
|
|
|
|
2022-06-14 10:28:03 -04:00
|
|
|
function ErrorLogEntry({ title, headerIcon, children }) {
|
2021-09-30 07:29:25 -04:00
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
return (
|
2021-10-15 06:42:47 -04:00
|
|
|
<PdfLogEntry
|
2021-09-30 07:29:25 -04:00
|
|
|
headerTitle={title}
|
2022-06-14 10:28:03 -04:00
|
|
|
headerIcon={headerIcon}
|
2021-09-30 07:29:25 -04:00
|
|
|
formattedContent={children}
|
|
|
|
entryAriaLabel={t('compile_error_entry_description')}
|
|
|
|
level="error"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
ErrorLogEntry.propTypes = {
|
|
|
|
title: PropTypes.string.isRequired,
|
2022-06-14 10:28:03 -04:00
|
|
|
headerIcon: PropTypes.element,
|
2021-09-30 07:29:25 -04:00
|
|
|
children: PropTypes.any.isRequired,
|
|
|
|
}
|
2022-06-13 08:08:38 -04:00
|
|
|
|
|
|
|
function TimedOutLogEntry() {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { enableStopOnFirstError } = useStopOnFirstError({
|
|
|
|
eventSource: 'timeout',
|
|
|
|
})
|
2022-06-13 08:29:35 -04:00
|
|
|
const { startCompile, lastCompileOptions, setAnimateCompileDropdownArrow } =
|
|
|
|
useCompileContext()
|
2022-06-13 08:08:38 -04:00
|
|
|
|
|
|
|
const handleEnableStopOnFirstErrorClick = useCallback(() => {
|
|
|
|
enableStopOnFirstError()
|
|
|
|
startCompile({ stopOnFirstError: true })
|
2022-06-13 08:29:35 -04:00
|
|
|
setAnimateCompileDropdownArrow(true)
|
|
|
|
}, [enableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
|
2022-06-13 08:08:38 -04:00
|
|
|
|
2022-10-03 11:22:13 -04:00
|
|
|
return (
|
|
|
|
<ErrorLogEntry title={t('timedout')}>
|
|
|
|
<p>{t('project_timed_out_intro')}</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
2022-06-13 08:08:38 -04:00
|
|
|
<Trans
|
2022-10-03 11:22:13 -04:00
|
|
|
i18nKey="project_timed_out_optimize_images"
|
2022-08-24 07:32:52 -04:00
|
|
|
components={[
|
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key
|
2022-10-03 11:22:13 -04:00
|
|
|
<a href="https://www.overleaf.com/learn/how-to/Optimising_very_large_image_files" />,
|
2022-08-24 07:32:52 -04:00
|
|
|
]}
|
2022-06-13 08:08:38 -04:00
|
|
|
/>
|
2022-10-03 11:22:13 -04:00
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<Trans
|
|
|
|
i18nKey="project_timed_out_fatal_error"
|
|
|
|
components={[
|
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key
|
|
|
|
<a href="https://www.overleaf.com/learn/how-to/Why_do_I_keep_getting_the_compile_timeout_error_message%3F#Fatal_compile_errors_blocking_the_compilation" />,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
{!lastCompileOptions.stopOnFirstError && (
|
|
|
|
<>
|
|
|
|
{' '}
|
|
|
|
<Trans
|
|
|
|
i18nKey="project_timed_out_enable_stop_on_first_error"
|
|
|
|
components={[
|
|
|
|
// eslint-disable-next-line react/jsx-key
|
2024-10-23 03:32:40 -04:00
|
|
|
<OLButton
|
|
|
|
variant="info"
|
|
|
|
size="sm"
|
|
|
|
bs3Props={{ bsSize: 'xsmall' }}
|
2022-10-03 11:22:13 -04:00
|
|
|
onClick={handleEnableStopOnFirstErrorClick}
|
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
/>{' '}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p>
|
|
|
|
<Trans
|
|
|
|
i18nKey="project_timed_out_learn_more"
|
|
|
|
components={[
|
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key
|
|
|
|
<a href="https://www.overleaf.com/learn/how-to/Why_do_I_keep_getting_the_compile_timeout_error_message%3F" />,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
</ErrorLogEntry>
|
|
|
|
)
|
2022-06-13 08:08:38 -04:00
|
|
|
}
|
|
|
|
TimedOutLogEntry.propTypes = {}
|