From e39e319ed41be1c24fcc93554a32614b35a08588 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Tue, 25 Oct 2016 22:22:12 +0200 Subject: [PATCH] fix cancel add/create toggle --- .../src/component/feature/add-container.jsx | 8 +++++--- .../src/component/feature/edit-container.jsx | 6 ++++-- packages/unleash-frontend-next/src/index.jsx | 7 ++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/unleash-frontend-next/src/component/feature/add-container.jsx b/packages/unleash-frontend-next/src/component/feature/add-container.jsx index 5eac3a3c67..3ece661dcd 100644 --- a/packages/unleash-frontend-next/src/component/feature/add-container.jsx +++ b/packages/unleash-frontend-next/src/component/feature/add-container.jsx @@ -1,4 +1,6 @@ import { connect } from 'react-redux'; +import { hashHistory } from 'react-router'; + import { createFeatureToggles } from '../../store/feature-actions'; import AddComponent from './add-component'; @@ -17,9 +19,9 @@ const prepare = (methods, dispatch) => { } ); - methods.onCancel = () => { - debugger; - window.history.back(); + methods.onCancel = (evt) => { + evt.preventDefault(); + hashHistory.push('/features'); }; methods.addStrategy = (v) => { diff --git a/packages/unleash-frontend-next/src/component/feature/edit-container.jsx b/packages/unleash-frontend-next/src/component/feature/edit-container.jsx index 32051cea69..d707c14d22 100644 --- a/packages/unleash-frontend-next/src/component/feature/edit-container.jsx +++ b/packages/unleash-frontend-next/src/component/feature/edit-container.jsx @@ -1,4 +1,5 @@ import { connect } from 'react-redux'; +import { hashHistory } from 'react-router'; import { requestUpdateFeatureToggle } from '../../store/feature-actions'; import AddComponent from './add-component'; @@ -39,8 +40,9 @@ const prepare = (methods, dispatch) => { } ); - methods.onCancel = () => { - window.history.back(); + methods.onCancel = (evt) => { + evt.preventDefault(); + hashHistory.push('/features'); }; methods.addStrategy = (v) => { diff --git a/packages/unleash-frontend-next/src/index.jsx b/packages/unleash-frontend-next/src/index.jsx index e86be7a31b..a45ca4a3ce 100644 --- a/packages/unleash-frontend-next/src/index.jsx +++ b/packages/unleash-frontend-next/src/index.jsx @@ -1,7 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { Router, Route, IndexRedirect, useRouterHistory } from 'react-router'; -import { createHashHistory } from 'history'; +import { Router, Route, IndexRedirect, hashHistory } from 'react-router'; import { Provider } from 'react-redux'; import thunkMiddleware from 'redux-thunk'; import { createStore, applyMiddleware } from 'redux'; @@ -17,8 +16,6 @@ import CreateStrategies from './page/strategies/create'; import HistoryPage from './page/history'; import Archive from './page/archive'; -const appHistory = useRouterHistory(createHashHistory)({ queryKey: false }); - const unleashStore = createStore( store, applyMiddleware( @@ -28,7 +25,7 @@ const unleashStore = createStore( ReactDOM.render( - +