From 25c6474b61fff92f76e08b056e0d3355be1a715e Mon Sep 17 00:00:00 2001 From: Anca Ursachi <anca.ursachi@thinslices.com> Date: Mon, 7 Jan 2019 14:57:38 +0200 Subject: [PATCH] fix(submissionWizard): Adding '/submit' in the manuscript link should not allow users to edit it, ju --- .../src/components/SubmissionWizard.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/component-wizard/src/components/SubmissionWizard.js b/packages/component-wizard/src/components/SubmissionWizard.js index d4d3d9c35..c5783d65e 100644 --- a/packages/component-wizard/src/components/SubmissionWizard.js +++ b/packages/component-wizard/src/components/SubmissionWizard.js @@ -9,7 +9,11 @@ import { DragDropContext } from 'react-dnd' import styled, { css } from 'styled-components' import HTML5Backend from 'react-dnd-html5-backend' import { Button, Spinner, Steps } from '@pubsweet/ui' -import { selectCollection, selectFragment } from 'xpub-selectors' +import { + selectFragment, + selectCollection, + selectCurrentUser, +} from 'xpub-selectors' import { Redirect } from 'react-router' import { compose, @@ -51,7 +55,6 @@ import { onChange, onSubmit, setInitialValues, validate } from './utils' const Wizard = ({ step, history, - canEdit, journal, prevStep, isEditMode, @@ -60,11 +63,12 @@ const Wizard = ({ handleSubmit, getButtonText, isFilesFetching, + canEditManuscript, isAuthorsFetching, journal: { manuscriptTypes = [] }, ...rest }) => - canEdit ? ( + canEditManuscript ? ( <Root className="wizard-root"> <Steps currentStep={step}> {wizardSteps.map(({ stepTitle }) => ( @@ -130,6 +134,7 @@ export default compose( formValues: getFormValues('submission')(state), submitFailed: hasSubmitFailed('submission')(state), formSyncErrors: getFormSyncErrors('submission')(state), + isAdmin: get(selectCurrentUser(state), 'admin', false), fragment: selectFragment(state, get(match, 'params.version')), collection: selectCollection(state, get(match, 'params.project')), isAuthorsFetching: getAuthorFetching(state) || getAutosaveFetching(state), @@ -183,9 +188,11 @@ export default compose( status: get(collection, 'status', ''), }), ), - withProps(({ status, isLastFragment }) => ({ - canEdit: - isLastFragment && !(status === 'accepted' || status === 'rejected'), + withProps(({ status, isAdmin, isLastFragment }) => ({ + canEditManuscript: + isAdmin && + isLastFragment && + !(status === 'accepted' || status === 'rejected'), })), withHandlers({ getButtonText: ({ isLastStep, isEditMode }) => () => { -- GitLab