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) => ...@@ -367,13 +367,17 @@ export const getInvitationsWithReviewersForFragment = (state, fragmentId) =>
export const canMakeHERecommendation = (state, { collection, statuses }) => { export const canMakeHERecommendation = (state, { collection, statuses }) => {
const validHE = isHEToManuscript(state, get(collection, 'id', '')) const validHE = isHEToManuscript(state, get(collection, 'id', ''))
if (!validHE) return false
const statusImportance = get( const statusImportance = get(
statuses, statuses,
`${get(collection, 'status', 'draft')}.importance`, `${get(collection, 'status', 'draft')}.importance`,
1, 1,
) )
return statusImportance > 1 && statusImportance < 9 && validHE if (!(statusImportance > 1 && statusImportance < 10)) return false
return true
} }
export const getFragmentAuthorResponse = (state, fragmentId) => export const getFragmentAuthorResponse = (state, fragmentId) =>
...@@ -387,6 +391,7 @@ export const getFragmentReviewerRecommendations = (state, fragmentId) => ...@@ -387,6 +391,7 @@ export const getFragmentReviewerRecommendations = (state, fragmentId) =>
getFragmentRecommendations(state, fragmentId).filter( getFragmentRecommendations(state, fragmentId).filter(
r => r.recommendationType === 'review', r => r.recommendationType === 'review',
) )
const getFragmentEditorialComments = (state, fragmentId) => const getFragmentEditorialComments = (state, fragmentId) =>
getFragmentRecommendations(state, fragmentId).filter( getFragmentRecommendations(state, fragmentId).filter(
r => r.recommendationType === 'editorRecommendation', r => r.recommendationType === 'editorRecommendation',
......
...@@ -46,6 +46,31 @@ const options = [ ...@@ -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 parseFormValues = ({ recommendation, ...rest }) => {
const comments = Object.entries(rest).map(([key, value]) => ({ const comments = Object.entries(rest).map(([key, value]) => ({
content: value, content: value,
...@@ -65,6 +90,8 @@ const HERecommendation = ({ ...@@ -65,6 +90,8 @@ const HERecommendation = ({
handleSubmit, handleSubmit,
hasReviewerReports, hasReviewerReports,
highlight, highlight,
collection,
fragment,
}) => ( }) => (
<ContextualBox <ContextualBox
highlight={highlight} highlight={highlight}
...@@ -82,7 +109,13 @@ const HERecommendation = ({ ...@@ -82,7 +109,13 @@ const HERecommendation = ({
<ValidatedField <ValidatedField
component={input => ( component={input => (
<Menu <Menu
options={hasReviewerReports ? options : tail(options)} options={showHEOptions({
collection,
hasReviewerReports,
fragment,
options,
optionsWhereHECanOnlyReject,
})}
{...input} {...input}
/> />
)} )}
......
...@@ -226,10 +226,11 @@ const ManuscriptLayout = ({ ...@@ -226,10 +226,11 @@ const ManuscriptLayout = ({
)} )}
{isLatestVersion && {isLatestVersion &&
get(currentUser, 'permissions.canMakeHERecommendation', false) && get(currentUser, 'permissions.canMakeHERecommendation', false) && (
reviewerRecommendations.length > 0 && (
<HERecommendation <HERecommendation
collection={collection}
formValues={get(formValues, 'editorialRecommendation', {})} formValues={get(formValues, 'editorialRecommendation', {})}
fragment={fragment}
hasReviewerReports={reviewerRecommendations.length > 0} hasReviewerReports={reviewerRecommendations.length > 0}
highlight={reviewerRecommendations.length > 0} highlight={reviewerRecommendations.length > 0}
modalKey="heRecommendation" modalKey="heRecommendation"
......