@eeacms/volto-cca-policy 0.1.12 → 0.1.13

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
+ ### [0.1.13](https://github.com/eea/volto-cca-policy/compare/0.1.12...0.1.13) - 23 March 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Clear console.logs [kreafox - [`7a6098f`](https://github.com/eea/volto-cca-policy/commit/7a6098f63de6eba9eb2d4122893f38893900f945)]
12
+ - Add AddLinkForm override [kreafox - [`83bd2f4`](https://github.com/eea/volto-cca-policy/commit/83bd2f482bfc5bfa6a7795849778dc34e4d07fa1)]
13
+ - Enable video block [kreafox - [`69f4c1d`](https://github.com/eea/volto-cca-policy/commit/69f4c1d8bb6bd08a29a6ab50d1e5532295c8d2f3)]
14
+ - Update footer links [kreafox - [`9d32e61`](https://github.com/eea/volto-cca-policy/commit/9d32e6132892e310d6215e8d0e87b4e6052de6d3)]
7
15
  ### [0.1.12](https://github.com/eea/volto-cca-policy/compare/0.1.11...0.1.12) - 21 March 2023
8
16
 
9
17
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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,321 @@
1
+ /**
2
+ * Add link form.
3
+ * @module components/manage/AnchorPlugin/components/LinkButton/AddLinkForm
4
+ */
5
+
6
+ import React, { Component } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { compose } from 'redux';
9
+
10
+ // import unionClassNames from 'union-class-names';
11
+ import cx from 'classnames';
12
+ import {
13
+ addAppURL,
14
+ isInternalURL,
15
+ flattenToAppURL,
16
+ URLUtils,
17
+ } from '@plone/volto/helpers';
18
+
19
+ import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
20
+ import { Input, Form, Button } from 'semantic-ui-react';
21
+ import { defineMessages, injectIntl } from 'react-intl';
22
+
23
+ import clearSVG from '@plone/volto/icons/clear.svg';
24
+ import navTreeSVG from '@plone/volto/icons/nav.svg';
25
+ import aheadSVG from '@plone/volto/icons/ahead.svg';
26
+
27
+ import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
28
+ import { withRouter } from 'react-router';
29
+
30
+ import { Icon } from '@plone/volto/components';
31
+
32
+ const messages = defineMessages({
33
+ placeholder: {
34
+ id: 'Enter URL or select an item',
35
+ defaultMessage: 'Enter URL or select an item',
36
+ },
37
+ });
38
+
39
+ /**
40
+ * Add link form class.
41
+ * @class AddLinkForm
42
+ * @extends Component
43
+ */
44
+ class AddLinkForm extends Component {
45
+ static propTypes = {
46
+ onChangeValue: PropTypes.func.isRequired,
47
+ onClear: PropTypes.func.isRequired,
48
+ onOverrideContent: PropTypes.func.isRequired,
49
+ theme: PropTypes.objectOf(PropTypes.any).isRequired,
50
+ openObjectBrowser: PropTypes.func.isRequired,
51
+ };
52
+
53
+ static defaultProps = {
54
+ placeholder: 'Enter URL or select an item',
55
+ };
56
+
57
+ /**
58
+ * Constructor
59
+ * @method constructor
60
+ * @param {Object} props Component properties
61
+ * @constructs AddLinkForm
62
+ */
63
+ constructor(props) {
64
+ super(props);
65
+
66
+ this.state = {
67
+ value: isInternalURL(props.data.url)
68
+ ? flattenToAppURL(props.data.url)
69
+ : props.data.url || '',
70
+ isInvalid: false,
71
+ };
72
+ this.onRef = this.onRef.bind(this);
73
+ this.onChange = this.onChange.bind(this);
74
+ this.onKeyDown = this.onKeyDown.bind(this);
75
+ this.onSubmit = this.onSubmit.bind(this);
76
+ }
77
+
78
+ /**
79
+ * Component did mount
80
+ * @method componentDidMount
81
+ * @returns {undefined}
82
+ */
83
+ componentDidMount() {
84
+ setTimeout(() => this.input.focus(), 50);
85
+ document.addEventListener('mousedown', this.handleClickOutside, false);
86
+ }
87
+
88
+ componentWillUnmount() {
89
+ document.removeEventListener('mousedown', this.handleClickOutside, false);
90
+ }
91
+
92
+ handleClickOutside = (e) => {
93
+ if (
94
+ this.linkFormContainer.current &&
95
+ doesNodeContainClick(this.linkFormContainer.current, e)
96
+ )
97
+ return;
98
+ if (this.linkFormContainer.current && this.props.isObjectBrowserOpen)
99
+ return;
100
+ this.onClose();
101
+ };
102
+
103
+ /**
104
+ * Ref handler
105
+ * @method onRef
106
+ * @param {Object} node Node
107
+ * @returns {undefined}
108
+ */
109
+ onRef(node) {
110
+ this.input = node;
111
+ }
112
+
113
+ linkFormContainer = React.createRef();
114
+
115
+ /**
116
+ * Change handler
117
+ * @method onChange
118
+ * @param {Object} value Value
119
+ * @returns {undefined}
120
+ */
121
+ onChange(value, clear, callback) {
122
+ let nextState = { value };
123
+ // debugger;
124
+ if (!clear) {
125
+ if (
126
+ this.state.isInvalid &&
127
+ URLUtils.isUrl(URLUtils.normalizeUrl(value))
128
+ ) {
129
+ nextState.isInvalid = false;
130
+ }
131
+
132
+ if (isInternalURL(value)) {
133
+ nextState = { value: flattenToAppURL(value) };
134
+ }
135
+ }
136
+ this.setState(nextState, callback);
137
+
138
+ if (clear) this.props.onClear();
139
+ }
140
+
141
+ /**
142
+ * Select item handler
143
+ * @method onSelectItem
144
+ * @param {string} e event
145
+ * @param {string} url Url
146
+ * @returns {undefined}
147
+ */
148
+ onSelectItem = (e, url) => {
149
+ e.preventDefault();
150
+ this.setState({
151
+ value: url,
152
+ isInvalid: false,
153
+ });
154
+ this.props.onChangeValue(addAppURL(url));
155
+ };
156
+
157
+ /**
158
+ * Clear handler
159
+ * @method clear
160
+ * @param {Object} value Value
161
+ * @returns {undefined}
162
+ */
163
+ clear() {
164
+ const nextState = { value: '' };
165
+ this.setState(nextState);
166
+
167
+ this.props.onClear();
168
+ }
169
+
170
+ /**
171
+ * Close handler
172
+ * @method onClose
173
+ * @returns {undefined}
174
+ */
175
+ onClose = () => this.props.onOverrideContent(undefined);
176
+
177
+ /**
178
+ * Keydown handler
179
+ * @method onKeyDown
180
+ * @param {Object} e Event object
181
+ * @returns {undefined}
182
+ */
183
+ onKeyDown(e) {
184
+ if (e.key === 'Enter') {
185
+ e.preventDefault();
186
+ e.stopPropagation();
187
+ this.onSubmit();
188
+ } else if (e.key === 'Escape') {
189
+ e.preventDefault();
190
+ this.onClose();
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Submit handler
196
+ * @method onSubmit
197
+ * @returns {undefined}
198
+ */
199
+ onSubmit() {
200
+ let { value: url } = this.state;
201
+
202
+ const checkedURL = URLUtils.checkAndNormalizeUrl(url);
203
+ url = checkedURL.url;
204
+ if (!checkedURL.isValid) {
205
+ this.setState({ isInvalid: true });
206
+ return;
207
+ }
208
+
209
+ const editorStateUrl = isInternalURL(url) ? addAppURL(url) : url;
210
+
211
+ this.props.onChangeValue(editorStateUrl);
212
+ this.onClose();
213
+ }
214
+
215
+ /**
216
+ * Render method.
217
+ * @method render
218
+ * @returns {string} Markup for the component.
219
+ */
220
+ render() {
221
+ const { value, isInvalid } = this.state;
222
+ const className = isInvalid
223
+ ? cx(
224
+ 'ui input editor-link',
225
+ 'input-anchorlink-theme',
226
+ 'input-anchorlink-theme-Invalid',
227
+ )
228
+ : cx('ui input editor-link', 'input-anchorlink-theme');
229
+
230
+ return (
231
+ <div className="link-form-container" ref={this.linkFormContainer}>
232
+ <div
233
+ style={{ marginLeft: '5px', display: 'flex', alignItems: 'center' }}
234
+ >
235
+ <svg
236
+ xmlns="http://www.w3.org/2000/svg"
237
+ width="24"
238
+ height="24"
239
+ viewBox="0 0 36 36"
240
+ fill="#B8B2C8"
241
+ >
242
+ <g fillRule="evenodd">
243
+ <path d="M27.1318,7.333 C24.4028,4.604 19.9618,4.604 17.2328,7.333 L12.9898,11.576 C11.8428,12.723 11.1288,14.248 10.9778,15.871 C10.8228,17.541 11.2708,19.211 12.2378,20.576 C12.4818,20.919 12.7278,21.213 12.9888,21.475 C13.7848,22.271 14.7778,22.868 15.8608,23.202 C16.5498,23.415 17.2548,23.519 17.9518,23.518 C19.7808,23.518 21.5598,22.804 22.8888,21.475 L23.9498,20.414 L22.5358,19 L21.4748,20.061 C20.1648,21.371 18.2388,21.842 16.4498,21.291 C15.6668,21.049 14.9778,20.635 14.4038,20.061 C14.2218,19.879 14.0478,19.668 13.8698,19.418 C13.1778,18.443 12.8588,17.249 12.9688,16.056 C13.0768,14.896 13.5868,13.808 14.4038,12.99 L18.6468,8.747 C20.5958,6.798 23.7688,6.798 25.7178,8.747 C26.6568,9.687 27.1748,10.942 27.1748,12.283 C27.1748,13.623 26.6568,14.878 25.7178,15.818 L27.1318,17.232 C28.4488,15.915 29.1748,14.157 29.1748,12.283 C29.1748,10.408 28.4488,8.65 27.1318,7.333" />
244
+ <path d="M25.0107,16.5254 C24.2147,15.7294 23.2217,15.1324 22.1387,14.7984 C19.6417,14.0284 16.9477,14.6894 15.1107,16.5254 L14.0507,17.5864 L15.4647,19.0004 L16.5247,17.9394 C17.8357,16.6294 19.7587,16.1554 21.5497,16.7094 C22.3337,16.9514 23.0217,17.3644 23.5957,17.9394 C23.7777,18.1214 23.9527,18.3314 24.1307,18.5824 C24.8217,19.5564 25.1417,20.7514 25.0317,21.9444 C24.9237,23.1034 24.4137,24.1924 23.5957,25.0104 L19.3537,29.2534 C17.4047,31.2024 14.2317,31.2024 12.2817,29.2534 C11.3427,28.3134 10.8247,27.0574 10.8247,25.7174 C10.8247,24.3774 11.3427,23.1214 12.2817,22.1824 L10.8677,20.7684 C9.5507,22.0854 8.8247,23.8424 8.8247,25.7174 C8.8247,27.5924 9.5507,29.3504 10.8677,30.6674 C12.2327,32.0314 14.0257,32.7134 15.8177,32.7134 C17.6107,32.7134 19.4027,32.0314 20.7677,30.6674 L25.0107,26.4244 C26.1567,25.2774 26.8717,23.7524 27.0227,22.1294 C27.1777,20.4594 26.7297,18.7894 25.7617,17.4244 C25.5177,17.0814 25.2717,16.7874 25.0107,16.5254" />
245
+ </g>
246
+ </svg>
247
+ <Form.Field inline>
248
+ <div className="wrapper">
249
+ <Input
250
+ className={className}
251
+ id={`field-link`}
252
+ name="link"
253
+ value={value || ''}
254
+ onChange={({ target }) => this.onChange(target.value)}
255
+ placeholder={this.props.intl.formatMessage(
256
+ messages.placeholder,
257
+ )}
258
+ onKeyDown={this.onKeyDown}
259
+ ref={this.onRef}
260
+ />
261
+ {value.length > 0 ? (
262
+ <Button.Group>
263
+ <Button
264
+ basic
265
+ className="cancel"
266
+ onClick={(e) => {
267
+ e.preventDefault();
268
+ e.stopPropagation();
269
+ this.clear();
270
+ }}
271
+ >
272
+ <Icon name={clearSVG} size="24px" />
273
+ </Button>
274
+ </Button.Group>
275
+ ) : (
276
+ <Button.Group>
277
+ <Button
278
+ basic
279
+ icon
280
+ onClick={(e) => {
281
+ e.preventDefault();
282
+ e.stopPropagation();
283
+ this.props.openObjectBrowser({
284
+ mode: 'link',
285
+ overlay: true,
286
+ onSelectItem: (url) => {
287
+ // console.log('incoming onchange', url);
288
+ this.onChange(url, null, this.onSubmit);
289
+ // console.log('now state is', this.state);
290
+ // this.onSubmit();
291
+ },
292
+ });
293
+ }}
294
+ >
295
+ <Icon name={navTreeSVG} size="24px" />
296
+ </Button>
297
+ </Button.Group>
298
+ )}
299
+ <Button.Group>
300
+ <Button
301
+ basic
302
+ primary
303
+ disabled={!value.length > 0}
304
+ onClick={(e) => {
305
+ e.preventDefault();
306
+ e.stopPropagation();
307
+ this.onSubmit();
308
+ }}
309
+ >
310
+ <Icon name={aheadSVG} size="24px" />
311
+ </Button>
312
+ </Button.Group>
313
+ </div>
314
+ </Form.Field>
315
+ </div>
316
+ </div>
317
+ );
318
+ }
319
+ }
320
+
321
+ export default compose(injectIntl, withRouter, withObjectBrowser)(AddLinkForm);
package/src/index.js CHANGED
@@ -86,13 +86,13 @@ const applyConfig = (config) => {
86
86
  {
87
87
  icon: 'comment outline',
88
88
  text: 'About us',
89
- link: '/en/mission/about-us',
89
+ link: '/en/mission/about',
90
90
  children: [],
91
91
  },
92
92
  {
93
93
  icon: 'comment outline',
94
94
  text: 'Contact us',
95
- link: '/en/mission/about-us/contact-us',
95
+ link: '/en/mission/about/contact',
96
96
  },
97
97
  // {
98
98
  // icon: 'envelope outline',
@@ -119,6 +119,11 @@ const applyConfig = (config) => {
119
119
  config.blocks.blocksConfig.maps.restricted = false;
120
120
  }
121
121
 
122
+ // Enable video
123
+ if (config.blocks.blocksConfig.video) {
124
+ config.blocks.blocksConfig.video.restricted = false;
125
+ }
126
+
122
127
  //console.log(config);
123
128
  config.views.contentTypesViews = {
124
129
  ...config.views.contentTypesViews,
@@ -137,7 +142,7 @@ const applyConfig = (config) => {
137
142
 
138
143
  config.settings.contextNavigationLocations = [
139
144
  {
140
- title: 'Regional Adaptation Tool',
145
+ title: 'Regional Adaptation Support Tool',
141
146
  columns: 4,
142
147
  topLevel: 2,
143
148
  bottomLevel: 0,