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

Merge branch 'HIN-1054' into 'develop'

Hin 1054

See merge request !139
parents f7107e63 3a0c0bcf
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!150Develop,!139Hin 1054
......@@ -367,13 +367,17 @@ export const getInvitationsWithReviewersForFragment = (state, fragmentId) =>
export const canMakeHERecommendation = (state, { collection, statuses }) => {
const validHE = isHEToManuscript(state, get(collection, 'id', ''))
if (!validHE) return false
const statusImportance = get(
statuses,
`${get(collection, 'status', 'draft')}.importance`,
1,
)
return statusImportance > 1 && statusImportance < 9 && validHE
if (!(statusImportance > 1 && statusImportance < 10)) return false
return true
}
export const getFragmentAuthorResponse = (state, fragmentId) =>
......@@ -387,6 +391,7 @@ 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',
......
......@@ -46,6 +46,31 @@ const options = [
},
]
const optionsWhereHECanOnlyReject = [
'reviewersInvited',
'underReview',
'revisionRequested',
]
const showHEOptions = ({
collection,
hasReviewerReports,
fragment,
options,
optionsWhereHECanOnlyReject,
}) => {
const { status, fragments } = collection
const { invitations } = fragment
if (optionsWhereHECanOnlyReject.includes(status)) {
return [options[1]]
} else if (!hasReviewerReports && fragments.length === 1) {
return tail(options)
} else if (invitations === []) {
return [options[1]]
}
return options
}
const parseFormValues = ({ recommendation, ...rest }) => {
const comments = Object.entries(rest).map(([key, value]) => ({
content: value,
......@@ -65,6 +90,8 @@ const HERecommendation = ({
handleSubmit,
hasReviewerReports,
highlight,
collection,
fragment,
}) => (
<ContextualBox
highlight={highlight}
......@@ -82,7 +109,13 @@ const HERecommendation = ({
<ValidatedField
component={input => (
<Menu
options={hasReviewerReports ? options : tail(options)}
options={showHEOptions({
collection,
hasReviewerReports,
fragment,
options,
optionsWhereHECanOnlyReject,
})}
{...input}
/>
)}
......
......@@ -226,10 +226,11 @@ const ManuscriptLayout = ({
)}
{isLatestVersion &&
get(currentUser, 'permissions.canMakeHERecommendation', false) &&
reviewerRecommendations.length > 0 && (
get(currentUser, 'permissions.canMakeHERecommendation', false) && (
<HERecommendation
collection={collection}
formValues={get(formValues, 'editorialRecommendation', {})}
fragment={fragment}
hasReviewerReports={reviewerRecommendations.length > 0}
highlight={reviewerRecommendations.length > 0}
modalKey="heRecommendation"
......
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