@eeacms/volto-eea-website-policy 1.7.0 → 1.7.2
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 +22 -2
- package/package.json +7 -2
- package/src/components/Blocks/ContextNavigation/ContextNavigationEdit.test.jsx +64 -0
- package/src/components/Blocks/ContextNavigation/ContextNavigationView.test.jsx +50 -0
- package/src/components/Widgets/DataProvenance.jsx +12 -0
- package/src/components/Widgets/FrequencyOfDissemination.jsx +15 -0
- package/src/components/Widgets/InstitutionalMandate.jsx +5 -0
- package/src/helpers.test.js +86 -0
- package/src/index.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,26 @@ 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.
|
|
7
|
+
### [1.7.2](https://github.com/eea/volto-eea-website-policy/compare/1.7.1...1.7.2) - 28 July 2023
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- chore: set DataProvenace based on behavior [Miu Razvan - [`b4623f0`](https://github.com/eea/volto-eea-website-policy/commit/b4623f066a2212ec60725dc16326eae9f0170a3b)]
|
|
12
|
+
|
|
13
|
+
### [1.7.1](https://github.com/eea/volto-eea-website-policy/compare/1.7.0...1.7.1) - 24 July 2023
|
|
8
14
|
|
|
9
15
|
#### :rocket: New Features
|
|
10
16
|
|
|
11
|
-
- feat:
|
|
17
|
+
- feat: Add IMSv4 custom widgets - refs #145772 [Alin Voinea - [`367f0b6`](https://github.com/eea/volto-eea-website-policy/commit/367f0b611d6f69f217b1b0aaa25783968b8911ba)]
|
|
18
|
+
|
|
19
|
+
#### :house: Internal changes
|
|
20
|
+
|
|
21
|
+
- chore: Disable InstitutionalMandate DataProvenance widgets for now as there are issues - refs #160747 [Alin Voinea - [`bbdc3fb`](https://github.com/eea/volto-eea-website-policy/commit/bbdc3fb85a6ebd04205d763a75a1288f00efa634)]
|
|
22
|
+
|
|
23
|
+
#### :hammer_and_wrench: Others
|
|
24
|
+
|
|
25
|
+
- test: add unit tests - refs #254313 [ana-oprea - [`b51c1a9`](https://github.com/eea/volto-eea-website-policy/commit/b51c1a95f6a0624e75d168627d80009762ac4803)]
|
|
26
|
+
### [1.7.0](https://github.com/eea/volto-eea-website-policy/compare/1.6.3...1.7.0) - 16 June 2023
|
|
12
27
|
|
|
13
28
|
#### :house: Internal changes
|
|
14
29
|
|
|
@@ -62,6 +77,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
62
77
|
|
|
63
78
|
- Release 1.5.0 [Alin Voinea - [`a3dea8e`](https://github.com/eea/volto-eea-website-policy/commit/a3dea8ea15cb8d2a876dc10da926ece3a5707ea9)]
|
|
64
79
|
- test(Jenkinsfile): Use latest stable volto for testing [Alin Voinea - [`a8f7123`](https://github.com/eea/volto-eea-website-policy/commit/a8f712364187f9638886667c249fa102cb49b5c0)]
|
|
80
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`124a8f8`](https://github.com/eea/volto-eea-website-policy/commit/124a8f8ad4ced507aeec27012d725f2e2b977e08)]
|
|
65
81
|
### [1.4.0](https://github.com/eea/volto-eea-website-policy/compare/1.3.4...1.4.0) - 21 February 2023
|
|
66
82
|
|
|
67
83
|
#### :rocket: New Features
|
|
@@ -141,6 +157,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
141
157
|
#### :hammer_and_wrench: Others
|
|
142
158
|
|
|
143
159
|
- Release 1.1.0 [Alin Voinea - [`0291b3b`](https://github.com/eea/volto-eea-website-policy/commit/0291b3bb7b4c6ab09ca98728885cea4051eac8e3)]
|
|
160
|
+
- yarn 3 [Alin Voinea - [`593aa58`](https://github.com/eea/volto-eea-website-policy/commit/593aa58eaa4d28aced0603b7f7dd125c857a6f54)]
|
|
144
161
|
### [1.0.4](https://github.com/eea/volto-eea-website-policy/compare/1.0.3...1.0.4) - 22 November 2022
|
|
145
162
|
|
|
146
163
|
#### :nail_care: Enhancements
|
|
@@ -186,6 +203,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
186
203
|
|
|
187
204
|
#### :hammer_and_wrench: Others
|
|
188
205
|
|
|
206
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d153f54`](https://github.com/eea/volto-eea-website-policy/commit/d153f54e55e918fa4746e05488c734624eaf14a9)]
|
|
189
207
|
### [0.4.0](https://github.com/eea/volto-eea-website-policy/compare/0.3.3...0.4.0) - 19 September 2022
|
|
190
208
|
|
|
191
209
|
#### :hammer_and_wrench: Others
|
|
@@ -261,6 +279,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
261
279
|
- format index.js [Andrei Grigore - [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)]
|
|
262
280
|
- Update index.js [Alexandru Ghica - [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)]
|
|
263
281
|
- Added externalRoutes [Alexandru Ghica - [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)]
|
|
282
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`575cca6`](https://github.com/eea/volto-eea-website-policy/commit/575cca674602ca2e1c2a41300c47ba594ff49aa0)]
|
|
264
283
|
### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1) - 4 March 2022
|
|
265
284
|
|
|
266
285
|
#### :hammer_and_wrench: Others
|
|
@@ -273,4 +292,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
273
292
|
|
|
274
293
|
#### :hammer_and_wrench: Others
|
|
275
294
|
|
|
295
|
+
- yarn bootstrap [Alin Voinea - [`9b4d197`](https://github.com/eea/volto-eea-website-policy/commit/9b4d197cbc7992566cb36524d190078d5ad21a44)]
|
|
276
296
|
- Initial commit [Alin Voinea - [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-website-policy",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "@eeacms/volto-eea-website-policy: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git@github.com:eea/volto-eea-website-policy.git"
|
|
18
18
|
},
|
|
19
|
-
"addons": [
|
|
19
|
+
"addons": [
|
|
20
|
+
"@eeacms/volto-widget-dataprovenance"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@eeacms/volto-widget-dataprovenance": "*"
|
|
24
|
+
},
|
|
20
25
|
"devDependencies": {
|
|
21
26
|
"@cypress/code-coverage": "^3.10.0",
|
|
22
27
|
"@plone/scripts": "*",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import ContextNavigationEdit from './ContextNavigationEdit';
|
|
4
|
+
import { Router } from 'react-router-dom';
|
|
5
|
+
import { createMemoryHistory } from 'history';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
|
|
8
|
+
jest.mock('@plone/volto/components', () => ({
|
|
9
|
+
InlineForm: ({ onChangeField }) => (
|
|
10
|
+
<div>
|
|
11
|
+
<p>InlineForm</p>
|
|
12
|
+
<input id="test" onChange={onChangeField} />
|
|
13
|
+
</div>
|
|
14
|
+
),
|
|
15
|
+
SidebarPortal: ({ children }) => (
|
|
16
|
+
<div>
|
|
17
|
+
<div>SidebarPortal</div>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('@plone/volto/components/theme/Navigation/ContextNavigation', () => {
|
|
24
|
+
return {
|
|
25
|
+
__esModule: true,
|
|
26
|
+
default: ({ params }) => {
|
|
27
|
+
return <div>ConnectedContextNavigation {params.root_path}</div>;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('ContextNavigationEdit', () => {
|
|
33
|
+
it('renders corectly', () => {
|
|
34
|
+
const history = createMemoryHistory();
|
|
35
|
+
const { getByText, queryByText } = render(
|
|
36
|
+
<Router history={history}>
|
|
37
|
+
<ContextNavigationEdit />
|
|
38
|
+
</Router>,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
expect(getByText('Context navigation')).toBeInTheDocument();
|
|
42
|
+
expect(getByText('ConnectedContextNavigation')).toBeInTheDocument();
|
|
43
|
+
expect(queryByText('InlineForm')).toBeNull();
|
|
44
|
+
expect(getByText('SidebarPortal')).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders corectly', () => {
|
|
48
|
+
const history = createMemoryHistory();
|
|
49
|
+
const { container, getByText } = render(
|
|
50
|
+
<Router history={history}>
|
|
51
|
+
<ContextNavigationEdit selected={true} onChangeBlock={() => {}} />
|
|
52
|
+
</Router>,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(getByText('Context navigation')).toBeInTheDocument();
|
|
56
|
+
expect(getByText('ConnectedContextNavigation')).toBeInTheDocument();
|
|
57
|
+
expect(getByText('InlineForm')).toBeInTheDocument();
|
|
58
|
+
expect(getByText('SidebarPortal')).toBeInTheDocument();
|
|
59
|
+
|
|
60
|
+
fireEvent.change(container.querySelector('#test'), {
|
|
61
|
+
target: { value: 'test' },
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import ContextNavigationView from './ContextNavigationView';
|
|
4
|
+
import { Router } from 'react-router-dom';
|
|
5
|
+
import { createMemoryHistory } from 'history';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
|
|
8
|
+
jest.mock('@plone/volto/components/theme/Navigation/ContextNavigation', () => {
|
|
9
|
+
return {
|
|
10
|
+
__esModule: true,
|
|
11
|
+
default: ({ params }) => {
|
|
12
|
+
return <div>ConnectedContextNavigation {params.root_path}</div>;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('ContextNavigationView', () => {
|
|
18
|
+
let history;
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
history = createMemoryHistory();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders corectly', () => {
|
|
24
|
+
const { container } = render(
|
|
25
|
+
<Router history={history}>
|
|
26
|
+
<ContextNavigationView />
|
|
27
|
+
</Router>,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(container.firstChild).toHaveTextContent(
|
|
31
|
+
'ConnectedContextNavigation',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders corectly', () => {
|
|
36
|
+
const { container } = render(
|
|
37
|
+
<Router history={history}>
|
|
38
|
+
<ContextNavigationView
|
|
39
|
+
data={{
|
|
40
|
+
navProps: { root_path: 'https://localhost:3000/test' },
|
|
41
|
+
root_node: [{ '@id': 'root_node' }],
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
</Router>,
|
|
45
|
+
);
|
|
46
|
+
expect(container.firstChild).toHaveTextContent(
|
|
47
|
+
'ConnectedContextNavigation root_node',
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import RichTextWidget from '@plone/volto-slate/widgets/RichTextWidget';
|
|
2
|
+
import { DataProvenance as NextDataProvenance } from '@eeacms/volto-widget-dataprovenance/components/theme/Widgets/DataProvenance';
|
|
3
|
+
|
|
4
|
+
export const DataProvenance = (props) => {
|
|
5
|
+
if (props.behavior === 'eea.coremetadata.behavior') {
|
|
6
|
+
return <NextDataProvenance {...props} />;
|
|
7
|
+
}
|
|
8
|
+
if (props.behavior === 'eea.dexterity.indicators.metadata') {
|
|
9
|
+
return <RichTextWidget {...props} />;
|
|
10
|
+
}
|
|
11
|
+
return ' Data Provenance ';
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
|
|
4
|
+
export const FrequencyOfDissemination = ({ value, children, className }) => {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const text = value > 1 ? `Every ${value} years` : 'Once a year';
|
|
10
|
+
return (
|
|
11
|
+
<span className={cx(className, 'text', 'widget')}>
|
|
12
|
+
{children ? children(text) : text}
|
|
13
|
+
</span>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as helpers from './helpers';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
import { serializeNodes } from '@plone/volto-slate/editor/render';
|
|
4
|
+
import { isArray } from 'lodash';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
|
|
7
|
+
jest.mock('@plone/volto/registry', () => ({
|
|
8
|
+
settings: {
|
|
9
|
+
slate: {
|
|
10
|
+
defaultValue: jest.fn(),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
blocks: {
|
|
14
|
+
groupBlocksOrder: [
|
|
15
|
+
{ id: 'group1', title: 'Group1' },
|
|
16
|
+
{ id: 'group2', title: 'Group2' },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('@plone/volto-slate/editor/render', () => ({
|
|
22
|
+
serializeNodes: jest.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
describe('createSlateParagraph', () => {
|
|
26
|
+
it('should return default value when input is not an array', () => {
|
|
27
|
+
const input = 'test';
|
|
28
|
+
helpers.createSlateParagraph(input);
|
|
29
|
+
expect(config.settings.slate.defaultValue).toHaveBeenCalledTimes(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should return input when input is an array', () => {
|
|
33
|
+
const input = ['test'];
|
|
34
|
+
const result = helpers.createSlateParagraph(input);
|
|
35
|
+
expect(result).toBe(input);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('serializeText', () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
jest.resetAllMocks();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should return the text when it is not an array', () => {
|
|
45
|
+
const text = 'Hello, World!';
|
|
46
|
+
|
|
47
|
+
expect(helpers.serializeText(text)).toEqual(text);
|
|
48
|
+
expect(isArray(text)).toBe(false);
|
|
49
|
+
expect(serializeNodes).not.toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should call serializeNodes when text is an array', () => {
|
|
53
|
+
const text = ['Hello', 'World!'];
|
|
54
|
+
|
|
55
|
+
helpers.serializeText(text);
|
|
56
|
+
expect(isArray(text)).toBe(true);
|
|
57
|
+
expect(serializeNodes).toHaveBeenCalledWith(text);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('appendGroup', () => {
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
jest.resetAllMocks();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should return the text when it is not an array', () => {
|
|
67
|
+
const id = 'group2';
|
|
68
|
+
const title = 'Group2';
|
|
69
|
+
const result = helpers.appendGroup(config, id, title);
|
|
70
|
+
expect(result).toEqual([
|
|
71
|
+
{ id: 'group1', title: 'Group1' },
|
|
72
|
+
{ id: 'group2', title: 'Group2' },
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should return the text when it is not an array', () => {
|
|
77
|
+
const id = 'group3';
|
|
78
|
+
const title = 'Group3';
|
|
79
|
+
const result = helpers.appendGroup(config, id, title);
|
|
80
|
+
expect(result).toEqual([
|
|
81
|
+
{ id: 'group1', title: 'Group1' },
|
|
82
|
+
{ id: 'group2', title: 'Group2' },
|
|
83
|
+
{ id, title },
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
});
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
2
2
|
import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
|
|
3
3
|
import { appendGroup } from './helpers';
|
|
4
|
+
import { FrequencyOfDissemination } from '@eeacms/volto-eea-website-policy/components/Widgets/FrequencyOfDissemination';
|
|
5
|
+
import { DataProvenance } from '@eeacms/volto-eea-website-policy/components/Widgets/DataProvenance';
|
|
6
|
+
import { InstitutionalMandate } from '@eeacms/volto-eea-website-policy/components/Widgets/InstitutionalMandate';
|
|
4
7
|
|
|
5
8
|
const restrictedBlocks = [
|
|
6
9
|
'imagecards',
|
|
@@ -116,6 +119,12 @@ const applyConfig = (config) => {
|
|
|
116
119
|
}
|
|
117
120
|
});
|
|
118
121
|
|
|
122
|
+
// Custom widgets
|
|
123
|
+
config.widgets.id.data_provenance = DataProvenance;
|
|
124
|
+
config.widgets.id.institutional_mandate = InstitutionalMandate;
|
|
125
|
+
config.widgets.views.id.frequency_of_dissemination = FrequencyOfDissemination;
|
|
126
|
+
|
|
127
|
+
// Subsite
|
|
119
128
|
config.settings.apiExpanders = [
|
|
120
129
|
...config.settings.apiExpanders,
|
|
121
130
|
{
|