@eeacms/volto-eea-website-theme 1.25.0 → 1.26.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.md +9 -2
- package/package.json +1 -1
- package/src/actions/index.js +1 -0
- package/src/actions/schema.js +5 -0
- package/src/components/theme/AppExtras/RemoveSchema.jsx +24 -0
- package/src/index.js +6 -1
- package/src/index.test.js +8 -0
- package/src/middleware/apiEnhancer.js +11 -0
- package/src/middleware/index.js +10 -0
- package/src/reducers/index.js +17 -0
- package/src/reducers/schema.js +48 -0
package/CHANGELOG.md
CHANGED
@@ -4,11 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
4
4
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
6
6
|
|
7
|
-
### [1.
|
7
|
+
### [1.26.0](https://github.com/eea/volto-eea-website-theme/compare/1.25.0...1.26.0) - 13 December 2023
|
8
8
|
|
9
9
|
#### :bug: Bug Fixes
|
10
10
|
|
11
|
-
- fix:
|
11
|
+
- fix: remove schema if content type is not the same as for the schema [Miu Razvan - [`0056fa9`](https://github.com/eea/volto-eea-website-theme/commit/0056fa9d68efb7d2f118c9767d756efbfb100f21)]
|
12
|
+
|
13
|
+
#### :hammer_and_wrench: Others
|
14
|
+
|
15
|
+
- bump version [Miu Razvan - [`69ee513`](https://github.com/eea/volto-eea-website-theme/commit/69ee51378cf6f5dddab0d5c54c3f5e4942756562)]
|
16
|
+
- fix tests [Miu Razvan - [`aa3d5c9`](https://github.com/eea/volto-eea-website-theme/commit/aa3d5c9aee1a49f7cdeb760c074f66029504c4de)]
|
17
|
+
- clean up [Miu Razvan - [`2a3f3dc`](https://github.com/eea/volto-eea-website-theme/commit/2a3f3dc14203b5641ee325256503527d550e9c5b)]
|
18
|
+
### [1.25.0](https://github.com/eea/volto-eea-website-theme/compare/1.24.3...1.25.0) - 13 December 2023
|
12
19
|
|
13
20
|
#### :house: Documentation changes
|
14
21
|
|
package/package.json
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './schema';
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { useEffect } from 'react';
|
2
|
+
import { connect } from 'react-redux';
|
3
|
+
import { removeSchema } from '@eeacms/volto-eea-website-theme/actions';
|
4
|
+
|
5
|
+
function RemoveSchema({ removeSchema, content, schema }) {
|
6
|
+
useEffect(() => {
|
7
|
+
if (
|
8
|
+
schema.schema &&
|
9
|
+
(!content || (content && schema.contentType !== content['@type']))
|
10
|
+
) {
|
11
|
+
removeSchema();
|
12
|
+
}
|
13
|
+
}, [removeSchema, content, schema]);
|
14
|
+
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
|
18
|
+
export default connect(
|
19
|
+
(state) => ({
|
20
|
+
content: state.content.data,
|
21
|
+
schema: state.schema,
|
22
|
+
}),
|
23
|
+
{ removeSchema },
|
24
|
+
)(RemoveSchema);
|
package/src/index.js
CHANGED
@@ -26,6 +26,8 @@ import contentBoxSVG from './icons/content-box.svg';
|
|
26
26
|
import okMiddleware from './middleware/ok';
|
27
27
|
import voltoCustomMiddleware from './middleware/voltoCustom';
|
28
28
|
import installSlate from './slate';
|
29
|
+
import installReducers from './reducers';
|
30
|
+
import installMiddlewares from './middleware';
|
29
31
|
|
30
32
|
import * as eea from './config';
|
31
33
|
import React from 'react';
|
@@ -493,7 +495,10 @@ const applyConfig = (config) => {
|
|
493
495
|
});
|
494
496
|
|
495
497
|
// Custom blocks: Title
|
496
|
-
return [installCustomTitle].reduce(
|
498
|
+
return [installCustomTitle, installMiddlewares, installReducers].reduce(
|
499
|
+
(acc, apply) => apply(acc),
|
500
|
+
config,
|
501
|
+
);
|
497
502
|
};
|
498
503
|
|
499
504
|
export default applyConfig;
|
package/src/index.test.js
CHANGED
@@ -45,12 +45,17 @@ jest.mock(
|
|
45
45
|
jest.mock('@plone/volto/components', () => ({
|
46
46
|
Icon: 'MockedIcon',
|
47
47
|
}));
|
48
|
+
jest.mock(
|
49
|
+
'@eeacms/volto-eea-website-theme/components/theme/AppExtras/RemoveSchema',
|
50
|
+
() => 'MockedRemoveSchema',
|
51
|
+
);
|
48
52
|
|
49
53
|
global.__SERVER__ = true;
|
50
54
|
|
51
55
|
describe('applyConfig', () => {
|
52
56
|
it('should update the config settings with EEA specific settings', () => {
|
53
57
|
const originalConfig = {
|
58
|
+
addonReducers: {},
|
54
59
|
blocks: {
|
55
60
|
blocksConfig: {
|
56
61
|
title: {
|
@@ -139,6 +144,7 @@ describe('applyConfig', () => {
|
|
139
144
|
{ match: '', component: 'MockedDraftBackground' },
|
140
145
|
{ match: '', component: 'MockedSubsiteClass' },
|
141
146
|
{ match: '', component: BaseTag },
|
147
|
+
{ match: '*', component: 'MockedRemoveSchema' },
|
142
148
|
]);
|
143
149
|
expect(config.settings.available_colors).toEqual(eea.colors);
|
144
150
|
expect(config.settings.hasLanguageDropdown).toBe(false);
|
@@ -183,6 +189,7 @@ describe('applyConfig', () => {
|
|
183
189
|
|
184
190
|
it('should update the config settings with EEA specific settings', () => {
|
185
191
|
const originalConfig = {
|
192
|
+
addonReducers: {},
|
186
193
|
blocks: {
|
187
194
|
blocksConfig: {
|
188
195
|
title: {
|
@@ -296,6 +303,7 @@ describe('applyConfig', () => {
|
|
296
303
|
{ match: '', component: 'MockedDraftBackground' },
|
297
304
|
{ match: '', component: 'MockedSubsiteClass' },
|
298
305
|
{ match: '', component: BaseTag },
|
306
|
+
{ match: '*', component: 'MockedRemoveSchema' },
|
299
307
|
]);
|
300
308
|
expect(config.settings.available_colors).toEqual(eea.colors);
|
301
309
|
expect(config.settings.hasLanguageDropdown).toBe(false);
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import RemoveSchema from '@eeacms/volto-eea-website-theme/components/theme/AppExtras/RemoveSchema';
|
2
|
+
|
3
|
+
import schema from './schema';
|
4
|
+
|
5
|
+
export default function applyConfig(config) {
|
6
|
+
config.addonReducers.schema = schema;
|
7
|
+
|
8
|
+
config.settings.appExtras = [
|
9
|
+
...(config.settings.appExtras || []),
|
10
|
+
{
|
11
|
+
match: '*',
|
12
|
+
component: RemoveSchema,
|
13
|
+
},
|
14
|
+
];
|
15
|
+
|
16
|
+
return config;
|
17
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import voltoSchema from '@plone/volto/reducers/schema/schema';
|
2
|
+
|
3
|
+
const initialState = {
|
4
|
+
contentUrl: null,
|
5
|
+
contentType: null,
|
6
|
+
error: null,
|
7
|
+
loaded: false,
|
8
|
+
loading: false,
|
9
|
+
schema: null,
|
10
|
+
post: {
|
11
|
+
loaded: false,
|
12
|
+
loading: false,
|
13
|
+
error: null,
|
14
|
+
},
|
15
|
+
update: {
|
16
|
+
loaded: false,
|
17
|
+
loading: false,
|
18
|
+
error: null,
|
19
|
+
},
|
20
|
+
put: {
|
21
|
+
loaded: false,
|
22
|
+
loading: false,
|
23
|
+
error: null,
|
24
|
+
},
|
25
|
+
};
|
26
|
+
|
27
|
+
export default function schema(state = initialState, action = {}) {
|
28
|
+
if (action.type === 'REMOVE_SCHEMA') {
|
29
|
+
return {
|
30
|
+
...state,
|
31
|
+
error: null,
|
32
|
+
loading: false,
|
33
|
+
loaded: true,
|
34
|
+
schema: null,
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
if (action.type === 'GET_SCHEMA_SUCCESS') {
|
39
|
+
const [contentUrl, contentType] = action._request.path.split('/@types/');
|
40
|
+
return {
|
41
|
+
...voltoSchema(state, action),
|
42
|
+
contentUrl,
|
43
|
+
contentType,
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
return voltoSchema(state, action);
|
48
|
+
}
|