@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.
- package/.changelog.draft +12 -6
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +30 -0
- package/cypress/support/commands.js +6 -0
- package/news/4104.internal +1 -0
- package/news/4165.feature +1 -0
- package/news/4189.bugfix +1 -0
- package/news/4194.bugfix +1 -0
- package/news/4223.bugfix +1 -0
- package/news/4231.feature +1 -0
- package/news/4282.feature +1 -0
- package/news/4285.feature +1 -0
- package/news/4311.bugfix +1 -0
- package/news/4313.feature +1 -0
- package/package.json +3 -2
- package/packages/volto-slate/package.json +1 -1
- package/packages/volto-slate/src/blocks/Text/DetachedTextBlockEditor.jsx +1 -0
- package/packages/volto-slate/src/editor/SlateEditor.jsx +5 -1
- package/packages/volto-slate/src/editor/ui/InlineToolbar.jsx +3 -1
- package/packages/volto-slate/src/editor/ui/SlateToolbar.jsx +3 -1
- package/src/components/manage/Blocks/Block/Edit.jsx +1 -0
- package/src/components/manage/Blocks/Listing/ListingData.jsx +5 -2
- package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +1 -1
- package/src/components/manage/Edit/Edit.jsx +5 -2
- package/src/components/manage/Toolbar/Toolbar.jsx +22 -5
- package/src/components/manage/UniversalLink/UniversalLink.jsx +2 -2
- package/src/components/manage/Widgets/ArrayWidget.jsx +1 -0
- package/src/components/manage/Widgets/SelectWidget.jsx +1 -0
- package/src/components/manage/Widgets/TokenWidget.jsx +1 -0
- package/src/components/theme/App/App.jsx +39 -13
- package/src/components/theme/View/View.jsx +9 -2
- package/src/config/index.js +10 -2
- package/src/helpers/Blocks/Blocks.js +7 -2
- package/src/helpers/Blocks/Blocks.test.js +44 -5
- package/src/helpers/FormValidation/FormValidation.js +11 -9
- package/src/helpers/ScrollToTop/ScrollToTop.jsx +4 -1
- package/src/helpers/Utils/Utils.js +5 -3
- package/src/middleware/api.js +22 -15
- package/src/reducers/actions/actions.js +36 -8
- package/src/reducers/actions/actions.test.js +87 -1
- package/src/reducers/breadcrumbs/breadcrumbs.js +50 -13
- package/src/reducers/breadcrumbs/breadcrumbs.test.js +47 -1
- package/src/reducers/navigation/navigation.js +41 -9
- package/src/reducers/navigation/navigation.test.js +49 -1
- package/src/reducers/types/types.js +36 -8
- package/src/reducers/types/types.test.js +31 -1
- package/src/registry.js +18 -0
- package/src/registry.test.js +34 -0
- 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
|
}
|
package/src/registry.test.js
CHANGED
|
@@ -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',
|
package/test-setup-config.js
CHANGED
|
@@ -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',
|