diff --git a/packages/component-faraday-ui/src/ActionLink.js b/packages/component-faraday-ui/src/ActionLink.js index 9f27cec30d1ba8e1584fed2f753653c952e23f77..05ad25cd28ff0ec15c333469b13f6ec6c16e9402 100644 --- a/packages/component-faraday-ui/src/ActionLink.js +++ b/packages/component-faraday-ui/src/ActionLink.js @@ -78,7 +78,7 @@ const Root = styled.div` ${marginHelper}; ${paddingHelper}; - height: max-content; + height: ${props => (props.height ? `${props.height}px` : 'max-content')}; width: max-content; & span { diff --git a/packages/component-faraday-ui/src/ManuscriptCard.js b/packages/component-faraday-ui/src/ManuscriptCard.js index ae360b12e7ae2b3220528f7e771b5cac322bd377..17e9e176354403406b6066cf5b09f589a9a93cfa 100644 --- a/packages/component-faraday-ui/src/ManuscriptCard.js +++ b/packages/component-faraday-ui/src/ManuscriptCard.js @@ -24,6 +24,7 @@ import { OpenModal } from './modals' const ManuscriptCard = ({ onDelete, canDelete, + isFetching, onCardClick, canViewReports, fragment = {}, @@ -87,16 +88,17 @@ const ManuscriptCard = ({ <Item justify="flex-end" onClick={e => e.stopPropagation()}> <OpenModal confirmText="Delete" + isFetching={isFetching} modalKey={`delete-${collId}`} onConfirm={onDelete} title="Are you sure you want to delete this submission?" > - {onClickEvent => ( + {showModal => ( <ActionLink + height={16} icon="trash" - onClick={onClickEvent} + onClick={showModal} size="small" - style={{ height: 16 }} > Delete </ActionLink> diff --git a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js index 6b6c3ae22a1f1c4f665e31ca919ea6c0f810bd02..ace1a76edeca379d7beb733515e56ae95d00e23a 100644 --- a/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js +++ b/packages/component-faraday-ui/src/submissionRevision/SubmitRevision.js @@ -90,6 +90,4 @@ const Root = styled.div` padding: calc(${th('gridUnit')} * 2); ` -export default reduxForm({ form: 'revision', destroyOnUnmount: false })( - SubmitRevision, -) +export default reduxForm({ form: 'revision' })(SubmitRevision) diff --git a/packages/components-faraday/src/components/Dashboard/Dashboard.js b/packages/components-faraday/src/components/Dashboard/Dashboard.js index 0c106443fd6d2da18ebbdce662c5d738bc6b8dd8..a03dce5045de7b34967ca35b9bc7c8d7ec24180c 100644 --- a/packages/components-faraday/src/components/Dashboard/Dashboard.js +++ b/packages/components-faraday/src/components/Dashboard/Dashboard.js @@ -4,12 +4,13 @@ import { compose, withProps } from 'recompose' import { DashboardItems, DashboardFilters } from './' const Dashboard = ({ - deleteProject, + journal, + isFetching, dashboardItems, + deleteCollection, getFilterOptions, changeFilterValue, getDefaultFilterValue, - journal, }) => ( <Fragment> <DashboardFilters @@ -17,7 +18,11 @@ const Dashboard = ({ getDefaultFilterValue={getDefaultFilterValue} getFilterOptions={getFilterOptions} /> - <DashboardItems deleteProject={deleteProject} list={dashboardItems} /> + <DashboardItems + deleteCollection={deleteCollection} + isFetching={isFetching} + list={dashboardItems} + /> </Fragment> ) diff --git a/packages/components-faraday/src/components/Dashboard/DashboardItems.js b/packages/components-faraday/src/components/Dashboard/DashboardItems.js index f5a5e24df3fff52a255f0a70b427cec11726a782..72d16891c5a40b967a4f7e5491dd9180c05e186d 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardItems.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardItems.js @@ -5,9 +5,9 @@ import { connect } from 'react-redux' import styled from 'styled-components' import { th } from '@pubsweet/ui-toolkit' import { withRouter } from 'react-router-dom' -import { compose, setDisplayName, withHandlers, withProps } from 'recompose' import { ManuscriptCard, Row } from 'pubsweet-component-faraday-ui' import { canViewReports } from 'pubsweet-component-faraday-selectors' +import { compose, setDisplayName, withHandlers, withProps } from 'recompose' const DashboardItem = compose( connect((state, { collection }) => ({ @@ -18,7 +18,13 @@ const DashboardItem = compose( })), )(ManuscriptCard) -const DashboardItems = ({ list, onClick, deleteProject, canViewReports }) => ( +const DashboardItems = ({ + list, + onClick, + isFetching, + canViewReports, + deleteCollection, +}) => ( <Root data-test-id="dashboard-list-items"> {!list.length ? ( <Row justify="center" mt={4}> @@ -29,9 +35,10 @@ const DashboardItems = ({ list, onClick, deleteProject, canViewReports }) => ( <HideLoading key={collection.id}> <DashboardItem collection={collection} + isFetching={isFetching} key={collection.id} onClick={onClick} - onDelete={() => deleteProject(collection)} + onDelete={deleteCollection(collection)} /> </HideLoading> )) diff --git a/packages/components-faraday/src/components/Dashboard/DashboardPage.js b/packages/components-faraday/src/components/Dashboard/DashboardPage.js index eda5819b44ca04a7b91afc876a6cec42bba2569c..2aadccce522ce995b4387b64b0f1b891433befe9 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardPage.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardPage.js @@ -4,8 +4,9 @@ import { actions } from 'pubsweet-client' import { withJournal } from 'xpub-journal' import { ConnectPage } from 'xpub-connect' import { withRouter } from 'react-router-dom' -import { compose, withContext } from 'recompose' import { selectCurrentUser } from 'xpub-selectors' +import { compose, withHandlers, withContext } from 'recompose' +import { handleError, withFetching } from 'pubsweet-component-faraday-ui' import { getUserPermissions, @@ -32,13 +33,13 @@ export default compose( userPermissions, } }, - dispatch => ({ - deleteProject: collection => - dispatch(actions.deleteCollection(collection)), - }), + { + deleteCollection: actions.deleteCollection, + }, ), withRouter, withJournal, + withFetching, withFiltersHOC({ priority: priorityFilter, order: orderFilter, @@ -50,4 +51,23 @@ export default compose( }, ({ journal, currentUser }) => ({ journal, currentUser }), ), + withHandlers({ + deleteCollection: ({ setFetching, deleteCollection }) => collection => ({ + hideModal, + setModalError, + }) => { + setFetching(true) + deleteCollection(collection) + .then(() => { + setFetching(false) + hideModal() + }) + // again, the error is not being thrown from deleteCollection action and + // the catch is never run + .catch(err => { + setFetching(false) + handleError(setModalError)(err) + }) + }, + }), )(Dashboard) diff --git a/packages/components-faraday/src/components/SignUp/SignUpStep0.js b/packages/components-faraday/src/components/SignUp/SignUpStep0.js index a158b73643dcabe91d17db7779a17f9f67ffae42..4cb4f094d06d1585a6a814e4cf1fda0af3b3d9bf 100644 --- a/packages/components-faraday/src/components/SignUp/SignUpStep0.js +++ b/packages/components-faraday/src/components/SignUp/SignUpStep0.js @@ -4,7 +4,6 @@ import { reduxForm } from 'redux-form' import { get, isUndefined } from 'lodash' import { required as requiredValidator } from 'xpub-validators' import { Menu, Button, Checkbox, TextField, ValidatedField } from '@pubsweet/ui' -import styled from 'styled-components' import { Row, @@ -27,9 +26,6 @@ const AgreeCheckbox = ({ value, onChange }) => ( </Text> </Row> ) -const ValidationRow = styled(Row)` - justify-content: left; -` const Step0 = ({ type, @@ -102,13 +98,13 @@ const Step0 = ({ </Item> </Row> - <ValidationRow data-test-id="sign-up-agree-TC" mb={2}> + <Row data-test-id="sign-up-agree-TC" justify="flex-start" mb={2}> <ValidatedField component={AgreeCheckbox} name="agreeTC" validate={[requiredValidator]} /> - </ValidationRow> + </Row> <Row> <Text secondary small> @@ -127,6 +123,7 @@ const Step0 = ({ data-test-id="sign-up-proceed-to-set-email-and-password" mt={4} onClick={handleSubmit} + primary > PROCEED TO SET {type === 'signup' && 'EMAIL AND'} PASSWORD </Button> diff --git a/packages/components-faraday/src/components/SignUp/SignUpStep1.js b/packages/components-faraday/src/components/SignUp/SignUpStep1.js index 2b704892b11d80f05b88ea4007b45d5ce8e9e0a5..21177e76eb9fa5006d88c02b432cf0057e3fa2a5 100644 --- a/packages/components-faraday/src/components/SignUp/SignUpStep1.js +++ b/packages/components-faraday/src/components/SignUp/SignUpStep1.js @@ -99,7 +99,7 @@ const Step1 = ({ {type === 'forgotPassword' && <ForgotEmailForm />} {type === 'invite' && <InviteForm />} {error && ( - <Row justify="flex-start" mb={1}> + <Row justify="flex-start" mb={2}> <Text error>{error}</Text> </Row> )}