Skip to content
Snippets Groups Projects

Hin 1043 fix

Merged Mihail Hagiu requested to merge HIN-1043-fix into develop
1 unresolved thread
10 files
+ 65
41
Compare changes
  • Side-by-side
  • Inline
Files
10
import { get, has, last, chain } from 'lodash'
import { get, has, last, chain, some } from 'lodash'
import { selectCurrentUser } from 'xpub-selectors'
export const isHEToManuscript = (state, collectionId = '') => {
@@ -114,12 +114,11 @@ export const canEICViewEditorialComments = (state, collection = {}) => {
return isEIC && canEICViewEditorialCommentsStatuses.includes(status)
}
const decisionTakenStatuses = ['rejected', 'accepted', 'inQA']
const canReviewerViewEditorialCommentsStatuses = [
'rejected',
'accepted',
'inQA',
'underReview',
'reviewCompleted',
'pendingApproval',
'revisionRequested',
]
export const canReviewerViewEditorialComments = (
@@ -127,16 +126,18 @@ export const canReviewerViewEditorialComments = (
collection = {},
fragment = {},
) => {
const isReviewer = currentUserIsReviewer(state, get(fragment, 'id', ''))
const hasRevision = get(fragment, 'revision', false)
const hasRecommendation = get(fragment, 'recommendations', false)
const status = get(collection, 'status', 'draft')
const isReviewer = currentUserIsReviewer(state, get(fragment, 'id', ''))
const hasDecision = decisionTakenStatuses.includes(status)
const hasSubmission = some(state.fragments, f => f.version > fragment.version)
return (
isReviewer &&
(hasRevision || hasRecommendation) &&
canReviewerViewEditorialCommentsStatuses.includes(status)
(hasDecision ||
(hasSubmission &&
canReviewerViewEditorialCommentsStatuses.includes(status)))
)
}
const cannotAuthorViewEditorialCommentsStatuses = [
'draft',
'technicalChecks',
@@ -430,3 +431,22 @@ export const canSubmitRevision = (state, fragment = {}) => {
return get(fragment, 'revision', null) && fragmentAuthors.includes(userId)
}
// #endregion
export const getVersionOptions = (state, collection = {}) => {
const fragments = get(state, 'fragments', {})
return chain(collection)
.get('fragments', [])
.reduce(
(acc, el) => [
...acc,
{
value: el,
label: `Version ${get(fragments, `${el}.version`)}`,
},
],
[],
)
.reverse()
.value()
}