From 47c05f828f39baa31a37c206d98c831b5f5c3778 Mon Sep 17 00:00:00 2001 From: Iosif Boanca <iosif.boanca@thinslices.com> Date: Fri, 2 Nov 2018 14:57:12 +0200 Subject: [PATCH] feat(HE can reject anytime): He can reject at any time --- .../component-faraday-selectors/src/index.js | 3 ++- .../src/contextualBoxes/HERecommendation.js | 21 +++++++++++++++++-- .../src/components/ManuscriptLayout.js | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index df747afbd..3de59eeef 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -369,7 +369,7 @@ export const canMakeHERecommendation = (state, { collection, statuses }) => { 1, ) - if (!(statusImportance > 1 && statusImportance < 9)) return false + if (!(statusImportance > 1 && statusImportance < 10)) return false return true } @@ -385,6 +385,7 @@ export const getFragmentReviewerRecommendations = (state, fragmentId) => getFragmentRecommendations(state, fragmentId).filter( r => r.recommendationType === 'review', ) + const getFragmentEditorialComments = (state, fragmentId) => getFragmentRecommendations(state, fragmentId).filter( r => r.recommendationType === 'editorRecommendation', diff --git a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js index 877243b16..43e98348b 100644 --- a/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js +++ b/packages/component-faraday-ui/src/contextualBoxes/HERecommendation.js @@ -1,5 +1,5 @@ import React from 'react' -import { get, tail } from 'lodash' +import { get, tail, findKey } from 'lodash' import { reduxForm } from 'redux-form' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' @@ -46,6 +46,22 @@ const options = [ }, ] +const optionsWhereHECanOnlyReject = { + reviewersInvited: 'reviewersInvited', + underReview: 'underReview', + revisionRequested: 'revisionRequested', +} + +const showHEOptions = (collection, hasReviewerReports) => { + const { status, fragments } = collection + if (findKey(optionsWhereHECanOnlyReject, sts => sts === status)) { + return [options[1]] + } else if (hasReviewerReports || fragments.length) { + return options + } + return tail(options) +} + const parseFormValues = ({ recommendation, ...rest }) => { const comments = Object.entries(rest).map(([key, value]) => ({ content: value, @@ -65,6 +81,7 @@ const HERecommendation = ({ handleSubmit, hasReviewerReports, highlight, + collection, }) => ( <ContextualBox highlight={highlight} @@ -82,7 +99,7 @@ const HERecommendation = ({ <ValidatedField component={input => ( <Menu - options={hasReviewerReports ? options : tail(options)} + options={showHEOptions(collection, hasReviewerReports)} {...input} /> )} diff --git a/packages/component-manuscript/src/components/ManuscriptLayout.js b/packages/component-manuscript/src/components/ManuscriptLayout.js index 161ca3fb1..1c680f3a6 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -222,6 +222,7 @@ const ManuscriptLayout = ({ {isLatestVersion && get(currentUser, 'permissions.canMakeHERecommendation', false) && ( <HERecommendation + collection={collection} formValues={get(formValues, 'editorialRecommendation', {})} hasReviewerReports={reviewerRecommendations.length > 0} highlight={reviewerRecommendations.length > 0} -- GitLab