@eeacms/volto-eea-website-policy 1.3.2 → 1.3.4

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,23 @@ 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.3.4](https://github.com/eea/volto-eea-website-policy/compare/1.3.3...1.3.4) - 17 February 2023
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(LinkView): Consider /en/ only links as internal - refs #158717 [Alin Voinea - [`a39598a`](https://github.com/eea/volto-eea-website-policy/commit/a39598ade9430bc9c3f20d63e33cb19774cd365a)]
12
+ - fix(LinkView): Try to use window.location.replace to redirect Links - refs #158717 [Alin Voinea - [`7210193`](https://github.com/eea/volto-eea-website-policy/commit/7210193090295fcd116aa831296b70238508f037)]
13
+ - fix(LinkView): Copy unchanged from volto 16.11.0 [Alin Voinea - [`3cf2634`](https://github.com/eea/volto-eea-website-policy/commit/3cf263464f1729b503561088582ca6657212fbd1)]
14
+
15
+ ### [1.3.3](https://github.com/eea/volto-eea-website-policy/compare/1.3.2...1.3.3) - 17 February 2023
16
+
17
+ #### :bug: Bug Fixes
18
+
19
+ - fix(externalRoutes): Consider everything outside /en as external routes - refs #158717 [Alin Voinea - [`cfa1bb7`](https://github.com/eea/volto-eea-website-policy/commit/cfa1bb756d2bf73cd492f1995116e2a17b36d414)]
20
+
21
+ #### :hammer_and_wrench: Others
22
+
23
+ - Do not override externalRoutes [Alin Voinea - [`feaa112`](https://github.com/eea/volto-eea-website-policy/commit/feaa1127ca81e67adafc3714a9bd5bcadb4af5a9)]
7
24
  ### [1.3.2](https://github.com/eea/volto-eea-website-policy/compare/1.3.1...1.3.2) - 16 February 2023
8
25
 
9
26
  #### :bug: Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-policy",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
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",
@@ -0,0 +1,92 @@
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 } from 'semantic-ui-react';
10
+ import { UniversalLink } from '@plone/volto/components';
11
+ import { FormattedMessage } from 'react-intl';
12
+ import config from '@plone/volto/registry';
13
+
14
+ /**
15
+ * View container class.
16
+ * @class View
17
+ * @extends Component
18
+ */
19
+ class LinkView extends Component {
20
+ /**
21
+ * Property types.
22
+ * @property {Object} propTypes Property types.
23
+ * @static
24
+ */
25
+ static propTypes = {
26
+ content: PropTypes.shape({
27
+ title: PropTypes.string,
28
+ description: PropTypes.string,
29
+ remoteUrl: PropTypes.string,
30
+ }),
31
+ token: PropTypes.string,
32
+ };
33
+
34
+ /**
35
+ * Default properties.
36
+ * @property {Object} defaultProps Default properties.
37
+ * @static
38
+ */
39
+ static defaultProps = {
40
+ content: null,
41
+ token: null,
42
+ };
43
+
44
+ componentDidMount() {
45
+ if (!this.props.token) {
46
+ const { remoteUrl } = this.props.content;
47
+ if (isInternalURL(remoteUrl) && remoteUrl.includes('/en/')) {
48
+ this.props.history.replace(flattenToAppURL(remoteUrl));
49
+ } else if (!__SERVER__) {
50
+ window.location.replace(flattenToAppURL(remoteUrl));
51
+ }
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Render method.
57
+ * @method render
58
+ * @returns {string} Markup for the component.
59
+ */
60
+ render() {
61
+ const { remoteUrl } = this.props.content;
62
+ const { openExternalLinkInNewTab } = config.settings;
63
+ return (
64
+ <Container id="page-document">
65
+ <h1 className="documentFirstHeading">{this.props.content.title}</h1>
66
+ {this.props.content.description && (
67
+ <p className="documentDescription">
68
+ {this.props.content.description}
69
+ </p>
70
+ )}
71
+ {remoteUrl && (
72
+ <p>
73
+ <FormattedMessage
74
+ id="The link address is:"
75
+ defaultMessage="The link address is:"
76
+ />{' '}
77
+ <UniversalLink
78
+ href={remoteUrl}
79
+ openLinkInNewTab={
80
+ openExternalLinkInNewTab && !isInternalURL(remoteUrl)
81
+ }
82
+ >
83
+ {flattenToAppURL(remoteUrl)}
84
+ </UniversalLink>
85
+ </p>
86
+ )}
87
+ </Container>
88
+ );
89
+ }
90
+ }
91
+
92
+ export default LinkView;
package/src/index.js CHANGED
@@ -5,18 +5,17 @@ import { addStylingFieldsetSchemaEnhancer } from '@eeacms/volto-eea-website-poli
5
5
 
6
6
  const applyConfig = (config) => {
7
7
  // #158717#note-25 any path that isn't static, en or controlpanel is treated as external
8
- if (!config.settings.publicURL.includes('localhost')) {
9
- const notInEN = /^(?!.*(\/en|\/static|\/controlpanel|\/cypress)).*$/;
10
- config.settings.externalRoutes = [
11
- {
12
- match: {
13
- path: notInEN,
14
- exact: false,
15
- strict: false,
16
- },
8
+ const notInEN = /^(?!.*(\/en|\/static|\/controlpanel|\/cypress)).*$/;
9
+ config.settings.externalRoutes = [
10
+ ...(config.settings.externalRoutes || []),
11
+ {
12
+ match: {
13
+ path: notInEN,
14
+ exact: false,
15
+ strict: false,
17
16
  },
18
- ];
19
- }
17
+ },
18
+ ];
20
19
 
21
20
  // #137187 Keycloak integration
22
21
  if (runtimeConfig['RAZZLE_KEYCLOAK'] === 'Yes') {
@@ -52,6 +51,11 @@ const applyConfig = (config) => {
52
51
  // (item) => item.code,
53
52
  // ) || ['en'];
54
53
 
54
+ // Logo URL
55
+ if (config.settings.eea) {
56
+ config.settings.eea.logoTargetUrl = '/en';
57
+ }
58
+
55
59
  // Block chooser
56
60
  config.blocks.blocksConfig.image.mostUsed = false;
57
61
  config.blocks.blocksConfig.video.mostUsed = false;