From c16455b21eb9ccca493829ebbf69b26f4daf932f Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Tue, 27 Mar 2018 16:42:48 +0300 Subject: [PATCH] feat(he-actions): accept or decline as he --- .../src/components/Dashboard/DashboardCard.js | 40 +++++++++++++++---- .../Dashboard/HandlingEditorActions.js | 3 +- .../src/components/Dashboard/utils.js | 2 + 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index 4ca60c5e2..d95dc0c25 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -24,6 +24,7 @@ const DashboardCard = ({ showConfirmationModal, theme, currentUser, + renderHandlingEditorRow, ...rest }) => { const { submitted, title, type } = parseVersion(version) @@ -137,14 +138,7 @@ const DashboardCard = ({ <Bottom> <LeftDetails flex="5"> <HEText>Handling Editor</HEText> - {get(currentUser, 'admin') || - (get(currentUser, 'editorInChief') && ( - <EditorInChiefActions project={project} /> - ))} - {get(currentUser, 'handlingEditor') && - status === 'he-invited' && ( - <HandlingEditorActions project={project} /> - )} + {renderHandlingEditorRow()} </LeftDetails> </Bottom> </DetailsView> @@ -161,6 +155,30 @@ export default compose( modalComponent: ConfirmationModal, }), withHandlers({ + renderHandlingEditorRow: ({ currentUser, project }) => () => { + const status = get(project, 'status') || 'draft' + const isAdmin = get(currentUser, 'admin') + const isEic = get(currentUser, 'editorInChief') + const isHe = get(currentUser, 'handlingEditor') + const assignedPeople = get(project, 'assignedPeople') + const assignedHE = + assignedPeople && assignedPeople.find(p => p.role === 'handlingEditor') + + if (isAdmin || isEic) { + if (status === 'submitted' || status === 'he-invited') + return <EditorInChiefActions project={project} /> + if (status === 'under-review') + return <AssignedHE>{get(assignedHE, 'name')}</AssignedHE> + return <div>bine bulanes</div> + } + + if (isHe) { + if (status === 'he-invited') + return <HandlingEditorActions project={project} /> + if (status === 'under-review') + return <AssignedHE>{get(assignedHE, 'name')}</AssignedHE> + } + }, showConfirmationModal: ({ deleteProject, showModal, @@ -191,6 +209,12 @@ const defaultText = css` font-size: ${th('fontSizeBaseSmall')}; ` +const AssignedHE = styled.span` + ${defaultText}; + margin-left: calc(${th('subGridUnit')} * 3); + text-decoration: underline; +` + const AuthorList = styled.span` ${defaultText}; text-align: left; diff --git a/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js b/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js index f66b955c4..6da2664f8 100644 --- a/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js +++ b/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js @@ -89,7 +89,7 @@ export default compose( title: 'Decline handling editor role', subtitle: `Clicking "Agree" will assign you as Handling Editor for this Manuscript.`, onConfirm: reason => () => { - handlingEditorDecision(project.id, true, reason).then(() => { + handlingEditorDecision(project.id, false, reason).then(() => { updateCollection({ id: project.id, status: 'submitted', @@ -128,6 +128,7 @@ const DeclineRoot = styled.div` & textarea { height: 100%; + padding: calc(${th('subGridUnit')} * 2); width: 100%; } diff --git a/packages/components-faraday/src/components/Dashboard/utils.js b/packages/components-faraday/src/components/Dashboard/utils.js index b8b45dcb7..3e0bc448f 100644 --- a/packages/components-faraday/src/components/Dashboard/utils.js +++ b/packages/components-faraday/src/components/Dashboard/utils.js @@ -81,6 +81,8 @@ export const mapStatusToLabel = status => { return 'Handling Editor Invited' case 'submitted': return 'Submitted' + case 'under-review': + return 'Under review' default: return 'Draft' } -- GitLab