diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index ef77e0937c4e71e96be9bcb8b4cfe56c4d3fa819..d95754c77024be19ff6932b5075a49a21d79e768 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -1,5 +1,5 @@ import { selectCurrentUser } from 'xpub-selectors' -import { get, has, last, chain, some } from 'lodash' +import { get, has, last, chain, some, isEmpty } from 'lodash' export const isHEToManuscript = (state, collectionId = '') => { const { id = '', isAccepted = false } = chain(state) @@ -181,6 +181,20 @@ export const canViewEditorialComments = ( ) } +const cannotViewResponseFromAuthorStatuses = ['reviewersInvited'] +export const canViewResponseFromAuthor = (state, collection, fragmentId) => { + const authorResponseToRevisonRequest = getFragmentAuthorResponse( + state, + fragmentId, + ) + return ( + !isEmpty(authorResponseToRevisonRequest) && + !cannotViewResponseFromAuthorStatuses.includes( + get(collection, 'status', 'draft'), + ) + ) +} + export const getUserToken = ({ currentUser }) => get(currentUser, 'user.token', '') diff --git a/packages/component-manuscript/src/components/ManuscriptLayout.js b/packages/component-manuscript/src/components/ManuscriptLayout.js index b328d774aada05a389071f6d477f18d1b849ab7d..f47d2b1db70a6490611df692ced8a250a9b598cf 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -137,7 +137,7 @@ const ManuscriptLayout = ({ /> )} - {get(authorResponseToRevisonRequest, 'content', false) && ( + {get(currentUser, 'permissions.canViewResponseFromAuthor', false) && ( <ResponseToRevisionRequest authorReply={get(authorResponseToRevisonRequest, 'content', '')} expanded={responseToRevisionRequest} diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index 685daeab9d5d245ca9caa4f966bebe64aab6adf7..030805e20e8baeb68ab9919f3cf34379c392ca51 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -40,6 +40,7 @@ import { isHEToManuscript, canSubmitRevision, canEditManuscript, + getVersionOptions, canInviteReviewers, pendingHEInvitation, currentUserIsReviewer, @@ -48,6 +49,7 @@ import { canViewReviewersDetails, canViewEditorialComments, pendingReviewerInvitation, + canViewResponseFromAuthor, getFragmentAuthorResponse, canOverrideTechnicalChecks, authorCanViewReportsDetails, @@ -56,7 +58,6 @@ import { canAuthorViewEditorialComments, getFragmentReviewerRecommendations, getInvitationsWithReviewersForFragment, - getVersionOptions, } from 'pubsweet-component-faraday-selectors' import { handleError, @@ -198,6 +199,11 @@ export default compose( collection, match.params.version, ), + canViewResponseFromAuthor: canViewResponseFromAuthor( + state, + collection, + match.params.version, + ), }, }, isFetchingData: {