Skip to content
Snippets Groups Projects
Commit c12ab558 authored by Anca Ursachi's avatar Anca Ursachi
Browse files

Merge branch 'hin-946' of gitlab.coko.foundation:xpub/xpub-faraday into hin-946

parents 25bb31b7 ba921a40
No related branches found
No related tags found
2 merge requests!110Sprint 21 Features,!92Hin 946
import React from 'react'
import { get } from 'lodash'
import { compose } from 'recompose'
import { get, last } from 'lodash'
import { compose, withProps } from 'recompose'
import styled from 'styled-components'
import { reduxForm } from 'redux-form'
import { th } from '@pubsweet/ui-toolkit'
......@@ -19,12 +19,34 @@ import {
withFetching,
} from '../'
const eicDecisions = [
{
value: 'return-to-handling-editor',
label: 'Return to Handling Editor',
modalTitle: 'Return Manuscript',
modalSubtitle:
'A returning manuscript to Handling Editor decision is final',
},
{
value: 'publish',
label: 'Publish',
modalTitle: 'Publish Manuscript',
modalSubtitle: 'A publish decision is final',
},
{
value: 'reject',
label: 'Reject',
modalTitle: 'Reject Manuscript',
modalSubtitle: 'A rejection decision is final',
},
]
const ManuscriptEicDecision = ({
isFetching,
formValues,
handleSubmit,
messagesLabel,
options = [],
collection = {},
...rest
}) => (
<ContextualBox label="Your Editorial Decision" {...rest}>
......@@ -33,7 +55,16 @@ const ManuscriptEicDecision = ({
<ItemOverrideAlert flex={0} vertical>
<Label required>Decision</Label>
<ValidatedField
component={input => <Menu {...input} options={options} />}
component={input => (
<Menu
{...input}
options={
get(collection, 'status', 'submitted') === 'submitted'
? [last(eicDecisions)]
: eicDecisions
}
/>
)}
name="decision"
validate={[required]}
/>
......@@ -71,15 +102,32 @@ export default compose(
modalKey: 'eic-decision',
modalComponent: MultiAction,
})),
withProps(({ formValues }) => ({
modalTitle: eicDecisions.find(
o => o.value === get(formValues, 'decision', 'publish'),
).modalTitle,
modalSubtitle: eicDecisions.find(
o => o.value === get(formValues, 'decision', 'publish'),
).modalSubtitle,
})),
reduxForm({
form: 'eic-decision',
onSubmit: (
values,
dispatch,
{ submitDecision, showModal, setFetching },
{
submitDecision,
showModal,
setFetching,
modalTitle,
confirmMessage,
modalSubtitle,
},
) => {
showModal({
title: 'Are you sure you want to submit this decision?',
title: `${modalTitle}?`,
confirmText: modalTitle,
subtitle: modalSubtitle,
onConfirm: modalProps => {
submitDecision(values, { ...modalProps, setFetching })
},
......
......@@ -20,7 +20,11 @@ const MultiAction = ({
<Root>
<IconButton icon="x" onClick={onClose} right={5} secondary top={5} />
<H2>{title}</H2>
{subtitle && <Text secondary>{subtitle}</Text>}
{subtitle && (
<Text mb={1} secondary>
{subtitle}
</Text>
)}
{renderContent()}
{modalError && (
<Text error mt={1}>
......
......@@ -60,7 +60,11 @@ module.exports = {
// the EiC recommends to publish so an email to the EQA needs to be sent,
// one requesting approval or one informing them that the manuscript has been published
if (isEditorInChief && recommendation === 'publish') {
if (
isEditorInChief &&
recommendation === 'publish' &&
collection.technicalChecks.token
) {
sendEQAEmail({
email,
eicName,
......@@ -77,7 +81,6 @@ module.exports = {
// send HE emails when a review is submitted
// or when the EiC makes a recommendation after peer review
if (
recommendationType === 'review' ||
(isEditorInChief &&
......
const config = require('config')
const { get } = require('lodash')
const Email = require('@pubsweet/component-email-templating')
const {
......@@ -9,12 +8,10 @@ const {
} = require('pubsweet-component-helper-service')
const { getEmailCopy } = require('./emailCopy')
const unsubscribeSlug = config.get('unsubscribe.url')
const { name: journalName, staffEmail } = config.get('journal')
module.exports = {
async sendNotifications({
isEQA,
agree,
baseUrl,
collection,
......@@ -28,10 +25,7 @@ module.exports = {
handlingEditor: collection.handlingEditor,
})
const {
activeAuthors: authors,
submittingAuthor,
} = await fragmentHelper.getAuthorData({
const { submittingAuthor } = await fragmentHelper.getAuthorData({
UserModel,
})
......@@ -60,42 +54,14 @@ module.exports = {
},
})
if (agree && isEQA) {
email.content.signatureName = await userHelper.getEiCName()
sendHandlingEditorEmail({
email,
baseUrl,
titleText,
subjectBaseText,
handlingEditor: get(collection, 'handlingEditor', {}),
})
sendSubmittedReviewersEmail({
email,
baseUrl,
titleText,
UserModel,
fragmentHelper,
subjectBaseText,
})
sendAuthorsEmail({
email,
baseUrl,
titleText,
subjectBaseText,
fragmentAuthors: authors,
})
} else {
sendEditorsEmail({
email,
agree,
customId,
comments,
titleText,
userHelper,
})
}
sendEditorsEmail({
email,
agree,
customId,
comments,
titleText,
userHelper,
})
},
}
......@@ -137,113 +103,3 @@ const sendEditorsEmail = async ({
email.sendEmail({ html, text })
})
}
const sendHandlingEditorEmail = ({
email,
baseUrl,
titleText,
handlingEditor,
subjectBaseText,
}) => {
email.content.subject = `${subjectBaseText} Decision`
const emailType = 'he-manuscript-published'
email.toUser = {
email: handlingEditor.email,
name: handlingEditor.name,
}
email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, {
id: handlingEditor.id,
})
const { html, text } = email.getNotificationBody({
emailBodyProps: getEmailCopy({
emailType,
titleText,
}),
})
email.sendEmail({ html, text })
}
const sendSubmittedReviewersEmail = async ({
email,
baseUrl,
titleText,
UserModel,
fragmentHelper,
subjectBaseText,
}) => {
email.content.subject = `${subjectBaseText} Decision`
const reviewers = (await fragmentHelper.getReviewers({
UserModel,
type: 'submitted',
})).map(rev => ({
...rev,
...getEmailCopy({
emailType: 'submitted-reviewers-after-publish',
titleText,
}),
}))
reviewers.forEach(reviewer => {
email.toUser = {
email: reviewer.email,
name: `${reviewer.firstName} ${reviewer.lastName}`,
}
email.content.unsubscribeLink = services.createUrl(
baseUrl,
unsubscribeSlug,
{
id: reviewer.id,
},
)
const { html, text } = email.getNotificationBody({
emailBodyProps: {
paragraph: reviewer.paragraph,
hasLink: reviewer.hasLink,
},
})
email.sendEmail({ html, text })
})
}
const sendAuthorsEmail = ({
email,
baseUrl,
titleText,
subjectBaseText,
fragmentAuthors,
}) => {
const emailType = 'author-manuscript-published'
email.content.subject = `${subjectBaseText} Published`
const authors = fragmentAuthors.map(author => ({
...author,
...getEmailCopy({
emailType,
titleText,
}),
}))
authors.forEach(author => {
email.toUser = {
email: author.email,
name: `${author.firstName} ${author.lastName}`,
}
email.content.unsubscribeLink = services.createUrl(
baseUrl,
unsubscribeSlug,
{
id: author.id,
},
)
const { html, text } = email.getNotificationBody({
emailBodyProps: {
paragraph: author.paragraph,
hasLink: author.hasLink,
},
})
email.sendEmail({ html, text })
})
}
const { get, find, isEmpty } = require('lodash')
const { get, find, isEmpty, has, last } = require('lodash')
const { services } = require('pubsweet-component-helper-service')
const { sendNotifications } = require('./notifications/notifications')
const {
sendNotifications: sendEQSNotifications,
} = require('./notifications/notifications')
const {
sendNotifications: sendEQANotifications,
} = require('../fragmentsRecommendations/notifications/notifications')
const TECHNICAL_STEPS = {
EQS: 'eqs',
......@@ -64,15 +70,33 @@ module.exports = ({ Collection, Fragment, User }) => async (req, res) => {
collection.status = setNewStatus(step, agree)
await collection.save()
sendNotifications({
User,
agree,
comments,
Fragment,
collection,
baseUrl: services.getBaseUrl(req),
isEQA: step === TECHNICAL_STEPS.EQA,
})
const isEQA = get(collection, 'technicalChecks.eqa', false)
const baseUrl = services.getBaseUrl(req)
if (isEQA) {
const fragment = await Fragment.find(last(collection.fragments))
sendEQANotifications({
baseUrl,
fragment,
collection,
hasEQA: true,
UserModel: User,
isEditorInChief: true,
newRecommendation: {
recommendation: 'publish',
recommendationType: 'editorRecommendation',
},
})
} else {
sendEQSNotifications({
User,
agree,
comments,
Fragment,
collection,
baseUrl,
})
}
return res.status(200).json(collection)
} catch (e) {
......
import React, { Fragment } from 'react'
import styled from 'styled-components'
import { isEmpty, get, last } from 'lodash'
import { isEmpty, get } from 'lodash'
import {
Text,
paddingHelper,
......@@ -18,12 +18,6 @@ import ReviewerReportCard from './ReviewReportCard'
import ReviewerReportForm from './ReviewerReportForm'
import EditorialCommentCard from './EditorialCommentCard'
const eicDecisions = [
{ value: 'return-to-handling-editor', label: 'Return to Handling Editor' },
{ value: 'publish', label: 'Publish' },
{ value: 'reject', label: 'Reject' },
]
const messagesLabel = {
'return-to-handling-editor': 'Comments for Handling Editor',
reject: 'Comments for Author',
......@@ -198,15 +192,11 @@ const ManuscriptLayout = ({
{get(currentUser, 'permissions.canMakeDecision', false) && (
<ManuscriptEicDecision
collection={collection}
formValues={get(formValues, 'eicDecision')}
highlight={editorialRecommendations.length > 0}
messagesLabel={messagesLabel}
mt={2}
options={
get(collection, 'status', 'submitted') === 'submitted'
? [last(eicDecisions)]
: eicDecisions
}
submitDecision={createRecommendation}
/>
)}
......
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