diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js index 70c2afdd45b6ddaf6027801ad72a21902afed42c..b7e6f5389f196f87344e2b5f35a2f0630117c644 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js @@ -22,7 +22,7 @@ const ManuscriptHeader = ({ fragment = {}, manuscriptType = {}, editorInChief = 'Unassigned', - collection: { visibleStatus = 'Draft', customId }, + collection: { visibleStatus = 'Draft', customId, handlingEditor }, }) => { const { authors = [], metadata = {}, submitted = null } = fragment const { title = 'No title', journal = '', type = '' } = metadata @@ -116,18 +116,25 @@ export default compose( revokeInvitation, pendingInvitation = {}, handlingEditors = [], - currentUser: { permissions: { canAssignHE }, id: currentUserId }, + currentUser: { + permissions: { canAssignHE }, + id: currentUserId, + admin, + editorInChief, + }, collection: { handlingEditor }, + currentUser, }) => () => { if (pendingInvitation.userId === currentUserId) { return <Text ml={1}>Invited</Text> } - if (pendingInvitation.userId) { + if (pendingInvitation.userId && (admin || editorInChief)) { const person = chain(handlingEditors) .filter(he => he.id === pendingInvitation.userId) .map(he => ({ ...he, name: `${he.firstName} ${he.lastName}` })) .first() .value() + return ( <PersonInvitation isFetching={isFetching} @@ -140,6 +147,7 @@ export default compose( /> ) } + if (heInvitation) { return <Text ml={1}>{handlingEditor.name}</Text> } diff --git a/packages/component-manuscript/src/components/ManuscriptLayout.js b/packages/component-manuscript/src/components/ManuscriptLayout.js index 619331cf13e8d0e144524be8dbcc934adc5bd84a..c02738c3496a6555c600151ee557cfe13ed6fc55 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -78,12 +78,12 @@ const ManuscriptLayout = ({ getSignedUrl={getSignedUrl} history={history} /> - <ManuscriptHeader collection={collection} currentUser={currentUser} editorInChief={editorInChief} fragment={fragment} + handlingEditors={handlingEditors} inviteHE={toggleAssignHE} isFetching={isFetching.editorsFetching} journal={journal} diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index 8e67c6d7ef148a2d47928657288a4f516e4937d5..5fd6b730f5fc68a7f685ab3a4bec6722105b78bf 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -129,7 +129,6 @@ export default compose( { changeForm, clearCustomError, - assignHandlingEditor, revokeHandlingEditor, getUsers: actions.getUsers, getFragment: actions.getFragment, @@ -258,7 +257,7 @@ export default compose( } }, assignHE: ({ - assignHandlingEditor, + setFetching, fetchUpdatedCollection, collection: { id: collectionId }, }) => (email, modalProps) => diff --git a/packages/component-manuscript/src/redux/editors.js b/packages/component-manuscript/src/redux/editors.js index ffe5ac1f4fd9382d1899270f2d419b7701528055..e28c0dd29ff392776fa2092639ec8fceda19026a 100644 --- a/packages/component-manuscript/src/redux/editors.js +++ b/packages/component-manuscript/src/redux/editors.js @@ -43,22 +43,11 @@ export const getHandlingEditors = () => dispatch => dispatch(setHandlingEditors(res.users)), ) -export const assignHandlingEditor = ({ email, collectionId }) => dispatch => { - dispatch(editorsRequest()) - return create(`/collections/${collectionId}/invitations`, { +export const assignHandlingEditor = ({ email, collectionId }) => + create(`/collections/${collectionId}/invitations`, { email, role: 'handlingEditor', - }).then( - res => { - dispatch(editorsDone()) - return res - }, - err => { - dispatch(editorsDone()) - throw err - }, - ) -} + }) export const revokeHandlingEditor = ({ invitationId,