diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index 6508a91a4921237406bd5b9e386e167f1e608977..82d6b27cecc05dff19ac1f018acf05305e125fde 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-helper-service/src/services/User.js b/packages/component-helper-service/src/services/User.js index 39d03896853ea00f5bb81425bdda1bb551f7af7f..09c722d31cabe70492fb2c0fcdae381ee4c0c1ef 100644 --- a/packages/component-helper-service/src/services/User.js +++ b/packages/component-helper-service/src/services/User.js @@ -72,7 +72,8 @@ class User { async getEiCName() { const editorsInChief = await this.getEditorsInChief() - const { firstName, lastName } = editorsInChief[0] + const firstName = get(editorsInChief, '0.firstName', 'Editor') + const lastName = get(editorsInChief, '0.lastName', 'in Chief') return `${firstName} ${lastName}` } } diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js index 16b1b960a7219e1b5629d3a9c1f60b50f18d6f5a..71f25cbf61b3b7a165a9666bfbb0b25cca118bc9 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js @@ -35,12 +35,15 @@ module.exports = { fragmentAuthors.submittingAuthor.firstName } ${fragmentAuthors.submittingAuthor.lastName}` + const userHelper = new User({ UserModel }) + const eicName = await userHelper.getEiCName() + const email = new Email({ type: 'user', content: { unsubscribeLink: baseUrl, ctaText: 'MANUSCRIPT DETAILS', - signatureName: get(collection, 'handlingEditor.name', 'N/A'), + signatureName: eicName, ctaLink: services.createUrl( baseUrl, `/projects/${collection.id}/versions/${fragment.id}/details`, @@ -48,9 +51,6 @@ module.exports = { }, }) - const userHelper = new User({ UserModel }) - const eicName = await userHelper.getEiCName() - if ( !hasEQA && isEditorInChief && @@ -112,30 +112,49 @@ module.exports = { isEditorInChief, subjectBaseText, newRecommendation, + handlingEditorName: get(collection, 'handlingEditor.name', eicName), }) } - if (hasPeerReview(collection)) { - sendReviewersEmail({ - email, - baseUrl, - UserModel, - titleText, - fragmentHelper, - isEditorInChief, - subjectBaseText, - recommendation: newRecommendation.recommendation, - handlingEditorName: get(collection, 'handlingEditor.name', 'N/A'), - }) - - sendEiCsEmail({ - email, - baseUrl, - userHelper, - titleText, - subjectBaseText, - recommendation: newRecommendation, - }) + if ( + newRecommendation.recommendationType !== 'review' && + newRecommendation.recommendation !== 'return-to-handling-editor' + ) { + if (isEditorInChief || collection.status === 'revisionRequested') { + sendAuthorsEmail({ + email, + baseUrl, + titleText, + parsedFragment, + fragmentAuthors, + isEditorInChief, + subjectBaseText, + newRecommendation, + }) + } + + if (hasPeerReview(collection)) { + sendReviewersEmail({ + email, + baseUrl, + UserModel, + titleText, + fragmentHelper, + isEditorInChief, + subjectBaseText, + recommendation: newRecommendation.recommendation, + handlingEditorName: get(collection, 'handlingEditor.name', 'N/A'), + }) + + sendEiCsEmail({ + email, + baseUrl, + userHelper, + titleText, + subjectBaseText, + recommendation: newRecommendation, + }) + } } } } @@ -182,7 +201,9 @@ const sendHandlingEditorEmail = ({ email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, { id: handlingEditor.id, }) + email.content.signatureName = eicName + const { html, text } = email.getBody({ body: getEmailCopy({ emailType, @@ -202,6 +223,7 @@ const sendAuthorsEmail = async ({ subjectBaseText, fragmentAuthors, newRecommendation, + handlingEditorName, parsedFragment: { heRecommendation }, }) => { let emailType, authors, comments @@ -235,7 +257,10 @@ const sendAuthorsEmail = async ({ })) } else { emailType = 'author-request-to-revision' + email.content.subject = `${subjectBaseText} Recommendation` + email.content.signatureName = handlingEditorName + const authorNote = newRecommendation.comments.find(comm => comm.public) const content = get(authorNote, 'content') const authorNoteText = content ? `Reason & Details: "${content}"` : '' diff --git a/packages/component-manuscript/src/components/SideBarActions.js b/packages/component-manuscript/src/components/SideBarActions.js index dbfc3d7cd8c6bcbd6f7ce6a70176913185514c9a..4ab282febce17b1393ae399c75a1153df3fa64cb 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/component-mts-package/src/PackageManager.js b/packages/component-mts-package/src/PackageManager.js index 967985f3a45c6170fbd6a4b5d2d627ebe8cac633..b98dbf10308c84b927b10d3f670b285a1b6ca8b7 100644 --- a/packages/component-mts-package/src/PackageManager.js +++ b/packages/component-mts-package/src/PackageManager.js @@ -17,30 +17,27 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => { }) const s3 = new AWS.S3() const asyncGetObject = promisify(s3.getObject.bind(s3)) - const asyncListObjects = promisify(s3.listObjects.bind(s3)) return async ({ fragment, fileTypes, xmlFile, isEQA = false }) => { - const { id } = fragment + const { files = {} } = fragment let packageName = get(xmlFile, 'name', '').replace('.xml', '') if (isEQA) { packageName = `ACCEPTED_${packageName}` } try { - const params = { - Bucket: s3Config.bucket, - Prefix: `${id}`, - } - const s3Items = await asyncListObjects(params) - if (s3Items) { + const s3FileIDs = Object.values(files) + .reduce((acc, f) => [...acc, ...f], []) + .map(f => f.id) + + if (s3FileIDs) { const s3Files = await Promise.all( - s3Items.Contents.map(content => + s3FileIDs.map(fileID => asyncGetObject({ Bucket: s3Config.bucket, - Key: content.Key, + Key: fileID, }), ), ) - if (s3Files) { const packageOutput = fs.createWriteStream(`${packageName}.zip`) const archive = archiver('zip') diff --git a/packages/component-mts-package/tests/MTS.test.js b/packages/component-mts-package/tests/MTS.test.js index 6655fbe07f3602b353cb89be4371bde679d4ddff..42c67eafd272402699e9be402e3f9d3f1860e0a6 100644 --- a/packages/component-mts-package/tests/MTS.test.js +++ b/packages/component-mts-package/tests/MTS.test.js @@ -27,7 +27,7 @@ describe('MTS integration', () => { }) it('should contain configured journal name ', () => { - const result = MTS.composeJson(mocks.fragment) + const result = MTS.composeJson({ fragment: mocks.fragment }) expect(result).toHaveProperty( 'article.front.journal-meta.journal-title-group.journal-title._text', 'Bioinorganic Chemistry and Applications', diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index 044a3a21e91903f72a444097b665d116eac4aff2..d0b8f03d47f45aa1f8a155754152933b970757a5 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 fb7452baf0ba87d8e6d3edb530511df05a9a4bfa..6ad740fde0799055cbc4a8684935b0e37e8b2511 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 b6723f9ff0a70dd03fb30668d2e8db606247cd66..1cb644c274d3bf7732c58e245090397fa33f2da6 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) }