diff --git a/docs/source/configuration/settings-reference.md b/docs/source/configuration/settings-reference.md
index 87ba1afce2..7c578e7748 100644
--- a/docs/source/configuration/settings-reference.md
+++ b/docs/source/configuration/settings-reference.md
@@ -205,8 +205,8 @@ controlpanels
The group can be one of the default groups 'General', 'Content', 'Security', 'Add-on Configuration', 'Users and Groups' or a custom group.
-filterControlPanelsSchema
- A schema factory for a control panel. It is used internally, to tweak the schemas provided by the controlpanel endpoint, to make them fit for Volto.
+unwantedControlPanelsFields
+ Control panels fields that are not used on the Volto. It is used internally, to tweak the schemas provided by the controlpanel endpoint, to make them fit for Volto.
errorHandlers
A list of error handlers that will be called when there is an unhandled exception. Each error handler is a function that
diff --git a/packages/volto/news/4819.feature b/packages/volto/news/4819.feature
new file mode 100644
index 0000000000..292c2386f2
--- /dev/null
+++ b/packages/volto/news/4819.feature
@@ -0,0 +1 @@
+Replaces ``filterControlPanelsSchema`` setting by ``unwantedControlPanelsFields`. @wesleybl
diff --git a/packages/volto/src/components/manage/Controlpanels/Controlpanel.jsx b/packages/volto/src/components/manage/Controlpanels/Controlpanel.jsx
index a55477d787..5193ac004f 100644
--- a/packages/volto/src/components/manage/Controlpanels/Controlpanel.jsx
+++ b/packages/volto/src/components/manage/Controlpanels/Controlpanel.jsx
@@ -45,6 +45,39 @@ const messages = defineMessages({
},
});
+// Filters props.controlpanel.schema to only valid/relevant fields
+const filterControlPanelsSchema = (controlpanel) => {
+ const panelType = controlpanel['@id'].split('/').pop();
+
+ const { unwantedControlPanelsFields } = config.settings;
+
+ // Creates modified version of properties object
+ const newPropertiesObj = Object.fromEntries(
+ Object.entries(controlpanel.schema.properties).filter(
+ ([key, _val]) =>
+ !(unwantedControlPanelsFields[panelType] || []).includes(key),
+ ),
+ );
+ // Filters props.controlpanel.schema.fieldsets.fields to only valid/relevant fields
+ const filterFields = (fields) => {
+ return fields.filter(
+ (field) =>
+ !(unwantedControlPanelsFields[panelType] || []).includes(field),
+ );
+ };
+ // Creates modified version of fieldsets array
+ const newFieldsets = controlpanel.schema.fieldsets.map((fieldset) => {
+ return { ...fieldset, fields: filterFields(fieldset.fields) };
+ });
+
+ // Returns clone of props.controlpanel.schema, with updated properties/fieldsets
+ return {
+ ...controlpanel.schema,
+ properties: newPropertiesObj,
+ fieldsets: newFieldsets,
+ };
+};
+
/**
* Controlpanel class.
* @class Controlpanel
@@ -149,8 +182,6 @@ class Controlpanel extends Component {
* @returns {string} Markup for the component.
*/
render() {
- const { filterControlPanelsSchema } = config.settings;
-
if (this.props.controlpanel) {
return (
diff --git a/packages/volto/src/config/ControlPanels.js b/packages/volto/src/config/ControlPanels.js
index 2f6a763986..a066ffc6f8 100644
--- a/packages/volto/src/config/ControlPanels.js
+++ b/packages/volto/src/config/ControlPanels.js
@@ -53,66 +53,37 @@ export const filterControlPanels = (controlpanels) => {
);
};
-// Filters props.controlpanel.schema to only valid/relevant fields
-export const filterControlPanelsSchema = (controlpanel) => {
- const panelType = controlpanel['@id'].split('/').pop();
-
- const unwantedSettings = {
- language: ['display_flags', 'always_show_selector'],
- search: ['enable_livesearch'],
- site: [
- 'display_publication_date_in_byline',
- 'icon_visibility',
- 'thumb_visibility',
- 'no_thumbs_portlet',
- 'no_thumbs_lists',
- 'no_thumbs_summary',
- 'no_thumbs_tables',
- 'thumb_scale_portlet',
- 'thumb_scale_listing',
- 'thumb_scale_table',
- 'thumb_scale_summary',
- 'toolbar_position',
- 'toolbar_logo',
- 'default_page',
- 'site_favicon',
- 'site_favicon_mimetype',
- 'exposeDCMetaTags',
- 'enable_sitemap',
- 'robots_txt',
- 'webstats_js',
- ],
- editing: ['available_editors', 'default_editor', 'ext_editor'],
- imaging: [
- 'highpixeldensity_scales',
- 'quality_2x',
- 'quality_3x',
- 'picture_variants',
- 'image_captioning',
- ],
- };
-
- // Creates modified version of properties object
- const newPropertiesObj = Object.fromEntries(
- Object.entries(controlpanel.schema.properties).filter(
- ([key, val]) => !(unwantedSettings[panelType] || []).includes(key),
- ),
- );
- // Filters props.controlpanel.schema.fieldsets.fields to only valid/relevant fields
- const filterFields = (fields) => {
- return fields.filter(
- (field) => !(unwantedSettings[panelType] || []).includes(field),
- );
- };
- // Creates modified version of fieldsets array
- const newFieldsets = controlpanel.schema.fieldsets.map((fieldset) => {
- return { ...fieldset, fields: filterFields(fieldset.fields) };
- });
-
- // Returns clone of props.controlpanel.schema, with updated properties/fieldsets
- return {
- ...controlpanel.schema,
- properties: newPropertiesObj,
- fieldsets: newFieldsets,
- };
+export const unwantedControlPanelsFields = {
+ language: ['display_flags', 'always_show_selector'],
+ search: ['enable_livesearch'],
+ site: [
+ 'display_publication_date_in_byline',
+ 'icon_visibility',
+ 'thumb_visibility',
+ 'no_thumbs_portlet',
+ 'no_thumbs_lists',
+ 'no_thumbs_summary',
+ 'no_thumbs_tables',
+ 'thumb_scale_portlet',
+ 'thumb_scale_listing',
+ 'thumb_scale_table',
+ 'thumb_scale_summary',
+ 'toolbar_position',
+ 'toolbar_logo',
+ 'default_page',
+ 'site_favicon',
+ 'site_favicon_mimetype',
+ 'exposeDCMetaTags',
+ 'enable_sitemap',
+ 'robots_txt',
+ 'webstats_js',
+ ],
+ editing: ['available_editors', 'default_editor', 'ext_editor'],
+ imaging: [
+ 'highpixeldensity_scales',
+ 'quality_2x',
+ 'quality_3x',
+ 'picture_variants',
+ 'image_captioning',
+ ],
};
diff --git a/packages/volto/src/config/index.js b/packages/volto/src/config/index.js
index e3e0b43fad..32fb6bb910 100644
--- a/packages/volto/src/config/index.js
+++ b/packages/volto/src/config/index.js
@@ -24,7 +24,7 @@ import { styleClassNameConverters, styleClassNameExtenders } from './Style';
import {
controlPanelsIcons,
filterControlPanels,
- filterControlPanelsSchema,
+ unwantedControlPanelsFields,
} from './ControlPanels';
import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons';
@@ -151,7 +151,7 @@ let config = {
controlpanels: [],
controlPanelsIcons,
filterControlPanels,
- filterControlPanelsSchema,
+ unwantedControlPanelsFields,
externalRoutes: [
// URL to be considered as external
// {
diff --git a/packages/volto/test-setup-config.js b/packages/volto/test-setup-config.js
index 3f9d1dc8d8..40e85349e4 100644
--- a/packages/volto/test-setup-config.js
+++ b/packages/volto/test-setup-config.js
@@ -19,7 +19,7 @@ import {
import {
controlPanelsIcons,
filterControlPanels,
- filterControlPanelsSchema,
+ unwantedControlPanelsFields,
} from '@plone/volto/config/ControlPanels';
import ListingBlockSchema from '@plone/volto/components/manage/Blocks/Listing/schema';
@@ -47,7 +47,7 @@ config.set('settings', {
},
controlPanelsIcons,
filterControlPanels,
- filterControlPanelsSchema,
+ unwantedControlPanelsFields,
apiExpanders: [],
downloadableObjects: ['File'],
viewableInBrowserObjects: [],