From fbde9606905fbc8286b38c4ae14f190da8c27067 Mon Sep 17 00:00:00 2001 From: M Fahru Date: Wed, 20 Jul 2022 07:05:42 -0400 Subject: [PATCH] Improve error message when a collaborator tries to refresh a linked file without access to the project (#8884) * Improve error message when a collaborator tries to refresh a linked file without access to the project * Move the AccessDeniedError hardcoded error message to translation file * apply prettier * remove period (dot) in test hardcoded string * revert unintended changes GitOrigin-RevId: 50a5bf46428a96e629e9091cc18068f3ee7084e3 --- .../app/src/Features/LinkedFiles/LinkedFilesController.js | 7 ++++++- services/web/frontend/extracted-translations.json | 1 + .../js/features/file-view/components/file-view-header.js | 2 +- services/web/locales/en.json | 4 +++- services/web/test/acceptance/src/LinkedFilesTests.js | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js index 32c05dfb36..bb3840d1dc 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesController.js @@ -140,7 +140,12 @@ module.exports = LinkedFilesController = { handleError(error, req, res, next) { if (error instanceof AccessDeniedError) { res.status(403) - plainTextResponse(res, 'You do not have access to this project') + plainTextResponse( + res, + res.locals.translate( + 'the_project_that_contains_this_file_is_not_shared_with_you' + ) + ) } else if (error instanceof BadDataError) { res.status(400) plainTextResponse(res, 'The submitted data is not valid') diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 97ae4e8f4c..3a3862a739 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -1,4 +1,5 @@ { + "access_denied": "", "access_your_projects_with_git": "", "account_not_linked_to_dropbox": "", "account_settings": "", diff --git a/services/web/frontend/js/features/file-view/components/file-view-header.js b/services/web/frontend/js/features/file-view/components/file-view-header.js index 92b5772bf4..a61d6b2d70 100644 --- a/services/web/frontend/js/features/file-view/components/file-view-header.js +++ b/services/web/frontend/js/features/file-view/components/file-view-header.js @@ -138,7 +138,7 @@ export default function FileViewHeader({ file, storeReferencesKeys }) {

- {t('error')}: {refreshError} + {t('access_denied')}: {refreshError} {tprLinkedFileRefreshError.map( ({ import: { LinkedFileRefreshError }, path }) => ( diff --git a/services/web/locales/en.json b/services/web/locales/en.json index def15faf10..38c5d498dd 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1793,5 +1793,7 @@ "would_you_like_to_see_a_university_subscription": "Would you like to see a university-wide __appName__ subscription at your university?", "student_and_faculty_support_make_difference": "Student and faculty support make a difference! We can share this information with our contacts at your university when discussing an Overleaf institutional account.", "show_your_support": "Show your support", - "approaching_compile_timeout_limit_upgrade_for_more_compile_time": "You are approaching your compile timeout limit. Upgrade to Overleaf Premium for <0>4x more compile time." + "approaching_compile_timeout_limit_upgrade_for_more_compile_time": "You are approaching your compile timeout limit. Upgrade to Overleaf Premium for <0>4x more compile time.", + "access_denied": "Access Denied", + "the_project_that_contains_this_file_is_not_shared_with_you": "The project that contains this file is not shared with you" } diff --git a/services/web/test/acceptance/src/LinkedFilesTests.js b/services/web/test/acceptance/src/LinkedFilesTests.js index f36f1a8daa..4913db983f 100644 --- a/services/web/test/acceptance/src/LinkedFilesTests.js +++ b/services/web/test/acceptance/src/LinkedFilesTests.js @@ -156,7 +156,9 @@ describe('LinkedFiles', function () { }, })) expect(response.statusCode).to.equal(403) - expect(body).to.equal('You do not have access to this project') + expect(body).to.equal( + 'The project that contains this file is not shared with you' + ) }) it('should generate a proper error message when the source file has been deleted', async function () {