From e48c2f1790aac0d2b27ffcd006ac46f5bfc59944 Mon Sep 17 00:00:00 2001 From: Demetriad Sinzeanu <demetriad.sinzeanu@thinslices.com> Date: Tue, 13 Nov 2018 15:52:40 +0200 Subject: [PATCH] fix(authsome-helpers): In manuscript status 'HE Invited', the Author shouldn't see the HE name on da --- .../src/ManuscriptCard.js | 2 +- .../src/manuscriptDetails/ManuscriptHeader.js | 2 +- .../xpub-faraday/config/authsome-helpers.js | 26 ++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index 17e9e1763..252281852 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -76,7 +76,7 @@ const ManuscriptCard = ({ <Row alignItems="center" justify="flex-start" mb={1}> <H4>Handling editor</H4> <Text ml={1} mr={3} whiteSpace="nowrap"> - {get(handlingEditor, 'name', 'Unassigned')} + {get(handlingEditor, 'name', 'Assigned')} </Text> {canViewReports && ( <Fragment> diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js index f93e6c4c3..699edec06 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js @@ -170,7 +170,7 @@ export default compose( </Button> ) } - return <Text ml={1}>Unassigned</Text> + return <Text ml={1}>Assigned</Text> }, }), setDisplayName('ManuscriptHeader'), diff --git a/packages/xpub-faraday/config/authsome-helpers.js b/packages/xpub-faraday/config/authsome-helpers.js index c43c00d91..81f646632 100644 --- a/packages/xpub-faraday/config/authsome-helpers.js +++ b/packages/xpub-faraday/config/authsome-helpers.js @@ -4,6 +4,8 @@ const { omit, get, last, chain } = require('lodash') const statuses = config.get('statuses') +const keysToOmit = [`email`, `id`] +const authorCannotViewHENameStatuses = ['heInvited'] const authorAllowedStatuses = ['revisionRequested', 'rejected', 'accepted'] const getTeamsByPermissions = async ( @@ -70,6 +72,23 @@ const filterAuthorRecommendations = (recommendations, status, isLast) => { return [] } +const stripeCollectionByRole = ({ collection = {}, role = '' }) => { + if (role === 'author') { + const { handlingEditor } = collection + + if (authorCannotViewHENameStatuses.includes(collection.status)) { + return { + ...collection, + handlingEditor: handlingEditor && + handlingEditor.isAccepted && { + ...omit(handlingEditor, keysToOmit), + name: 'Assigned', + }, + } + } + } + return collection +} const stripeFragmentByRole = ({ fragment = {}, role = '', @@ -176,8 +195,13 @@ const getCollections = async ({ user, models }) => { collection, FragmentModel: models.Fragment, }) + const stripedColl = stripeCollectionByRole({ + collection, + role: up.role, + }) + return { - ...collection, + ...stripedColl, ...parsedStatuses, } }), -- GitLab