From a8c2a373e6e1ef33b35591741e3342e5820020a0 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Tue, 30 Oct 2018 11:38:34 +0200 Subject: [PATCH] feat(ReviewersTableVersions): Added checks for latest versions for reviewer table --- .../src/contextualBoxes/ReviewerDetails.js | 37 ++++++++++--------- .../src/components/ManuscriptLayout.js | 2 + .../src/components/ManuscriptPage.js | 16 +++++--- .../src/components/utils.js | 3 ++ 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js b/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js index efa929afe..ec5e14dd4 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js +++ b/packages/component-faraday-ui/src/contextualBoxes/ReviewerDetails.js @@ -40,6 +40,7 @@ const ReviewerDetails = ({ highlight, canViewReviewersDetails, authorCanViewReportsDetails, + isLatestVersion, ...rest }) => ( <ContextualBox @@ -62,17 +63,18 @@ const ReviewerDetails = ({ > <H4>Reviewer Details</H4> </TabButton> - {canInviteReviewers && ( - <TabButton - data-test-id="reviewer-tab-suggestions" - ml={1} - mr={1} - onClick={() => changeTab(2)} - selected={selectedTab === 2} - > - <H4>Reviewer Suggestions</H4> - </TabButton> - )} + {canInviteReviewers && + isLatestVersion && ( + <TabButton + data-test-id="reviewer-tab-suggestions" + ml={1} + mr={1} + onClick={() => changeTab(2)} + selected={selectedTab === 2} + > + <H4>Reviewer Suggestions</H4> + </TabButton> + )} <TabButton data-test-id="reviewer-tab-reports" ml={1} @@ -87,12 +89,13 @@ const ReviewerDetails = ({ <TabContent> {selectedTab === 0 && ( <Fragment> - {canInviteReviewers && ( - <InviteReviewers - modalKey="invite-reviewers" - onInvite={onInviteReviewer} - /> - )} + {canInviteReviewers && + isLatestVersion && ( + <InviteReviewers + modalKey="invite-reviewers" + onInvite={onInviteReviewer} + /> + )} <ReviewersTable invitations={invitations} diff --git a/packages/component-manuscript/src/components/ManuscriptLayout.js b/packages/component-manuscript/src/components/ManuscriptLayout.js index ab97d2960..93cfc502a 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -67,6 +67,7 @@ const ManuscriptLayout = ({ recommendationHandler, inviteHandlingEditor, versions, + isLatestVersion, }) => ( <Root pb={30}> {!isEmpty(collection) && !isEmpty(fragment) ? ( @@ -186,6 +187,7 @@ const ManuscriptLayout = ({ } invitations={invitationsWithReviewers} isFetching={isFetchingData.publonsFetching} + isLatestVersion={isLatestVersion} journal={journal} mb={2} publonReviewers={publonReviewers} diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index ab96f5c6b..5b902498b 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -72,6 +72,7 @@ import { redirectToError, parseSearchParams, getPublonsReviewers, + isLatestVersion, } from './utils' import { @@ -281,12 +282,15 @@ export default compose( toggleEditorialComments: toggle, editorialCommentsExpanded: expanded, })), - withProps(({ currentUser, collection, submittedOwnRecommendation }) => ({ - getSignedUrl, - shouldReview: - get(currentUser, 'isReviewer', false) && - isUndefined(submittedOwnRecommendation), - })), + withProps( + ({ currentUser, collection, submittedOwnRecommendation, fragment }) => ({ + getSignedUrl, + shouldReview: + get(currentUser, 'isReviewer', false) && + isUndefined(submittedOwnRecommendation), + isLatestVersion: isLatestVersion(collection, fragment), + }), + ), withInviteHandlingEditor, withInviteReviewer, withSubmitRevision, diff --git a/packages/component-manuscript/src/components/utils.js b/packages/component-manuscript/src/components/utils.js index e579d6836..5b8195f42 100644 --- a/packages/component-manuscript/src/components/utils.js +++ b/packages/component-manuscript/src/components/utils.js @@ -96,6 +96,9 @@ export const parseVersionOptions = (fragments = []) => })) .reverse() +export const isLatestVersion = (collection, fragment) => + collection.fragments.indexOf(fragment.id) === collection.fragments.length - 1 + const alreadyAnswered = `You have already answered this invitation.` export const redirectToError = redirectFn => err => { const errorText = get(JSON.parse(err.response), 'error') -- GitLab