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

fix(index(component-faraday-selectors)): Stuff can see now...

fix(index(component-faraday-selectors)): Stuff can see now ResponseToRevisionRequst in the status re
parent 13f106ac
No related branches found
No related tags found
3 merge requests!176Sprint 24,!171Sprint 24,!165Hin 845 revoke and assign he
...@@ -64,6 +64,13 @@ const canViewContextualBoxOnOldVersion = (collection, fragmentId) => { ...@@ -64,6 +64,13 @@ const canViewContextualBoxOnOldVersion = (collection, fragmentId) => {
) )
) )
} }
const canHEViewContextualBoxOnOldVersion = (collection, fragmentId) => {
const fragments = get(collection, 'fragments', [])
const oldVersions = slice(fragments, 0, fragments.length - 1)
const isOldVersion = !!find(oldVersions, fragment => fragment === fragmentId)
return isOldVersion && get(collection, 'status', 'draft') === 'heInvited'
}
const cannotViewReviewersDetails = [ const cannotViewReviewersDetails = [
'draft', 'draft',
'technicalChecks', 'technicalChecks',
...@@ -193,8 +200,12 @@ export const canViewEditorialComments = ( ...@@ -193,8 +200,12 @@ export const canViewEditorialComments = (
state, state,
fragmentId, fragmentId,
) )
const isHE = currentUserIs(state, 'isHE')
const canViewEditorialCommentsOnOldVersion = isHE
? !canHEViewContextualBoxOnOldVersion(collection, fragmentId)
: canViewContextualBoxOnOldVersion(collection, fragmentId)
return ( return (
(canViewContextualBoxOnOldVersion(collection, fragmentId) || (canViewEditorialCommentsOnOldVersion ||
canHeViewEditorialComments(state, collection) || canHeViewEditorialComments(state, collection) ||
canEICViewEditorialComments(state, collection) || canEICViewEditorialComments(state, collection) ||
canReviewerViewEditorialComments(state, collection, fragment) || canReviewerViewEditorialComments(state, collection, fragment) ||
...@@ -203,7 +214,6 @@ export const canViewEditorialComments = ( ...@@ -203,7 +214,6 @@ export const canViewEditorialComments = (
) )
} }
const cannotViewResponseFromAuthorStatuses = ['reviewersInvited']
export const canViewResponseFromAuthor = (state, collection, fragmentId) => { export const canViewResponseFromAuthor = (state, collection, fragmentId) => {
const authorResponseToRevisonRequest = getFragmentAuthorResponse( const authorResponseToRevisonRequest = getFragmentAuthorResponse(
state, state,
...@@ -212,12 +222,14 @@ export const canViewResponseFromAuthor = (state, collection, fragmentId) => { ...@@ -212,12 +222,14 @@ export const canViewResponseFromAuthor = (state, collection, fragmentId) => {
const canHEViewResponseFromAuthor = const canHEViewResponseFromAuthor =
currentUserIs(state, 'isHE') && currentUserIs(state, 'isHE') &&
get(collection, 'status', 'draft') === 'heInvited' get(collection, 'status', 'draft') === 'heInvited'
const canReviewerViewResponsefromAuthor =
currentUserIsReviewerInPending(state, fragmentId) &&
get(collection, 'status', 'draft') === 'reviewersInvited'
return ( return (
!isEmpty(authorResponseToRevisonRequest) && !isEmpty(authorResponseToRevisonRequest) &&
!canHEViewResponseFromAuthor && !canHEViewResponseFromAuthor &&
!cannotViewResponseFromAuthorStatuses.includes( !canReviewerViewResponsefromAuthor
get(collection, 'status', 'draft'),
)
) )
} }
...@@ -348,6 +360,13 @@ export const pendingReviewerInvitation = (state, fragmentId) => ...@@ -348,6 +360,13 @@ export const pendingReviewerInvitation = (state, fragmentId) =>
) )
.value() .value()
export const currentUserIsReviewerInPending = (state, fragmentId) => {
const currentUser = selectCurrentUser(state)
const invitations = get(state, `fragments.${fragmentId}.invitations`, [])
return !!invitations.find(
i => i.userId === currentUser.id && i.role === 'reviewer' && !i.isAccepted,
)
}
export const currentUserIsReviewer = (state, fragmentId) => { export const currentUserIsReviewer = (state, fragmentId) => {
const currentUser = selectCurrentUser(state) const currentUser = selectCurrentUser(state)
const invitations = get(state, `fragments.${fragmentId}.invitations`, []) const invitations = get(state, `fragments.${fragmentId}.invitations`, [])
......
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