From 843a9dd400eff8859ea0df75fb1118123dd297c0 Mon Sep 17 00:00:00 2001 From: Tania Fecheta <tania.fecheta@thinslices.com> Date: Tue, 16 Oct 2018 15:07:49 +0300 Subject: [PATCH] feat(authorCanSeeEditorialComments): create selector for author to see editorial comments --- .../component-faraday-selectors/src/index.js | 16 ++++++++++++++++ .../src/components/ManuscriptLayout.js | 2 +- .../src/components/ManuscriptPage.js | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index 925aac7a8..e75abcec1 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 f3bfdbb74..0fbbeee62 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 af451b26a..49a5ad985 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: { -- GitLab