diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index 723635e6564357bce46295e6dadf6c05d555435a..afa389aea53be5b595dc83202123b900d08f8500 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -16,8 +16,8 @@ import { selectInvitation } from '../../redux/reviewers' import { ReviewerDecision, HandlingEditorSection, DeleteManuscript } from './' import { parseVersion, parseJournalIssue, mapStatusToLabel } from './../utils' import { - currentUserIs, canMakeDecision, + isHEToManuscript, canInviteReviewers, canMakeRecommendation, } from '../../../../component-faraday-selectors/src' @@ -147,6 +147,7 @@ const DashboardCard = ({ <LeftDetails flex={4}> <HandlingEditorSection currentUser={currentUser} + isHE={isHE} project={project} /> </LeftDetails> @@ -187,8 +188,8 @@ export default compose( getContext({ journal: PropTypes.object, currentUser: PropTypes.object }), withTheme, connect((state, { project, version }) => ({ - isHE: currentUserIs(state, 'handlingEditor'), canMakeDecision: canMakeDecision(state, project), + isHE: isHEToManuscript(state, get(project, 'id')), canInviteReviewers: canInviteReviewers(state, project), invitation: selectInvitation(state, get(version, 'id')), canMakeRecommendation: canMakeRecommendation(state, project), diff --git a/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js b/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js index b48d96eb07e3fecd249ab622ef560a4e4bce97a5..a77e2e32f7d1d83971d4b8268dc5323aefd27161 100644 --- a/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js +++ b/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js @@ -4,11 +4,11 @@ import { th } from '@pubsweet/ui' import styled, { css } from 'styled-components' import { EditorInChiefActions, HandlingEditorActions } from './' -const renderHE = (currentUser, project) => { +const renderHE = (currentUser, isHE, project) => { const status = get(project, 'status') || 'draft' const isAdmin = get(currentUser, 'admin') const isEic = get(currentUser, 'editorInChief') - const isHe = get(currentUser, 'handlingEditor') + const handlingEditor = get(project, 'handlingEditor') const eicActionsStatuses = ['submitted', 'heInvited'] const heActionsStatuses = ['heInvited'] @@ -22,7 +22,7 @@ const renderHE = (currentUser, project) => { ) } - if (isHe && heActionsStatuses.includes(status)) { + if (isHE && heActionsStatuses.includes(status)) { return ( <HandlingEditorActions currentUser={currentUser} @@ -35,10 +35,10 @@ const renderHE = (currentUser, project) => { return <AssignedHE>{get(handlingEditor, 'name') || 'N/A'}</AssignedHE> } -const HandlingEditorSection = ({ currentUser, project }) => ( +const HandlingEditorSection = ({ isHE, currentUser, project }) => ( <Root> <HEText>Handling Editor</HEText> - {renderHE(currentUser, project)} + {renderHE(currentUser, isHE, project)} </Root> ) diff --git a/packages/xpub-faraday/config/authsome-mode.js b/packages/xpub-faraday/config/authsome-mode.js index 20e0d691891e9804d44e7912a821e560b3ccdaf9..56a74c08ce67bdfbb5b3f0328e25b67d44aea051 100644 --- a/packages/xpub-faraday/config/authsome-mode.js +++ b/packages/xpub-faraday/config/authsome-mode.js @@ -147,6 +147,10 @@ async function authenticatedUser(user, operation, object, context) { } } + if (get(object, 'type') === 'user') { + return true + } + // allow HE to get reviewer invitations if (get(object, 'fragment.type') === 'fragment') { const collectionId = get(object, 'fragment.collectionId') @@ -224,6 +228,10 @@ async function authenticatedUser(user, operation, object, context) { ) { return helpers.isHandlingEditor({ user, object }) } + + if (get(object, 'type') === 'collection') { + return helpers.isOwner({ user, object }) + } } // If no individual permissions exist (above), fallback to unauthenticated