diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index efeb000e0dedeafcf3483df439aa5db903974977..b693fa6162726c6c61163f57ad04cd7d305f7151 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 6d08c78bb1b32a5c536ab1b63b3a1807ab241799..900ae71b91f2b27e458743d642377e8e74119140 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..7ef6a11644a3e312b2a0de0da6d97f7f97f7aa0f 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,7 +49,7 @@ import { canViewReviewersDetails, canViewEditorialComments, pendingReviewerInvitation, - getFragmentAuthorResponse, + canViewResponseFromAuthor, canOverrideTechnicalChecks, authorCanViewReportsDetails, getOwnPendingRecommendation, @@ -56,7 +57,6 @@ import { canAuthorViewEditorialComments, getFragmentReviewerRecommendations, getInvitationsWithReviewersForFragment, - getVersionOptions, } from 'pubsweet-component-faraday-selectors' import { handleError, @@ -129,10 +129,6 @@ export default compose( state, match.params.version, ), - authorResponseToRevisonRequest: getFragmentAuthorResponse( - state, - match.params.version, - ), }), { changeForm, @@ -198,6 +194,11 @@ export default compose( collection, match.params.version, ), + canViewResponseFromAuthor: canViewResponseFromAuthor( + state, + collection, + match.params.version, + ), }, }, isFetchingData: {