Skip to content
Snippets Groups Projects
Commit 5fe97fe0 authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

Merge branch 'HIN-1242' into 'develop'

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

See merge request !212
parents 66894936 ab4e04a0
No related branches found
No related tags found
3 merge requests!222Sprint #26,!217Sprint #26,!212fix(submissionWizzard): Admin should not be able to edit metadata for old versions using the link.
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({
......
......@@ -13,9 +13,9 @@ const NotFound = ({ history }) => (
The page you are looking for might have been removed, had its name
changed, or is temporarily unavailable.
</H3>
<Button onClick={() => history.push('/')} primary>
<RedirectButton onClick={() => history.push('/')} primary>
Go to dashboard
</Button>
</RedirectButton>
</Root>
)
......@@ -26,6 +26,10 @@ const Root = styled.div`
text-align: center;
width: 90vw;
`
const RedirectButton = styled(Button)`
display: inline-flex;
align-self: center;
`
const H2 = styled.h2`
font-size: ${th('fontSizeHeading2')};
`
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment