From eac347493046a45f34d9fe04df0e0bbfac451fed Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Wed, 6 Apr 2022 13:10:22 +0200 Subject: [PATCH] WIP2 --- src/helpers/AuthToken/AuthToken.js | 10 +- src/routes.js | 287 ++++++++++++++--------------- src/start-client.jsx | 8 +- src/store.js | 13 +- 4 files changed, 147 insertions(+), 171 deletions(-) diff --git a/src/helpers/AuthToken/AuthToken.js b/src/helpers/AuthToken/AuthToken.js index 74cb20ce20..e5f2c5c3a7 100644 --- a/src/helpers/AuthToken/AuthToken.js +++ b/src/helpers/AuthToken/AuthToken.js @@ -7,7 +7,6 @@ import Cookies from 'universal-cookie'; import jwtDecode from 'jwt-decode'; import { loginRenew } from '@plone/volto/actions'; -import { push } from 'connected-react-router'; /** * Get auth token method (does not work in SSR) @@ -79,14 +78,7 @@ export function persistAuthToken(store, req) { ) { store.dispatch(loginRenew()); } else { - // Logout - store.dispatch( - push( - `/logout?return_url=${ - store.getState().router.location.pathname - }`, - ), - ); + // TODO: issue Logout } } }, exp); diff --git a/src/routes.js b/src/routes.js index 19a95e213d..a94e1ffb3d 100644 --- a/src/routes.js +++ b/src/routes.js @@ -83,11 +83,6 @@ export const multilingualRoutes = [ ]; export const defaultRoutes = [ - // { - // path: '/', - // element: (props) => 'hello', - // exact: true, - // }, { index: true, element: }, { path: 'login', @@ -97,141 +92,141 @@ export const defaultRoutes = [ path: '/logout', element: , }, - // { - // path: '/sitemap', - // element: , - // }, - // { - // path: '/search', - // element: , - // }, - // { - // path: '/contact-form', - // element: , - // }, - // { - // path: '/controlpanel', - // exact: true, - // element: , - // }, - // { - // path: '/controlpanel/dexterity-types/:id/layout', - // element: , - // }, - // { - // path: '/controlpanel/dexterity-types/:id/schema', - // element: , - // }, - // { - // path: '/controlpanel/dexterity-types/:id', - // element: , - // }, - // { - // path: '/controlpanel/dexterity-types', - // element: , - // }, - // { - // path: '/controlpanel/addons', - // element: , - // }, - // { - // path: '/controlpanel/database', - // element: , - // }, - // { - // path: '/controlpanel/moderate-comments', - // element: , - // }, - // { - // path: '/controlpanel/users', - // element: , - // }, - // { - // path: '/controlpanel/groups', - // element: , - // }, - // { - // path: '/controlpanel/:id', - // element: , - // }, - // { - // path: '/change-password', - // element: , - // }, - // { - // path: '/add', - // element: , - // }, - // { - // path: '/edit', - // element: , - // }, - // { - // path: '/contents', - // element: , - // }, - // { - // path: '/sharing', - // element: , - // }, - // { - // path: '/**/add', - // element: , - // }, - // { - // path: '/**/create-translation', - // element: , - // }, - // { - // path: '/**/contents', - // element: , - // }, - // { - // path: '/**/sharing', - // element: , - // }, - // { - // path: '/**/delete', - // element: , - // }, - // { - // path: '/**/diff', - // element: , - // }, - // { - // path: '/**/edit', - // element: , - // }, - // { - // path: '/**/history', - // element: , - // }, - // { - // path: '/**/sharing', - // element: , - // }, - // { - // path: '/**/manage-translations', - // element: , - // }, - // { - // path: '/**/login', - // element: , - // }, - // { - // path: '/register', - // element: , - // }, - // { - // path: '/password-reset', - // element: , - // exact: true, - // }, - // { - // path: '/password-reset/:token', - // element: , - // exact: true, - // }, + { + path: '/sitemap', + element: , + }, + { + path: '/search', + element: , + }, + { + path: '/contact-form', + element: , + }, + { + path: '/controlpanel', + exact: true, + element: , + }, + { + path: '/controlpanel/dexterity-types/:id/layout', + element: , + }, + { + path: '/controlpanel/dexterity-types/:id/schema', + element: , + }, + { + path: '/controlpanel/dexterity-types/:id', + element: , + }, + { + path: '/controlpanel/dexterity-types', + element: , + }, + { + path: '/controlpanel/addons', + element: , + }, + { + path: '/controlpanel/database', + element: , + }, + { + path: '/controlpanel/moderate-comments', + element: , + }, + { + path: '/controlpanel/users', + element: , + }, + { + path: '/controlpanel/groups', + element: , + }, + { + path: '/controlpanel/:id', + element: , + }, + { + path: '/change-password', + element: , + }, + { + path: '/add', + element: , + }, + { + path: '/edit', + element: , + }, + { + path: '/contents', + element: , + }, + { + path: '/sharing', + element: , + }, + { + path: '/**/add', + element: , + }, + { + path: '/**/create-translation', + element: , + }, + { + path: '/**/contents', + element: , + }, + { + path: '/**/sharing', + element: , + }, + { + path: '/**/delete', + element: , + }, + { + path: '/**/diff', + element: , + }, + { + path: '/**/edit', + element: , + }, + { + path: '/**/history', + element: , + }, + { + path: '/**/sharing', + element: , + }, + { + path: '/**/manage-translations', + element: , + }, + { + path: '/**/login', + element: , + }, + { + path: '/register', + element: , + }, + { + path: '/password-reset', + element: , + exact: true, + }, + { + path: '/password-reset/:token', + element: , + exact: true, + }, { path: '*', element: , @@ -248,14 +243,14 @@ const routes = [ path: '/', element: , children: [ - // // redirect to external links if path is in blacklist - // ...(config.settings?.externalRoutes || []).map((route) => ({ - // ...route.match, - // element: , - // })), + // redirect to external links if path is in blacklist + ...(config.settings?.externalRoutes || []).map((route) => ({ + ...route.match, + element: , + })), // addon routes have a higher priority then default routes ...(config.addonRoutes || []), - // ...((config.settings?.isMultilingual && multilingualRoutes) || []), + ...((config.settings?.isMultilingual && multilingualRoutes) || []), ...defaultRoutes, ], }, diff --git a/src/start-client.jsx b/src/start-client.jsx index 14da74c28d..a1301cd9d6 100644 --- a/src/start-client.jsx +++ b/src/start-client.jsx @@ -4,7 +4,7 @@ import React from 'react'; import { hydrate } from 'react-dom'; import { Provider } from 'react-redux'; import { IntlProvider } from 'react-intl-redux'; -import { HistoryRouter as Router } from 'redux-first-history/rr6'; +import { BrowserRouter } from 'react-router-dom'; import { createBrowserHistory } from 'history'; import { loadableReady } from '@loadable/component'; import { CookiesProvider } from 'react-cookie'; @@ -29,7 +29,7 @@ function reactIntlErrorHandler(error) { export default () => { const api = new Api(); - const [store, connectedHistory] = configureStore(window.__data, history, api); + const store = configureStore(window.__data, history, api); persistAuthToken(store); // On Cypress we expose the history, the store and the settings @@ -58,11 +58,11 @@ export default () => { - + - + , diff --git a/src/store.js b/src/store.js index 68afae11d2..7781699142 100644 --- a/src/store.js +++ b/src/store.js @@ -1,7 +1,6 @@ import { combineReducers, createStore, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly'; -import { createReduxHistoryContext } from 'redux-first-history'; import { save, load } from 'redux-localstorage-simple'; import config from '@plone/volto/registry'; @@ -10,17 +9,8 @@ import reducers from '@root/reducers'; import { api, crashReporter, blacklistRoutes } from '@plone/volto/middleware'; const configureStore = (initialState, history, apiHelper) => { - const { - createReduxHistory, - routerMiddleware, - routerReducer, - } = createReduxHistoryContext({ - history, - }); - let stack = [ blacklistRoutes, - routerMiddleware, crashReporter, thunk, ...(apiHelper ? [api(apiHelper)] : []), @@ -35,7 +25,6 @@ const configureStore = (initialState, history, apiHelper) => { const middlewares = composeWithDevTools(applyMiddleware(...stack)); const store = createStore( combineReducers({ - router: routerReducer, ...reducers, ...config.addonReducers, }), @@ -48,7 +37,7 @@ const configureStore = (initialState, history, apiHelper) => { middlewares, ); - return [store, createReduxHistory(store)]; + return store; }; export default configureStore;