Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: publicUi routes to not have cms-ui in public nonContentRoutes #6173

Merged
merged 26 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c029ca4
feat: publicui routes
giuliaghisini Jul 19, 2024
b35d837
chore: news file
giuliaghisini Jul 19, 2024
5921acb
fix: name
giuliaghisini Jul 19, 2024
d7a6706
fix: news and import
giuliaghisini Jul 19, 2024
f1b00c0
Update packages/volto/news/6173.feature
pnicolli Jul 19, 2024
4ca9d29
Update packages/volto/news/6173.feature
giuliaghisini Jul 24, 2024
bdf9963
Update packages/volto/src/config/PublicNonContentRoutes.jsx
giuliaghisini Jul 24, 2024
afb8143
Update packages/volto/src/helpers/Url/Url.js
giuliaghisini Jul 24, 2024
6d3b431
Update packages/volto/src/config/PublicNonContentRoutes.jsx
giuliaghisini Jul 24, 2024
cfdacd3
Merge branch 'main' into publicui-routes
ichim-david Jul 29, 2024
14519c3
Update Url.js
giuliaghisini Aug 14, 2024
4c92d20
fix tests
mamico Aug 16, 2024
5be3a54
Merge branch 'main' into publicui-routes
stevepiercy Aug 17, 2024
48ad008
Update how-to.md
giuliaghisini Aug 19, 2024
38cda9a
Update how-to.md
mamico Aug 22, 2024
332d0b0
Update how-to.md
mamico Aug 22, 2024
a14688b
Update how-to.md
mamico Aug 22, 2024
fc1a874
Update how-to.md
mamico Aug 22, 2024
d75106e
Update how-to.md
mamico Aug 22, 2024
c0a3f19
Merge branch 'main' into publicui-routes
mamico Aug 22, 2024
da4c659
chore: changed var name
giuliaghisini Sep 20, 2024
5eefe0c
fix: name
giuliaghisini Sep 20, 2024
ddf8f7e
fix: tests
giuliaghisini Sep 20, 2024
d92c303
Update packages/volto/src/config/NonContentRoutesPublic.jsx
giuliaghisini Sep 20, 2024
2292cab
Update packages/volto/src/config/NonContentRoutesPublic.jsx
giuliaghisini Sep 20, 2024
9f6e1e9
Update how-to.md
giuliaghisini Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
giuliaghisini marked this conversation as resolved.
Show resolved Hide resolved
// You can include either RegEx or a string representing the ending of the
// nonContentRoute eg. '/add' will match '/foo/bar/add'
giuliaghisini marked this conversation as resolved.
Show resolved Hide resolved
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
Loading