From c029ca43cbd171ddeb88baaf049a0359ca2ba119 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 19 Jul 2024 14:57:29 +0200 Subject: [PATCH 01/23] feat: publicui routes --- packages/volto/src/config/PublicUiRoutes.jsx | 17 +++++++++++++++++ packages/volto/src/config/index.js | 2 ++ packages/volto/src/helpers/Url/Url.js | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 packages/volto/src/config/PublicUiRoutes.jsx diff --git a/packages/volto/src/config/PublicUiRoutes.jsx b/packages/volto/src/config/PublicUiRoutes.jsx new file mode 100644 index 0000000000..52ad3743eb --- /dev/null +++ b/packages/volto/src/config/PublicUiRoutes.jsx @@ -0,0 +1,17 @@ +import config from '@plone/volto/registry'; + +// 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 publicUiRoutes = [ + '/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 9c7b625fcc..c99bb703ce 100644 --- a/packages/volto/src/config/index.js +++ b/packages/volto/src/config/index.js @@ -8,6 +8,7 @@ import { layoutViewsNamesMapping, } from './Views'; import { nonContentRoutes } from './NonContentRoutes'; +import { publicUiRoutes } from './PublicUiRoutes'; import { groupBlocksOrder, requiredBlocks, @@ -110,6 +111,7 @@ let config = { legacyTraverse: process.env.RAZZLE_LEGACY_TRAVERSE || false, cookieExpires: 15552000, //in seconds. Default is 6 month (15552000) nonContentRoutes, + publicUiRoutes, 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 fe58098824..adc98db863 100644 --- a/packages/volto/src/helpers/Url/Url.js +++ b/packages/volto/src/helpers/Url/Url.js @@ -139,7 +139,10 @@ export const isCmsUi = memoize((currentPathname) => { // because the regexp test does not take that into account // https://github.com/plone/volto/issues/870 return settings.nonContentRoutes.reduce( - (acc, route) => acc || new RegExp(route).test(`/${fullPath}`), + (acc, route) => + acc || + (settings.publicUiRoutes.indexOf(route) < 0 && + new RegExp(route).test(`/${fullPath}`)), false, ); }); From b35d8375947f38b284e74bfcdf34b40553951a6f Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 19 Jul 2024 15:02:44 +0200 Subject: [PATCH 02/23] chore: news file --- packages/volto/news/6173.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/volto/news/6173.feature diff --git a/packages/volto/news/6173.feature b/packages/volto/news/6173.feature new file mode 100644 index 0000000000..69d9f3ec8a --- /dev/null +++ b/packages/volto/news/6173.feature @@ -0,0 +1 @@ +Added config.settings.publicUiRoutes to avoid cms-ui in this public routes. @giuliaghisini From 5921acbe02152a590a295bd402570ce1cef3df49 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 19 Jul 2024 15:20:02 +0200 Subject: [PATCH 03/23] fix: name --- .../config/{PublicUiRoutes.jsx => PublicNonContentRoutes.jsx} | 2 +- packages/volto/src/config/index.js | 4 ++-- packages/volto/src/helpers/Url/Url.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename packages/volto/src/config/{PublicUiRoutes.jsx => PublicNonContentRoutes.jsx} (91%) diff --git a/packages/volto/src/config/PublicUiRoutes.jsx b/packages/volto/src/config/PublicNonContentRoutes.jsx similarity index 91% rename from packages/volto/src/config/PublicUiRoutes.jsx rename to packages/volto/src/config/PublicNonContentRoutes.jsx index 52ad3743eb..756c484e2a 100644 --- a/packages/volto/src/config/PublicUiRoutes.jsx +++ b/packages/volto/src/config/PublicNonContentRoutes.jsx @@ -3,7 +3,7 @@ import config from '@plone/volto/registry'; // 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 publicUiRoutes = [ +export const publicNonContentRoutes = [ '/login', '/logout', '/sitemap', diff --git a/packages/volto/src/config/index.js b/packages/volto/src/config/index.js index c99bb703ce..bf6b4baccc 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 { publicUiRoutes } from './PublicUiRoutes'; +import { publicNonContentRoutes } from './PublicNonContentRoutes'; import { groupBlocksOrder, requiredBlocks, @@ -111,7 +111,7 @@ let config = { legacyTraverse: process.env.RAZZLE_LEGACY_TRAVERSE || false, cookieExpires: 15552000, //in seconds. Default is 6 month (15552000) nonContentRoutes, - publicUiRoutes, + publicNonContentRoutes, 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 adc98db863..7680c3093b 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.publicUiRoutes.indexOf(route) < 0 && + (settings.publicNonContentRoutes.indexOf(route) < 0 && new RegExp(route).test(`/${fullPath}`)), false, ); From d7a6706051050597650ae05868a2db4ec479c34a Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 19 Jul 2024 15:21:02 +0200 Subject: [PATCH 04/23] fix: news and import --- packages/volto/news/6173.feature | 2 +- packages/volto/src/config/PublicNonContentRoutes.jsx | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/volto/news/6173.feature b/packages/volto/news/6173.feature index 69d9f3ec8a..0782f3279a 100644 --- a/packages/volto/news/6173.feature +++ b/packages/volto/news/6173.feature @@ -1 +1 @@ -Added config.settings.publicUiRoutes to avoid cms-ui in this public routes. @giuliaghisini +Added config.settings.publicNonContentRoutes to avoid cms-ui in this public routes. @giuliaghisini diff --git a/packages/volto/src/config/PublicNonContentRoutes.jsx b/packages/volto/src/config/PublicNonContentRoutes.jsx index 756c484e2a..5118b07adf 100644 --- a/packages/volto/src/config/PublicNonContentRoutes.jsx +++ b/packages/volto/src/config/PublicNonContentRoutes.jsx @@ -1,5 +1,3 @@ -import config from '@plone/volto/registry'; - // 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' From f1b00c0a4147c98de5f96d0daceb1a879d975433 Mon Sep 17 00:00:00 2001 From: Piero Nicolli Date: Fri, 19 Jul 2024 15:21:42 +0200 Subject: [PATCH 05/23] Update packages/volto/news/6173.feature --- packages/volto/news/6173.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/news/6173.feature b/packages/volto/news/6173.feature index 0782f3279a..3a348e223f 100644 --- a/packages/volto/news/6173.feature +++ b/packages/volto/news/6173.feature @@ -1 +1 @@ -Added config.settings.publicNonContentRoutes to avoid cms-ui in this public routes. @giuliaghisini +Added config.settings.publicNonContentRoutes to avoid cms-ui in these public routes. @giuliaghisini From 4ca9d295f949d8cb2b10cb768196c6a876e9c18e Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:34:41 +0200 Subject: [PATCH 06/23] Update packages/volto/news/6173.feature Co-authored-by: Steve Piercy --- packages/volto/news/6173.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/news/6173.feature b/packages/volto/news/6173.feature index 3a348e223f..fefb36c354 100644 --- a/packages/volto/news/6173.feature +++ b/packages/volto/news/6173.feature @@ -1 +1 @@ -Added config.settings.publicNonContentRoutes to avoid cms-ui in these public routes. @giuliaghisini +Added `config.settings.publicNonContentRoutes` to avoid `isCmsUi` issues in these public routes. @giuliaghisini From bdf9963c5e5b02ae58d5cfdee263b31f315aa751 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:34:53 +0200 Subject: [PATCH 07/23] Update packages/volto/src/config/PublicNonContentRoutes.jsx Co-authored-by: Steve Piercy --- packages/volto/src/config/PublicNonContentRoutes.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/config/PublicNonContentRoutes.jsx b/packages/volto/src/config/PublicNonContentRoutes.jsx index 5118b07adf..4443d30291 100644 --- a/packages/volto/src/config/PublicNonContentRoutes.jsx +++ b/packages/volto/src/config/PublicNonContentRoutes.jsx @@ -1,4 +1,4 @@ -// PublicUi routes that are noContentRoutes, and we won't cms-ui +// PublicUi routes that are nonContentRoutes, and should not be members of isCmsUi // You can include either RegEx or a string representing the ending of the // nonContentRoute eg. '/add' will match '/foo/bar/add' export const publicNonContentRoutes = [ From afb814392e845466f9a84fbdd4935332d58b0602 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:41:02 +0200 Subject: [PATCH 08/23] Update packages/volto/src/helpers/Url/Url.js we need it. it was with / already before my changes. Co-authored-by: Mauro Amico --- packages/volto/src/helpers/Url/Url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/helpers/Url/Url.js b/packages/volto/src/helpers/Url/Url.js index 7680c3093b..05e8a2583f 100644 --- a/packages/volto/src/helpers/Url/Url.js +++ b/packages/volto/src/helpers/Url/Url.js @@ -142,7 +142,7 @@ export const isCmsUi = memoize((currentPathname) => { (acc, route) => acc || (settings.publicNonContentRoutes.indexOf(route) < 0 && - new RegExp(route).test(`/${fullPath}`)), + new RegExp(route).test(fullPath)), false, ); }); From 6d3b43129119fc9dac57bfd5e44f97a2155bf376 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:41:33 +0200 Subject: [PATCH 09/23] Update packages/volto/src/config/PublicNonContentRoutes.jsx Co-authored-by: Steve Piercy --- packages/volto/src/config/PublicNonContentRoutes.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/config/PublicNonContentRoutes.jsx b/packages/volto/src/config/PublicNonContentRoutes.jsx index 4443d30291..0de2965ccd 100644 --- a/packages/volto/src/config/PublicNonContentRoutes.jsx +++ b/packages/volto/src/config/PublicNonContentRoutes.jsx @@ -1,5 +1,5 @@ // PublicUi routes that are nonContentRoutes, and should not be members of isCmsUi -// You can include either RegEx or a string representing the ending of the +// You can include either RegExp or a string representing the ending of the // nonContentRoute eg. '/add' will match '/foo/bar/add' export const publicNonContentRoutes = [ '/login', From 14519c32d0aea66dd2b0cd7cbcc36d3f14df811a Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Wed, 14 Aug 2024 11:26:12 +0200 Subject: [PATCH 10/23] Update Url.js --- packages/volto/src/helpers/Url/Url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/helpers/Url/Url.js b/packages/volto/src/helpers/Url/Url.js index 05e8a2583f..52d67f33ac 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.indexOf(route) < 0 && + (settings.publicNonContentRoutes?.indexOf(route) < 0 && new RegExp(route).test(fullPath)), false, ); From 4c92d202fa30a8ca2ba85170813346742de2d030 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Fri, 16 Aug 2024 23:38:34 +0200 Subject: [PATCH 11/23] fix tests --- .../volto/src/config/NonContentRoutes.jsx | 15 ++++++++++++++ .../src/config/PublicNonContentRoutes.jsx | 15 -------------- packages/volto/src/config/index.js | 2 +- packages/volto/src/helpers/Url/Url.js | 2 +- packages/volto/src/helpers/Url/Url.test.js | 20 ++++++++++++++++--- packages/volto/test-setup-config.jsx | 6 +++++- 6 files changed, 39 insertions(+), 21 deletions(-) delete mode 100644 packages/volto/src/config/PublicNonContentRoutes.jsx diff --git a/packages/volto/src/config/NonContentRoutes.jsx b/packages/volto/src/config/NonContentRoutes.jsx index 8d66cae6d8..330418502a 100644 --- a/packages/volto/src/config/NonContentRoutes.jsx +++ b/packages/volto/src/config/NonContentRoutes.jsx @@ -35,3 +35,18 @@ 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/PublicNonContentRoutes.jsx b/packages/volto/src/config/PublicNonContentRoutes.jsx deleted file mode 100644 index 0de2965ccd..0000000000 --- a/packages/volto/src/config/PublicNonContentRoutes.jsx +++ /dev/null @@ -1,15 +0,0 @@ -// PublicUi routes that are nonContentRoutes, and should not be members of isCmsUi -// You can include either RegExp or a string representing the ending of the -// nonContentRoute eg. '/add' will match '/foo/bar/add' -export const publicNonContentRoutes = [ - '/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 bf6b4baccc..3ec07b9419 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 './PublicNonContentRoutes'; +import { publicNonContentRoutes } from './NonContentRoutes'; import { groupBlocksOrder, requiredBlocks, diff --git a/packages/volto/src/helpers/Url/Url.js b/packages/volto/src/helpers/Url/Url.js index 52d67f33ac..41f082b6c6 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?.indexOf(route) < 0 && + (!settings.publicNonContentRoutes?.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 c3e9491e95..db11a56cc0 100644 --- a/packages/volto/src/helpers/Url/Url.test.js +++ b/packages/volto/src/helpers/Url/Url.test.js @@ -151,15 +151,29 @@ describe('Url', () => { describe('isCmsUi', () => { [...settings.nonContentRoutes, '/controlpanel/mypanel'].forEach((route) => { if (typeof route === 'string') { - it(`matches non-content-route ${route}`, () => { - expect(isCmsUi(`/mycontent/${route}`)).toBe(true); - }); + if (settings.publicNonContentRoutes.includes(route)) { + it(`matches public-non-content-route ${route}`, () => { + expect(isCmsUi(route)).toBe(false); + }); + } else { + it(`matches non-content-route ${route}`, () => { + expect(isCmsUi(`/mycontent/${route}`)).toBe(true); + }); + } } }); it('returns false on non-cms-ui views', () => { expect(isCmsUi('/mycontent')).toBe(false); }); + + it('returns true on non content routes', () => { + expect(isCmsUi('/mycontent/historyview')).toBe(true); + }); + + it('returns false on public non content routes', () => { + expect(isCmsUi('/mycontent/login')).toBe(false); + }); }); describe('flattenHTMLToAppURL', () => { diff --git a/packages/volto/test-setup-config.jsx b/packages/volto/test-setup-config.jsx index 3f9d1dc8d8..c75095ce11 100644 --- a/packages/volto/test-setup-config.jsx +++ b/packages/volto/test-setup-config.jsx @@ -9,7 +9,10 @@ import React from 'react'; import config from '@plone/volto/registry'; import { loadables } from '@plone/volto/config/Loadables'; -import { nonContentRoutes } from '@plone/volto/config/NonContentRoutes'; +import { + nonContentRoutes, + publicNonContentRoutes, +} from '@plone/volto/config/NonContentRoutes'; import { contentIcons } from '@plone/volto/config/ContentIcons'; import { styleClassNameConverters, @@ -32,6 +35,7 @@ config.set('settings', { defaultPageSize: 25, isMultilingual: false, nonContentRoutes, + publicNonContentRoutes, contentIcons: contentIcons, loadables, lazyBundles: { From 48ad0080f5a46072605ed53476a1d784219b7881 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Mon, 19 Aug 2024 09:54:45 +0200 Subject: [PATCH 12/23] Update how-to.md --- docs/source/configuration/how-to.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index 5d4eafd897..994986a76b 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -150,3 +150,24 @@ export default function applyConfig(config) { return config; } +``` + +## nonContentRoutes and publicNonContentRoutes + +The `nonContentRoutes` is a list of routes declaration for which is applied the body-class `cms-ui`. This are the routes usesed in the `backoffice` side of Volto. +You can include either RegEx or a string representing the ending of the url. + +The `publicNonContentRoutes` is a list of nonContentRoutes used in the `public` side of Volto. For example, some static public route such as '/search', or '/sitemap', ... + +```js +export default function applyConfig(config) { + config.settings = { + ...config.settings, + nonContentRoutes:[....], + publicNonContentRoutes: [....] + }; + + return config; +} +``` + From 38cda9a43c9fc2f697d6d5baff3e681769c63bac Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 22 Aug 2024 19:56:06 +0200 Subject: [PATCH 13/23] Update how-to.md Co-authored-by: Steve Piercy --- docs/source/configuration/how-to.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index 994986a76b..d0585f96bb 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -152,7 +152,7 @@ export default function applyConfig(config) { } ``` -## nonContentRoutes and publicNonContentRoutes +## `nonContentRoutes` and `publicNonContentRoutes` The `nonContentRoutes` is a list of routes declaration for which is applied the body-class `cms-ui`. This are the routes usesed in the `backoffice` side of Volto. You can include either RegEx or a string representing the ending of the url. From 332d0b064cc160c23d2dc586a5c391bfad5c7cfb Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 22 Aug 2024 19:57:01 +0200 Subject: [PATCH 14/23] Update how-to.md Co-authored-by: Steve Piercy --- docs/source/configuration/how-to.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index d0585f96bb..65903ad3d2 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -154,7 +154,11 @@ export default function applyConfig(config) { ## `nonContentRoutes` and `publicNonContentRoutes` -The `nonContentRoutes` is a list of routes declaration for which is applied the body-class `cms-ui`. This are the routes usesed in the `backoffice` side of Volto. +`nonContentRoutes` is a list of routes reserved in Volto for its functionality as a content management system. +These functions include user authentication and registration, changing settings through control panels, generating a site map, and other functions. +Examples of these routes include `/login`, `/register`, and `/\/controlpanel\/.*$/`. +Editors can't use them for content. +The HTML attribute class value `cms-ui` is applied to members of `nonContentRoutes`. You can include either RegEx or a string representing the ending of the url. The `publicNonContentRoutes` is a list of nonContentRoutes used in the `public` side of Volto. For example, some static public route such as '/search', or '/sitemap', ... From a14688b67d43b57ec7684a84dad352bf24f78dc0 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 22 Aug 2024 19:57:17 +0200 Subject: [PATCH 15/23] Update how-to.md Co-authored-by: Steve Piercy --- docs/source/configuration/how-to.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index 65903ad3d2..d52ed303bb 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -159,7 +159,7 @@ These functions include user authentication and registration, changing settings Examples of these routes include `/login`, `/register`, and `/\/controlpanel\/.*$/`. Editors can't use them for content. The HTML attribute class value `cms-ui` is applied to members of `nonContentRoutes`. -You can include either RegEx or a string representing the ending of the url. +You can configure `nonContentRoutes` with either a regular expression or a string representing the end of the URI. The `publicNonContentRoutes` is a list of nonContentRoutes used in the `public` side of Volto. For example, some static public route such as '/search', or '/sitemap', ... From fc1a87471d7dff661318db0c2a45c401ecc28465 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 22 Aug 2024 19:57:56 +0200 Subject: [PATCH 16/23] Update how-to.md Co-authored-by: Steve Piercy --- docs/source/configuration/how-to.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index d52ed303bb..feedd9c6c3 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -161,7 +161,9 @@ Editors can't use them for content. The HTML attribute class value `cms-ui` is applied to members of `nonContentRoutes`. You can configure `nonContentRoutes` with either a regular expression or a string representing the end of the URI. -The `publicNonContentRoutes` is a list of nonContentRoutes used in the `public` side of Volto. For example, some static public route such as '/search', or '/sitemap', ... +`publicNonContentRoutes` is a subset of `nonContentRoutes`. +These routes are used for public sections of a Volto site that do not require authentication. +This subset includes `/login`, `/search`, and `/sitemap`. ```js export default function applyConfig(config) { From d75106e31822a77b9a39898525f1d22f9918def4 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Thu, 22 Aug 2024 19:58:16 +0200 Subject: [PATCH 17/23] Update how-to.md Co-authored-by: Steve Piercy --- docs/source/configuration/how-to.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index feedd9c6c3..38cb60efb0 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -165,6 +165,7 @@ You can configure `nonContentRoutes` with either a regular expression or a strin These routes are used for public sections of a Volto site that do not require authentication. This subset includes `/login`, `/search`, and `/sitemap`. +The following example shows how to configure settings for `nonContentRoutes` and `publicNonContentRoutes`. ```js export default function applyConfig(config) { config.settings = { From da4c6592c80232a6ed3424a45694628fd513e068 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 20 Sep 2024 11:12:49 +0200 Subject: [PATCH 18/23] 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: { From 5eefe0ce1b209326069d6b9d0992a1f63c9209e4 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 20 Sep 2024 11:14:16 +0200 Subject: [PATCH 19/23] fix: name --- docs/source/configuration/how-to.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index 38cb60efb0..0e9ab15572 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -1,10 +1,10 @@ --- myst: html_meta: - "description": "Volto has a centralized configuration registry used to parameterize Volto." - "property=og:description": "Volto has a centralized configuration registry used to parameterize Volto." - "property=og:title": "The configuration registry" - "keywords": "Volto, Plone, frontend, React, configuration, registry" + 'description': 'Volto has a centralized configuration registry used to parameterize Volto.' + 'property=og:description': 'Volto has a centralized configuration registry used to parameterize Volto.' + 'property=og:title': 'The configuration registry' + 'keywords': 'Volto, Plone, frontend, React, configuration, registry' --- # The configuration registry @@ -20,7 +20,7 @@ then access any of its internal configuration to retrieve the configuration you like: ```js -const absoluteUrl = `${config.settings.apiPath}/${content.url}` +const absoluteUrl = `${config.settings.apiPath}/${content.url}`; ``` Both the main project and individual add-ons can extend Volto's configuration registry. @@ -152,7 +152,7 @@ export default function applyConfig(config) { } ``` -## `nonContentRoutes` and `publicNonContentRoutes` +## `nonContentRoutes` and `nonContentRoutesPublic` `nonContentRoutes` is a list of routes reserved in Volto for its functionality as a content management system. These functions include user authentication and registration, changing settings through control panels, generating a site map, and other functions. @@ -161,20 +161,20 @@ Editors can't use them for content. The HTML attribute class value `cms-ui` is applied to members of `nonContentRoutes`. You can configure `nonContentRoutes` with either a regular expression or a string representing the end of the URI. -`publicNonContentRoutes` is a subset of `nonContentRoutes`. +`nonContentRoutesPublic` is a subset of `nonContentRoutes`. These routes are used for public sections of a Volto site that do not require authentication. This subset includes `/login`, `/search`, and `/sitemap`. -The following example shows how to configure settings for `nonContentRoutes` and `publicNonContentRoutes`. +The following example shows how to configure settings for `nonContentRoutes` and `nonContentRoutesPublic`. + ```js export default function applyConfig(config) { config.settings = { ...config.settings, nonContentRoutes:[....], - publicNonContentRoutes: [....] + nonContentRoutesPublic: [....] }; return config; } ``` - From ddf8f7e5de7c7d7b7730d51c0cef4f637c7967bb Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Fri, 20 Sep 2024 11:15:29 +0200 Subject: [PATCH 20/23] fix: tests --- packages/volto/src/helpers/Url/Url.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/helpers/Url/Url.test.js b/packages/volto/src/helpers/Url/Url.test.js index 781a9b2e20..d5ca89fb3f 100644 --- a/packages/volto/src/helpers/Url/Url.test.js +++ b/packages/volto/src/helpers/Url/Url.test.js @@ -152,7 +152,7 @@ describe('Url', () => { [...settings.nonContentRoutes, '/controlpanel/mypanel'].forEach((route) => { if (typeof route === 'string') { if (settings.nonContentRoutesPublic.includes(route)) { - it(`matches public-non-content-route ${route}`, () => { + it(`matches non-content-route-public ${route}`, () => { expect(isCmsUi(route)).toBe(false); }); } else { From d92c303234d1d0025c42214b1f64ae4965000c27 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:27:21 +0200 Subject: [PATCH 21/23] Update packages/volto/src/config/NonContentRoutesPublic.jsx Co-authored-by: Steve Piercy --- packages/volto/src/config/NonContentRoutesPublic.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/config/NonContentRoutesPublic.jsx b/packages/volto/src/config/NonContentRoutesPublic.jsx index eeb7f2cf4f..c2a588c9d2 100644 --- a/packages/volto/src/config/NonContentRoutesPublic.jsx +++ b/packages/volto/src/config/NonContentRoutesPublic.jsx @@ -1,6 +1,6 @@ // 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' +// nonContentRoute. For example, '/add' will match '/foo/bar/add'. export const nonContentRoutesPublic = [ '/login', '/logout', From 2292cabb15f44b8ec9bb79f0d1aab9c7ee3699b2 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:27:34 +0200 Subject: [PATCH 22/23] Update packages/volto/src/config/NonContentRoutesPublic.jsx Co-authored-by: Steve Piercy --- packages/volto/src/config/NonContentRoutesPublic.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/volto/src/config/NonContentRoutesPublic.jsx b/packages/volto/src/config/NonContentRoutesPublic.jsx index c2a588c9d2..30583c15f3 100644 --- a/packages/volto/src/config/NonContentRoutesPublic.jsx +++ b/packages/volto/src/config/NonContentRoutesPublic.jsx @@ -1,4 +1,4 @@ -// PublicUi routes that are noContentRoutes, and we won't cms-ui +// PublicUi routes that are nonContentRoutes, and should not be members of isCmsUi // You can include either RegEx or a string representing the ending of the // nonContentRoute. For example, '/add' will match '/foo/bar/add'. export const nonContentRoutesPublic = [ From 9f6e1e9bb08b5537c23e16319585f458618cae9a Mon Sep 17 00:00:00 2001 From: Giulia Ghisini <51911425+giuliaghisini@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:38:09 +0200 Subject: [PATCH 23/23] Update how-to.md --- docs/source/configuration/how-to.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/configuration/how-to.md b/docs/source/configuration/how-to.md index 0e9ab15572..a1023c1837 100644 --- a/docs/source/configuration/how-to.md +++ b/docs/source/configuration/how-to.md @@ -1,10 +1,10 @@ --- myst: html_meta: - 'description': 'Volto has a centralized configuration registry used to parameterize Volto.' - 'property=og:description': 'Volto has a centralized configuration registry used to parameterize Volto.' - 'property=og:title': 'The configuration registry' - 'keywords': 'Volto, Plone, frontend, React, configuration, registry' + "description": "Volto has a centralized configuration registry used to parameterize Volto." + "property=og:description": "Volto has a centralized configuration registry used to parameterize Volto." + "property=og:title": "The configuration registry" + "keywords": "Volto, Plone, frontend, React, configuration, registry" --- # The configuration registry