Skip to content
Snippets Groups Projects
Commit e3999201 authored by Sinzeanu Demetriad's avatar Sinzeanu Demetriad
Browse files

Merge branch 'HIN-1014' into 'develop'

Hin 1014

See merge request !90
parents 03dac209 82435713
No related branches found
No related tags found
2 merge requests!110Sprint 21 Features,!90Hin 1014
...@@ -53,6 +53,7 @@ const cannotViewReviewersDetails = [ ...@@ -53,6 +53,7 @@ const cannotViewReviewersDetails = [
'submitted', 'submitted',
'heInvited', 'heInvited',
] ]
export const canViewReviewersDetails = (state, collection = {}) => { export const canViewReviewersDetails = (state, collection = {}) => {
if (cannotViewReviewersDetails.includes(get(collection, 'status', 'draft'))) { if (cannotViewReviewersDetails.includes(get(collection, 'status', 'draft'))) {
return false return false
...@@ -60,6 +61,41 @@ export const canViewReviewersDetails = (state, collection = {}) => { ...@@ -60,6 +61,41 @@ export const canViewReviewersDetails = (state, collection = {}) => {
return canViewReports(state, collection.id) return canViewReports(state, collection.id)
} }
const canHeViewEditorialCommentsStatuses = [
'revisionRequested',
'rejected',
'accepted',
'inQA',
]
export const canHeViewEditorialComments = (state, collection = {}) => {
const isHE = isHEToManuscript(state, collection.id)
const status = get(collection, 'status', 'draft')
return isHE && canHeViewEditorialCommentsStatuses.includes(status)
}
const canEICViewEditorialCommentsStatuses = ['rejected', 'accepted', 'inQA']
export const canEICViewEditorialComments = (state, collection = {}) => {
const isEIC = currentUserIs(state, 'adminEiC')
const status = get(collection, 'status', 'draft')
return isEIC && canEICViewEditorialCommentsStatuses.includes(status)
}
export const canViewEditorialComments = (
state,
collection = {},
fragmentId,
) => {
const editorialRecommentations = getFragmentEditorialComments(
state,
fragmentId,
)
return (
(canHeViewEditorialComments(state, collection) ||
canEICViewEditorialComments(state, collection)) &&
editorialRecommentations.length > 0
)
}
export const getUserToken = ({ currentUser }) => export const getUserToken = ({ currentUser }) =>
get(currentUser, 'user.token', '') get(currentUser, 'user.token', '')
...@@ -254,6 +290,10 @@ export const getFragmentReviewerRecommendations = (state, fragmentId) => ...@@ -254,6 +290,10 @@ export const getFragmentReviewerRecommendations = (state, fragmentId) =>
getFragmentRecommendations(state, fragmentId).filter( getFragmentRecommendations(state, fragmentId).filter(
r => r.recommendationType === 'review', r => r.recommendationType === 'review',
) )
const getFragmentEditorialComments = (state, fragmentId) =>
getFragmentRecommendations(state, fragmentId).filter(
r => r.recommendationType === 'editorRecommendation',
)
const getOwnRecommendations = (state, fragmentId) => const getOwnRecommendations = (state, fragmentId) =>
chain(state) chain(state)
......
...@@ -9,26 +9,32 @@ import { Label, Item, Row, Text, Tag } from './' ...@@ -9,26 +9,32 @@ import { Label, Item, Row, Text, Tag } from './'
import { getReportComments } from './helpers' import { getReportComments } from './helpers'
const EditorialReportCard = ({ const EditorialReportCard = ({
publicLabel,
privateLabel,
journal, journal,
publicReport, publicReport,
privateReport, privateReport,
recommendation, recommendation,
reviewerName, editorName,
reviewerRole, editorRole,
report: { createdOn, reviewer }, report: { createdOn, reviewer },
}) => ( }) => (
<Root> <Root>
<Row justify="space-between" mb={2}> <Row justify="space-between" mb={2}>
<Item vertical> <Item vertical>
<Label mb={1 / 2}>Decision</Label> {editorRole === 'HE' ? (
<Label mb={1 / 2}>Recommendation</Label>
) : (
<Label mb={1 / 2}>Decision</Label>
)}
<Text>{recommendation}</Text> <Text>{recommendation}</Text>
</Item> </Item>
<Item justify="flex-end"> <Item justify="flex-end">
{reviewer && ( {reviewer && (
<Fragment> <Fragment>
<Text mr={1 / 2}>{reviewerName}</Text> <Text mr={1 / 2}>{editorName}</Text>
<Tag mr={2}>{reviewerRole}</Tag> <Tag mr={2}>{editorRole}</Tag>
</Fragment> </Fragment>
)} )}
<DateParser timestamp={createdOn}> <DateParser timestamp={createdOn}>
...@@ -40,7 +46,7 @@ const EditorialReportCard = ({ ...@@ -40,7 +46,7 @@ const EditorialReportCard = ({
{publicReport && ( {publicReport && (
<Row mb={2}> <Row mb={2}>
<Item vertical> <Item vertical>
<Label mb={1 / 2}>Message For Author</Label> <Label mb={1 / 2}>{publicLabel}</Label>
<Text>{publicReport}</Text> <Text>{publicReport}</Text>
</Item> </Item>
</Row> </Row>
...@@ -49,7 +55,7 @@ const EditorialReportCard = ({ ...@@ -49,7 +55,7 @@ const EditorialReportCard = ({
{privateReport && ( {privateReport && (
<Row mb={2}> <Row mb={2}>
<Item vertical> <Item vertical>
<Label mb={1 / 2}>Message For Editorial Team</Label> <Label mb={1 / 2}>{privateLabel}</Label>
<Text>{privateReport}</Text> <Text>{privateReport}</Text>
</Item> </Item>
</Row> </Row>
...@@ -85,8 +91,8 @@ export default compose( ...@@ -85,8 +91,8 @@ export default compose(
recommendation: getRecommendationLabel(), recommendation: getRecommendationLabel(),
publicReport: getReportComments({ report, isPublic: true }), publicReport: getReportComments({ report, isPublic: true }),
privateReport: getReportComments({ report, isPublic: false }), privateReport: getReportComments({ report, isPublic: false }),
reviewerName: getReviewerName(), editorName: getReviewerName(),
reviewerRole: getReviewerRole(), editorRole: getReviewerRole(),
}), }),
), ),
)(EditorialReportCard) )(EditorialReportCard)
......
...@@ -47,7 +47,12 @@ const journal = { ...@@ -47,7 +47,12 @@ const journal = {
}, },
], ],
} }
;<EditorialReportCard report={report} journal={journal} /> ;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
``` ```
Card with message for the editorial team Card with message for the editorial team
...@@ -97,7 +102,12 @@ const journal = { ...@@ -97,7 +102,12 @@ const journal = {
}, },
], ],
} }
;<EditorialReportCard report={report} journal={journal} /> ;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
``` ```
Card with message for the editorial team and for the author Card with message for the editorial team and for the author
...@@ -152,5 +162,11 @@ const journal = { ...@@ -152,5 +162,11 @@ const journal = {
}, },
], ],
} }
;<EditorialReportCard report={report} journal={journal} />
;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
``` ```
...@@ -9,7 +9,13 @@ import { ...@@ -9,7 +9,13 @@ import {
const EditorialCommentCard = ({ journal, reports = [] }) => ( const EditorialCommentCard = ({ journal, reports = [] }) => (
<ContextualBox label="Editorial Comments" mb={2}> <ContextualBox label="Editorial Comments" mb={2}>
{reports.map(report => ( {reports.map(report => (
<EditorialReportCard journal={journal} key={report.id} report={report} /> <EditorialReportCard
journal={journal}
key={report.id}
privateLabel="Message For Editorial Team"
publicLabel="Message For Author"
report={report}
/>
))} ))}
</ContextualBox> </ContextualBox>
) )
......
...@@ -102,13 +102,12 @@ const ManuscriptLayout = ({ ...@@ -102,13 +102,12 @@ const ManuscriptLayout = ({
getSignedUrl={getSignedUrl} getSignedUrl={getSignedUrl}
/> />
{get(currentUser, 'permissions.canViewReports', true) && {get(currentUser, 'permissions.canViewEditorialComments', true) && (
!!editorialRecommendations.length && ( <EditorialCommentCard
<EditorialCommentCard journal={journal}
journal={journal} reports={editorialRecommendations}
reports={editorialRecommendations} />
/> )}
)}
{submittedOwnRecommendation && ( {submittedOwnRecommendation && (
<ReviewerReportCard <ReviewerReportCard
......
...@@ -48,6 +48,7 @@ import { ...@@ -48,6 +48,7 @@ import {
currentUserIsReviewer, currentUserIsReviewer,
parseCollectionDetails, parseCollectionDetails,
canMakeHERecommendation, canMakeHERecommendation,
canViewEditorialComments,
canViewReviewersDetails, canViewReviewersDetails,
pendingReviewerInvitation, pendingReviewerInvitation,
canOverrideTechnicalChecks, canOverrideTechnicalChecks,
...@@ -166,6 +167,11 @@ export default compose( ...@@ -166,6 +167,11 @@ export default compose(
}), }),
canAssignHE: canAssignHE(state, match.params.project), canAssignHE: canAssignHE(state, match.params.project),
canViewReports: canViewReports(state, match.params.project), canViewReports: canViewReports(state, match.params.project),
canViewEditorialComments: canViewEditorialComments(
state,
collection,
match.params.version,
),
canInviteReviewers: canInviteReviewers(state, collection), canInviteReviewers: canInviteReviewers(state, collection),
canMakeRecommendation: !isUndefined(pendingOwnRecommendation), canMakeRecommendation: !isUndefined(pendingOwnRecommendation),
canMakeRevision: canMakeRevision(state, collection, fragment), canMakeRevision: canMakeRevision(state, collection, fragment),
......
...@@ -184,7 +184,11 @@ const stripeFragmentByRole = ({ ...@@ -184,7 +184,11 @@ const stripeFragmentByRole = ({
return { return {
...fragment, ...fragment,
recommendations: recommendations recommendations: recommendations
? recommendations.filter(r => r.submittedOn) ? recommendations.filter(
r =>
r.submittedOn ||
r.recommendationType === 'editorRecommendation',
)
: [], : [],
} }
default: default:
......
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