@eeacms/volto-bise-policy 1.3.5 → 1.3.7
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 +43 -0
- package/package.json +2 -1
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerEdit.jsx +22 -1
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.jsx +17 -12
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyExplorerView.test.jsx +1 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyFilters.jsx +59 -13
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyListing.jsx +28 -16
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyListing.test.jsx +54 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.jsx +68 -35
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.test.jsx +37 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.jsx +41 -39
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.test.jsx +39 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/index.js +2 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/schema.js +19 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/styles.less +33 -0
- package/src/components/manage/Blocks/CaseStudyExplorer/utils.js +171 -93
- package/src/components/manage/Blocks/CaseStudyExplorer/utils.test.js +96 -1
- package/src/components/manage/Blocks/Title/CountryProfileView.jsx +27 -0
- package/src/components/manage/Blocks/Title/index.js +19 -0
- package/src/components/manage/Blocks/Title/schema.js +42 -0
- package/src/components/manage/Blocks/index.js +2 -0
- package/src/customizations/volto/reducers/navigation/navigation.js +6 -7
- package/src/index.js +11 -0
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import './mockJsdom';
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FALLBACK_STATUS_COLOR,
|
|
5
|
+
getFeatures,
|
|
6
|
+
getStatusColor,
|
|
7
|
+
filterCases,
|
|
8
|
+
getFilters,
|
|
9
|
+
} from './utils';
|
|
4
10
|
|
|
5
11
|
describe('utils.js', () => {
|
|
12
|
+
test('maps exact statuses and unknown statuses to colors', () => {
|
|
13
|
+
expect(getStatusColor('planned')).toBe('#006bb8');
|
|
14
|
+
expect(getStatusColor('ongoing')).toBe('#ff9933');
|
|
15
|
+
expect(getStatusColor('completed')).toBe('#00a390');
|
|
16
|
+
expect(getStatusColor('Planned')).toBe(FALLBACK_STATUS_COLOR);
|
|
17
|
+
expect(getStatusColor('future')).toBe(FALLBACK_STATUS_COLOR);
|
|
18
|
+
});
|
|
19
|
+
|
|
6
20
|
const mockCases = [
|
|
7
21
|
{
|
|
8
22
|
geometry: { coordinates: [0, 0] },
|
|
@@ -70,6 +84,83 @@ describe('utils.js', () => {
|
|
|
70
84
|
expect(mockCasesFiltered).toStrictEqual([]);
|
|
71
85
|
});
|
|
72
86
|
|
|
87
|
+
test('filterCases treats search input as literal text (ReDoS-safe)', () => {
|
|
88
|
+
const cases = [
|
|
89
|
+
{
|
|
90
|
+
geometry: { coordinates: [0, 0] },
|
|
91
|
+
properties: {
|
|
92
|
+
title: 'the river project (R1)',
|
|
93
|
+
description: 'a aaa aaaa aaaaa b',
|
|
94
|
+
url: '/the-river-project-r1',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const noFilters = {
|
|
99
|
+
measures_implemented: [],
|
|
100
|
+
typology_of_measures: [],
|
|
101
|
+
current_status: [],
|
|
102
|
+
habitat_ecosystem_type: [],
|
|
103
|
+
nrr_article: [],
|
|
104
|
+
scale_of_planning: [],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Malformed regex input must not throw (previously: SyntaxError)
|
|
108
|
+
expect(() => filterCases(cases, noFilters, null, '(')).not.toThrow();
|
|
109
|
+
// Regex metacharacters are matched literally, not interpreted
|
|
110
|
+
expect(() => filterCases(cases, noFilters, null, '(a+)+$')).not.toThrow();
|
|
111
|
+
expect(filterCases(cases, noFilters, null, '(a+)+$')).toHaveLength(0);
|
|
112
|
+
expect(filterCases(cases, noFilters, null, '(r1')).toHaveLength(1);
|
|
113
|
+
// Whole-word semantics are preserved
|
|
114
|
+
expect(filterCases(cases, noFilters, null, 'rive')).toHaveLength(0);
|
|
115
|
+
expect(filterCases(cases, noFilters, null, 'river')).toHaveLength(1);
|
|
116
|
+
// Case-insensitive
|
|
117
|
+
expect(filterCases(cases, noFilters, null, 'R1')).toHaveLength(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('filters new scalar and multi-value fields', () => {
|
|
121
|
+
const cases = [
|
|
122
|
+
{
|
|
123
|
+
geometry: { coordinates: [0, 0] },
|
|
124
|
+
properties: {
|
|
125
|
+
title: 'planned river case',
|
|
126
|
+
description: '',
|
|
127
|
+
url: '/planned-river-case',
|
|
128
|
+
current_status: 'planned',
|
|
129
|
+
ecosystem_typology: ['River', 'Wetland'],
|
|
130
|
+
nrr_article: [{ id: 'article-1', title: 'Article 1' }],
|
|
131
|
+
scale_of_planning: 'Regional',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
geometry: { coordinates: [0, 0] },
|
|
136
|
+
properties: {
|
|
137
|
+
title: 'future case',
|
|
138
|
+
description: '',
|
|
139
|
+
url: '/future-case',
|
|
140
|
+
current_status: 'Future',
|
|
141
|
+
ecosystem_typology: ['Forest'],
|
|
142
|
+
nrr_article: ['article-2'],
|
|
143
|
+
scale_of_planning: 'National',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
expect(
|
|
149
|
+
filterCases(cases, {
|
|
150
|
+
measures_implemented: [],
|
|
151
|
+
typology_of_measures: [],
|
|
152
|
+
current_status: ['planned'],
|
|
153
|
+
habitat_ecosystem_type: ['River'],
|
|
154
|
+
nrr_article: ['article-1'],
|
|
155
|
+
scale_of_planning: ['Regional'],
|
|
156
|
+
}),
|
|
157
|
+
).toHaveLength(1);
|
|
158
|
+
expect(getFilters(cases).nrr_article).toEqual({
|
|
159
|
+
'article-1': 'Article 1',
|
|
160
|
+
'article-2': 'article-2',
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
73
164
|
test('getFilters', () => {
|
|
74
165
|
const mockCasesObject = mockCases.reduce((acc, item, index) => {
|
|
75
166
|
acc[index] = item;
|
|
@@ -83,6 +174,10 @@ describe('utils.js', () => {
|
|
|
83
174
|
typology_of_measures: {
|
|
84
175
|
testsector: 'testsector',
|
|
85
176
|
},
|
|
177
|
+
current_status: {},
|
|
178
|
+
habitat_ecosystem_type: {},
|
|
179
|
+
nrr_article: {},
|
|
180
|
+
scale_of_planning: {},
|
|
86
181
|
});
|
|
87
182
|
});
|
|
88
183
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
|
|
4
|
+
const CountryProfileView = (props) => {
|
|
5
|
+
const defaultVariation = (
|
|
6
|
+
config.blocks.blocksConfig.title.variations || []
|
|
7
|
+
).find((v) => v.isDefault);
|
|
8
|
+
const DefaultTemplate = defaultVariation?.view;
|
|
9
|
+
const CountryFlagView = config.blocks.blocksConfig?.countryFlag?.view;
|
|
10
|
+
|
|
11
|
+
if (!DefaultTemplate) return null;
|
|
12
|
+
|
|
13
|
+
const banner = CountryFlagView
|
|
14
|
+
? {
|
|
15
|
+
...(props.banner || {}),
|
|
16
|
+
title: {
|
|
17
|
+
view: (
|
|
18
|
+
<CountryFlagView {...props} path={props.path || props.pathname} />
|
|
19
|
+
),
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
: props.banner;
|
|
23
|
+
|
|
24
|
+
return <DefaultTemplate {...props} banner={banner} />;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default CountryProfileView;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import CountryProfileView from './CountryProfileView';
|
|
2
|
+
import { countryProfileSchemaEnhancer } from './schema';
|
|
3
|
+
|
|
4
|
+
export default function installTitleVariations(config) {
|
|
5
|
+
const titleBlock = config.blocks.blocksConfig.title;
|
|
6
|
+
if (!titleBlock) return config;
|
|
7
|
+
|
|
8
|
+
titleBlock.variations = [
|
|
9
|
+
...(titleBlock.variations || []),
|
|
10
|
+
{
|
|
11
|
+
id: 'countryProfile',
|
|
12
|
+
title: 'Country Profile',
|
|
13
|
+
view: CountryProfileView,
|
|
14
|
+
schemaEnhancer: countryProfileSchemaEnhancer,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import CountryFlagSchema from '@eeacms/volto-datablocks/components/manage/Blocks/CountryFlag/schema';
|
|
2
|
+
import countryNames from '@eeacms/volto-datablocks/components/manage/Blocks/CountryFlag/data/countries';
|
|
3
|
+
|
|
4
|
+
export const countryProfileSchemaEnhancer = ({ schema, intl }) => {
|
|
5
|
+
const cfSchema = CountryFlagSchema(intl);
|
|
6
|
+
|
|
7
|
+
cfSchema.properties.country_name.choices = Object.keys(countryNames).map(
|
|
8
|
+
(k) => [k, countryNames[k]],
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
schema.fieldsets.push(
|
|
12
|
+
{
|
|
13
|
+
id: 'countryFlag',
|
|
14
|
+
title: 'Country flag',
|
|
15
|
+
fields: [
|
|
16
|
+
'country_name',
|
|
17
|
+
'show_name',
|
|
18
|
+
'show_flag',
|
|
19
|
+
'show_dropdown',
|
|
20
|
+
'render_as',
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'dropdownItems',
|
|
25
|
+
title: 'Dropdown items',
|
|
26
|
+
fields: ['querystring', 'exclude'],
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
schema.properties = {
|
|
31
|
+
...schema.properties,
|
|
32
|
+
country_name: cfSchema.properties.country_name,
|
|
33
|
+
show_name: cfSchema.properties.show_name,
|
|
34
|
+
show_flag: cfSchema.properties.show_flag,
|
|
35
|
+
show_dropdown: cfSchema.properties.show_dropdown,
|
|
36
|
+
render_as: cfSchema.properties.render_as,
|
|
37
|
+
querystring: cfSchema.properties.querystring,
|
|
38
|
+
exclude: cfSchema.properties.exclude,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return schema;
|
|
42
|
+
};
|
|
@@ -7,6 +7,7 @@ import installKeyFacts from './KeyFacts';
|
|
|
7
7
|
import installMaesViewer from './MaesViewer';
|
|
8
8
|
import installNavigation from './Navigation';
|
|
9
9
|
import installCaseStudyExplorer from './CaseStudyExplorer';
|
|
10
|
+
import installTitleVariations from './Title';
|
|
10
11
|
|
|
11
12
|
const config = (config) => {
|
|
12
13
|
return [
|
|
@@ -19,6 +20,7 @@ const config = (config) => {
|
|
|
19
20
|
installMaesViewer,
|
|
20
21
|
installNavigation,
|
|
21
22
|
installCaseStudyExplorer,
|
|
23
|
+
installTitleVariations,
|
|
22
24
|
].reduce((acc, apply) => apply(acc), config);
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -28,9 +28,8 @@ const initialState = {
|
|
|
28
28
|
*/
|
|
29
29
|
function getRecursiveItems(items) {
|
|
30
30
|
return map(items, (item) => ({
|
|
31
|
-
title: item.title,
|
|
32
|
-
description: item.description,
|
|
33
31
|
url: flattenToAppURL(item['@id']),
|
|
32
|
+
...item,
|
|
34
33
|
...(item.items && { items: getRecursiveItems(item.items) }),
|
|
35
34
|
}));
|
|
36
35
|
}
|
|
@@ -71,11 +70,11 @@ export default function navigation(state = initialState, action = {}) {
|
|
|
71
70
|
}
|
|
72
71
|
return state;
|
|
73
72
|
case `${GET_NAVIGATION}_SUCCESS`:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
if (!
|
|
73
|
+
// Even if the expander is set or not, if the GET_NAVIGATION is
|
|
74
|
+
// called, we want it to store the data if the actions data is
|
|
75
|
+
// not set in the expander data (['@components']) but in the "normal"
|
|
76
|
+
// action result (we look for the object property returned by the endpoint)
|
|
77
|
+
if (!action.result?.['@components'] && action.result?.items) {
|
|
79
78
|
return {
|
|
80
79
|
...state,
|
|
81
80
|
error: null,
|
package/src/index.js
CHANGED
|
@@ -110,6 +110,17 @@ const applyConfig = (config) => {
|
|
|
110
110
|
'nominatim.openstreetmap.org',
|
|
111
111
|
];
|
|
112
112
|
|
|
113
|
+
// Needed by the CountryFlag block to fall back to sibling items when it
|
|
114
|
+
// has no listing/query results (e.g. Title block's Country Profile
|
|
115
|
+
// variation).
|
|
116
|
+
config.settings.apiExpanders = [
|
|
117
|
+
...(config.settings.apiExpanders || []),
|
|
118
|
+
{
|
|
119
|
+
match: '',
|
|
120
|
+
GET_CONTENT: ['siblings'],
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
|
|
113
124
|
// EEA customizations
|
|
114
125
|
config.settings.eea = {
|
|
115
126
|
...(config.settings.eea || {}),
|