mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-30 02:32:58 +05:30
#85: drop react-router-redux dependency
This commit is contained in:
parent
2dda41ccce
commit
6f4eb97b48
5
npm-shrinkwrap.json
generated
5
npm-shrinkwrap.json
generated
@ -6172,11 +6172,6 @@
|
||||
"from": "react-router@3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-3.0.5.tgz"
|
||||
},
|
||||
"react-router-redux": {
|
||||
"version": "3.0.0",
|
||||
"from": "react-router-redux@>=3.0.0 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router-redux/-/react-router-redux-3.0.0.tgz"
|
||||
},
|
||||
"react-side-effect": {
|
||||
"version": "1.1.0",
|
||||
"from": "react-side-effect@>=1.1.0 <2.0.0",
|
||||
|
@ -39,7 +39,6 @@
|
||||
"react-motion": "^0.4.0",
|
||||
"react-redux": "^5.0.0",
|
||||
"react-router": "^3.0.0",
|
||||
"react-router-redux": "^3.0.0",
|
||||
"redux": "^3.0.4",
|
||||
"redux-localstorage": "^0.4.1",
|
||||
"redux-thunk": "^2.0.0",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
import { sessionStorage } from 'services/localStorage';
|
||||
import authentication from 'services/api/authentication';
|
||||
@ -124,7 +124,7 @@ export function logoutAll() {
|
||||
|
||||
dispatch(reset());
|
||||
|
||||
dispatch(routeActions.push('/login'));
|
||||
browserHistory.push('/login');
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
import logger from 'services/logger';
|
||||
import localStorage from 'services/localStorage';
|
||||
@ -25,9 +25,9 @@ export { authenticate, logoutAll as logout } from 'components/accounts/actions';
|
||||
*/
|
||||
export function goBack(fallbackUrl = null) {
|
||||
if (history.canGoBack()) {
|
||||
return routeActions.goBack();
|
||||
browserHistory.goBack();
|
||||
} else if (fallbackUrl) {
|
||||
return routeActions.push(fallbackUrl);
|
||||
browserHistory.push(fallbackUrl);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -125,8 +125,10 @@ export function register({
|
||||
username,
|
||||
email
|
||||
}));
|
||||
|
||||
dispatch(needActivation());
|
||||
dispatch(routeActions.push('/activation'));
|
||||
|
||||
browserHistory.push('/activation');
|
||||
})
|
||||
.catch(validationErrorsHandler(dispatch))
|
||||
);
|
||||
|
@ -42,14 +42,14 @@ class ProfilePage extends Component {
|
||||
}
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
import { fetchUserData } from 'components/user/actions';
|
||||
import { create as createPopup } from 'components/ui/popup/actions';
|
||||
import PasswordRequestForm from 'components/profile/passwordRequestForm/PasswordRequestForm';
|
||||
|
||||
export default connect(null, {
|
||||
goToProfile() {
|
||||
return routeActions.push('/');
|
||||
return browserHistory.push('/');
|
||||
},
|
||||
fetchUserData,
|
||||
onSubmit: ({form, sendData}) => (dispatch) => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
import { routeReducer } from 'react-router-redux';
|
||||
|
||||
import auth from 'components/auth/reducer';
|
||||
import user from 'components/user/reducer';
|
||||
import accounts from 'components/accounts/reducer';
|
||||
@ -15,6 +13,5 @@ export default combineReducers({
|
||||
user,
|
||||
accounts,
|
||||
i18n,
|
||||
popup,
|
||||
routing: routeReducer
|
||||
popup
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
import logger from 'services/logger';
|
||||
import localStorage from 'services/localStorage';
|
||||
@ -40,7 +40,8 @@ export default class AuthFlow {
|
||||
if (this.replace) {
|
||||
this.replace(route);
|
||||
}
|
||||
store.dispatch(routeActions[options.replace ? 'replace' : 'push'](route));
|
||||
|
||||
browserHistory[options.replace ? 'replace' : 'push'](route);
|
||||
}
|
||||
|
||||
this.replace = null;
|
||||
|
@ -5,15 +5,11 @@ import { createStore, applyMiddleware, compose } from 'redux';
|
||||
// или даже вообще его не запускать в зависимости от условий
|
||||
import thunk from 'redux-thunk';
|
||||
import persistState from 'redux-localstorage';
|
||||
import { syncHistory } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
import reducers from 'reducers';
|
||||
|
||||
export default function storeFactory() {
|
||||
const reduxRouterMiddleware = syncHistory(browserHistory);
|
||||
const middlewares = applyMiddleware(
|
||||
reduxRouterMiddleware,
|
||||
thunk
|
||||
);
|
||||
const persistStateEnhancer = persistState([
|
||||
|
@ -1,7 +1,7 @@
|
||||
import expect from 'unexpected';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
import logger from 'services/logger';
|
||||
import { InternalServerError } from 'services/request';
|
||||
@ -292,10 +292,12 @@ describe('components/accounts/actions', () => {
|
||||
});
|
||||
|
||||
sinon.stub(authentication, 'logout').named('authentication.logout');
|
||||
sinon.stub(browserHistory, 'push').named('browserHistory.push');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
authentication.logout.restore();
|
||||
browserHistory.push.restore();
|
||||
});
|
||||
|
||||
it('should call logout api method for each account', () => {
|
||||
@ -317,8 +319,8 @@ describe('components/accounts/actions', () => {
|
||||
|
||||
it('should redirect to /login', () =>
|
||||
logoutAll()(dispatch, getState).then(() => {
|
||||
expect(dispatch, 'to have a call satisfying', [
|
||||
routeActions.push('/login')
|
||||
expect(browserHistory.push, 'to have a call satisfying', [
|
||||
'/login'
|
||||
]);
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user