Skip to content
Snippets Groups Projects
Commit 109fb64a authored by Anca Ursachi's avatar Anca Ursachi
Browse files

feat(heCanSeeEditorialComments): Make selector for eic and he to view editorial comments

parent aa24a0a9
No related branches found
No related tags found
2 merge requests!110Sprint 21 Features,!90Hin 1014
......@@ -53,6 +53,7 @@ const cannotViewReviewersDetails = [
'submitted',
'heInvited',
]
export const canViewReviewersDetails = (state, collection = {}) => {
if (cannotViewReviewersDetails.includes(get(collection, 'status', 'draft'))) {
return false
......@@ -60,9 +61,39 @@ export const canViewReviewersDetails = (state, collection = {}) => {
return canViewReports(state, collection.id)
}
const canHeViewEditorialCommentsStatuses = [
'revisionRequested',
'rejected',
'accepted',
'inQA',
]
export const canHeViewEditorialComments = (state, collection = {}) => {
const isHE = isHEToManuscript(state, collection.id)
return isHE && collection.status === 'revisionRequested'
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 }) =>
......@@ -259,6 +290,10 @@ export const getFragmentReviewerRecommendations = (state, fragmentId) =>
getFragmentRecommendations(state, fragmentId).filter(
r => r.recommendationType === 'review',
)
const getFragmentEditorialComments = (state, fragmentId) =>
getFragmentRecommendations(state, fragmentId).filter(
r => r.recommendationType === 'editorRecommendation',
)
const getOwnRecommendations = (state, fragmentId) =>
chain(state)
......
......@@ -102,13 +102,12 @@ const ManuscriptLayout = ({
getSignedUrl={getSignedUrl}
/>
{get(currentUser, 'permissions.canHeViewEditorialComments', true) &&
!!editorialRecommendations.length && (
<EditorialCommentCard
journal={journal}
reports={editorialRecommendations}
/>
)}
{get(currentUser, 'permissions.canViewEditorialComments', true) && (
<EditorialCommentCard
journal={journal}
reports={editorialRecommendations}
/>
)}
{submittedOwnRecommendation && (
<ReviewerReportCard
......
......@@ -48,10 +48,10 @@ import {
currentUserIsReviewer,
parseCollectionDetails,
canMakeHERecommendation,
canViewEditorialComments,
canViewReviewersDetails,
pendingReviewerInvitation,
canOverrideTechnicalChecks,
canHeViewEditorialComments,
getOwnPendingRecommendation,
getOwnSubmittedRecommendation,
getFragmentReviewerRecommendations,
......@@ -167,9 +167,10 @@ export default compose(
}),
canAssignHE: canAssignHE(state, match.params.project),
canViewReports: canViewReports(state, match.params.project),
canHeViewEditorialComments: canHeViewEditorialComments(
canViewEditorialComments: canViewEditorialComments(
state,
collection,
match.params.version,
),
canInviteReviewers: canInviteReviewers(state, collection),
canMakeRecommendation: !isUndefined(pendingOwnRecommendation),
......
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