From da4c6592c80232a6ed3424a45694628fd513e068 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 20 Sep 2024 11:12:49 +0200 Subject: [PATCH] chore: changed var name --- packages/volto/news/6173.feature | 2 +- packages/volto/src/config/NonContentRoutes.jsx | 15 --------------- .../volto/src/config/NonContentRoutesPublic.jsx | 15 +++++++++++++++ packages/volto/src/config/index.js | 4 ++-- packages/volto/src/helpers/Url/Url.js | 2 +- packages/volto/src/helpers/Url/Url.test.js | 2 +- packages/volto/test-setup-config.jsx | 8 +++----- 7 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 packages/volto/src/config/NonContentRoutesPublic.jsx diff --git a/packages/volto/news/6173.feature b/packages/volto/news/6173.feature index fefb36c354..1d887eae5d 100644 --- a/packages/volto/news/6173.feature +++ b/packages/volto/news/6173.feature @@ -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 diff --git a/packages/volto/src/config/NonContentRoutes.jsx b/packages/volto/src/config/NonContentRoutes.jsx index 330418502a..8d66cae6d8 100644 --- a/packages/volto/src/config/NonContentRoutes.jsx +++ b/packages/volto/src/config/NonContentRoutes.jsx @@ -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', -]; diff --git a/packages/volto/src/config/NonContentRoutesPublic.jsx b/packages/volto/src/config/NonContentRoutesPublic.jsx new file mode 100644 index 0000000000..eeb7f2cf4f --- /dev/null +++ b/packages/volto/src/config/NonContentRoutesPublic.jsx @@ -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', +]; diff --git a/packages/volto/src/config/index.js b/packages/volto/src/config/index.js index a815616cbe..aff8393606 100644 --- a/packages/volto/src/config/index.js +++ b/packages/volto/src/config/index.js @@ -8,7 +8,7 @@ import { layoutViewsNamesMapping, } from './Views'; import { nonContentRoutes } from './NonContentRoutes'; -import { publicNonContentRoutes } from './NonContentRoutes'; +import { nonContentRoutesPublic } from './NonContentRoutesPublic'; import { groupBlocksOrder, requiredBlocks, @@ -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 diff --git a/packages/volto/src/helpers/Url/Url.js b/packages/volto/src/helpers/Url/Url.js index 41f082b6c6..889d2c04a2 100644 --- a/packages/volto/src/helpers/Url/Url.js +++ b/packages/volto/src/helpers/Url/Url.js @@ -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, ); diff --git a/packages/volto/src/helpers/Url/Url.test.js b/packages/volto/src/helpers/Url/Url.test.js index 0cc9055254..781a9b2e20 100644 --- a/packages/volto/src/helpers/Url/Url.test.js +++ b/packages/volto/src/helpers/Url/Url.test.js @@ -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); }); diff --git a/packages/volto/test-setup-config.jsx b/packages/volto/test-setup-config.jsx index 8d3ee9bd00..7d12bf40a6 100644 --- a/packages/volto/test-setup-config.jsx +++ b/packages/volto/test-setup-config.jsx @@ -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, @@ -36,7 +34,7 @@ config.set('settings', { defaultPageSize: 25, isMultilingual: false, nonContentRoutes, - publicNonContentRoutes, + nonContentRoutesPublic, contentIcons: contentIcons, loadables, lazyBundles: {