@eeacms/volto-cca-policy 0.2.78 → 0.2.80

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,11 +4,29 @@ 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.2.78](https://github.com/eea/volto-cca-policy/compare/0.2.77...0.2.78) - 12 November 2024
7
+ ### [0.2.80](https://github.com/eea/volto-cca-policy/compare/0.2.79...0.2.80) - 15 November 2024
8
+
9
+ #### :rocket: Dependency updates
10
+
11
+ - Release @eeacms/volto-eea-website-theme@3.2.0 [EEA Jenkins - [`1308dd8`](https://github.com/eea/volto-cca-policy/commit/1308dd86de26ed38680967f31b4e83874b54160b)]
8
12
 
9
13
  #### :hammer_and_wrench: Others
10
14
 
11
- - Fix links in acecontent blocks [Tiberiu Ichim - [`93be4c9`](https://github.com/eea/volto-cca-policy/commit/93be4c97e840827574de9b7c70c00b7c96fed49d)]
15
+ - Cleanup [Tiberiu Ichim - [`965ac84`](https://github.com/eea/volto-cca-policy/commit/965ac84f05dea092dff9b9900dfc41259b3b2caf)]
16
+ - Downgrade eea website theme [Tiberiu Ichim - [`d074718`](https://github.com/eea/volto-cca-policy/commit/d0747189db37e3496baf11b0886c91b18f70b9d4)]
17
+ - Downgrade eea website theme [Tiberiu Ichim - [`38f482f`](https://github.com/eea/volto-cca-policy/commit/38f482fdb52bf7f35c6102021347d3d77b4ee177)]
18
+ - Add patch for compatibility with volto 17 [Tiberiu Ichim - [`393bb08`](https://github.com/eea/volto-cca-policy/commit/393bb085551b8cdef7a0a29fcddb72e5c95f6255)]
19
+ - Add override for LinkView [Tiberiu Ichim - [`b478df3`](https://github.com/eea/volto-cca-policy/commit/b478df3b6cdaa24cdfffd7146181f66c5e3e5ddb)]
20
+ ### [0.2.79](https://github.com/eea/volto-cca-policy/compare/0.2.78...0.2.79) - 14 November 2024
21
+
22
+ #### :hammer_and_wrench: Others
23
+
24
+ - Fix match of url [Tiberiu Ichim - [`9afd6d0`](https://github.com/eea/volto-cca-policy/commit/9afd6d0fae594c70b8e22c77e5017b8a5c3211fb)]
25
+ - Fix match of url [Tiberiu Ichim - [`199befd`](https://github.com/eea/volto-cca-policy/commit/199befd31202a2f2c97b904eb9471027b47e4e18)]
26
+ - Fix getURL [Tiberiu Ichim - [`a9488e2`](https://github.com/eea/volto-cca-policy/commit/a9488e2f289c9898e9182190ba597af00949bef6)]
27
+ - Allow iframes in database items views [Tiberiu Ichim - [`1995e04`](https://github.com/eea/volto-cca-policy/commit/1995e04d86d5594035cd37e8d5f161b33c04280e)]
28
+ ### [0.2.78](https://github.com/eea/volto-cca-policy/compare/0.2.77...0.2.78) - 12 November 2024
29
+
12
30
  ### [0.2.77](https://github.com/eea/volto-cca-policy/compare/0.2.76...0.2.77) - 7 November 2024
13
31
 
14
32
  #### :house: Internal changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.2.78",
3
+ "version": "0.2.80",
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",
@@ -30,7 +30,7 @@
30
30
  "@eeacms/volto-block-style": "github:eea/volto-block-style#6.x.x",
31
31
  "@eeacms/volto-datablocks": "^7.2.5",
32
32
  "@eeacms/volto-eea-design-system": "*",
33
- "@eeacms/volto-eea-website-theme": "1.35.0",
33
+ "@eeacms/volto-eea-website-theme": "^1.35.0",
34
34
  "@eeacms/volto-embed": "^9.1.1",
35
35
  "@eeacms/volto-globalsearch": "^1.1.0",
36
36
  "@eeacms/volto-hero-block": "^7.1.0",
@@ -53,6 +53,83 @@ const dataprotection = {
53
53
  ],
54
54
  };
55
55
 
56
+ const MaybeFlourishVisualization = ({ content }) => {
57
+ const { map_graphs } = content;
58
+
59
+ // https://helpcenter.flourish.studio/hc/en-us/articles/8761537208463-How-to-embed-Flourish-charts-in-your-CMS
60
+ const data_src = (map_graphs) => {
61
+ if (typeof map_graphs === 'string') {
62
+ const regex = /data-src="([^"]*)"/;
63
+ const match = regex.exec(map_graphs);
64
+
65
+ if (match && match.length > 1) {
66
+ const dataSrcValue = match[1];
67
+ return dataSrcValue;
68
+ }
69
+ }
70
+ return null;
71
+ };
72
+ const flourishPath = data_src(map_graphs);
73
+ const flourishUrl = map_graphs
74
+ ? `https://flo.uri.sh/${flourishPath}/embed`
75
+ : null;
76
+
77
+ return !!flourishPath ? (
78
+ <PrivacyProtection
79
+ data={{
80
+ url: flourishUrl,
81
+ dataprotection: dataprotection,
82
+ }}
83
+ >
84
+ <iframe
85
+ height="980"
86
+ width="100%"
87
+ src={flourishUrl}
88
+ title="Interactive or visual content"
89
+ className="flourish-embed-iframe"
90
+ sandbox="allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"
91
+ ></iframe>
92
+ </PrivacyProtection>
93
+ ) : null;
94
+ };
95
+
96
+ function getFirstIframeSrc(htmlString) {
97
+ const regex = /<iframe[^>]+src=["']([^"']+)["']/;
98
+ const match = htmlString.match(regex);
99
+ return match ? match[1] : null;
100
+ }
101
+
102
+ const MaybeIframeVisualization = ({ content }) => {
103
+ const { map_graphs } = content;
104
+
105
+ const url = getFirstIframeSrc(map_graphs || '');
106
+
107
+ const [isClient, setIsClient] = React.useState();
108
+
109
+ React.useEffect(() => setIsClient(true), []);
110
+
111
+ if (!(isClient && url)) return null;
112
+
113
+ // <div dangerouslySetInnerHTML={{ __html: map_graphs }} />
114
+ return (
115
+ <PrivacyProtection
116
+ data={{
117
+ url: url,
118
+ dataprotection: dataprotection,
119
+ }}
120
+ >
121
+ <iframe
122
+ height="980"
123
+ width="100%"
124
+ src={url}
125
+ title="Interactive or visual content"
126
+ className="flourish-embed-iframe"
127
+ sandbox="allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"
128
+ ></iframe>
129
+ </PrivacyProtection>
130
+ );
131
+ };
132
+
56
133
  const DatabaseItemView = (props) => {
57
134
  const { content } = props;
58
135
  const type = content['@type'];
@@ -62,7 +139,6 @@ const DatabaseItemView = (props) => {
62
139
  title,
63
140
  acronym,
64
141
  embed_url,
65
- map_graphs,
66
142
  long_description,
67
143
  organisational_websites,
68
144
  organisational_key_activities,
@@ -98,24 +174,6 @@ const DatabaseItemView = (props) => {
98
174
  subtitle = '';
99
175
  }
100
176
 
101
- // https://helpcenter.flourish.studio/hc/en-us/articles/8761537208463-How-to-embed-Flourish-charts-in-your-CMS
102
- const data_src = (map_graphs) => {
103
- if (typeof map_graphs === 'string') {
104
- const regex = /data-src="([^"]*)"/;
105
- const match = regex.exec(map_graphs);
106
-
107
- if (match && match.length > 1) {
108
- const dataSrcValue = match[1];
109
- return dataSrcValue;
110
- }
111
- }
112
- return null;
113
- };
114
- const flourishPath = data_src(map_graphs);
115
- const flourishUrl = map_graphs
116
- ? `https://flo.uri.sh/${flourishPath}/embed`
117
- : null;
118
-
119
177
  const is_cmshare_video = share_eea.some((domain) =>
120
178
  content?.embed_url?.includes(domain),
121
179
  );
@@ -217,23 +275,8 @@ const DatabaseItemView = (props) => {
217
275
  </>
218
276
  )}
219
277
 
220
- {!!flourishPath && (
221
- <PrivacyProtection
222
- data={{
223
- url: flourishUrl,
224
- dataprotection: dataprotection,
225
- }}
226
- >
227
- <iframe
228
- height="980"
229
- width="100%"
230
- src={flourishUrl}
231
- title="Interactive or visual content"
232
- className="flourish-embed-iframe"
233
- sandbox="allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"
234
- ></iframe>
235
- </PrivacyProtection>
236
- )}
278
+ <MaybeFlourishVisualization {...props} />
279
+ <MaybeIframeVisualization {...props} />
237
280
 
238
281
  <Divider />
239
282
 
@@ -53,7 +53,7 @@ const UniversalLink = ({
53
53
  //case: item like a Link
54
54
  let remoteUrl = item.remoteUrl || item.getRemoteUrl;
55
55
  if (!token && remoteUrl) {
56
- url = remoteUrl;
56
+ url = item.getURL; // we use getURL, it is better
57
57
  }
58
58
 
59
59
  //case: item of type 'File'
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Link View.
3
+ * @module components/theme/View/LinkView
4
+ */
5
+
6
+ import React, { Component } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
9
+ import { Container as SemanticContainer } from 'semantic-ui-react';
10
+ import { UniversalLink } from '@plone/volto/components';
11
+ import { Redirect } from 'react-router-dom';
12
+ import { FormattedMessage } from 'react-intl';
13
+ import config from '@plone/volto/registry';
14
+
15
+ /**
16
+ * View container class.
17
+ * @class View
18
+ * @extends Component
19
+ */
20
+ class LinkView extends Component {
21
+ /**
22
+ * Property types.
23
+ * @property {Object} propTypes Property types.
24
+ * @static
25
+ */
26
+ static propTypes = {
27
+ content: PropTypes.shape({
28
+ title: PropTypes.string,
29
+ description: PropTypes.string,
30
+ remoteUrl: PropTypes.string,
31
+ }),
32
+ token: PropTypes.string,
33
+ };
34
+
35
+ /**
36
+ * Default properties.
37
+ * @property {Object} defaultProps Default properties.
38
+ * @static
39
+ */
40
+ static defaultProps = {
41
+ content: null,
42
+ token: null,
43
+ };
44
+
45
+ componentDidMount() {
46
+ if (!this.props.token) {
47
+ let { remoteUrl } = this.props.content;
48
+ // eslint-disable-next-line
49
+ remoteUrl = remoteUrl.replaceAll('${portal_url}', '');
50
+
51
+ if (isInternalURL(remoteUrl)) {
52
+ this.props.history.replace(flattenToAppURL(remoteUrl));
53
+ } else if (!__SERVER__) {
54
+ window.location.href = flattenToAppURL(remoteUrl);
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Render method.
61
+ * @method render
62
+ * @returns {string} Markup for the component.
63
+ */
64
+ render() {
65
+ let { remoteUrl } = this.props.content;
66
+ // eslint-disable-next-line
67
+ remoteUrl = flattenToAppURL(remoteUrl.replaceAll('${portal_url}', ''));
68
+
69
+ if (__SERVER__ && !this.props.token && remoteUrl) {
70
+ return <Redirect to={remoteUrl} />;
71
+ }
72
+ const { openExternalLinkInNewTab } = config.settings;
73
+ const Container =
74
+ config.getComponent({ name: 'Container' }).component || SemanticContainer;
75
+
76
+ return (
77
+ <Container id="page-document">
78
+ <h1 className="documentFirstHeading">{this.props.content.title}</h1>
79
+ {this.props.content.description && (
80
+ <p className="documentDescription">
81
+ {this.props.content.description}
82
+ </p>
83
+ )}
84
+ {remoteUrl && (
85
+ <p>
86
+ <FormattedMessage
87
+ id="The link address is:"
88
+ defaultMessage="The link address is:"
89
+ />{' '}
90
+ <UniversalLink
91
+ href={remoteUrl}
92
+ openLinkInNewTab={
93
+ openExternalLinkInNewTab && !isInternalURL(remoteUrl)
94
+ }
95
+ >
96
+ {flattenToAppURL(remoteUrl)}
97
+ </UniversalLink>
98
+ </p>
99
+ )}
100
+ </Container>
101
+ );
102
+ }
103
+ }
104
+
105
+ export default LinkView;