diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index c5ce6d09d54c048e5024a4b27a7fe69bb13ba12d..ea5790b14676bae5f84abc8be5f230fb9677c4fa 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -7,10 +7,12 @@ export const isHEToManuscript = (state, collectionId) => { return get(collection, 'handlingEditor.id') === currentUserId } +const canMakeRecommendationStatuses = ['reviewCompleted', 'heAssigned'] export const canMakeRecommendation = (state, collection, fragment = {}) => { if (fragment.id !== last(collection.fragments)) return false const isHE = isHEToManuscript(state, collection.id) - return isHE && get(collection, 'status') === 'reviewCompleted' + const status = get(collection, 'status') + return isHE && canMakeRecommendationStatuses.includes(status) } export const currentUserIs = ({ currentUser: { user } }, role) => { diff --git a/packages/component-manuscript/src/components/SubmitRevision.js b/packages/component-manuscript/src/components/SubmitRevision.js index a962668fb2bbb1537795e8057505a23526e109ad..afaf7697ebebc111d39a773e01ccf69e594c5e48 100644 --- a/packages/component-manuscript/src/components/SubmitRevision.js +++ b/packages/component-manuscript/src/components/SubmitRevision.js @@ -24,6 +24,7 @@ import { import { AuthorList, Files } from 'pubsweet-components-faraday/src/components' import { submitRevision } from 'pubsweet-component-wizard/src/redux/conversion' import AutosaveIndicator from 'pubsweet-component-wizard/src/components/AutosaveIndicator' +import { selectReviewRecommendations } from 'pubsweet-components-faraday/src/redux/recommendations' import { toClass, compose, @@ -60,6 +61,7 @@ const SubmitRevision = ({ removeFile, handleSubmit, responseFiles, + reviews = [], submitFailed, }) => ( <Root> @@ -108,39 +110,41 @@ const SubmitRevision = ({ /> </CustomValidatedField> </Expandable> - <Expandable label="RESPONSE TO REVIEWER COMMENTS" startExpanded> - <Title>Reply text*</Title> - <Row> - <FullWidth className="full-width"> - <ValidatedField - component={TextAreaField} - name="commentsToReviewers" - validate={ - isEmpty(get(formValues, 'files.responseToReviewers')) - ? [required] - : [] - } - /> - </FullWidth> - </Row> - <Row left> - {responseFiles.map(file => ( - <FileItem - compact - id={file.id} - key={file.id} - {...file} - removeFile={removeFile} - /> - ))} - </Row> - <FilePicker - allowedFileExtensions={['pdf', 'doc', 'docx']} - onUpload={addFile} - > - <ActionText left={12}>Upload file</ActionText> - </FilePicker> - </Expandable> + {!isEmpty(reviews) && ( + <Expandable label="RESPONSE TO REVIEWER COMMENTS" startExpanded> + <Title>Reply text*</Title> + <Row> + <FullWidth className="full-width"> + <ValidatedField + component={TextAreaField} + name="commentsToReviewers" + validate={ + isEmpty(get(formValues, 'files.responseToReviewers')) + ? [required] + : [] + } + /> + </FullWidth> + </Row> + <Row left> + {responseFiles.map(file => ( + <FileItem + compact + id={file.id} + key={file.id} + {...file} + removeFile={removeFile} + /> + ))} + </Row> + <FilePicker + allowedFileExtensions={['pdf', 'doc', 'docx']} + onUpload={addFile} + > + <ActionText left={12}>Upload file</ActionText> + </FilePicker> + </Expandable> + )} <SubmitContainer> {submitFailed && formError && <Error>There are some errors above.</Error>} @@ -169,8 +173,9 @@ export default compose( modalComponent: ConfirmationModal, })), connect( - state => ({ + (state, { version }) => ({ fileFetching: getRequestStatus(state), + reviews: selectReviewRecommendations(state, version.id), formValues: getFormValues('revision')(state), formError: getFormSyncErrors('revision')(state), }), diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index d0b8f03d47f45aa1f8a155754152933b970757a5..044a3a21e91903f72a444097b665d116eac4aff2 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -74,6 +74,7 @@ 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/Recommendation.js b/packages/components-faraday/src/components/MakeRecommendation/Recommendation.js index 10d7fc6d98a6a1f1ce932aa5b6622015eee59530..dff35cbd4f9388814ac47cb005a418462845e9a5 100644 --- a/packages/components-faraday/src/components/MakeRecommendation/Recommendation.js +++ b/packages/components-faraday/src/components/MakeRecommendation/Recommendation.js @@ -30,12 +30,14 @@ export default compose( })), withHandlers({ showFirstStep: ({ + status, showModal, hideModal, fragmentId, collectionId, }) => () => { showModal({ + status, hideModal, fragmentId, collectionId, diff --git a/packages/components-faraday/src/components/MakeRecommendation/StepOne.js b/packages/components-faraday/src/components/MakeRecommendation/StepOne.js index 6185a09a1677c060032875ce80ebf83c4e1139be..b6723f9ff0a70dd03fb30668d2e8db606247cd66 100644 --- a/packages/components-faraday/src/components/MakeRecommendation/StepOne.js +++ b/packages/components-faraday/src/components/MakeRecommendation/StepOne.js @@ -7,7 +7,7 @@ import { FormItems } from '../UIComponents' const { Row, Title, RowItem, RootContainer, CustomRadioGroup } = FormItems -const StepOne = ({ hideModal, disabled, onSubmit }) => ( +const StepOne = ({ hideModal, disabled, onSubmit, status }) => ( <RootContainer> <Title>Recommendation for Next Phase</Title> <Row> @@ -20,7 +20,11 @@ const StepOne = ({ hideModal, disabled, onSubmit }) => ( > <RadioGroup name="decision" - options={utils.recommendationOptions} + options={ + status === 'reviewCompleted' + ? utils.recommendationOptions + : utils.recommendationOptions.slice(1) + } {...input} /> </CustomRadioGroup> diff --git a/packages/components-faraday/src/components/MakeRecommendation/utils.js b/packages/components-faraday/src/components/MakeRecommendation/utils.js index 2884cdb904717cfdd4958cc99accf9f852adc489..69e5b63f12e4b979dba34332a98fa8bec20eed17 100644 --- a/packages/components-faraday/src/components/MakeRecommendation/utils.js +++ b/packages/components-faraday/src/components/MakeRecommendation/utils.js @@ -1,8 +1,8 @@ import { omit } from 'lodash' export const recommendationOptions = [ - { value: 'reject', label: 'Reject' }, { value: 'publish', label: 'Publish' }, + { value: 'reject', label: 'Reject' }, { value: 'revise', label: 'Request revision' }, ]