From 73b8717c1eeca8dfb8f9bb14ae24d93107b2321b Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Fri, 28 Sep 2018 10:02:39 +0300 Subject: [PATCH] fix(reviewer-reports): only staff and he can see the reviewer reports breakdown --- .../src/ManuscriptCard.js | 3 ++- .../components/Dashboard/DashboardItems.js | 21 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index eb945229f..4c71c77f4 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -25,6 +25,7 @@ const ManuscriptCard = ({ onDelete, canDelete, onCardClick, + canSeeReviewersReports, fragment = {}, manuscriptType = {}, collection: { visibleStatus = 'Draft', handlingEditor, customId, id: collId }, @@ -76,7 +77,7 @@ const ManuscriptCard = ({ <Text ml={1} mr={3} whiteSpace="nowrap"> {get(handlingEditor, 'name', 'Unassigned')} </Text> - {handlingEditor && ( + {canSeeReviewersReports && ( <Fragment> <Label mr={1}>Reviewers Reports</Label> <ReviewerBreakdown fragment={fragment} label="Reviewer Reports" /> diff --git a/packages/components-faraday/src/components/Dashboard/DashboardItems.js b/packages/components-faraday/src/components/Dashboard/DashboardItems.js index c97ff0b1f..aad166bb2 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardItems.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardItems.js @@ -1,17 +1,32 @@ import React from 'react' import { H3 } from '@pubsweet/ui' import { get, has } from 'lodash' +import { connect } from 'react-redux' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { withRouter } from 'react-router-dom' -import { ManuscriptCard, Row } from 'pubsweet-component-faraday-ui' import { compose, setDisplayName, withHandlers } from 'recompose' +import { ManuscriptCard, Row } from 'pubsweet-component-faraday-ui' +import { canSeeReviewersReports } from 'pubsweet-component-faraday-selectors' import withVersion from './withVersion' -const DashboardItem = withVersion(ManuscriptCard) +const DashboardItem = compose( + withVersion, + connect((state, { collection }) => ({ + canSeeReviewersReports: canSeeReviewersReports( + state, + get(collection, 'id', ''), + ), + })), +)(ManuscriptCard) -const DashboardItems = ({ onClick, list, deleteProject }) => ( +const DashboardItems = ({ + list, + onClick, + deleteProject, + canSeeReviewersReports, +}) => ( <Root> {!list.length ? ( <Row justify="center" mt={4}> -- GitLab