From eb5e78390efe60bd2db26f834733d2c4ba01a321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Wed, 8 Feb 2017 21:42:21 +0000 Subject: [PATCH] handle deprecation of transitionTo --- .../src/containers/new-project/billing.js | 4 +-- .../src/containers/new-project/new-billing.js | 4 +-- .../src/containers/new-project/new-project.js | 10 +++--- frontend/src/state/thunks/app.js | 19 +--------- frontend/test/thunks/app.js | 35 ------------------- 5 files changed, 10 insertions(+), 62 deletions(-) delete mode 100644 frontend/test/thunks/app.js diff --git a/frontend/src/containers/new-project/billing.js b/frontend/src/containers/new-project/billing.js index 48f689e5..b5081816 100644 --- a/frontend/src/containers/new-project/billing.js +++ b/frontend/src/containers/new-project/billing.js @@ -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 ( { } = 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 ( diff --git a/frontend/src/containers/new-project/new-project.js b/frontend/src/containers/new-project/new-project.js index 77a8b22e..89574e90 100644 --- a/frontend/src/containers/new-project/new-project.js +++ b/frontend/src/containers/new-project/new-project.js @@ -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 ( { 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 diff --git a/frontend/src/state/thunks/app.js b/frontend/src/state/thunks/app.js index d343b63e..f053ebf7 100644 --- a/frontend/src/state/thunks/app.js +++ b/frontend/src/state/thunks/app.js @@ -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 = {}; diff --git a/frontend/test/thunks/app.js b/frontend/test/thunks/app.js deleted file mode 100644 index f26241d8..00000000 --- a/frontend/test/thunks/app.js +++ /dev/null @@ -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); -});