Skip to content

Commit

Permalink
WIP2
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Apr 6, 2022
1 parent 4fd646e commit eac3474
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 171 deletions.
10 changes: 1 addition & 9 deletions src/helpers/AuthToken/AuthToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
287 changes: 141 additions & 146 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ export const multilingualRoutes = [
];

export const defaultRoutes = [
// {
// path: '/',
// element: (props) => 'hello',
// exact: true,
// },
{ index: true, element: <View /> },
{
path: 'login',
Expand All @@ -97,141 +92,141 @@ export const defaultRoutes = [
path: '/logout',
element: <Logout />,
},
// {
// path: '/sitemap',
// element: <Sitemap />,
// },
// {
// path: '/search',
// element: <Search />,
// },
// {
// path: '/contact-form',
// element: <ContactForm />,
// },
// {
// path: '/controlpanel',
// exact: true,
// element: <Controlpanels />,
// },
// {
// path: '/controlpanel/dexterity-types/:id/layout',
// element: <ContentTypeLayout />,
// },
// {
// path: '/controlpanel/dexterity-types/:id/schema',
// element: <ContentTypeSchema />,
// },
// {
// path: '/controlpanel/dexterity-types/:id',
// element: <ContentType />,
// },
// {
// path: '/controlpanel/dexterity-types',
// element: <ContentTypes />,
// },
// {
// path: '/controlpanel/addons',
// element: <AddonsControlpanel />,
// },
// {
// path: '/controlpanel/database',
// element: <DatabaseInformation />,
// },
// {
// path: '/controlpanel/moderate-comments',
// element: <ModerateComments />,
// },
// {
// path: '/controlpanel/users',
// element: <UsersControlpanel />,
// },
// {
// path: '/controlpanel/groups',
// element: <GroupsControlpanel />,
// },
// {
// path: '/controlpanel/:id',
// element: <Controlpanel />,
// },
// {
// path: '/change-password',
// element: <ChangePassword />,
// },
// {
// path: '/add',
// element: <Add />,
// },
// {
// path: '/edit',
// element: <Edit />,
// },
// {
// path: '/contents',
// element: <Contents />,
// },
// {
// path: '/sharing',
// element: <Sharing />,
// },
// {
// path: '/**/add',
// element: <Add />,
// },
// {
// path: '/**/create-translation',
// element: <CreateTranslation />,
// },
// {
// path: '/**/contents',
// element: <Contents />,
// },
// {
// path: '/**/sharing',
// element: <Sharing />,
// },
// {
// path: '/**/delete',
// element: <Delete />,
// },
// {
// path: '/**/diff',
// element: <Diff />,
// },
// {
// path: '/**/edit',
// element: <Edit />,
// },
// {
// path: '/**/history',
// element: <History />,
// },
// {
// path: '/**/sharing',
// element: <Sharing />,
// },
// {
// path: '/**/manage-translations',
// element: <ManageTranslations />,
// },
// {
// path: '/**/login',
// element: <Login />,
// },
// {
// path: '/register',
// element: <Register />,
// },
// {
// path: '/password-reset',
// element: <RequestPasswordReset />,
// exact: true,
// },
// {
// path: '/password-reset/:token',
// element: <PasswordReset />,
// exact: true,
// },
{
path: '/sitemap',
element: <Sitemap />,
},
{
path: '/search',
element: <Search />,
},
{
path: '/contact-form',
element: <ContactForm />,
},
{
path: '/controlpanel',
exact: true,
element: <Controlpanels />,
},
{
path: '/controlpanel/dexterity-types/:id/layout',
element: <ContentTypeLayout />,
},
{
path: '/controlpanel/dexterity-types/:id/schema',
element: <ContentTypeSchema />,
},
{
path: '/controlpanel/dexterity-types/:id',
element: <ContentType />,
},
{
path: '/controlpanel/dexterity-types',
element: <ContentTypes />,
},
{
path: '/controlpanel/addons',
element: <AddonsControlpanel />,
},
{
path: '/controlpanel/database',
element: <DatabaseInformation />,
},
{
path: '/controlpanel/moderate-comments',
element: <ModerateComments />,
},
{
path: '/controlpanel/users',
element: <UsersControlpanel />,
},
{
path: '/controlpanel/groups',
element: <GroupsControlpanel />,
},
{
path: '/controlpanel/:id',
element: <Controlpanel />,
},
{
path: '/change-password',
element: <ChangePassword />,
},
{
path: '/add',
element: <Add />,
},
{
path: '/edit',
element: <Edit />,
},
{
path: '/contents',
element: <Contents />,
},
{
path: '/sharing',
element: <Sharing />,
},
{
path: '/**/add',
element: <Add />,
},
{
path: '/**/create-translation',
element: <CreateTranslation />,
},
{
path: '/**/contents',
element: <Contents />,
},
{
path: '/**/sharing',
element: <Sharing />,
},
{
path: '/**/delete',
element: <Delete />,
},
{
path: '/**/diff',
element: <Diff />,
},
{
path: '/**/edit',
element: <Edit />,
},
{
path: '/**/history',
element: <History />,
},
{
path: '/**/sharing',
element: <Sharing />,
},
{
path: '/**/manage-translations',
element: <ManageTranslations />,
},
{
path: '/**/login',
element: <Login />,
},
{
path: '/register',
element: <Register />,
},
{
path: '/password-reset',
element: <RequestPasswordReset />,
exact: true,
},
{
path: '/password-reset/:token',
element: <PasswordReset />,
exact: true,
},
{
path: '*',
element: <View />,
Expand All @@ -248,14 +243,14 @@ const routes = [
path: '/',
element: <App />,
children: [
// // redirect to external links if path is in blacklist
// ...(config.settings?.externalRoutes || []).map((route) => ({
// ...route.match,
// element: <NotFound />,
// })),
// redirect to external links if path is in blacklist
...(config.settings?.externalRoutes || []).map((route) => ({
...route.match,
element: <NotFound />,
})),
// addon routes have a higher priority then default routes
...(config.addonRoutes || []),
// ...((config.settings?.isMultilingual && multilingualRoutes) || []),
...((config.settings?.isMultilingual && multilingualRoutes) || []),
...defaultRoutes,
],
},
Expand Down
8 changes: 4 additions & 4 deletions src/start-client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -58,11 +58,11 @@ export default () => {
<CookiesProvider>
<Provider store={store}>
<IntlProvider onError={reactIntlErrorHandler}>
<Router history={connectedHistory}>
<BrowserRouter>
<ScrollToTop>
<Routes />
</ScrollToTop>
</Router>
</BrowserRouter>
</IntlProvider>
</Provider>
</CookiesProvider>,
Expand Down
Loading

0 comments on commit eac3474

Please sign in to comment.