Skip to content
Snippets Groups Projects
Commit 3edf3be2 authored by Tania Fecheta's avatar Tania Fecheta
Browse files

fix(authorCanSeeEditorialComments): hide HE name from server

parent 09ac0510
No related branches found
No related tags found
2 merge requests!110Sprint 21 Features,!93Hin 1013
......@@ -17,51 +17,55 @@ const EditorialReportCard = ({
recommendation,
editorName,
editorRole,
collection,
report: { createdOn, reviewer },
}) => (
<Root>
<Row justify="space-between" mb={2}>
<Item vertical>
{editorRole === 'HE' ? (
<Label mb={1 / 2}>Recommendation</Label>
) : (
<Label mb={1 / 2}>Decision</Label>
)}
<Text>{recommendation}</Text>
</Item>
<Item justify="flex-end">
{reviewer && (
<Fragment>
<Text mr={1 / 2}>{editorName}</Text>
<Tag mr={2}>{editorRole}</Tag>
</Fragment>
)}
<DateParser timestamp={createdOn}>
{date => <Text>{date}</Text>}
</DateParser>
</Item>
</Row>
{publicReport && (
<Row mb={2}>
}) =>
console.log('col', reviewer) || (
<Root>
<Row justify="space-between" mb={2}>
<Item vertical>
<Label mb={1 / 2}>{publicLabel}</Label>
<Text>{publicReport}</Text>
{editorRole === 'HE' ? (
<Label mb={1 / 2}>Recommendation</Label>
) : (
<Label mb={1 / 2}>Decision</Label>
)}
<Text>{recommendation}</Text>
</Item>
</Row>
)}
{privateReport && (
<Row mb={2}>
<Item vertical>
<Label mb={1 / 2}>{privateLabel}</Label>
<Text>{privateReport}</Text>
<Item justify="flex-end">
{reviewer && (
<Fragment>
<Text mr={1 / 2}>
{editorName !== 'Assigned' ? editorName : ''}
</Text>
<Tag mr={2}>{editorRole}</Tag>
</Fragment>
)}
<DateParser timestamp={createdOn}>
{date => <Text>{date}</Text>}
</DateParser>
</Item>
</Row>
)}
</Root>
)
{publicReport && (
<Row mb={2}>
<Item vertical>
<Label mb={1 / 2}>{publicLabel}</Label>
<Text>{publicReport}</Text>
</Item>
</Row>
)}
{privateReport && (
<Row mb={2}>
<Item vertical>
<Label mb={1 / 2}>{privateLabel}</Label>
<Text>{privateReport}</Text>
</Item>
</Row>
)}
</Root>
)
export default compose(
withHandlers({
......@@ -71,12 +75,8 @@ export default compose(
}
return get(report, 'reviewer.editorInChief') ? 'EiC' : ''
},
getReviewerName: ({ report }) => () =>
`${get(report, 'reviewer.firstName', '')} ${get(
report,
'reviewer.lastName',
'',
)}`,
getEditorName: ({ collection }) => () =>
`${get(collection, 'handlingEditor.name', '')}`,
getRecommendationLabel: ({
report,
journal: { recommendations = [] },
......@@ -87,11 +87,11 @@ export default compose(
),
}),
withProps(
({ report, getReviewerRole, getReviewerName, getRecommendationLabel }) => ({
({ report, getReviewerRole, getEditorName, getRecommendationLabel }) => ({
recommendation: getRecommendationLabel(),
publicReport: getReportComments({ report, isPublic: true }),
privateReport: getReportComments({ report, isPublic: false }),
editorName: getReviewerName(),
editorName: getEditorName(),
editorRole: getReviewerRole(),
}),
),
......
......@@ -6,7 +6,13 @@ import {
withFileDownload,
} from 'pubsweet-component-faraday-ui'
const EditorialCommentCard = ({ journal, reports = [], toggle, expanded }) => (
const EditorialCommentCard = ({
journal,
reports = [],
toggle,
expanded,
collection,
}) => (
<ContextualBox
expanded={expanded}
label="Editorial Comments"
......@@ -16,6 +22,7 @@ const EditorialCommentCard = ({ journal, reports = [], toggle, expanded }) => (
>
{reports.map(report => (
<EditorialReportCard
collection={collection}
journal={journal}
key={report.id}
privateLabel="Message For Editorial Team"
......
......@@ -98,6 +98,7 @@ const ManuscriptLayout = ({
{get(currentUser, 'permissions.canViewEditorialComments', true) && (
<EditorialCommentCard
collection={collection}
expanded={heRecommendationExpanded}
journal={journal}
reports={editorialRecommendations}
......
......@@ -7,6 +7,7 @@ const statuses = config.get('statuses')
const keysToOmit = ['email', 'id']
const publicStatusesPermissions = ['author', 'reviewer']
const authorAllowedStatuses = ['revisionRequested', 'rejected', 'accepted']
const authorCanViewHENameStatuses = ['rejected', 'accepted']
const parseAuthorsData = (coll, matchingCollPerm) => {
if (['reviewer'].includes(matchingCollPerm.permission)) {
......@@ -137,13 +138,13 @@ const filterAuthorRecommendations = (recommendations, status, isLast) => {
return []
}
const stripeCollectionByRole = (coll = {}, role = '') => {
const stripeCollectionByRole = ({ collection = {}, role = '' }) => {
if (role === 'author') {
const { handlingEditor } = coll
const { handlingEditor } = collection
if (!authorAllowedStatuses.includes(coll.status)) {
if (!authorCanViewHENameStatuses.includes(collection.status)) {
return {
...coll,
...collection,
handlingEditor: handlingEditor &&
handlingEditor.isAccepted && {
...omit(handlingEditor, keysToOmit),
......@@ -152,7 +153,7 @@ const stripeCollectionByRole = (coll = {}, role = '') => {
}
}
}
return coll
return collection
}
const stripeFragmentByRole = ({
......@@ -246,7 +247,7 @@ const getCollections = async ({ user, models }) => {
collection.visibleStatus = get(statuses, `${status}.${up.role}.label`)
const stripedColl = stripeCollectionByRole({
coll: collection,
collection,
role: up.role,
})
......@@ -262,7 +263,7 @@ const getCollections = async ({ user, models }) => {
})
}
return { ...stripedColl.coll, visibleStatus }
return { ...stripedColl, visibleStatus }
}),
)).filter(Boolean)
}
......
......@@ -96,10 +96,10 @@ async function applyAuthenticatedUserPolicy(user, operation, object, context) {
)
}
const parsedCollection = helpers.stripeCollectionByRole(
const parsedCollection = helpers.stripeCollectionByRole({
collection,
role,
)
})
return {
...parsedCollection,
......
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