@plone/volto 16.8.0 → 16.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.changelog.draft +12 -6
  2. package/.yarn/install-state.gz +0 -0
  3. package/CHANGELOG.md +30 -0
  4. package/cypress/support/commands.js +6 -0
  5. package/news/4104.internal +1 -0
  6. package/news/4165.feature +1 -0
  7. package/news/4189.bugfix +1 -0
  8. package/news/4194.bugfix +1 -0
  9. package/news/4223.bugfix +1 -0
  10. package/news/4231.feature +1 -0
  11. package/news/4282.feature +1 -0
  12. package/news/4285.feature +1 -0
  13. package/news/4311.bugfix +1 -0
  14. package/news/4313.feature +1 -0
  15. package/package.json +3 -2
  16. package/packages/volto-slate/package.json +1 -1
  17. package/packages/volto-slate/src/blocks/Text/DetachedTextBlockEditor.jsx +1 -0
  18. package/packages/volto-slate/src/editor/SlateEditor.jsx +5 -1
  19. package/packages/volto-slate/src/editor/ui/InlineToolbar.jsx +3 -1
  20. package/packages/volto-slate/src/editor/ui/SlateToolbar.jsx +3 -1
  21. package/src/components/manage/Blocks/Block/Edit.jsx +1 -0
  22. package/src/components/manage/Blocks/Listing/ListingData.jsx +5 -2
  23. package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +1 -1
  24. package/src/components/manage/Edit/Edit.jsx +5 -2
  25. package/src/components/manage/Toolbar/Toolbar.jsx +22 -5
  26. package/src/components/manage/UniversalLink/UniversalLink.jsx +2 -2
  27. package/src/components/manage/Widgets/ArrayWidget.jsx +1 -0
  28. package/src/components/manage/Widgets/SelectWidget.jsx +1 -0
  29. package/src/components/manage/Widgets/TokenWidget.jsx +1 -0
  30. package/src/components/theme/App/App.jsx +39 -13
  31. package/src/components/theme/View/View.jsx +9 -2
  32. package/src/config/index.js +10 -2
  33. package/src/helpers/Blocks/Blocks.js +7 -2
  34. package/src/helpers/Blocks/Blocks.test.js +44 -5
  35. package/src/helpers/FormValidation/FormValidation.js +11 -9
  36. package/src/helpers/ScrollToTop/ScrollToTop.jsx +4 -1
  37. package/src/helpers/Utils/Utils.js +5 -3
  38. package/src/middleware/api.js +22 -15
  39. package/src/reducers/actions/actions.js +36 -8
  40. package/src/reducers/actions/actions.test.js +87 -1
  41. package/src/reducers/breadcrumbs/breadcrumbs.js +50 -13
  42. package/src/reducers/breadcrumbs/breadcrumbs.test.js +47 -1
  43. package/src/reducers/navigation/navigation.js +41 -9
  44. package/src/reducers/navigation/navigation.test.js +49 -1
  45. package/src/reducers/types/types.js +36 -8
  46. package/src/reducers/types/types.test.js +31 -1
  47. package/src/registry.js +18 -0
  48. package/src/registry.test.js +34 -0
  49. package/test-setup-config.js +3 -0
@@ -1,5 +1,6 @@
1
1
  import types from './types';
2
- import { GET_TYPES } from '@plone/volto/constants/ActionTypes';
2
+ import { GET_CONTENT, GET_TYPES } from '@plone/volto/constants/ActionTypes';
3
+ import config from '@plone/volto/registry';
3
4
 
4
5
  describe('Types reducer', () => {
5
6
  it('should return the initial state', () => {
@@ -52,3 +53,32 @@ describe('Types reducer', () => {
52
53
  });
53
54
  });
54
55
  });
56
+
57
+ describe('Types reducer - (TYPES)GET_CONTENT_SUCCESS', () => {
58
+ beforeEach(() => {
59
+ config.settings.apiExpanders = [
60
+ {
61
+ match: '',
62
+ GET_CONTENT: ['types'],
63
+ },
64
+ ];
65
+ });
66
+
67
+ it('should handle (TYPES)GET_CONTENT_SUCCESS', () => {
68
+ expect(
69
+ types(undefined, {
70
+ type: `${GET_CONTENT}_SUCCESS`,
71
+ result: {
72
+ '@components': {
73
+ types: 'My types',
74
+ },
75
+ },
76
+ }),
77
+ ).toEqual({
78
+ error: null,
79
+ loaded: true,
80
+ loading: false,
81
+ types: 'My types',
82
+ });
83
+ });
84
+ });
package/src/registry.js CHANGED
@@ -120,6 +120,24 @@ class Config {
120
120
  const componentName = `${name}${depsString ? `|${depsString}` : ''}`;
121
121
 
122
122
  this._data.components[componentName] = { component };
123
+ // Try to set a displayName (useful for React dev tools) for the registered component
124
+ // Only if it's a function and it's not set previously
125
+ try {
126
+ const displayName = this._data.components[componentName].component
127
+ .displayName;
128
+
129
+ if (
130
+ !displayName &&
131
+ typeof this._data.components[componentName].component === 'function'
132
+ ) {
133
+ this._data.components[componentName].component.displayName = name;
134
+ }
135
+ } catch (error) {
136
+ // eslint-disable-next-line no-console
137
+ console.warning(
138
+ `Not setting the component displayName because ${error}`,
139
+ );
140
+ }
123
141
  }
124
142
  }
125
143
  }
@@ -50,6 +50,40 @@ describe('registry', () => {
50
50
  'this is a Bar component',
51
51
  );
52
52
  });
53
+ it('registers and gets a component by name (as an object) - check displayName', () => {
54
+ config.registerComponent({
55
+ name: 'Toolbar.Bar',
56
+ component: (props) => <div>Hello</div>,
57
+ });
58
+ expect(config.getComponent('Toolbar.Bar').component.displayName).toEqual(
59
+ 'Toolbar.Bar',
60
+ );
61
+ });
62
+ it('registers and gets a component by name (as an object) - check displayName if it has already one, it does not overwrite it', () => {
63
+ const TestComponent = (props) => <div>Hello</div>;
64
+ TestComponent.displayName = 'DisplayNameAlreadySet';
65
+ config.registerComponent({
66
+ name: 'Toolbar.Bar',
67
+ component: TestComponent,
68
+ });
69
+
70
+ expect(config.getComponent('Toolbar.Bar').component.displayName).toEqual(
71
+ 'DisplayNameAlreadySet',
72
+ );
73
+ });
74
+ it('registers and gets a component by name (as an object) - check displayName - do not break if it is a normal function', () => {
75
+ function myFunction() {
76
+ return 'true';
77
+ }
78
+
79
+ config.registerComponent({
80
+ name: 'Toolbar.Bar',
81
+ component: myFunction,
82
+ });
83
+ expect(config.getComponent('Toolbar.Bar').component.displayName).toEqual(
84
+ 'Toolbar.Bar',
85
+ );
86
+ });
53
87
  it('registers a component by name with dependencies', () => {
54
88
  config.registerComponent({
55
89
  name: 'Toolbar.Bar',
@@ -31,6 +31,8 @@ import {
31
31
  filterControlPanelsSchema,
32
32
  } from '@plone/volto/config/ControlPanels';
33
33
 
34
+ import ListingBlockSchema from '@plone/volto/components/manage/Blocks/Listing/schema';
35
+
34
36
  // we need to do a redefinition here because of circular import issues
35
37
  // because draftjs-based components are not really tested, this is basically
36
38
  // dummy code.
@@ -84,6 +86,7 @@ config.set('settings', {
84
86
  config.set('blocks', {
85
87
  blocksConfig: {
86
88
  listing: {
89
+ blockSchema: ListingBlockSchema,
87
90
  variations: [
88
91
  {
89
92
  id: 'default',