Skip to content
Snippets Groups Projects
Commit 5c32f1b3 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'HIN-816' into 'develop'

feat(reject): show reject button on manuscript status submitted

See merge request !22
parents 09e377b2 acf62aa4
No related branches found
No related tags found
2 merge requests!34Sprint 17 features,!22feat(reject): show reject button on manuscript status submitted
...@@ -60,15 +60,13 @@ export const getHERecommendation = (state, collectionId, fragmentId) => { ...@@ -60,15 +60,13 @@ export const getHERecommendation = (state, collectionId, fragmentId) => {
) )
} }
const cantMakeDecisionStatuses = ['rejected', 'published', 'draft'] const canMakeDecisionStatuses = ['submitted', 'pendingApproval']
export const canMakeDecision = (state, collection, fragment = {}) => { export const canMakeDecision = (state, collection, fragment = {}) => {
if (fragment.id !== last(collection.fragments)) return false if (fragment.id !== last(collection.fragments)) return false
const status = get(collection, 'status') const status = get(collection, 'status')
if (!status || cantMakeDecisionStatuses.includes(status)) return false
const isEIC = currentUserIs(state, 'adminEiC') const isEIC = currentUserIs(state, 'adminEiC')
return isEIC && status return isEIC && canMakeDecisionStatuses.includes(status)
} }
export const canSeeReviewersReports = (state, collectionId) => { export const canSeeReviewersReports = (state, collectionId) => {
......
...@@ -64,8 +64,10 @@ module.exports = { ...@@ -64,8 +64,10 @@ module.exports = {
comments = eicComments comments = eicComments
} }
if (
if (isEditorInChief || newRecommendation.recommendationType === 'review') { (isEditorInChief || newRecommendation.recommendationType === 'review') &&
collection.status !== 'rejected'
) {
// the request came from either the Editor in Chief or a reviewer, so the HE needs to be notified // the request came from either the Editor in Chief or a reviewer, so the HE needs to be notified
sendHandlingEditorEmail({ sendHandlingEditorEmail({
email, email,
...@@ -95,28 +97,29 @@ module.exports = { ...@@ -95,28 +97,29 @@ module.exports = {
subjectBaseText, subjectBaseText,
newRecommendation, newRecommendation,
}) })
if (collection.status !== 'rejected') {
sendReviewersEmail({
email,
baseUrl,
UserModel,
titleText,
fragmentHelper,
isEditorInChief,
subjectBaseText,
recommendation: newRecommendation.recommendation,
handlingEditorName: get(collection, 'handlingEditor.name', 'N/A'),
})
sendReviewersEmail({ sendEiCEmail({
email, email,
baseUrl, baseUrl,
UserModel, eicName,
titleText, eicEmail,
fragmentHelper, titleText,
isEditorInChief, subjectBaseText,
subjectBaseText, recommendation: newRecommendation,
recommendation: newRecommendation.recommendation, })
handlingEditorName: get(collection, 'handlingEditor.name', 'N/A'), }
})
sendEiCEmail({
email,
baseUrl,
eicName,
eicEmail,
titleText,
subjectBaseText,
recommendation: newRecommendation,
})
} }
}, },
} }
......
...@@ -66,6 +66,7 @@ const DashboardCard = ({ ...@@ -66,6 +66,7 @@ const DashboardCard = ({
collectionId={project.id} collectionId={project.id}
fragmentId={version.id} fragmentId={version.id}
modalKey={`decide-${version.id}`} modalKey={`decide-${version.id}`}
status={project.status}
/> />
)} )}
{canMakeRecommendation && ( {canMakeRecommendation && (
......
import React from 'react' import React from 'react'
import { th } from '@pubsweet/ui' import { th } from '@pubsweet/ui'
import { connect } from 'react-redux'
import styled from 'styled-components' import styled from 'styled-components'
import { compose, withHandlers, setDisplayName } from 'recompose' import { actions } from 'pubsweet-client'
import { compose, withHandlers, setDisplayName, withProps } from 'recompose'
import { import {
ConfirmationModal, ConfirmationModal,
withModal, withModal,
} from 'pubsweet-component-modal/src/components' } from 'pubsweet-component-modal/src/components'
import { handleError } from '../utils'
import { createRecommendation } from '../../redux/recommendations'
import { DecisionForm } from './' import { DecisionForm } from './'
const Decision = ({ showDecisionModal }) => ( const Decision = ({ showDecisionModal, buttonText }) => (
<Root onClick={showDecisionModal}>Make decision</Root> <Root onClick={showDecisionModal}>{buttonText}</Root>
) )
const ModalComponent = ({ type, ...rest }) => { const ModalComponent = ({ type, ...rest }) => {
...@@ -28,19 +32,55 @@ export default compose( ...@@ -28,19 +32,55 @@ export default compose(
withModal(() => ({ withModal(() => ({
modalComponent: ModalComponent, modalComponent: ModalComponent,
})), })),
connect(null, {
createRecommendation,
getFragments: actions.getFragments,
getCollections: actions.getCollections,
}),
withProps(({ status }) => ({
buttonText: status === 'submitted' ? 'Reject' : 'Make Decision',
})),
withHandlers({ withHandlers({
showDecisionModal: ({ showDecisionModal: ({
status,
showModal, showModal,
hideModal, hideModal,
fragmentId, fragmentId,
collectionId, collectionId,
getFragments,
setModalError,
getCollections,
createRecommendation,
}) => () => { }) => () => {
showModal({ status !== 'submitted'
type: 'decision', ? showModal({
hideModal, type: 'decision',
fragmentId, hideModal,
collectionId, fragmentId,
}) collectionId,
})
: showModal({
hideModal,
fragmentId,
collectionId,
title: 'Reject Manuscript?',
confirmText: 'Reject',
onConfirm: () => {
const recommendation = {
recommendation: 'reject',
recommendationType: 'editorRecommendation',
}
createRecommendation(
collectionId,
fragmentId,
recommendation,
).then(() => {
getCollections()
getFragments()
hideModal()
}, handleError(setModalError))
},
})
}, },
}), }),
)(Decision) )(Decision)
......
...@@ -27,7 +27,6 @@ const { ...@@ -27,7 +27,6 @@ const {
const Form = RootContainer.withComponent(FormContainer) const Form = RootContainer.withComponent(FormContainer)
const DecisionForm = ({ const DecisionForm = ({
aHERec,
decision, decision,
hideModal, hideModal,
handleSubmit, handleSubmit,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment