1
0
mirror of https://github.com/yldio/copilot.git synced 2024-09-21 05:43:52 +03:00

handle deprecation of transitionTo

This commit is contained in:
Sérgio Ramos 2017-02-08 21:42:21 +00:00 committed by Sérgio Ramos
parent 935ab4a749
commit eb5e78390e
5 changed files with 10 additions and 62 deletions

View File

@ -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

View File

@ -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 (

View File

@ -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

View File

@ -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 = {};

View File

@ -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);
});