diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js index 70c2afdd45b6ddaf6027801ad72a21902afed42c..64fe6e64760c1b2c7e384f4eb2d60e16d798dd6f 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,30 @@ 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 && (admin || editorInChief)) { + return <Text ml={1}>{handlingEditor.name}</Text> + } + if (pendingInvitation.userId) { 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 +152,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 e9d46aa19c314190e49577a80db5d482fb8c8ac8..9bd884c9c677556f412527ee5a1903338b3313ed 100644 --- a/packages/component-manuscript/src/components/ManuscriptLayout.js +++ b/packages/component-manuscript/src/components/ManuscriptLayout.js @@ -82,7 +82,6 @@ const ManuscriptLayout = ({ getSignedUrl={getSignedUrl} history={history} /> - <ManuscriptHeader collection={collection} currentUser={currentUser} diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index 3c642ff364b6a4b265b392c3d9a45308a0cbaa5c..636aea6e55a2736ba3907cca5f3c2e2e67833710 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -132,7 +132,6 @@ export default compose( { changeForm, clearCustomError, - assignHandlingEditor, revokeHandlingEditor, getUsers: actions.getUsers, getFragment: actions.getFragment, @@ -261,7 +260,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,