@eeacms/volto-cca-policy 0.1.37 → 0.1.39

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,7 +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
- ### [0.1.37](https://github.com/eea/volto-cca-policy/compare/0.1.36...0.1.37) - 11 August 2023
7
+ ### [0.1.39](https://github.com/eea/volto-cca-policy/compare/0.1.38...0.1.39) - 22 August 2023
8
+
9
+ ### [0.1.38](https://github.com/eea/volto-cca-policy/compare/0.1.37...0.1.38) - 21 August 2023
10
+
11
+ #### :hammer_and_wrench: Others
12
+
13
+ - Add readme [Tiberiu Ichim - [`10d78c6`](https://github.com/eea/volto-cca-policy/commit/10d78c65336a3f5d38d2843910eae40b47aa8d98)]
14
+ ### [0.1.37](https://github.com/eea/volto-cca-policy/compare/0.1.36...0.1.37) - 14 August 2023
8
15
 
9
16
  ### [0.1.36](https://github.com/eea/volto-cca-policy/compare/0.1.35...0.1.36) - 11 August 2023
10
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
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",
@@ -0,0 +1 @@
1
+ Fix for https://github.com/plone/volto/pull/5106
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Login container.
3
+ * @module components/theme/Sitemap/Sitemap
4
+ */
5
+
6
+ import React, { Component } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { compose } from 'redux';
9
+ import { connect } from 'react-redux';
10
+ import { asyncConnect } from '@plone/volto/helpers';
11
+ import { defineMessages, injectIntl } from 'react-intl';
12
+ import { Container } from 'semantic-ui-react';
13
+ import { Helmet } from '@plone/volto/helpers';
14
+ import { Link } from 'react-router-dom';
15
+ import config from '@plone/volto/registry';
16
+
17
+ import { getNavigation } from '@plone/volto/actions';
18
+
19
+ const messages = defineMessages({
20
+ Sitemap: {
21
+ id: 'Sitemap',
22
+ defaultMessage: 'Sitemap',
23
+ },
24
+ });
25
+
26
+ export function getSitemapPath(pathname = '', lang) {
27
+ const prefix = pathname.replace(/\/sitemap$/gm, '').replace(/^\//, '');
28
+ const path = prefix || lang || '';
29
+ return path;
30
+ }
31
+
32
+ export const toReactIntlLang = (language) => {
33
+ if (language.includes('_') || language.includes('-')) {
34
+ let langCode = language.split(/[-_]/);
35
+ langCode = `${langCode[0]}-${langCode[1].toUpperCase()}`;
36
+ return langCode;
37
+ }
38
+
39
+ return language;
40
+ };
41
+ // export const toLangUnderscoreRegion = toReactIntlLang; // old name for backwards-compat
42
+
43
+ /**
44
+ * Converts a language code like pt_BR or pt-BR to the format `pt-br`.
45
+ * This format is used on the backend and in volto config settings.
46
+ * @param {string} language Language to be converted
47
+ * @returns {string} Language converted
48
+ */
49
+ export const toBackendLang = (language) => {
50
+ return toReactIntlLang(language).toLowerCase();
51
+ };
52
+
53
+ /**
54
+ * Sitemap class.
55
+ * @class Sitemap
56
+ * @extends Component
57
+ */
58
+ class Sitemap extends Component {
59
+ /**
60
+ * Property types.
61
+ * @property {Object} propTypes Property types.
62
+ * @static
63
+ */
64
+ static propTypes = {
65
+ getNavigation: PropTypes.func.isRequired,
66
+ };
67
+
68
+ componentDidMount() {
69
+ const { settings } = config;
70
+
71
+ const lang = settings.isMultilingual
72
+ ? `${toBackendLang(this.props.lang)}`
73
+ : null;
74
+
75
+ const path = getSitemapPath(this.props.location.pathname, lang);
76
+ this.props.getNavigation(path, 4);
77
+ }
78
+
79
+ /**
80
+ * Render method.
81
+ * @method render
82
+ * @returns {string} Markup for the component.
83
+ */
84
+
85
+ renderItems = (items) => {
86
+ return (
87
+ <ul>
88
+ {items.map((item) => (
89
+ <li
90
+ key={item.url}
91
+ className={item.items?.length > 0 ? 'with-children' : ''}
92
+ >
93
+ <Link to={item.url}>{item.title}</Link>
94
+ {item.items && this.renderItems(item.items)}
95
+ </li>
96
+ ))}
97
+ </ul>
98
+ );
99
+ };
100
+ render() {
101
+ const { items } = this.props;
102
+ return (
103
+ <div id="page-sitemap">
104
+ <Helmet title={this.props.intl.formatMessage(messages.Sitemap)} />
105
+ <Container className="view-wrapper">
106
+ <h1>{this.props.intl.formatMessage(messages.Sitemap)} </h1>
107
+ {items && this.renderItems(items)}
108
+ </Container>
109
+ </div>
110
+ );
111
+ }
112
+ }
113
+
114
+ export const __test__ = compose(
115
+ injectIntl,
116
+ connect(
117
+ (state) => ({
118
+ items: state.navigation.items,
119
+ lang: state.intl.locale,
120
+ }),
121
+ { getNavigation },
122
+ ),
123
+ )(Sitemap);
124
+
125
+ export default compose(
126
+ injectIntl,
127
+ connect(
128
+ (state) => ({
129
+ items: state.navigation.items,
130
+ lang: state.intl.locale,
131
+ }),
132
+ { getNavigation },
133
+ ),
134
+ asyncConnect([
135
+ {
136
+ key: 'navigation',
137
+ promise: ({ location, store: { dispatch, getState } }) => {
138
+ if (!__SERVER__) return;
139
+ const { settings } = config;
140
+
141
+ const path = getSitemapPath(
142
+ location.pathname,
143
+ settings.isMultilingual
144
+ ? toBackendLang(getState().intl.locale)
145
+ : null,
146
+ );
147
+
148
+ return dispatch(getNavigation(path, 4));
149
+ },
150
+ },
151
+ ]),
152
+ )(Sitemap);