From 2ab5189771c2ecaca20d56667bc876f5191571ca Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Thu, 2 Jun 2022 10:35:43 -0400 Subject: [PATCH] Merge pull request #8237 from overleaf/em-halt-on-error Stop on first error dropdown UI GitOrigin-RevId: 5191a37f6c227ff5a91c10ce965832e1702c3931 --- .../src/Features/Project/ProjectController.js | 20 +++++++++++++++++ .../web/app/views/project/editor/meta.pug | 1 + .../web/frontend/extracted-translations.json | 3 +++ .../components/pdf-compile-button.js | 22 +++++++++++++++++++ .../shared/context/detach-compile-context.js | 20 +++++++++++++++++ .../shared/context/local-compile-context.js | 13 +++++++++++ services/web/locales/en.json | 5 ++++- 7 files changed, 83 insertions(+), 1 deletion(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index be28267b39..f7aad09591 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -884,6 +884,21 @@ const ProjectController = { } ) }, + stopOnFirstErrorAssignment(cb) { + SplitTestHandler.getAssignment( + req, + res, + 'stop-on-first-error', + (error, assignment) => { + // do not fail editor load if assignment fails + if (error) { + cb(null, { variant: 'default' }) + } else { + cb(null, assignment) + } + } + ) + }, }, ( err, @@ -900,6 +915,7 @@ const ProjectController = { pdfDetachAssignment, pdfjsAssignment, dictionaryEditorAssignment, + stopOnFirstErrorAssignment, } ) => { if (err != null) { @@ -1017,6 +1033,9 @@ const ProjectController = { !userIsMemberOfGroupSubscription && !userHasInstitutionLicence + const showStopOnFirstError = + stopOnFirstErrorAssignment.variant === 'enabled' + const template = detachRole === 'detached' ? 'project/editor_detached' @@ -1082,6 +1101,7 @@ const ProjectController = { debugPdfDetach, showNewSourceEditorOption, showSymbolPalette, + showStopOnFirstError, trackPdfDownload: partOfPdfCachingRollout('collect-metrics'), enablePdfCaching: partOfPdfCachingRollout('enable-caching'), resetServiceWorker: diff --git a/services/web/app/views/project/editor/meta.pug b/services/web/app/views/project/editor/meta.pug index a167ea3180..8960e71857 100644 --- a/services/web/app/views/project/editor/meta.pug +++ b/services/web/app/views/project/editor/meta.pug @@ -31,6 +31,7 @@ meta(name="ol-trackPdfDownload" data-type="boolean" content=trackPdfDownload) meta(name="ol-resetServiceWorker" data-type="boolean" content=resetServiceWorker) meta(name="ol-detachRole" data-type="string" content=detachRole) meta(name="ol-showHeaderUpgradePrompt" data-type="boolean" content=showHeaderUpgradePrompt) +meta(name="ol-showStopOnFirstError" data-type="boolean" content=showStopOnFirstError) - var fileActionI18n = ['edited', 'renamed', 'created', 'deleted'].reduce((acc, i) => {acc[i] = translate('file_action_' + i); return acc}, {}) meta(name="ol-fileActionI18n" data-type="json" content=fileActionI18n) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 6c52024c23..ecef5f0342 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -59,6 +59,7 @@ "commit": "", "common": "", "compile_error_entry_description": "", + "compile_error_handling": "", "compile_larger_projects": "", "compile_mode": "", "compile_terminated_by_user": "", @@ -433,6 +434,7 @@ "start_by_adding_your_email": "", "start_free_trial": "", "stop_compile": "", + "stop_on_first_error": "", "stop_on_validation_error": "", "store_your_work": "", "subject": "", @@ -470,6 +472,7 @@ "try_premium_for_free": "", "try_recompile_project": "", "try_refresh_page": "", + "try_to_compile_despite_errors": "", "turn_off_link_sharing": "", "turn_on_link_sharing": "", "unconfirmed": "", diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js b/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js index 583e68f07d..a521977af6 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-compile-button.js @@ -6,6 +6,7 @@ import { memo } from 'react' import classnames from 'classnames' import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context' import PdfCompileButtonInner from './pdf-compile-button-inner' +import getMeta from '../../../utils/meta' function PdfCompileButton() { const { @@ -15,7 +16,9 @@ function PdfCompileButton() { hasChanges, setAutoCompile, setDraft, + setStopOnFirstError, setStopOnValidationError, + stopOnFirstError, stopOnValidationError, startCompile, stopCompile, @@ -23,6 +26,7 @@ function PdfCompileButton() { } = useCompileContext() const { t } = useTranslation() + const showStopOnFirstError = getMeta('ol-showStopOnFirstError') return ( + {showStopOnFirstError && ( + {t('compile_error_handling')} + )} + + {showStopOnFirstError && ( + setStopOnFirstError(true)}> + + {t('stop_on_first_error')} + + )} + + {showStopOnFirstError && ( + setStopOnFirstError(false)}> + + {t('try_to_compile_despite_errors')} + + )} + set or reset your password." + "email_or_password_wrong_try_again_or_reset": "Your email or password is incorrect. Please try again, or <0>set or reset your password.", + "compile_error_handling": "Compile Error Handling", + "stop_on_first_error": "Stop on first error", + "try_to_compile_despite_errors": "Try to compile despite errors" }