From f146319bc285afcc47b1232fc15856ad4cf7c4b1 Mon Sep 17 00:00:00 2001 From: Bogdan Cochior <bogdan.cochior@thinslices.com> Date: Thu, 9 Aug 2018 15:55:44 +0300 Subject: [PATCH] fix(he-recommendation): hide publish if no reviews --- packages/component-faraday-selectors/src/index.js | 6 +++++- .../component-manuscript/src/components/SideBarActions.js | 1 + .../src/components/Dashboard/DashboardCard.js | 1 - .../src/components/MakeRecommendation/RecommendWizard.js | 8 ++++++-- .../src/components/MakeRecommendation/StepOne.js | 5 +++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index 6508a91a4..82d6b27ce 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -7,7 +7,11 @@ export const isHEToManuscript = (state, collectionId) => { return get(collection, 'handlingEditor.id') === currentUserId } -const canMakeRecommendationStatuses = ['reviewCompleted', 'heAssigned'] +const canMakeRecommendationStatuses = [ + 'reviewCompleted', + 'heAssigned', + 'underReview', +] export const canMakeRecommendation = (state, collection, fragment = {}) => { if (fragment.id !== last(collection.fragments)) return false const isHE = isHEToManuscript(state, collection.id) diff --git a/packages/component-manuscript/src/components/SideBarActions.js b/packages/component-manuscript/src/components/SideBarActions.js index dbfc3d7cd..4ab282feb 100644 --- a/packages/component-manuscript/src/components/SideBarActions.js +++ b/packages/component-manuscript/src/components/SideBarActions.js @@ -40,6 +40,7 @@ const SideBarActions = ({ collectionId={project.id} fragmentId={version.id} modalKey={`decide-${version.id}`} + status={project.status} /> )} diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index 044a3a21e..d0b8f03d4 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -74,7 +74,6 @@ const DashboardCard = ({ collectionId={project.id} fragmentId={version.id} modalKey={`recommend-${version.id}`} - status={project.status} /> )} <ZipFiles diff --git a/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js b/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js index fb7452baf..6ad740fde 100644 --- a/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js +++ b/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js @@ -9,7 +9,10 @@ import { getFormValues, reset as resetForm } from 'redux-form' import { FormItems } from '../UIComponents' import { StepOne, StepTwo, utils } from './' -import { createRecommendation } from '../../redux/recommendations' +import { + createRecommendation, + selectReviewRecommendations, +} from '../../redux/recommendations' const RecommendWizard = ({ step, @@ -40,8 +43,9 @@ const RecommendWizard = ({ export default compose( connect( - state => ({ + (state, { fragmentId }) => ({ decision: get(getFormValues('recommendation')(state), 'decision'), + reviews: selectReviewRecommendations(state, fragmentId), }), { resetForm, diff --git a/packages/components-faraday/src/components/MakeRecommendation/StepOne.js b/packages/components-faraday/src/components/MakeRecommendation/StepOne.js index b6723f9ff..1cb644c27 100644 --- a/packages/components-faraday/src/components/MakeRecommendation/StepOne.js +++ b/packages/components-faraday/src/components/MakeRecommendation/StepOne.js @@ -1,5 +1,6 @@ import React from 'react' import { reduxForm } from 'redux-form' +import { isEmpty } from 'lodash' import { RadioGroup, ValidatedField, Button } from '@pubsweet/ui' import { utils } from './' @@ -7,7 +8,7 @@ import { FormItems } from '../UIComponents' const { Row, Title, RowItem, RootContainer, CustomRadioGroup } = FormItems -const StepOne = ({ hideModal, disabled, onSubmit, status }) => ( +const StepOne = ({ hideModal, disabled, onSubmit, reviews }) => ( <RootContainer> <Title>Recommendation for Next Phase</Title> <Row> @@ -21,7 +22,7 @@ const StepOne = ({ hideModal, disabled, onSubmit, status }) => ( <RadioGroup name="decision" options={ - status === 'reviewCompleted' + !isEmpty(reviews) ? utils.recommendationOptions : utils.recommendationOptions.slice(1) } -- GitLab