@eeacms/volto-cca-policy 0.3.45 → 0.3.47

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 CHANGED
@@ -4,6 +4,27 @@ 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
+ ### [0.3.47](https://github.com/eea/volto-cca-policy/compare/0.3.46...0.3.47) - 21 May 2025
8
+
9
+ #### :nail_care: Enhancements
10
+
11
+ - change(mission): cleanup, remove unused component [kreafox - [`0440183`](https://github.com/eea/volto-cca-policy/commit/044018381a8c42e1a45ff9ba3668613dc08f5198)]
12
+ - change(mission): add link to signatory landing page - refs #287964 [kreafox - [`78378a3`](https://github.com/eea/volto-cca-policy/commit/78378a3d7f8bab7aa6414342e228b45fc24ec57b)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - update test [kreafox - [`ae30035`](https://github.com/eea/volto-cca-policy/commit/ae30035c6f3f1d81d560b5552afc0bc9764df983)]
17
+ ### [0.3.46](https://github.com/eea/volto-cca-policy/compare/0.3.45...0.3.46) - 21 May 2025
18
+
19
+ #### :house: Internal changes
20
+
21
+ - style: Automated code fix [eea-jenkins - [`ea4b8be`](https://github.com/eea/volto-cca-policy/commit/ea4b8beed2cb7426c3125b6edb85d3b1fadf66a1)]
22
+
23
+ #### :hammer_and_wrench: Others
24
+
25
+ - Dont' need this now [Tiberiu Ichim - [`eff27fb`](https://github.com/eea/volto-cca-policy/commit/eff27fb4022b445c6c298a1c59e36ecab661e91e)]
26
+ - Add actions customization [Tiberiu Ichim - [`69f9b00`](https://github.com/eea/volto-cca-policy/commit/69f9b00cb45149e9b4d06085f4688800cb4d1d9f)]
27
+ - Remove etag from server [Tiberiu Ichim - [`7d94455`](https://github.com/eea/volto-cca-policy/commit/7d94455440b69ebd97c0ef5cc3dd839687b13e54)]
7
28
  ### [0.3.45](https://github.com/eea/volto-cca-policy/compare/0.3.44...0.3.45) - 21 May 2025
8
29
 
9
30
  #### :rocket: New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.3.45",
3
+ "version": "0.3.47",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
- import { Tab, Container, Divider } from 'semantic-ui-react';
2
+ import { Link } from 'react-router-dom';
3
+ import { Tab, Container, Divider, Button, Icon } from 'semantic-ui-react';
3
4
  import { formatTextToHTML } from '@eeacms/volto-cca-policy/utils';
4
5
  import { BannerTitle, HTMLField } from '@eeacms/volto-cca-policy/helpers';
6
+ import { flattenToAppURL } from '@plone/volto/helpers';
5
7
 
6
8
  import GovernanceTab from './TabSections/GovernanceTab';
7
9
  import AssessmentTab from './TabSections/AssessmentTab';
@@ -29,6 +31,9 @@ const MissionSignatoryProfileView = ({ content }) => {
29
31
  general_text = [{}],
30
32
  } = signatoryData;
31
33
 
34
+ const { Back_To_Map_Link, Country_Or_Area } = general_text?.[0] || {};
35
+ const backToMapPath = flattenToAppURL(content?.parent?.['@id'] || '/');
36
+
32
37
  const [activeIndex, setActiveIndex] = React.useState(0);
33
38
 
34
39
  const tabData = {
@@ -60,12 +65,18 @@ const MissionSignatoryProfileView = ({ content }) => {
60
65
  hidePublishingDate: true,
61
66
  hideDownloadButton: false,
62
67
  hideShareButton: false,
63
- subtitle: general_text?.[0]?.Country_Or_Area,
68
+ subtitle: Country_Or_Area,
64
69
  }}
65
70
  />
66
71
 
67
72
  <div className="signatory-profile">
68
- <br />
73
+ <Link to={backToMapPath}>
74
+ <Button icon inverted primary className="left labeled back-to-map">
75
+ <Icon className="chevron left icon" />
76
+ {Back_To_Map_Link || 'Back to Signatories map'}
77
+ </Button>
78
+ </Link>
79
+
69
80
  <Tab
70
81
  menu={{
71
82
  fluid: true,
@@ -1,4 +1,5 @@
1
1
  import { render, fireEvent, screen } from '@testing-library/react';
2
+ import { MemoryRouter } from 'react-router-dom';
2
3
  import '@testing-library/jest-dom';
3
4
  import MissionSignatoryProfileView from './MissionSignatoryProfileView';
4
5
 
@@ -38,15 +39,25 @@ describe('MissionSignatoryProfileView', () => {
38
39
  { key: 'Action_Label', value: 'Action' },
39
40
  { key: 'Language', value: 'en' },
40
41
  ],
42
+ general_text: [
43
+ {
44
+ Back_To_Map_Link: 'Back to map',
45
+ Country_Or_Area: 'Testland',
46
+ },
47
+ ],
41
48
  },
42
49
  },
43
50
  },
51
+ parent: {
52
+ '@id': '/signatories-map',
53
+ },
44
54
  };
45
55
 
56
+ const renderWithRouter = (ui) => render(<MemoryRouter>{ui}</MemoryRouter>);
57
+
46
58
  it('renders tab labels and default content', () => {
47
- render(<MissionSignatoryProfileView content={content} />);
59
+ renderWithRouter(<MissionSignatoryProfileView content={content} />);
48
60
 
49
- // Tab labels
50
61
  expect(screen.getByText('Governance')).toBeInTheDocument();
51
62
  expect(screen.getByText('Assessment')).toBeInTheDocument();
52
63
  expect(screen.getByText('Planning & Target')).toBeInTheDocument();
@@ -54,7 +65,7 @@ describe('MissionSignatoryProfileView', () => {
54
65
  });
55
66
 
56
67
  it('switches tabs and renders corresponding content', () => {
57
- render(<MissionSignatoryProfileView content={content} />);
68
+ renderWithRouter(<MissionSignatoryProfileView content={content} />);
58
69
 
59
70
  fireEvent.click(screen.getByText('Governance'));
60
71
  expect(screen.getByText('Mocked Governance')).toBeInTheDocument();
@@ -70,10 +81,10 @@ describe('MissionSignatoryProfileView', () => {
70
81
  });
71
82
 
72
83
  it('renders footer disclaimer text if present', () => {
73
- render(<MissionSignatoryProfileView content={content} />);
84
+ renderWithRouter(<MissionSignatoryProfileView content={content} />);
74
85
  expect(screen.getByText('Disclaimer Title')).toBeInTheDocument();
75
86
  expect(
76
- screen.getByText((content) => content.includes('This is a disclaimer.')),
87
+ screen.getByText((text) => text.includes('This is a disclaimer.')),
77
88
  ).toBeInTheDocument();
78
89
  });
79
90
  });
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Html helper.
3
+ * @module helpers/Html
4
+ */
5
+
6
+ import React, { Component } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import Helmet from '@plone/volto/helpers/Helmet/Helmet';
9
+ import serialize from 'serialize-javascript';
10
+ import { join } from 'lodash';
11
+ import BodyClass from '@plone/volto/helpers/BodyClass/BodyClass';
12
+ import { runtimeConfig } from '@plone/volto/runtime_config';
13
+ import config from '@plone/volto/registry';
14
+
15
+ const CRITICAL_CSS_TEMPLATE = `function alter() {
16
+ document.querySelectorAll("head link[rel='prefetch']").forEach(function(el) { el.rel = 'stylesheet'});
17
+ }
18
+ if (window.addEventListener) {
19
+ window.addEventListener('DOMContentLoaded', alter, false)
20
+ } else {
21
+ window.onload=alter
22
+ }`;
23
+
24
+ export const loadReducers = (state = {}) => {
25
+ const { settings } = config;
26
+ return Object.assign(
27
+ {},
28
+ ...Object.keys(state).map((name) =>
29
+ settings.initialReducersBlacklist.includes(name)
30
+ ? {}
31
+ : { [name]: state[name] },
32
+ ),
33
+ );
34
+ };
35
+
36
+ /**
37
+ * Html class.
38
+ * Wrapper component containing HTML metadata and boilerplate tags.
39
+ * Used in server-side code only to wrap the string output of the
40
+ * rendered route component.
41
+ *
42
+ * The only thing this component doesn't (and can't) include is the
43
+ * HTML doctype declaration, which is added to the rendered output
44
+ * by the server.js file.
45
+ *
46
+ * Critical.css behaviour: when a file `public/critical.css` is present, the
47
+ * loading of stylesheets is changed. The styles in critical.css are inlined in
48
+ * the generated HTML, and the whole story needs to change completely: instead
49
+ * of treating stylesheets as priority for rendering, we want to defer their
50
+ * loading as much as possible. So we change the stylesheets to be prefetched
51
+ * and we switch their rel back to stylesheets at document ready event.
52
+ *
53
+ * @function Html
54
+ * @param {Object} props Component properties.
55
+ * @param {Object} props.assets Assets to be rendered.
56
+ * @param {Object} props.component Content to be rendered as child node.
57
+ * @param {Object} props.store Store object.
58
+ * @returns {string} Markup of the not found page.
59
+ */
60
+
61
+ /**
62
+ * Html class.
63
+ * @class Html
64
+ * @extends Component
65
+ */
66
+ class Html extends Component {
67
+ /**
68
+ * Property types.
69
+ * @property {Object} propTypes Property types.
70
+ * @static
71
+ */
72
+ static propTypes = {
73
+ extractor: PropTypes.shape({
74
+ getLinkElements: PropTypes.func.isRequired,
75
+ getScriptElements: PropTypes.func.isRequired,
76
+ getStyleElements: PropTypes.func.isRequired,
77
+ }).isRequired,
78
+ markup: PropTypes.string.isRequired,
79
+ store: PropTypes.shape({
80
+ getState: PropTypes.func,
81
+ }).isRequired,
82
+ nonce: PropTypes.string,
83
+ };
84
+
85
+ /**
86
+ * Render method.
87
+ * @method render
88
+ * @returns {string} Markup for the component.
89
+ */
90
+ render() {
91
+ const {
92
+ extractor,
93
+ markup,
94
+ store,
95
+ criticalCss,
96
+ apiPath,
97
+ publicURL,
98
+ nonce,
99
+ } = this.props;
100
+ const head = Helmet.rewind();
101
+ const bodyClass = join(BodyClass.rewind(), ' ');
102
+ const htmlAttributes = head.htmlAttributes.toComponent();
103
+
104
+ return (
105
+ <html lang={htmlAttributes.lang}>
106
+ <head>
107
+ <meta charSet="utf-8" />
108
+ {head.base.toComponent()}
109
+ {head.title.toComponent()}
110
+ {head.meta.toComponent()}
111
+ {head.link.toComponent()}
112
+ {head.script.toComponent()}
113
+
114
+ {React.createElement('script', {
115
+ nonce: nonce,
116
+ dangerouslySetInnerHTML: {
117
+ __html: `window.env = ${serialize(
118
+ {
119
+ ...runtimeConfig,
120
+ // Seamless mode requirement, the client need to know where the API is located
121
+ // if not set in the API_PATH
122
+ ...(apiPath && {
123
+ apiPath,
124
+ }),
125
+ ...(publicURL && {
126
+ publicURL,
127
+ }),
128
+ },
129
+ { space: 2 },
130
+ )};`,
131
+ },
132
+ })}
133
+
134
+ <link rel="icon" href="/favicon.ico" sizes="any" />
135
+ <link rel="icon" href="/icon.svg" type="image/svg+xml" />
136
+ <link
137
+ rel="apple-touch-icon"
138
+ sizes="180x180"
139
+ href="/apple-touch-icon.png"
140
+ />
141
+ <link rel="manifest" href="/site.webmanifest" />
142
+ <meta name="generator" content="Plone 6 - https://plone.org" />
143
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
144
+ <meta name="apple-mobile-web-app-capable" content="yes" />
145
+ {process.env.NODE_ENV === 'production' && criticalCss && (
146
+ <style
147
+ dangerouslySetInnerHTML={{ __html: this.props.criticalCss }}
148
+ />
149
+ )}
150
+ {/* Add the crossorigin while in development */}
151
+ {extractor.getLinkElements().map((elem) =>
152
+ React.cloneElement(elem, {
153
+ crossOrigin:
154
+ process.env.NODE_ENV === 'production' ? undefined : 'true',
155
+ rel: !criticalCss
156
+ ? elem.props.rel
157
+ : elem.props.as === 'style'
158
+ ? 'prefetch'
159
+ : elem.props.rel,
160
+ }),
161
+ )}
162
+ {/* Styles in development are loaded with Webpack's style-loader, in production,
163
+ they need to be static*/}
164
+ {process.env.NODE_ENV === 'production' ? (
165
+ criticalCss ? (
166
+ <>
167
+ <script
168
+ dangerouslySetInnerHTML={{
169
+ __html: CRITICAL_CSS_TEMPLATE,
170
+ }}
171
+ ></script>
172
+ {extractor.getStyleElements().map((elem) => (
173
+ <noscript>
174
+ {React.cloneElement(elem, {
175
+ rel: 'stylesheet',
176
+ crossOrigin:
177
+ process.env.NODE_ENV === 'production'
178
+ ? undefined
179
+ : 'true',
180
+ })}
181
+ </noscript>
182
+ ))}
183
+ </>
184
+ ) : (
185
+ extractor.getStyleElements()
186
+ )
187
+ ) : undefined}
188
+ </head>
189
+ <body className={bodyClass}>
190
+ <div role="navigation" aria-label="Toolbar" id="toolbar" />
191
+ <div id="main" dangerouslySetInnerHTML={{ __html: markup }} />
192
+ <div role="complementary" aria-label="Sidebar" id="sidebar" />
193
+ {React.createElement('script', {
194
+ nonce: nonce,
195
+ dangerouslySetInnerHTML: {
196
+ __html: `window.__data=${serialize(
197
+ loadReducers(store.getState()),
198
+ { space: 2 },
199
+ )};`,
200
+ },
201
+ charSet: 'UTF-8',
202
+ })}
203
+ {/* Add the crossorigin while in development */}
204
+ {this.props.extractScripts !== false
205
+ ? extractor.getScriptElements().map((elem) =>
206
+ React.cloneElement(elem, {
207
+ nonce: nonce,
208
+ crossOrigin:
209
+ process.env.NODE_ENV === 'production' ? undefined : 'true',
210
+ }),
211
+ )
212
+ : ''}
213
+ </body>
214
+ </html>
215
+ );
216
+ }
217
+ }
218
+
219
+ export default Html;
@@ -0,0 +1,3 @@
1
+ Customized for CSP support. Copy of https://github.com/plone/volto/blob/8b0f2af98ce0362f6975ce9c50137f6bd7cc3bb8/src/helpers/Html/Html.jsx Volto 17.x.x branch
2
+
3
+ Added formatting of json serialized strings
@@ -20,6 +20,7 @@ import { resetServerContext } from 'react-beautiful-dnd';
20
20
  import { CookiesProvider } from 'react-cookie';
21
21
  import cookiesMiddleware from 'universal-cookie-express';
22
22
  import debug from 'debug';
23
+ // import crypto from 'crypto';
23
24
 
24
25
  import routes from '@root/routes';
25
26
  import config from '@plone/volto/registry';
@@ -64,6 +65,18 @@ if (config.settings) {
64
65
  });
65
66
  }
66
67
 
68
+ // function buildCSPHeader(opts, nonce) {
69
+ // return Object.keys(opts)
70
+ // .sort()
71
+ // .reduce((acc, key) => {
72
+ // return [
73
+ // ...acc,
74
+ // `${key} ${opts[key].replaceAll('{nonce}', `'nonce-${nonce}'`)}`,
75
+ // ];
76
+ // }, [])
77
+ // .join('; ');
78
+ // }
79
+
67
80
  function reactIntlErrorHandler(error) {
68
81
  debug('i18n')(error);
69
82
  }
@@ -71,6 +84,7 @@ function reactIntlErrorHandler(error) {
71
84
  const supported = new locale.Locales(keys(languages), 'en');
72
85
 
73
86
  const server = express()
87
+ .set('etag', false)
74
88
  .disable('x-powered-by')
75
89
  .head('/*', function (req, res) {
76
90
  // Support for HEAD requests. Required by start-test utility in CI.
package/src/index.js CHANGED
@@ -555,6 +555,13 @@ const applyConfig = (config) => {
555
555
  ...config.settings.storeExtenders,
556
556
  ];
557
557
 
558
+ config.settings.initialReducersBlacklist = [
559
+ ...config.settings.initialReducersBlacklist,
560
+ 'intl',
561
+ // 'router',
562
+ // 'content',
563
+ ];
564
+
558
565
  config.widgets.vocabulary[
559
566
  'plone.app.vocabularies.Users'
560
567
  ] = SelectAutoCompleteWidget;
@@ -63,7 +63,6 @@ cca_build_runtime_mappings['op_cluster'] = {
63
63
 
64
64
  export default function installMainSearch(config) {
65
65
  const envConfig = ccaConfig;
66
-
67
66
  const pjson = require('@eeacms/volto-cca-policy/../package.json');
68
67
 
69
68
  envConfig.app_name = pjson.name;
@@ -221,7 +220,17 @@ export default function installMainSearch(config) {
221
220
  config.searchui.ccaSearch.host =
222
221
  process.env.RAZZLE_ES_PROXY_ADDR || getClientProxyAddress();
223
222
  }
223
+ let fieldsMatchAll = [
224
+ 'cca_climate_impacts.keyword',
225
+ 'cca_adaptation_sectors.keyword',
226
+ 'cca_adaptation_elements.keyword',
227
+ 'cca_key_type_measure.keyword',
228
+ ];
229
+ config.searchui.ccaSearch.facets.forEach((facet) => {
230
+ if (fieldsMatchAll.includes(facet.field)) {
231
+ facet.filterType = 'all';
232
+ }
233
+ });
224
234
 
225
- // console.log(config);
226
235
  return config;
227
236
  }
@@ -123,6 +123,19 @@ body.subsite-mkh {
123
123
  margin: 2em 0 !important;
124
124
  }
125
125
 
126
+ .ui.inverted.button.back-to-map {
127
+ margin-bottom: 2em;
128
+ box-shadow: 0px 0px 0px 2px @pineGreen inset !important;
129
+ color: @pineGreen;
130
+
131
+ &:hover,
132
+ &:active,
133
+ &:focus,
134
+ &:focus-visible {
135
+ background-color: @pineGreen;
136
+ }
137
+ }
138
+
126
139
  .column > .ui.segment {
127
140
  background-color: #fff !important;
128
141
  }
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import { Tab } from 'semantic-ui-react';
3
- import { Callout } from '@eeacms/volto-eea-design-system/ui';
4
-
5
- const IntroductionTab = () => {
6
- return (
7
- <Tab.Pane>
8
- <h2>Introduction</h2>
9
- <Callout>
10
- Duis non quam et nisi tincidunt fermentum. Pellentesque habitant morbi
11
- tristique senectus et netus et malesuada fames ac turpis egestas.
12
- </Callout>
13
- <h3>The Mission on Adaptation</h3>
14
- <p>
15
- Nulla facilisi. Donec fringilla urna id ligula ullamcorper, vel
16
- tristique lorem posuere. Donec et orci mauris. Nullam tempor velit id mi
17
- luctus, a scelerisque libero accumsan. In hac habitasse platea dictumst.
18
- Cras ac nunc nec massa tristique fringilla.
19
- </p>
20
- <h3>Data source</h3>
21
- <p>
22
- Donec eget libero id leo congue venenatis. Ut enim ad minim veniam, quis
23
- nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
24
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit
25
- esse cillum dolore eu fugiat nulla pariatur.
26
- </p>
27
- <p>
28
- Donec eget libero id leo congue venenatis. Ut enim ad minim veniam, quis
29
- nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
30
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit
31
- esse cillum dolore eu fugiat nulla pariatur.
32
- </p>
33
- </Tab.Pane>
34
- );
35
- };
36
-
37
- export default IntroductionTab;