Skip to content
Snippets Groups Projects
Commit 5f8f43df authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

feat: merge with develop

parents e5c2dcd0 07858b3e
No related branches found
No related tags found
2 merge requests!34Sprint 17 features,!31Hin 730
...@@ -7,7 +7,11 @@ export const isHEToManuscript = (state, collectionId) => { ...@@ -7,7 +7,11 @@ export const isHEToManuscript = (state, collectionId) => {
return get(collection, 'handlingEditor.id') === currentUserId return get(collection, 'handlingEditor.id') === currentUserId
} }
const canMakeRecommendationStatuses = ['reviewCompleted', 'heAssigned'] const canMakeRecommendationStatuses = [
'reviewCompleted',
'heAssigned',
'underReview',
]
export const canMakeRecommendation = (state, collection, fragment = {}) => { export const canMakeRecommendation = (state, collection, fragment = {}) => {
if (fragment.id !== last(collection.fragments)) return false if (fragment.id !== last(collection.fragments)) return false
const isHE = isHEToManuscript(state, collection.id) const isHE = isHEToManuscript(state, collection.id)
......
...@@ -72,7 +72,8 @@ class User { ...@@ -72,7 +72,8 @@ class User {
async getEiCName() { async getEiCName() {
const editorsInChief = await this.getEditorsInChief() 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}` return `${firstName} ${lastName}`
} }
} }
......
...@@ -35,12 +35,15 @@ module.exports = { ...@@ -35,12 +35,15 @@ module.exports = {
fragmentAuthors.submittingAuthor.firstName fragmentAuthors.submittingAuthor.firstName
} ${fragmentAuthors.submittingAuthor.lastName}` } ${fragmentAuthors.submittingAuthor.lastName}`
const userHelper = new User({ UserModel })
const eicName = await userHelper.getEiCName()
const email = new Email({ const email = new Email({
type: 'user', type: 'user',
content: { content: {
unsubscribeLink: baseUrl, unsubscribeLink: baseUrl,
ctaText: 'MANUSCRIPT DETAILS', ctaText: 'MANUSCRIPT DETAILS',
signatureName: get(collection, 'handlingEditor.name', 'N/A'), signatureName: eicName,
ctaLink: services.createUrl( ctaLink: services.createUrl(
baseUrl, baseUrl,
`/projects/${collection.id}/versions/${fragment.id}/details`, `/projects/${collection.id}/versions/${fragment.id}/details`,
...@@ -48,9 +51,6 @@ module.exports = { ...@@ -48,9 +51,6 @@ module.exports = {
}, },
}) })
const userHelper = new User({ UserModel })
const eicName = await userHelper.getEiCName()
if ( if (
!hasEQA && !hasEQA &&
isEditorInChief && isEditorInChief &&
...@@ -112,30 +112,49 @@ module.exports = { ...@@ -112,30 +112,49 @@ module.exports = {
isEditorInChief, isEditorInChief,
subjectBaseText, subjectBaseText,
newRecommendation, newRecommendation,
handlingEditorName: get(collection, 'handlingEditor.name', eicName),
}) })
} }
if (hasPeerReview(collection)) { if (
sendReviewersEmail({ newRecommendation.recommendationType !== 'review' &&
email, newRecommendation.recommendation !== 'return-to-handling-editor'
baseUrl, ) {
UserModel, if (isEditorInChief || collection.status === 'revisionRequested') {
titleText, sendAuthorsEmail({
fragmentHelper, email,
isEditorInChief, baseUrl,
subjectBaseText, titleText,
recommendation: newRecommendation.recommendation, parsedFragment,
handlingEditorName: get(collection, 'handlingEditor.name', 'N/A'), fragmentAuthors,
}) isEditorInChief,
subjectBaseText,
sendEiCsEmail({ newRecommendation,
email, })
baseUrl, }
userHelper,
titleText, if (hasPeerReview(collection)) {
subjectBaseText, sendReviewersEmail({
recommendation: newRecommendation, 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 = ({ ...@@ -182,7 +201,9 @@ const sendHandlingEditorEmail = ({
email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, { email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, {
id: handlingEditor.id, id: handlingEditor.id,
}) })
email.content.signatureName = eicName email.content.signatureName = eicName
const { html, text } = email.getBody({ const { html, text } = email.getBody({
body: getEmailCopy({ body: getEmailCopy({
emailType, emailType,
...@@ -202,6 +223,7 @@ const sendAuthorsEmail = async ({ ...@@ -202,6 +223,7 @@ const sendAuthorsEmail = async ({
subjectBaseText, subjectBaseText,
fragmentAuthors, fragmentAuthors,
newRecommendation, newRecommendation,
handlingEditorName,
parsedFragment: { heRecommendation }, parsedFragment: { heRecommendation },
}) => { }) => {
let emailType, authors, comments let emailType, authors, comments
...@@ -235,7 +257,10 @@ const sendAuthorsEmail = async ({ ...@@ -235,7 +257,10 @@ const sendAuthorsEmail = async ({
})) }))
} else { } else {
emailType = 'author-request-to-revision' emailType = 'author-request-to-revision'
email.content.subject = `${subjectBaseText} Recommendation` email.content.subject = `${subjectBaseText} Recommendation`
email.content.signatureName = handlingEditorName
const authorNote = newRecommendation.comments.find(comm => comm.public) const authorNote = newRecommendation.comments.find(comm => comm.public)
const content = get(authorNote, 'content') const content = get(authorNote, 'content')
const authorNoteText = content ? `Reason & Details: "${content}"` : '' const authorNoteText = content ? `Reason & Details: "${content}"` : ''
......
...@@ -40,6 +40,7 @@ const SideBarActions = ({ ...@@ -40,6 +40,7 @@ const SideBarActions = ({
collectionId={project.id} collectionId={project.id}
fragmentId={version.id} fragmentId={version.id}
modalKey={`decide-${version.id}`} modalKey={`decide-${version.id}`}
status={project.status}
/> />
)} )}
......
...@@ -17,30 +17,27 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => { ...@@ -17,30 +17,27 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => {
}) })
const s3 = new AWS.S3() const s3 = new AWS.S3()
const asyncGetObject = promisify(s3.getObject.bind(s3)) const asyncGetObject = promisify(s3.getObject.bind(s3))
const asyncListObjects = promisify(s3.listObjects.bind(s3))
return async ({ fragment, fileTypes, xmlFile, isEQA = false }) => { return async ({ fragment, fileTypes, xmlFile, isEQA = false }) => {
const { id } = fragment const { files = {} } = fragment
let packageName = get(xmlFile, 'name', '').replace('.xml', '') let packageName = get(xmlFile, 'name', '').replace('.xml', '')
if (isEQA) { if (isEQA) {
packageName = `ACCEPTED_${packageName}` packageName = `ACCEPTED_${packageName}`
} }
try { try {
const params = { const s3FileIDs = Object.values(files)
Bucket: s3Config.bucket, .reduce((acc, f) => [...acc, ...f], [])
Prefix: `${id}`, .map(f => f.id)
}
const s3Items = await asyncListObjects(params) if (s3FileIDs) {
if (s3Items) {
const s3Files = await Promise.all( const s3Files = await Promise.all(
s3Items.Contents.map(content => s3FileIDs.map(fileID =>
asyncGetObject({ asyncGetObject({
Bucket: s3Config.bucket, Bucket: s3Config.bucket,
Key: content.Key, Key: fileID,
}), }),
), ),
) )
if (s3Files) { if (s3Files) {
const packageOutput = fs.createWriteStream(`${packageName}.zip`) const packageOutput = fs.createWriteStream(`${packageName}.zip`)
const archive = archiver('zip') const archive = archiver('zip')
......
...@@ -27,7 +27,7 @@ describe('MTS integration', () => { ...@@ -27,7 +27,7 @@ describe('MTS integration', () => {
}) })
it('should contain configured journal name ', () => { it('should contain configured journal name ', () => {
const result = MTS.composeJson(mocks.fragment) const result = MTS.composeJson({ fragment: mocks.fragment })
expect(result).toHaveProperty( expect(result).toHaveProperty(
'article.front.journal-meta.journal-title-group.journal-title._text', 'article.front.journal-meta.journal-title-group.journal-title._text',
'Bioinorganic Chemistry and Applications', 'Bioinorganic Chemistry and Applications',
......
...@@ -74,7 +74,6 @@ const DashboardCard = ({ ...@@ -74,7 +74,6 @@ const DashboardCard = ({
collectionId={project.id} collectionId={project.id}
fragmentId={version.id} fragmentId={version.id}
modalKey={`recommend-${version.id}`} modalKey={`recommend-${version.id}`}
status={project.status}
/> />
)} )}
<ZipFiles <ZipFiles
......
...@@ -9,7 +9,10 @@ import { getFormValues, reset as resetForm } from 'redux-form' ...@@ -9,7 +9,10 @@ import { getFormValues, reset as resetForm } from 'redux-form'
import { FormItems } from '../UIComponents' import { FormItems } from '../UIComponents'
import { StepOne, StepTwo, utils } from './' import { StepOne, StepTwo, utils } from './'
import { createRecommendation } from '../../redux/recommendations' import {
createRecommendation,
selectReviewRecommendations,
} from '../../redux/recommendations'
const RecommendWizard = ({ const RecommendWizard = ({
step, step,
...@@ -40,8 +43,9 @@ const RecommendWizard = ({ ...@@ -40,8 +43,9 @@ const RecommendWizard = ({
export default compose( export default compose(
connect( connect(
state => ({ (state, { fragmentId }) => ({
decision: get(getFormValues('recommendation')(state), 'decision'), decision: get(getFormValues('recommendation')(state), 'decision'),
reviews: selectReviewRecommendations(state, fragmentId),
}), }),
{ {
resetForm, resetForm,
......
import React from 'react' import React from 'react'
import { reduxForm } from 'redux-form' import { reduxForm } from 'redux-form'
import { isEmpty } from 'lodash'
import { RadioGroup, ValidatedField, Button } from '@pubsweet/ui' import { RadioGroup, ValidatedField, Button } from '@pubsweet/ui'
import { utils } from './' import { utils } from './'
...@@ -7,7 +8,7 @@ import { FormItems } from '../UIComponents' ...@@ -7,7 +8,7 @@ import { FormItems } from '../UIComponents'
const { Row, Title, RowItem, RootContainer, CustomRadioGroup } = FormItems const { Row, Title, RowItem, RootContainer, CustomRadioGroup } = FormItems
const StepOne = ({ hideModal, disabled, onSubmit, status }) => ( const StepOne = ({ hideModal, disabled, onSubmit, reviews }) => (
<RootContainer> <RootContainer>
<Title>Recommendation for Next Phase</Title> <Title>Recommendation for Next Phase</Title>
<Row> <Row>
...@@ -21,7 +22,7 @@ const StepOne = ({ hideModal, disabled, onSubmit, status }) => ( ...@@ -21,7 +22,7 @@ const StepOne = ({ hideModal, disabled, onSubmit, status }) => (
<RadioGroup <RadioGroup
name="decision" name="decision"
options={ options={
status === 'reviewCompleted' !isEmpty(reviews)
? utils.recommendationOptions ? utils.recommendationOptions
: utils.recommendationOptions.slice(1) : utils.recommendationOptions.slice(1)
} }
......
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