diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index 9f77bdce73bd1b74f7497f6442df8d1964cbabfb..c66b0458956787a52f6002ae661eb10e726a6bee 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -1,24 +1,23 @@ import React from 'react' import { get } from 'lodash' -import { H3, H4 } from '@pubsweet/ui' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' 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 { Tag, Text, Row, - Item, + // Item, IconButton, - ActionLink, + // ActionLink, AuthorTagList, ReviewerBreakdown, } from './' -import { OpenModal } from './modals' +// import { OpenModal } from './modals' const ManuscriptCard = ({ onCardClick, @@ -73,7 +72,7 @@ const ManuscriptCard = ({ {handlingEditor && ( <ReviewerBreakdown fragment={fragment} label="Reviewer Reports" /> )} - {canDelete && ( + {/* {canDelete && ( <Item justify="flex-end" onClick={e => e.stopPropagation()}> <OpenModal confirmAction={onDelete} @@ -88,7 +87,7 @@ const ManuscriptCard = ({ )} </OpenModal> </Item> - )} + )} */} </Row> </MainContainer> <SideNavigation> diff --git a/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js b/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js deleted file mode 100644 index 6ad740fde0799055cbc4a8684935b0e37e8b2511..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/MakeRecommendation/RecommendWizard.js +++ /dev/null @@ -1,97 +0,0 @@ -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 diff --git a/packages/components-faraday/src/components/MakeRecommendation/Recommendation.js b/packages/components-faraday/src/components/MakeRecommendation/Recommendation.js deleted file mode 100644 index 1bb9cb39078746154520a3c5dada612f8ee87385..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/MakeRecommendation/Recommendation.js +++ /dev/null @@ -1,66 +0,0 @@ -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 diff --git a/packages/components-faraday/src/components/MakeRecommendation/StepOne.js b/packages/components-faraday/src/components/MakeRecommendation/StepOne.js deleted file mode 100644 index 1cb644c274d3bf7732c58e245090397fa33f2da6..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/MakeRecommendation/StepOne.js +++ /dev/null @@ -1,55 +0,0 @@ -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) diff --git a/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js b/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js deleted file mode 100644 index c1d1c0e5e1526a27af4499f2de4907026795b146..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js +++ /dev/null @@ -1,214 +0,0 @@ -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 diff --git a/packages/components-faraday/src/components/MakeRecommendation/index.js b/packages/components-faraday/src/components/MakeRecommendation/index.js deleted file mode 100644 index 9eb54e667aef35486ff67219b71d6ea64ea1e4f6..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/MakeRecommendation/index.js +++ /dev/null @@ -1,7 +0,0 @@ -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' diff --git a/packages/components-faraday/src/components/MakeRecommendation/utils.js b/packages/components-faraday/src/components/MakeRecommendation/utils.js deleted file mode 100644 index 69e5b63f12e4b979dba34332a98fa8bec20eed17..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/MakeRecommendation/utils.js +++ /dev/null @@ -1,34 +0,0 @@ -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 -} diff --git a/packages/styleguide/src/webpack-config.js b/packages/styleguide/src/webpack-config.js index 06e77cbf45e00fa48a6975029552b49f4e6d35e8..5b92100e766e6cb19b30a1fbacccef855fa64771 100644 --- a/packages/styleguide/src/webpack-config.js +++ b/packages/styleguide/src/webpack-config.js @@ -12,8 +12,6 @@ module.exports = dir => { /@pubsweet\/[^/]+\/src/, /component-faraday-ui\/src/, /component-modal\/src/, - /component-faraday-selectors\/src/, - /components-faraday\/src/, ] return { devtool: 'cheap-module-source-map',