@eeacms/volto-eea-website-policy 1.3.3 → 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,14 @@ 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
+
7
15
  ### [1.3.3](https://github.com/eea/volto-eea-website-policy/compare/1.3.2...1.3.3) - 17 February 2023
8
16
 
9
17
  #### :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.3",
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;