Skip to content
Snippets Groups Projects
Commit 1254674e authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

fix(styleguide): fix buggy imports

parent cf22ee4c
No related branches found
No related tags found
1 merge request!43Sprint #19
import React from 'react' import React from 'react'
import { get } from 'lodash' import { get } from 'lodash'
import { H3, H4 } from '@pubsweet/ui'
import styled from 'styled-components' import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
import { withJournal } from 'xpub-journal' import { withJournal } from 'xpub-journal'
import { DateParser } from 'pubsweet-components-faraday/src/components' import { H3, H4, DateParser } from '@pubsweet/ui'
import { compose, withHandlers, setDisplayName, withProps } from 'recompose' import { compose, withHandlers, setDisplayName, withProps } from 'recompose'
import { import {
Tag, Tag,
Text, Text,
Row, Row,
Item, // Item,
IconButton, IconButton,
ActionLink, // ActionLink,
AuthorTagList, AuthorTagList,
ReviewerBreakdown, ReviewerBreakdown,
} from './' } from './'
import { OpenModal } from './modals' // import { OpenModal } from './modals'
const ManuscriptCard = ({ const ManuscriptCard = ({
onCardClick, onCardClick,
...@@ -73,7 +72,7 @@ const ManuscriptCard = ({ ...@@ -73,7 +72,7 @@ const ManuscriptCard = ({
{handlingEditor && ( {handlingEditor && (
<ReviewerBreakdown fragment={fragment} label="Reviewer Reports" /> <ReviewerBreakdown fragment={fragment} label="Reviewer Reports" />
)} )}
{canDelete && ( {/* {canDelete && (
<Item justify="flex-end" onClick={e => e.stopPropagation()}> <Item justify="flex-end" onClick={e => e.stopPropagation()}>
<OpenModal <OpenModal
confirmAction={onDelete} confirmAction={onDelete}
...@@ -88,7 +87,7 @@ const ManuscriptCard = ({ ...@@ -88,7 +87,7 @@ const ManuscriptCard = ({
)} )}
</OpenModal> </OpenModal>
</Item> </Item>
)} )} */}
</Row> </Row>
</MainContainer> </MainContainer>
<SideNavigation> <SideNavigation>
......
import React from 'react'
import { get } from 'lodash'
import { Icon } from '@pubsweet/ui'
import { connect } from 'react-redux'
import styled from 'styled-components'
import { actions } from 'pubsweet-client'
import { compose, withState, withHandlers } from 'recompose'
import { getFormValues, reset as resetForm } from 'redux-form'
import { FormItems } from '../UIComponents'
import { StepOne, StepTwo, utils } from './'
import {
createRecommendation,
selectReviewRecommendations,
} from '../../redux/recommendations'
const RecommendWizard = ({
step,
decision,
nextStep,
prevStep,
closeModal,
submitForm,
...rest
}) => (
<FormItems.RootContainer>
<IconButton onClick={closeModal}>
<Icon primary>x</Icon>
</IconButton>
{step === 0 && (
<StepOne
disabled={!decision}
hideModal={closeModal}
onSubmit={nextStep}
{...rest}
/>
)}
{step === 1 && (
<StepTwo decision={decision} goBack={prevStep} onSubmit={submitForm} />
)}
</FormItems.RootContainer>
)
export default compose(
connect(
(state, { fragmentId }) => ({
decision: get(getFormValues('recommendation')(state), 'decision'),
reviews: selectReviewRecommendations(state, fragmentId),
}),
{
resetForm,
createRecommendation,
getFragments: actions.getFragments,
getCollections: actions.getCollections,
},
),
withState('step', 'changeStep', 0),
withHandlers({
nextStep: ({ changeStep }) => () => changeStep(s => s + 1),
prevStep: ({ changeStep }) => () => changeStep(s => (s === 0 ? 0 : s - 1)),
closeModal: ({ hideModal, resetForm }) => () => {
hideModal()
resetForm('recommendation')
},
submitForm: ({
showModal,
hideModal,
resetForm,
fragmentId,
collectionId,
getFragments,
getCollections,
createRecommendation,
}) => values => {
const recommendation = utils.parseRecommendationValues(values)
createRecommendation(collectionId, fragmentId, recommendation).then(r => {
resetForm('recommendation')
showModal({
title: 'Recommendation sent',
cancelText: 'OK',
onCancel: () => {
getCollections()
getFragments()
hideModal()
},
})
})
},
}),
)(RecommendWizard)
// #region styled components
const IconButton = styled.div`
align-self: flex-end;
cursor: pointer;
`
// #endregion
import React from 'react'
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
import { compose, withHandlers } from 'recompose'
import {
ConfirmationModal,
withModal,
} from 'pubsweet-component-modal/src/components'
import { RecommendWizard } from './'
const Recommendation = ({ showFirstStep }) => (
<Root onClick={showFirstStep}>Make recommendation</Root>
)
const SHOW_WIZARD = 'SHOW_WIZARD'
const ModalComponent = ({ type, ...rest }) => {
switch (type) {
case SHOW_WIZARD:
return <RecommendWizard {...rest} />
default:
return <ConfirmationModal {...rest} />
}
}
export default compose(
withModal(props => ({
modalComponent: ModalComponent,
})),
withHandlers({
showFirstStep: ({
status,
showModal,
hideModal,
fragmentId,
collectionId,
}) => () => {
showModal({
status,
hideModal,
fragmentId,
collectionId,
type: SHOW_WIZARD,
})
},
}),
)(Recommendation)
// #region styled components
const Root = styled.div`
align-items: center;
background-color: ${th('colorPrimary')};
color: ${th('colorTextReverse')};
cursor: pointer;
display: flex;
font-family: ${th('fontInterface')};
font-size: ${th('fontSizeBaseSmall')};
height: calc(${th('subGridUnit')} * 5);
justify-content: center;
min-width: 200px;
padding: 0 calc(${th('subGridUnit')} * 2);
text-transform: uppercase;
white-space: nowrap;
`
// #endregion
import React from 'react'
import { reduxForm } from 'redux-form'
import { isEmpty } from 'lodash'
import { RadioGroup, ValidatedField, Button } from '@pubsweet/ui'
import { utils } from './'
import { FormItems } from '../UIComponents'
const { Row, Title, RowItem, RootContainer, CustomRadioGroup } = FormItems
const StepOne = ({ hideModal, disabled, onSubmit, reviews }) => (
<RootContainer>
<Title>Recommendation for Next Phase</Title>
<Row>
<RowItem>
<ValidatedField
component={input => (
<CustomRadioGroup
className="custom-radio-group"
justify="space-between"
>
<RadioGroup
name="decision"
options={
!isEmpty(reviews)
? utils.recommendationOptions
: utils.recommendationOptions.slice(1)
}
{...input}
/>
</CustomRadioGroup>
)}
name="decision"
/>
</RowItem>
</Row>
<Row>
<RowItem centered>
<Button onClick={hideModal}>Cancel</Button>
</RowItem>
<RowItem centered>
<Button disabled={disabled} onClick={onSubmit} primary>
Next
</Button>
</RowItem>
</Row>
</RootContainer>
)
export default reduxForm({
form: 'recommendation',
destroyOnUnmount: false,
enableReinitialize: false,
forceUnregisterOnUnmount: true,
})(StepOne)
import React, { Fragment } from 'react'
import { capitalize } from 'lodash'
import { connect } from 'react-redux'
import { th } from '@pubsweet/ui-toolkit'
import { required } from 'xpub-validators'
import styled, { css } from 'styled-components'
import { reduxForm, change as changeForm } from 'redux-form'
import { compose, withState, withHandlers } from 'recompose'
import { Icon, Button, Spinner, RadioGroup, ValidatedField } from '@pubsweet/ui'
import { utils } from './'
import { FormItems } from '../UIComponents'
const {
Row: FormRow,
Err,
Label,
Title,
RowItem,
TextAreaField,
RootContainer,
FormContainer,
CustomRadioGroup,
} = FormItems
const Form = RootContainer.withComponent(FormContainer)
const StepTwo = ({
goBack,
hasNote,
decision,
showNote,
removeNote,
isFetching,
handleSubmit,
recommendationError,
}) => (
<Form onSubmit={handleSubmit}>
<Title>
{decision !== 'revise'
? `Recommandation to ${capitalize(decision)}`
: `Request a revision from Author`}
</Title>
{decision !== 'revise' ? (
<Fragment>
<Row>
<RowItem vertical>
<Label>Message for Editor in Chief (optional)</Label>
<ValidatedField component={TextAreaField} name="message.eic" />
</RowItem>
</Row>
<Row>
<RowItem vertical>
<Label>Message for Author (optional)</Label>
<ValidatedField component={TextAreaField} name="message.author" />
</RowItem>
</Row>
{recommendationError && (
<Row>
<RowItem centered>
<Err>{recommendationError}</Err>
</RowItem>
</Row>
)}
</Fragment>
) : (
<Fragment>
<Row>
<RowItem vertical>
<Label>REVISION TYPE</Label>
<ValidatedField
component={input => (
<CustomRadioGroup justify="flex-start">
<RadioGroup
name="revision.revision-type"
{...input}
options={utils.revisionOptions}
/>
</CustomRadioGroup>
)}
name="revision.revisionType"
validate={[required]}
/>
</RowItem>
</Row>
<Row>
<RowItem vertical>
<Label>
REASON & DETAILS
<SubLabel>Required</SubLabel>
</Label>
<ValidatedField
component={TextAreaField}
name="revision.reason"
validate={[required]}
/>
</RowItem>
</Row>
{!hasNote ? (
<Row>
<RowItem>
<TextButton onClick={showNote}>Add Internal Note</TextButton>
<HintText>Not shared with author</HintText>
</RowItem>
</Row>
) : (
<Fragment>
<Row noMargin>
<RowItem flex={2}>
<Label>
INTERNAL NOTE
<SubLabel>Not shared with author</SubLabel>
</Label>
</RowItem>
<CustomRowItem onClick={removeNote}>
<IconButton>
<Icon primary>x</Icon>
</IconButton>
<TextButton>Remove</TextButton>
</CustomRowItem>
</Row>
<Row noMargin>
<RowItem>
<ValidatedField
component={TextAreaField}
name="revision.internal-note"
/>
</RowItem>
</Row>
</Fragment>
)}
</Fragment>
)}
<Row>
<RowItem centered>
<Button onClick={goBack}>Back</Button>
</RowItem>
<RowItem centered>
{isFetching ? (
<Spinner size={3} />
) : (
<Button primary type="submit">
Submit
</Button>
)}
</RowItem>
</Row>
</Form>
)
export default compose(
connect(null, { changeForm }),
withState('hasNote', 'changeHasNote', false),
withHandlers({
showNote: ({ changeHasNote }) => () => {
changeHasNote(true)
},
removeNote: ({ changeHasNote, changeForm }) => () => {
changeHasNote(false)
changeForm('recommendation', 'revision.internal-note', '')
},
}),
reduxForm({
form: 'recommendation',
destroyOnUnmount: false,
forceUnregisterOnUnmount: true,
}),
)(StepTwo)
// #region styled components
const defaultText = css`
color: ${th('colorPrimary')};
font-family: ${th('fontInterface')};
font-size: ${th('fontSizeBaseSmall')};
`
const SubLabel = styled.span`
${defaultText};
font-style: oblique;
margin-left: ${th('subGridUnit')};
text-transform: capitalize;
`
const TextButton = styled.span`
${defaultText};
cursor: pointer;
margin-right: ${th('subGridUnit')};
text-decoration: underline;
`
const HintText = styled.span`
${defaultText};
font-style: oblique;
`
const IconButton = styled.div`
display: flex;
justify-content: center;
`
const CustomRowItem = RowItem.extend`
align-items: center;
justify-content: flex-end;
& > div {
justify-content: flex-end;
}
`
const Row = FormRow.extend`
div[role='alert'] {
margin-top: 0;
}
`
// #endregion
import * as utils from './utils'
export { utils }
export { default as StepOne } from './StepOne'
export { default as StepTwo } from './StepTwo'
export { default as Recommendation } from './Recommendation'
export { default as RecommendWizard } from './RecommendWizard'
import { omit } from 'lodash'
export const recommendationOptions = [
{ value: 'publish', label: 'Publish' },
{ value: 'reject', label: 'Reject' },
{ value: 'revise', label: 'Request revision' },
]
export const revisionOptions = [
{ value: 'minor', label: 'Minor' },
{ value: 'major', label: 'Major' },
]
export const parseMessages = (messages = {}) => {
const publicKeys = ['author', 'reason']
return Object.entries(messages).map(([k, v]) => ({
content: v,
public: publicKeys.includes(k),
}))
}
export const parseRecommendationValues = ({ decision, message, revision }) => {
const recommendation = {
recommendationType: 'editorRecommendation',
}
if (decision !== 'revise') {
recommendation.recommendation = decision
recommendation.comments = parseMessages(message)
} else {
recommendation.recommendation = revision.revisionType
recommendation.comments = parseMessages(omit(revision, 'revisionType'))
}
return recommendation
}
...@@ -12,8 +12,6 @@ module.exports = dir => { ...@@ -12,8 +12,6 @@ module.exports = dir => {
/@pubsweet\/[^/]+\/src/, /@pubsweet\/[^/]+\/src/,
/component-faraday-ui\/src/, /component-faraday-ui\/src/,
/component-modal\/src/, /component-modal\/src/,
/component-faraday-selectors\/src/,
/components-faraday\/src/,
] ]
return { return {
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
......
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