diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index bf2882df847d0071004dd88d8aaa50e4921cbd29..dc6058df1952753ac83d84766fcbecb644ce7204 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -12,12 +12,7 @@ import { import ZipFiles from './ZipFiles' import { InviteReviewers } from '../Reviewers/' import { parseVersion, parseJournalIssue, mapStatusToLabel } from './../utils' -import { - EditorInChiefActions, - HandlingEditorActions, - AuthorTooltip, - ReviewerDecision, -} from './' +import { AuthorTooltip, ReviewerDecision, HandlingEditorSection } from './' const DashboardCard = ({ deleteProject, @@ -29,7 +24,6 @@ const DashboardCard = ({ showConfirmationModal, theme, currentUser, - renderHandlingEditorRow, canInviteReviewers, ...rest }) => { @@ -151,8 +145,10 @@ const DashboardCard = ({ </Top> <Bottom> <LeftDetails flex="5"> - <HEText>Handling Editor</HEText> - {renderHandlingEditorRow()} + <HandlingEditorSection + currentUser={currentUser} + project={project} + /> </LeftDetails> {canInviteReviewers() && ( <InviteReviewers @@ -187,34 +183,6 @@ export default compose( const isAccepted = get(handlingEditor, 'isAccepted') return (isAdmin || isEic || isHe) && isAccepted }, - 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 handlingEditor = get(project, 'handlingEditor') - - // this can be changed, but it works; cba - if (isAdmin || isEic) { - if (status === 'submitted' || status === 'heInvited') - return <EditorInChiefActions project={project} /> - if (status === 'underReview') - return <AssignedHE>{get(handlingEditor, 'name')}</AssignedHE> - return <div /> - } - - if (isHe) { - if (status === 'heInvited') - return ( - <HandlingEditorActions - currentUser={currentUser} - project={project} - /> - ) - if (status === 'underReview' || status === 'heAssigned') - return <AssignedHE>{get(handlingEditor, 'name')}</AssignedHE> - } - }, showConfirmationModal: ({ deleteProject, showModal, @@ -245,12 +213,6 @@ 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; @@ -418,9 +380,4 @@ const DateField = styled.span` text-align: left; ` -const HEText = styled.div` - ${defaultText}; - text-transform: uppercase; -` - // #endregion diff --git a/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js b/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js index d8c676896c2af9751618b5fc98305eb8c92b3dbb..5bacddb1c567c306b37ffd0f882476444a328d86 100644 --- a/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js +++ b/packages/components-faraday/src/components/Dashboard/HandlingEditorActions.js @@ -116,7 +116,7 @@ const DecisionButton = styled(Button)` ${defaultText}; align-items: center; color: ${({ primary }) => - primary ? th('colorTextReverse') : th('colorPrimary')}); + primary ? th('colorTextReverse') : th('colorPrimary')}; background-color: ${({ primary }) => primary ? th('colorPrimary') : th('backgroundColorReverse')}; height: calc(${th('subGridUnit')}*5); diff --git a/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js b/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js new file mode 100644 index 0000000000000000000000000000000000000000..888521696125e3a17770defbc39e0ea1a40e1f4d --- /dev/null +++ b/packages/components-faraday/src/components/Dashboard/HandlingEditorSection.js @@ -0,0 +1,56 @@ +import React from 'react' +import { th } from '@pubsweet/ui' +import { get } from 'lodash' +import styled, { css } from 'styled-components' +import { EditorInChiefActions, HandlingEditorActions } from './' + +const renderHE = (currentUser, 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'] + + if ((isAdmin || isEic) && eicActionsStatuses.includes(status)) { + return <EditorInChiefActions project={project} /> + } + + if (isHe && heActionsStatuses.includes(status)) { + return <HandlingEditorActions currentUser={currentUser} project={project} /> + } + + return <AssignedHE>{get(handlingEditor, 'name')}</AssignedHE> +} + +const HandlingEditorSection = ({ currentUser, project }) => ( + <Root> + <HEText>Handling Editor</HEText> + {renderHE(currentUser, project)} + </Root> +) + +export default HandlingEditorSection + +// #region styled-components +const defaultText = css` + color: ${th('colorText')}; + font-family: ${th('fontReading')}; + font-size: ${th('fontSizeBaseSmall')}; +` +const Root = styled.div` + display: flex; +` + +const HEText = styled.div` + ${defaultText}; + text-transform: uppercase; +` + +const AssignedHE = styled.span` + ${defaultText}; + margin-left: calc(${th('subGridUnit')} * 3); + text-decoration: underline; +` +// #endregion diff --git a/packages/components-faraday/src/components/Dashboard/index.js b/packages/components-faraday/src/components/Dashboard/index.js index cfa6184507f8434ea086260d9ceeabb7b1a7883f..25397e39beeab99b17fc2c39a929760ff1d206c3 100644 --- a/packages/components-faraday/src/components/Dashboard/index.js +++ b/packages/components-faraday/src/components/Dashboard/index.js @@ -4,5 +4,6 @@ export { default as AuthorTooltip } from './AuthorTooltip' export { default as ReviewerDecision } from './ReviewerDecision' export { default as EditorInChiefActions } from './EditorInChiefActions' export { default as HandlingEditorActions } from './HandlingEditorActions' +export { default as HandlingEditorSection } from './HandlingEditorSection' export default DashboardPage diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js index cda6abd92040706304d0b15490164c238d107592..4fa8b8115c675da35240a8a46baeb8671d239c10 100644 --- a/packages/xpub-faraday/config/default.js +++ b/packages/xpub-faraday/config/default.js @@ -92,11 +92,11 @@ module.exports = { }, heInvited: { public: 'Submitted', - private: 'HE Invited', + private: 'Handling Editor Invited', }, heAssigned: { - public: 'HE Assigned', - private: 'HE Assigned', + public: 'Handling Editor Assigned', + private: 'Handling Editor Assigned', }, reviewersInvited: { public: 'Reviewers Invited',