pdf-preview-error.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import PropTypes from 'prop-types'
  2. import { useTranslation, Trans } from 'react-i18next'
  3. import PreviewLogsPaneEntry from '../../preview/components/preview-logs-pane-entry'
  4. import { memo } from 'react'
  5. function PdfPreviewError({ error }) {
  6. const { t } = useTranslation()
  7. switch (error) {
  8. case 'rendering-error':
  9. return (
  10. <ErrorLogEntry title={t('pdf_rendering_error')}>
  11. {t('something_went_wrong_rendering_pdf')}
  12. </ErrorLogEntry>
  13. )
  14. case 'clsi-maintenance':
  15. return (
  16. <ErrorLogEntry title={t('server_error')}>
  17. {t('clsi_maintenance')}
  18. </ErrorLogEntry>
  19. )
  20. case 'clsi-unavailable':
  21. return (
  22. <ErrorLogEntry title={t('server_error')}>
  23. {t('clsi_unavailable')}
  24. </ErrorLogEntry>
  25. )
  26. case 'too-recently-compiled':
  27. return (
  28. <ErrorLogEntry title={t('server_error')}>
  29. {t('too_recently_compiled')}
  30. </ErrorLogEntry>
  31. )
  32. case 'terminated':
  33. return (
  34. <ErrorLogEntry title={t('terminated')}>
  35. {t('compile_terminated_by_user')}
  36. </ErrorLogEntry>
  37. )
  38. case 'rate-limited':
  39. return (
  40. <ErrorLogEntry title={t('pdf_compile_rate_limit_hit')}>
  41. {t('project_flagged_too_many_compiles')}
  42. </ErrorLogEntry>
  43. )
  44. case 'compile-in-progress':
  45. return (
  46. <ErrorLogEntry title={t('pdf_compile_in_progress_error')}>
  47. {t('pdf_compile_try_again')}
  48. </ErrorLogEntry>
  49. )
  50. case 'auto-compile-disabled':
  51. return (
  52. <ErrorLogEntry title={t('autocompile_disabled')}>
  53. {t('autocompile_disabled_reason')}
  54. </ErrorLogEntry>
  55. )
  56. case 'project-too-large':
  57. return (
  58. <ErrorLogEntry title={t('project_too_large')}>
  59. {t('project_too_much_editable_text')}
  60. </ErrorLogEntry>
  61. )
  62. case 'timedout':
  63. return (
  64. <ErrorLogEntry title={t('timedout')}>
  65. {t('proj_timed_out_reason')}
  66. <div>
  67. <a
  68. href="https://www.overleaf.com/learn/how-to/Why_do_I_keep_getting_the_compile_timeout_error_message%3F"
  69. target="_blank"
  70. rel="noopener"
  71. >
  72. {t('learn_how_to_make_documents_compile_quickly')}
  73. </a>
  74. </div>
  75. </ErrorLogEntry>
  76. )
  77. case 'failure':
  78. return (
  79. <ErrorLogEntry title={t('no_pdf_error_title')}>
  80. {t('no_pdf_error_explanation')}
  81. <ul className="log-entry-formatted-content-list">
  82. <li>{t('no_pdf_error_reason_unrecoverable_error')}</li>
  83. <li>
  84. <Trans
  85. i18nKey="no_pdf_error_reason_no_content"
  86. components={{ code: <code /> }}
  87. />
  88. </li>
  89. <li>
  90. <Trans
  91. i18nKey="no_pdf_error_reason_output_pdf_already_exists"
  92. components={{ code: <code /> }}
  93. />
  94. </li>
  95. </ul>
  96. </ErrorLogEntry>
  97. )
  98. case 'clear-cache':
  99. return (
  100. <ErrorLogEntry title={t('server_error')}>
  101. {t('somthing_went_wrong_compiling')}
  102. </ErrorLogEntry>
  103. )
  104. case 'validation-problems':
  105. return null // handled elsewhere
  106. case 'error':
  107. default:
  108. return (
  109. <ErrorLogEntry title={t('server_error')}>
  110. {t('somthing_went_wrong_compiling')}
  111. </ErrorLogEntry>
  112. )
  113. }
  114. }
  115. PdfPreviewError.propTypes = {
  116. error: PropTypes.string.isRequired,
  117. }
  118. export default memo(PdfPreviewError)
  119. function ErrorLogEntry({ title, children }) {
  120. const { t } = useTranslation()
  121. return (
  122. <PreviewLogsPaneEntry
  123. headerTitle={title}
  124. formattedContent={children}
  125. entryAriaLabel={t('compile_error_entry_description')}
  126. level="error"
  127. />
  128. )
  129. }
  130. ErrorLogEntry.propTypes = {
  131. title: PropTypes.string.isRequired,
  132. children: PropTypes.any.isRequired,
  133. }