handle deprecation of transitionTo
This commit is contained in:
parent
935ab4a749
commit
eb5e78390e
@ -34,11 +34,11 @@ const Billing = (props) => {
|
||||
values,
|
||||
org
|
||||
});
|
||||
router.transitionTo(`/${org.id}/projects`);
|
||||
router.push(`/${org.id}/projects`);
|
||||
};
|
||||
|
||||
const onNewBilling = (evt) =>
|
||||
router.transitionTo(`/${org.id}/new-project/new-billing`);
|
||||
router.push(`/${org.id}/new-project/new-billing`);
|
||||
|
||||
return (
|
||||
<BillingForm
|
||||
|
@ -27,14 +27,14 @@ const NewBilling = (props) => {
|
||||
} = props;
|
||||
|
||||
const onBack = (evt) =>
|
||||
router.transitionTo(`/${org.id}/new-project/billing`);
|
||||
router.push(`/${org.id}/new-project/billing`);
|
||||
|
||||
const onSubmit = (values) => {
|
||||
handleNewProject({
|
||||
values,
|
||||
org
|
||||
});
|
||||
router.transitionTo(`/${org.id}/projects`);
|
||||
router.push(`/${org.id}/projects`);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -1,7 +1,7 @@
|
||||
const React = require('react');
|
||||
const ReactRedux = require('react-redux');
|
||||
const selectors = require('@state/selectors');
|
||||
|
||||
const selectors = require('@state/selectors');
|
||||
const PropTypes = require('@root/prop-types');
|
||||
const NewProjectForm = require('@components/new-project');
|
||||
|
||||
@ -17,14 +17,14 @@ const NewProject = (props) => {
|
||||
|
||||
const {
|
||||
org,
|
||||
router
|
||||
push
|
||||
} = props;
|
||||
|
||||
const onCancel = (values) =>
|
||||
router.transitionTo(`/${org.id}/projects`);
|
||||
push(`/${org.id}/projects`);
|
||||
|
||||
const onSubmit = (values) =>
|
||||
router.transitionTo(`/${org.id}/new-project/billing`);
|
||||
push(`/${org.id}/new-project/billing`);
|
||||
|
||||
return (
|
||||
<NewProjectForm
|
||||
@ -37,7 +37,7 @@ const NewProject = (props) => {
|
||||
|
||||
NewProject.propTypes = {
|
||||
org: PropTypes.org.isRequired,
|
||||
router: React.PropTypes.object
|
||||
push: React.PropTypes.func
|
||||
};
|
||||
// TODO we'll need to know whether there any cards
|
||||
// otherwise go to new billing straight away
|
||||
|
@ -1,18 +1 @@
|
||||
const transitionTo = (pathname) => (dispatch, getState) => {
|
||||
const {
|
||||
app: {
|
||||
router: {
|
||||
transitionTo
|
||||
}
|
||||
}
|
||||
} = getState();
|
||||
|
||||
return dispatch({
|
||||
type: 'TRANSITION_TO',
|
||||
PAYLOAD: transitionTo(pathname)
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
transitionTo
|
||||
};
|
||||
module.exports = {};
|
||||
|
@ -1,35 +0,0 @@
|
||||
const mock = require('simple-mock');
|
||||
const test = require('ava');
|
||||
|
||||
const thunks = require('@state/thunks');
|
||||
|
||||
const {
|
||||
transitionTo
|
||||
} = thunks;
|
||||
|
||||
test('transitionTo should dispatch', (t) => {
|
||||
const pathname = '/hello';
|
||||
|
||||
const state = {
|
||||
app: {
|
||||
router: {
|
||||
transitionTo: mock.spy((pathname) => pathname)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const dispatch = mock.spy(({
|
||||
PAYLOAD
|
||||
}) => {
|
||||
t.deepEqual(PAYLOAD, pathname);
|
||||
});
|
||||
|
||||
const getState = () => state;
|
||||
|
||||
transitionTo(pathname)(dispatch, getState);
|
||||
|
||||
t.deepEqual(dispatch.called, true);
|
||||
t.deepEqual(dispatch.callCount, 1);
|
||||
t.deepEqual(state.app.router.transitionTo.called, true);
|
||||
t.deepEqual(state.app.router.transitionTo.callCount, 1);
|
||||
});
|
Loading…
Reference in New Issue
Block a user