Преглед изворни кода

Add support for groups when importing references from Zotero (#6204)

* Add Zotero groups support to third-party-references
* Return 400 response with { relink: true } if remote response was 403
* Handle Zotero groups in tpr-webmodule
* Handle Zotero groups in the frontend
* Handle JSON OAuth token error response from Mendeley API

GitOrigin-RevId: 8011d71a5596f7671aca16a228f9ef40be4a02d0
Alf Eaton пре 4 година
родитељ
комит
6025d3571c

+ 6 - 2
services/web/app/src/Features/LinkedFiles/LinkedFilesController.js

@@ -190,8 +190,12 @@ module.exports = LinkedFilesController = {
       res.status(400)
       res.status(400)
       plainTextResponse(res, 'This feature is not enabled on your account')
       plainTextResponse(res, 'This feature is not enabled on your account')
     } else if (error instanceof RemoteServiceError) {
     } else if (error instanceof RemoteServiceError) {
-      res.status(502)
-      plainTextResponse(res, 'The remote service produced an error')
+      if (error.info?.statusCode === 403) {
+        res.status(400).json({ relink: true })
+      } else {
+        res.status(502)
+        plainTextResponse(res, 'The remote service produced an error')
+      }
     } else if (error instanceof FileCannotRefreshError) {
     } else if (error instanceof FileCannotRefreshError) {
       res.status(400)
       res.status(400)
       plainTextResponse(res, 'This file cannot be refreshed')
       plainTextResponse(res, 'This file cannot be refreshed')

+ 3 - 0
services/web/frontend/extracted-translations.json

@@ -253,6 +253,7 @@
   "math_inline": "",
   "math_inline": "",
   "maximum_files_uploaded_together": "",
   "maximum_files_uploaded_together": "",
   "mendeley_groups_loading_error": "",
   "mendeley_groups_loading_error": "",
+  "mendeley_groups_relink": "",
   "mendeley_integration": "",
   "mendeley_integration": "",
   "mendeley_is_premium": "",
   "mendeley_is_premium": "",
   "mendeley_reference_loading_error": "",
   "mendeley_reference_loading_error": "",
@@ -358,6 +359,7 @@
   "refresh_page_after_linking_dropbox": "",
   "refresh_page_after_linking_dropbox": "",
   "refresh_page_after_starting_free_trial": "",
   "refresh_page_after_starting_free_trial": "",
   "refreshing": "",
   "refreshing": "",
+  "relink_your_account": "",
   "remote_service_error": "",
   "remote_service_error": "",
   "remove": "",
   "remove": "",
   "remove_collaborator": "",
   "remove_collaborator": "",
@@ -486,6 +488,7 @@
   "work_with_non_overleaf_users": "",
   "work_with_non_overleaf_users": "",
   "your_message": "",
   "your_message": "",
   "zotero_groups_loading_error": "",
   "zotero_groups_loading_error": "",
+  "zotero_groups_relink": "",
   "zotero_integration": "",
   "zotero_integration": "",
   "zotero_is_premium": "",
   "zotero_is_premium": "",
   "zotero_reference_loading_error": "",
   "zotero_reference_loading_error": "",

+ 12 - 0
services/web/frontend/stories/modals/create-file/create-file-modal-decorator.js

@@ -65,6 +65,18 @@ export const mockCreateFileModalFetch = fetchMock =>
         },
         },
       ],
       ],
     })
     })
+    .get('path:/zotero/groups', {
+      groups: [
+        {
+          id: 'group-1',
+          name: 'Group One',
+        },
+        {
+          id: 'group-2',
+          name: 'Group Two',
+        },
+      ],
+    })
     .get('express:/project/:projectId/entities', {
     .get('express:/project/:projectId/entities', {
       entities: [
       entities: [
         {
         {

+ 3 - 0
services/web/locales/en.json

@@ -750,6 +750,7 @@
   "mendeley_reference_loading_success": "Loaded references from Mendeley",
   "mendeley_reference_loading_success": "Loaded references from Mendeley",
   "mendeley_reference_loading_error": "Error, could not load references from Mendeley",
   "mendeley_reference_loading_error": "Error, could not load references from Mendeley",
   "mendeley_groups_loading_error": "There was an error loading groups from Mendeley",
   "mendeley_groups_loading_error": "There was an error loading groups from Mendeley",
+  "mendeley_groups_relink": "There was an error accessing your Mendeley data. This was likely caused by lack of permissions. Please re-link your account and try again.",
   "zotero_integration": "Zotero Integration",
   "zotero_integration": "Zotero Integration",
   "zotero_sync_description": "With Zotero integration you can import your references from Zotero into your __appName__ projects.",
   "zotero_sync_description": "With Zotero integration you can import your references from Zotero into your __appName__ projects.",
   "zotero_is_premium": "Zotero integration is a premium feature",
   "zotero_is_premium": "Zotero integration is a premium feature",
@@ -759,6 +760,8 @@
   "zotero_reference_loading_success": "Loaded references from Zotero",
   "zotero_reference_loading_success": "Loaded references from Zotero",
   "zotero_reference_loading_error": "Error, could not load references from Zotero",
   "zotero_reference_loading_error": "Error, could not load references from Zotero",
   "zotero_groups_loading_error": "There was an error loading groups from Zotero",
   "zotero_groups_loading_error": "There was an error loading groups from Zotero",
+  "zotero_groups_relink": "There was an error accessing your Zotero data. This was likely caused by lack of permissions. Please re-link your account and try again.",
+  "relink_your_account": "Re-link your account",
   "reference_import_button": "Import References to",
   "reference_import_button": "Import References to",
   "unlink_reference": "Unlink References Provider",
   "unlink_reference": "Unlink References Provider",
   "unlink_warning_reference": "Warning: When you unlink your account from this provider you will not be able to import references into your projects.",
   "unlink_warning_reference": "Warning: When you unlink your account from this provider you will not be able to import references into your projects.",