Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mynameissmeall/xpub-faraday
1 result
Show changes
Commits on Source (13)
......@@ -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"
......