From d1f3f45995a937edc778a6d3c11a46d04ec6bfc1 Mon Sep 17 00:00:00 2001 From: Iosif Boanca <iosif.boanca@thinslices.com> Date: Tue, 6 Nov 2018 16:13:57 +0200 Subject: [PATCH] fix(Only authors can see Reviewer Reports): Only authors can see Reviewer Reports --- packages/component-faraday-selectors/src/index.js | 15 ++++++--------- .../src/components/ReviewsAndReports.js | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index 0ab630ff6..c948890e6 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -79,7 +79,7 @@ export const authorCanViewReportsDetails = ( collection = {}, fragmentId, ) => { - const isAuthor = currentUserIsAuthor(state, fragmentId) + const isAuthor = currentUserIsAuthor(state) return ( authorCanViewReportsDetailsStatuses.includes( get(collection, 'status', 'draft'), @@ -152,7 +152,7 @@ export const canAuthorViewEditorialComments = ( collection = {}, fragmentId, ) => { - const isAuthor = currentUserIsAuthor(state, fragmentId) + const isAuthor = currentUserIsAuthor(state) return ( isAuthor && !cannotAuthorViewEditorialCommentsStatuses.includes( @@ -245,13 +245,10 @@ export const canMakeRevision = (state, collection = {}, fragment = {}) => { ) } -export const currentUserIsAuthor = (state, id) => { - const permissions = getUserPermissions(state) - - return permissions - .filter(f => f.role === 'author') - .map(p => p.objectId) - .includes(id) +export const currentUserIsAuthor = state => { + const authors = state.collections[0].owners.map(e => e.id) + const user = state.currentUser.user.id + return authors.includes(user) } export const getUserPermissions = ({ teams = [] }) => diff --git a/packages/component-manuscript/src/components/ReviewsAndReports.js b/packages/component-manuscript/src/components/ReviewsAndReports.js index d2efda6e7..37019432c 100644 --- a/packages/component-manuscript/src/components/ReviewsAndReports.js +++ b/packages/component-manuscript/src/components/ReviewsAndReports.js @@ -106,7 +106,7 @@ export default compose( reviewers: selectReviewers(state), fetchingReviewers: selectFetchingReviewers(state), isReviewer: currentUserIsReviewer(state, version.id), - isAuthor: currentUserIsAuthor(state, version.id), + isAuthor: currentUserIsAuthor(state), recommendations: selectReviewRecommendations(state, version.id), canViewReports: canViewReports(state, project.id), }), -- GitLab