From 613f0e2a4a7991f080bef0cedbd20abf895f2634 Mon Sep 17 00:00:00 2001 From: Taslan Graham Date: Tue, 31 Dec 2024 13:03:53 -0500 Subject: [PATCH] pkp/pkp-lib#10744 Increase opportunity for ORCID work/review deposits --- .../ReviewerManager/reviewerManagerStore.js | 5 ++ .../useReviewerManagerActions.js | 58 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/managers/ReviewerManager/reviewerManagerStore.js b/src/managers/ReviewerManager/reviewerManagerStore.js index 1e1e90339..88704353e 100644 --- a/src/managers/ReviewerManager/reviewerManagerStore.js +++ b/src/managers/ReviewerManager/reviewerManagerStore.js @@ -172,6 +172,10 @@ export const useReviewerManagerStore = defineComponentStore( return _actionFns.getItemPrimaryActions(args); } + function reviewerSendToOrcid({reviewAssignment}) { + return _actionFns.reviewerSendToOrcid(getActionArgs({reviewAssignment})); + } + return { getReviewMethodIcons, reviewAssignments, @@ -198,6 +202,7 @@ export const useReviewerManagerStore = defineComponentStore( reviewerRevertConsider, reviewerSendReminder, reviewerLogResponse, + reviewerSendToOrcid, _reviewerManagerActionFns: _actionFns, }; }, diff --git a/src/managers/ReviewerManager/useReviewerManagerActions.js b/src/managers/ReviewerManager/useReviewerManagerActions.js index 969960da1..0e96c48db 100644 --- a/src/managers/ReviewerManager/useReviewerManagerActions.js +++ b/src/managers/ReviewerManager/useReviewerManagerActions.js @@ -26,6 +26,7 @@ export const Actions = { REVIEWER_REVERT_CONSIDER: 'reviewerRevertConsider', REVIEWER_SEND_REMINDER: 'reviewerSendReminder', REVIEWER_LOG_RESPONSE: 'reviewerLogResponse', + REVIEWER_SEND_TO_ORCID: 'reviewerSendToOrcid', }; export function useReviewerManagerActions() { @@ -198,6 +199,18 @@ export function useReviewerManagerActions() { }); } + // ORCID reviewer deposit + if ( + reviewAssignment.reviewerHasOrcid && + pkp.const.REVIEW_ASSIGNMENT_STATUS_COMPLETE + ) { + actions.push({ + label: t('dashboard.reviewAssignment.action.sendReviewToOrcid'), + name: Actions.REVIEWER_SEND_TO_ORCID, + icon: 'Orcid', + }); + } + return actions; } @@ -609,6 +622,50 @@ export function useReviewerManagerActions() { ); } + function reviewerSendToOrcid({ + submission, + reviewAssignment, + submissionStageId, + }) { + const {openDialog, openDialogNetworkError} = useModal(); + + let submissionId = submission.id; + + openDialog({ + actions: [ + { + label: t('common.ok'), + isPrimary: true, + callback: async (close) => { + const {apiUrl} = useApiUrl( + `reviews/${submissionId}/${reviewAssignment.id}/sendToOrcid`, + ); + + const formData = new FormData(); + formData.append('csrfToken', getCSRFToken()); + + const {fetch, isSuccess} = useFetch(apiUrl, { + method: 'POST', + body: formData, + }); + + await fetch(); + close(); + if (!isSuccess.value) { + openDialogNetworkError(); + } + }, + }, + { + label: t('common.cancel'), + callback: (close) => close(), + }, + ], + title: t('dashboard.reviewAssignment.action.sendReviewToOrcid'), + message: t('dashboard.reviewAssignment.action.sendReviewToOrcid.confirm'), + }); + } + return { getTopActions, getItemActions, @@ -630,5 +687,6 @@ export function useReviewerManagerActions() { reviewerRevertConsider, reviewerSendReminder, reviewerLogResponse, + reviewerSendToOrcid, }; }