Skip to content
Snippets Groups Projects
Commit 67fd8d9e authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'develop' of gitlab.coko.foundation:xpub/xpub-faraday into HIN-858

parents 6ec46ab8 ca202cbc
No related branches found
No related tags found
3 merge requests!108Hin 858 revision fix,!106Hin 858,!97HIN-858
......@@ -61,6 +61,29 @@ export const canViewReviewersDetails = (state, collection = {}) => {
return canViewReports(state, collection.id)
}
const cannotAuthorViewEditorialCommentsStatuses = [
'draft',
'technicalChecks',
'submitted',
'heInvited',
'heAssigned',
'reviewersInvited',
]
export const canAuthorViewEditorialComments = (
state,
collection = {},
fragmentId,
) => {
const isAuthor = currentUserIsAuthor(state, fragmentId)
return (
isAuthor &&
!cannotAuthorViewEditorialCommentsStatuses.includes(
get(collection, 'status', 'draft'),
)
)
}
const canHeViewEditorialCommentsStatuses = [
'revisionRequested',
'rejected',
......@@ -74,7 +97,12 @@ export const canHeViewEditorialComments = (state, collection = {}) => {
return isHE && canHeViewEditorialCommentsStatuses.includes(status)
}
const canEICViewEditorialCommentsStatuses = ['rejected', 'accepted', 'inQA']
const canEICViewEditorialCommentsStatuses = [
'rejected',
'accepted',
'inQA',
'pendingApproval',
]
export const canEICViewEditorialComments = (state, collection = {}) => {
const isEIC = currentUserIs(state, 'adminEiC')
const status = get(collection, 'status', 'draft')
......@@ -92,7 +120,8 @@ export const canViewEditorialComments = (
)
return (
(canHeViewEditorialComments(state, collection) ||
canEICViewEditorialComments(state, collection)) &&
canEICViewEditorialComments(state, collection) ||
canAuthorViewEditorialComments(state, collection, fragmentId)) &&
editorialRecommentations.length > 0
)
}
......
......@@ -17,6 +17,8 @@ const EditorialReportCard = ({
recommendation,
editorName,
editorRole,
handlingEditorName,
collection,
report: { createdOn, reviewer },
}) => (
<Root>
......@@ -33,7 +35,9 @@ const EditorialReportCard = ({
<Item justify="flex-end">
{reviewer && (
<Fragment>
<Text mr={1 / 2}>{editorName}</Text>
<Text mr={1 / 2}>
{handlingEditorName !== 'Assigned' ? editorName : ''}
</Text>
<Tag mr={2}>{editorRole}</Tag>
</Fragment>
)}
......@@ -77,6 +81,8 @@ export default compose(
'reviewer.lastName',
'',
)}`,
getHandlingEditorName: ({ collection }) => () =>
`${get(collection, 'handlingEditor.name', '')}`,
getRecommendationLabel: ({
report,
journal: { recommendations = [] },
......@@ -87,10 +93,17 @@ export default compose(
),
}),
withProps(
({ report, getReviewerRole, getReviewerName, getRecommendationLabel }) => ({
({
report,
getReviewerRole,
getReviewerName,
getHandlingEditorName,
getRecommendationLabel,
}) => ({
recommendation: getRecommendationLabel(),
publicReport: getReportComments({ report, isPublic: true }),
privateReport: getReportComments({ report, isPublic: false }),
handlingEditorName: getHandlingEditorName(),
editorName: getReviewerName(),
editorRole: getReviewerRole(),
}),
......
......@@ -47,12 +47,12 @@ const journal = {
},
],
}
;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
```
Card with message for the editorial team
......@@ -102,12 +102,12 @@ const journal = {
},
],
}
;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
;<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
......@@ -162,11 +162,10 @@ const journal = {
},
],
}
;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
;<EditorialReportCard
report={report}
journal={journal}
publicLabel="Message For Author"
privateLabel="Message For Editorial Team"
/>
```
......@@ -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"
......
......@@ -85,7 +85,6 @@ const ManuscriptLayout = ({
currentUser={currentUser}
editorInChief={editorInChief}
fragment={fragment}
handlingEditors={handlingEditors}
inviteHE={toggleAssignHE}
isFetching={isFetching.editorsFetching}
journal={journal}
......@@ -105,6 +104,7 @@ const ManuscriptLayout = ({
{get(currentUser, 'permissions.canViewEditorialComments', true) && (
<EditorialCommentCard
collection={collection}
expanded={heRecommendationExpanded}
journal={journal}
reports={editorialRecommendations}
......@@ -173,7 +173,10 @@ const ManuscriptLayout = ({
fetchingError={fetchingError}
fragment={fragment}
getSignedUrl={getSignedUrl}
highlight={reviewerReports.length === 0}
highlight={
reviewerReports.length === 0 &&
get(collection, 'status', 'draft') !== 'pendingApproval'
}
invitations={invitationsWithReviewers}
isFetching={isFetching.publonsFetching}
journal={journal}
......
......@@ -55,6 +55,7 @@ import {
canOverrideTechnicalChecks,
getOwnPendingRecommendation,
getOwnSubmittedRecommendation,
canAuthorViewEditorialComments,
getFragmentReviewerRecommendations,
getInvitationsWithReviewersForFragment,
} from 'pubsweet-component-faraday-selectors'
......@@ -182,6 +183,11 @@ export default compose(
canEditManuscript: canEditManuscript(state, collection, fragment),
canViewReviewersDetails: canViewReviewersDetails(state, collection),
canOverrideTechChecks: canOverrideTechnicalChecks(state, collection),
canAuthorViewEditorialComments: canAuthorViewEditorialComments(
state,
collection,
match.params.version,
),
},
},
isFetching: {
......
......@@ -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,
......
......@@ -11,7 +11,7 @@ describe('Authsome Helpers', () => {
})
it('stripeCollection - should return collection', () => {
const { collection } = testFixtures.collections
const result = ah.stripeCollectionByRole(collection)
const result = ah.stripeCollectionByRole({ collection })
expect(result).toBeTruthy()
})
it('stripeFragment - should return fragment', () => {
......@@ -28,7 +28,8 @@ describe('Authsome Helpers', () => {
isAccepted: true,
}
const result = ah.stripeCollectionByRole(collection, 'author')
const role = 'author'
const result = ah.stripeCollectionByRole({ collection, role })
const { handlingEditor = {} } = result
expect(handlingEditor.email).toBeFalsy()
......@@ -43,7 +44,8 @@ describe('Authsome Helpers', () => {
isAccepted: false,
}
const result = ah.stripeCollectionByRole(collection, 'author')
const role = 'author'
const result = ah.stripeCollectionByRole({ collection, role })
const { handlingEditor = {} } = result
expect(handlingEditor).toBeFalsy()
......@@ -54,7 +56,8 @@ describe('Authsome Helpers', () => {
const { collection } = testFixtures.collections
collection.status = 'revisionRequested'
const result = ah.stripeCollectionByRole(collection, 'author')
const role = 'author'
const result = ah.stripeCollectionByRole({ collection, role })
const { handlingEditor = {} } = result
expect(handlingEditor.name).not.toEqual('Assigned')
......@@ -64,7 +67,8 @@ describe('Authsome Helpers', () => {
const { collection } = testFixtures.collections
collection.status = 'underReview'
const result = ah.stripeCollectionByRole(collection, 'admin')
const role = 'admin'
const result = ah.stripeCollectionByRole({ collection, role })
const { handlingEditor = {} } = result
expect(handlingEditor.name).not.toEqual('Assigned')
......@@ -74,7 +78,8 @@ describe('Authsome Helpers', () => {
const { collection } = testFixtures.collections
collection.status = 'revisionRequested'
const result = ah.stripeCollectionByRole(collection, 'admin')
const role = 'admin'
const result = ah.stripeCollectionByRole({ collection, role })
const { handlingEditor = {} } = result
expect(handlingEditor.name).not.toEqual('Assigned')
......@@ -84,7 +89,8 @@ describe('Authsome Helpers', () => {
const { collection } = testFixtures.collections
delete collection.handlingEditor
const result = ah.stripeCollectionByRole(collection, 'admin')
const role = 'admin'
const result = ah.stripeCollectionByRole({ collection, role })
expect(result.handlingEditor).toBeFalsy()
})
......
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