diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index 925aac7a881fce50bf971f765a560042755bf468..e75abcec1deab9f87fd1ae35785c958def01c26c 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -60,6 +60,22 @@ export const canViewReviewersDetails = (state, collection = {}) => { return canViewReports(state, collection.id) } +const canAuthorViewEditorialCommentsStatuses = [ + 'accepted', + 'rejected', + 'revisionRequested', +] + +export const canAuthorViewEditorialComments = (state, collection = {}, id) => { + const isAuthor = currentUserIsAuthor(state, id) + return ( + isAuthor && + canAuthorViewEditorialCommentsStatuses.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 f3bfdbb744fc13812e5afdf256cfd53c34584276..0fbbeee6231482ce23988f5b7ece978a4aa3c91b 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -102,7 +102,7 @@ const ManuscriptLayout = ({ getSignedUrl={getSignedUrl} /> - {get(currentUser, 'permissions.canViewReports', true) && + {get(currentUser, 'permissions.canAuthorViewEditorialComments', true) && !!editorialRecommendations.length && ( <EditorialCommentCard journal={journal} diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index af451b26a93a5d81891cb85f584e108fb404ac36..49a5ad9850038211b5d8003018eb48d5ee2bb8c1 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -53,6 +53,7 @@ import { canOverrideTechnicalChecks, getOwnPendingRecommendation, getOwnSubmittedRecommendation, + canAuthorViewEditorialComments, getFragmentReviewerRecommendations, getInvitationsWithReviewersForFragment, } from 'pubsweet-component-faraday-selectors' @@ -173,6 +174,11 @@ export default compose( canEditManuscript: canEditManuscript(state, collection, fragment), canViewReviewersDetails: canViewReviewersDetails(state, collection), canOverrideTechChecks: canOverrideTechnicalChecks(state, collection), + canAuthorViewEditorialComments: canAuthorViewEditorialComments( + state, + collection, + match.params.version, + ), }, }, isFetching: {