Skip to content
Snippets Groups Projects

fix(submissionWizzard): Admin should not be able to edit metadata for old versions using the link.

Merged Anca Ursachi requested to merge HIN-1242 into develop
All threads resolved!
2 files
+ 67
50
Compare changes
  • Side-by-side
  • Inline
Files
2
import React, { Fragment } from 'react'
import { get, isNull } from 'lodash'
import { get, isNull, last } from 'lodash'
import { connect } from 'react-redux'
import { th } from '@pubsweet/ui-toolkit'
import { actions } from 'pubsweet-client'
@@ -10,6 +10,7 @@ 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 { Redirect } from 'react-router'
import {
compose,
toClass,
@@ -57,58 +58,66 @@ const Wizard = ({
isFirstStep,
handleSubmit,
getButtonText,
isLastFragment,
isFilesFetching,
isAuthorsFetching,
journal: { manuscriptTypes = [] },
...rest
}) => (
<Root className="wizard-root">
<Steps currentStep={step}>
{wizardSteps.map(({ stepTitle }) => (
<Steps.Step key={stepTitle} title={stepTitle} />
))}
</Steps>
}) =>
isLastFragment ? (
<Root className="wizard-root">
<Steps currentStep={step}>
{wizardSteps.map(({ stepTitle }) => (
<Steps.Step key={stepTitle} title={stepTitle} />
))}
</Steps>
<StepRoot className="wizard-step" step={step}>
{React.createElement(wizardSteps[step].component, {
manuscriptTypes,
journal,
isAuthorsFetching,
...rest,
})}
<Row justify="center" mt={2}>
{(isAuthorsFetching || isFilesFetching) && isLastStep ? (
<Spinner />
) : (
<Fragment>
<Button
data-test-id="submission-back"
mr={1}
onClick={isFirstStep ? history.goBack : prevStep}
>
<IconButton
fontIcon="arrowLeft"
mb={0.1}
paddingBottom={1.2}
paddingRight={0.9}
/>
Back
</Button>
<Button
data-test-id="submission-next"
ml={isFirstStep ? 0 : 1}
onClick={handleSubmit}
primary
>
{getButtonText()}
<IconButton fontIcon="arrowRight" mb={0.1} paddingBottom={0.5} />
</Button>
</Fragment>
)}
</Row>
</StepRoot>
</Root>
)
<StepRoot className="wizard-step" step={step}>
{React.createElement(wizardSteps[step].component, {
manuscriptTypes,
journal,
isAuthorsFetching,
...rest,
})}
<Row justify="center" mt={2}>
{(isAuthorsFetching || isFilesFetching) && isLastStep ? (
<Spinner />
) : (
<Fragment>
<Button
data-test-id="submission-back"
mr={1}
onClick={isFirstStep ? history.goBack : prevStep}
>
<IconButton
fontIcon="arrowLeft"
mb={0.1}
paddingBottom={1.2}
paddingRight={0.9}
/>
Back
</Button>
<Button
data-test-id="submission-next"
ml={isFirstStep ? 0 : 1}
onClick={handleSubmit}
primary
>
{getButtonText()}
<IconButton
fontIcon="arrowRight"
mb={0.1}
paddingBottom={0.5}
/>
</Button>
</Fragment>
)}
</Row>
</StepRoot>
</Root>
) : (
<Redirect to="/404" />
)
// #endregion
// #region export
@@ -157,7 +166,9 @@ export default compose(
({
step,
location,
fragment,
formValues,
collection,
submitFailed,
formSyncErrors,
authorEditIndex,
@@ -176,6 +187,8 @@ export default compose(
authorsError:
(submitFailed && get(formSyncErrors, 'authors', '')) ||
reduxAuthorError,
isLastFragment:
get(fragment, 'id', '') === last(get(collection, 'fragments', [])),
}),
),
withHandlers({