Skip to content

Commit

Permalink
chore: changed var name
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Sep 20, 2024
1 parent c0a3f19 commit da4c659
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/volto/news/6173.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Added `config.settings.publicNonContentRoutes` to avoid `isCmsUi` issues in these public routes. @giuliaghisini
Added `config.settings.nonContentRoutesPublic` to avoid `isCmsUi` issues in these public routes. @giuliaghisini
15 changes: 0 additions & 15 deletions packages/volto/src/config/NonContentRoutes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,3 @@ export const nonContentRoutes = [
'/manage-translations',
...(config.settings?.externalRoutes?.map((route) => route.match.path) || []),
];

// PublicUi routes that are nonContentRoutes, and should not be members of isCmsUi
// Must be a subset of nonContentRoutes !
export const publicNonContentRoutes = [
'/login',
'/logout',
'/sitemap',
'/register',
'/search',
'/change-password',
'/contact-form',
'/register',
/\/passwordreset\/.*$/,
'/passwordreset',
];
15 changes: 15 additions & 0 deletions packages/volto/src/config/NonContentRoutesPublic.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// PublicUi routes that are noContentRoutes, and we won't cms-ui
// You can include either RegEx or a string representing the ending of the
// nonContentRoute eg. '/add' will match '/foo/bar/add'
export const nonContentRoutesPublic = [
'/login',
'/logout',
'/sitemap',
'/register',
'/search',
'/change-password',
'/contact-form',
'/register',
/\/passwordreset\/.*$/,
'/passwordreset',
];
4 changes: 2 additions & 2 deletions packages/volto/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
layoutViewsNamesMapping,
} from './Views';
import { nonContentRoutes } from './NonContentRoutes';
import { publicNonContentRoutes } from './NonContentRoutes';
import { nonContentRoutesPublic } from './NonContentRoutesPublic';
import {
groupBlocksOrder,
requiredBlocks,
Expand Down Expand Up @@ -112,7 +112,7 @@ let config = {
legacyTraverse: process.env.RAZZLE_LEGACY_TRAVERSE || false,
cookieExpires: 15552000, //in seconds. Default is 6 month (15552000)
nonContentRoutes,
publicNonContentRoutes,
nonContentRoutesPublic,
imageObjects: ['Image'],
reservedIds: ['login', 'layout', 'plone', 'zip', 'properties'],
downloadableObjects: ['File'], //list of content-types for which the direct download of the file will be carried out if the user is not authenticated
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/src/helpers/Url/Url.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const isCmsUi = memoize((currentPathname) => {
return settings.nonContentRoutes.reduce(
(acc, route) =>
acc ||
(!settings.publicNonContentRoutes?.includes(route) &&
(!settings.nonContentRoutesPublic?.includes(route) &&
new RegExp(route).test(fullPath)),
false,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/src/helpers/Url/Url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('Url', () => {
describe('isCmsUi', () => {
[...settings.nonContentRoutes, '/controlpanel/mypanel'].forEach((route) => {
if (typeof route === 'string') {
if (settings.publicNonContentRoutes.includes(route)) {
if (settings.nonContentRoutesPublic.includes(route)) {
it(`matches public-non-content-route ${route}`, () => {
expect(isCmsUi(route)).toBe(false);
});
Expand Down
8 changes: 3 additions & 5 deletions packages/volto/test-setup-config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
import React from 'react';
import config from '@plone/volto/registry';
import { loadables } from '@plone/volto/config/Loadables';
import {
nonContentRoutes,
publicNonContentRoutes,
} from '@plone/volto/config/NonContentRoutes';
import { nonContentRoutes } from '@plone/volto/config/NonContentRoutes';
import { nonContentRoutesPublic } from '@plone/volto/config/NonContentRoutesPublic';
import { contentIcons } from '@plone/volto/config/ContentIcons';
import {
styleClassNameConverters,
Expand All @@ -36,7 +34,7 @@ config.set('settings', {
defaultPageSize: 25,
isMultilingual: false,
nonContentRoutes,
publicNonContentRoutes,
nonContentRoutesPublic,
contentIcons: contentIcons,
loadables,
lazyBundles: {
Expand Down

0 comments on commit da4c659

Please sign in to comment.