@eeacms/volto-eea-website-theme 1.33.0 → 1.33.1

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,13 @@ 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.33.0](https://github.com/eea/volto-eea-website-theme/compare/1.32.1...1.33.0) - 2 April 2024
7
+ ### [1.33.1](https://github.com/eea/volto-eea-website-theme/compare/1.33.0...1.33.1) - 4 April 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: adding page with an empty title - refs #268074 [dobri1408 - [`6443924`](https://github.com/eea/volto-eea-website-theme/commit/64439247ab34eef693d4192c778e330267b25fd0)]
12
+
13
+ ### [1.33.0](https://github.com/eea/volto-eea-website-theme/compare/1.32.1...1.33.0) - 3 April 2024
8
14
 
9
15
  #### :rocket: New Features
10
16
 
@@ -131,6 +137,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
131
137
 
132
138
  - bump version [Razvan - [`721e939`](https://github.com/eea/volto-eea-website-theme/commit/721e939d12e324b459ebfa78a2e656ee7142a3d6)]
133
139
  - merge master into this branch [Razvan - [`586c8f9`](https://github.com/eea/volto-eea-website-theme/commit/586c8f910bac55a043bd8dda60e9444bd2ae1663)]
140
+ - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`fd90044`](https://github.com/eea/volto-eea-website-theme/commit/fd9004442a9d1d465f7601ecdefe3e23c61e6a9c)]
141
+ - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`4bc3dd3`](https://github.com/eea/volto-eea-website-theme/commit/4bc3dd3ae412a66befd04b5b80fab3716c929240)]
134
142
  - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`c4dbd28`](https://github.com/eea/volto-eea-website-theme/commit/c4dbd289358205bc2d849aab7edb11ccf3b89cee)]
135
143
  - fix tests [Razvan - [`042330b`](https://github.com/eea/volto-eea-website-theme/commit/042330bc97d32ffe7ba769b4f2453f71cffed706)]
136
144
  - remove RemoveSchema logic [Razvan - [`08d10f8`](https://github.com/eea/volto-eea-website-theme/commit/08d10f8bf6f75478260e4e4c66d7316ba87b907a)]
@@ -225,6 +233,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
225
233
  - test: Add real image to cypress test [Alin Voinea - [`4ff591a`](https://github.com/eea/volto-eea-website-theme/commit/4ff591ae3318c9588b4e2114582c0fa6cfdf31ae)]
226
234
  - test: Add cypress tests for Image block styling position and align [Alin Voinea - [`7341ef7`](https://github.com/eea/volto-eea-website-theme/commit/7341ef7b92714fc0cc3ab0c31c39033e7b3e19e7)]
227
235
  - Revert "change(tests): commented out rss test since title block config is missing" [Alin Voinea - [`fb61191`](https://github.com/eea/volto-eea-website-theme/commit/fb611918d6ca380b89b594f283dcf9f685a4b294)]
236
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`6a3be30`](https://github.com/eea/volto-eea-website-theme/commit/6a3be3092589411af7808a235f76de5222fd3868)]
237
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`c3978f2`](https://github.com/eea/volto-eea-website-theme/commit/c3978f23375ef066e9fd6f6c2e34ba6c1c058f69)]
238
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`f672779`](https://github.com/eea/volto-eea-website-theme/commit/f672779e845bec9240ccc901e9f53ec80c5a1819)]
239
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`ae5d8e3`](https://github.com/eea/volto-eea-website-theme/commit/ae5d8e3f4e04dc2808d47ce2ee886e1b23b528da)]
240
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`170ff0c`](https://github.com/eea/volto-eea-website-theme/commit/170ff0c8e3b30e69479bdf1117e811fea94f1027)]
228
241
  ### [1.23.0](https://github.com/eea/volto-eea-website-theme/compare/1.22.1...1.23.0) - 2 November 2023
229
242
 
230
243
  #### :rocket: New Features
@@ -237,6 +250,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
237
250
 
238
251
  #### :house: Internal changes
239
252
 
253
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`f28fce3`](https://github.com/eea/volto-eea-website-theme/commit/f28fce3d1eb815f95fb9aa40de42b10b7e8e30c5)]
240
254
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`6d15088`](https://github.com/eea/volto-eea-website-theme/commit/6d150886c5aeb2ca0b569270486e60f7cc274e2c)]
241
255
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`20c0323`](https://github.com/eea/volto-eea-website-theme/commit/20c032380b33c0077c869a05136f93e2fb68e5d4)]
242
256
 
@@ -422,6 +436,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
422
436
 
423
437
  #### :house: Internal changes
424
438
 
439
+ - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`370dcbf`](https://github.com/eea/volto-eea-website-theme/commit/370dcbfbf1a8135ce7b1b3b271b004552a631837)]
425
440
 
426
441
  #### :hammer_and_wrench: Others
427
442
 
@@ -577,6 +592,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
577
592
 
578
593
  #### :hammer_and_wrench: Others
579
594
 
595
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6c5e2f8`](https://github.com/eea/volto-eea-website-theme/commit/6c5e2f80456e2061d9e9c15fd0a0b91b9ac70568)]
580
596
  ### [1.9.1](https://github.com/eea/volto-eea-website-theme/compare/1.9.0...1.9.1) - 28 February 2023
581
597
 
582
598
  #### :bug: Bug Fixes
@@ -723,6 +739,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
723
739
 
724
740
  - For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)]
725
741
  - Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)]
742
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)]
726
743
  ### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023
727
744
 
728
745
  #### :hammer_and_wrench: Others
@@ -756,6 +773,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
756
773
 
757
774
  - Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)]
758
775
  - bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)]
776
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)]
759
777
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`df252a9`](https://github.com/eea/volto-eea-website-theme/commit/df252a9bfed0bb86cadf53c59dd1603b1e2cd822)]
760
778
  ### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022
761
779
 
@@ -765,6 +783,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
765
783
 
766
784
  #### :hammer_and_wrench: Others
767
785
 
786
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)]
768
787
  - Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)]
769
788
  - Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)]
770
789
  ### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022
@@ -775,6 +794,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
775
794
 
776
795
  #### :hammer_and_wrench: Others
777
796
 
797
+ - yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)]
778
798
  ### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022
779
799
 
780
800
  #### :rocket: New Features
@@ -815,6 +835,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
815
835
  - Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)]
816
836
  - Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)]
817
837
  - fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)]
838
+ - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)]
818
839
  ### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022
819
840
 
820
841
  #### :nail_care: Enhancements
@@ -862,6 +883,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
862
883
 
863
884
  #### :hammer_and_wrench: Others
864
885
 
886
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)]
865
887
  ### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
866
888
 
867
889
  #### :hammer_and_wrench: Others
@@ -1129,6 +1151,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1129
1151
  - Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)]
1130
1152
  - Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)]
1131
1153
  - feature(breadcrumbs): implement eea-design-system breadcrumb as Volto component #32 #7 [ichim-david - [`181af41`](https://github.com/eea/volto-eea-website-theme/commit/181af4125ce2b9ddac56dab4723cb11c26633221)]
1154
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)]
1132
1155
  - use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)]
1133
1156
  - Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)]
1134
1157
  - Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)]
@@ -1170,4 +1193,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1170
1193
 
1171
1194
  #### :hammer_and_wrench: Others
1172
1195
 
1196
+ - yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)]
1173
1197
  - Initial commit [Alin Voinea - [`6a9c03a`](https://github.com/eea/volto-eea-website-theme/commit/6a9c03a7cebe71ca87e82cf58c42904063e9d8d3)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-theme",
3
- "version": "1.33.0",
3
+ "version": "1.33.1",
4
4
  "description": "@eeacms/volto-eea-website-theme: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,498 @@
1
+ /**
2
+ * Add container.
3
+ * @module components/manage/Add/Add
4
+ */
5
+
6
+ import React, { Component } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { BodyClass, Helmet } from '@plone/volto/helpers';
9
+ import { connect } from 'react-redux';
10
+ import { compose } from 'redux';
11
+ import { keys, isEmpty } from 'lodash';
12
+ import { defineMessages, injectIntl } from 'react-intl';
13
+ import { Button, Grid, Menu } from 'semantic-ui-react';
14
+ import { Portal } from 'react-portal';
15
+ import { v4 as uuid } from 'uuid';
16
+ import qs from 'query-string';
17
+ import { toast } from 'react-toastify';
18
+
19
+ import { createContent, getSchema, changeLanguage } from '@plone/volto/actions';
20
+ import {
21
+ Form,
22
+ Icon,
23
+ Toolbar,
24
+ Sidebar,
25
+ Toast,
26
+ TranslationObject,
27
+ } from '@plone/volto/components';
28
+ import {
29
+ getBaseUrl,
30
+ hasBlocksData,
31
+ flattenToAppURL,
32
+ getBlocksFieldname,
33
+ getBlocksLayoutFieldname,
34
+ getLanguageIndependentFields,
35
+ langmap,
36
+ toGettextLang,
37
+ } from '@plone/volto/helpers';
38
+
39
+ import { preloadLazyLibs } from '@plone/volto/helpers/Loadable';
40
+ import { tryParseJSON } from '@plone/volto/helpers';
41
+
42
+ import config from '@plone/volto/registry';
43
+
44
+ import saveSVG from '@plone/volto/icons/save.svg';
45
+ import clearSVG from '@plone/volto/icons/clear.svg';
46
+
47
+ const messages = defineMessages({
48
+ add: {
49
+ id: 'Add {type}',
50
+ defaultMessage: 'Add {type}',
51
+ },
52
+ save: {
53
+ id: 'Save',
54
+ defaultMessage: 'Save',
55
+ },
56
+ cancel: {
57
+ id: 'Cancel',
58
+ defaultMessage: 'Cancel',
59
+ },
60
+ error: {
61
+ id: 'Error',
62
+ defaultMessage: 'Error',
63
+ },
64
+ translateTo: {
65
+ id: 'Translate to {lang}',
66
+ defaultMessage: 'Translate to {lang}',
67
+ },
68
+ someErrors: {
69
+ id: 'There are some errors.',
70
+ defaultMessage: 'There are some errors.',
71
+ },
72
+ });
73
+
74
+ /**
75
+ * Add class.
76
+ * @class Add
77
+ * @extends Component
78
+ */
79
+ class Add extends Component {
80
+ /**
81
+ * Property types.
82
+ * @property {Object} propTypes Property types.
83
+ * @static
84
+ */
85
+ static propTypes = {
86
+ createContent: PropTypes.func.isRequired,
87
+ getSchema: PropTypes.func.isRequired,
88
+ pathname: PropTypes.string.isRequired,
89
+ schema: PropTypes.objectOf(PropTypes.any),
90
+ content: PropTypes.shape({
91
+ // eslint-disable-line react/no-unused-prop-types
92
+ '@id': PropTypes.string,
93
+ '@type': PropTypes.string,
94
+ }),
95
+ returnUrl: PropTypes.string,
96
+ createRequest: PropTypes.shape({
97
+ loading: PropTypes.bool,
98
+ loaded: PropTypes.bool,
99
+ }).isRequired,
100
+ schemaRequest: PropTypes.shape({
101
+ loading: PropTypes.bool,
102
+ loaded: PropTypes.bool,
103
+ }).isRequired,
104
+ type: PropTypes.string,
105
+ location: PropTypes.objectOf(PropTypes.any),
106
+ };
107
+
108
+ /**
109
+ * Default properties
110
+ * @property {Object} defaultProps Default properties.
111
+ * @static
112
+ */
113
+ static defaultProps = {
114
+ schema: null,
115
+ content: null,
116
+ returnUrl: null,
117
+ type: 'Default',
118
+ };
119
+
120
+ /**
121
+ * Constructor
122
+ * @method constructor
123
+ * @param {Object} props Component properties
124
+ * @constructs WysiwygEditor
125
+ */
126
+ constructor(props) {
127
+ super(props);
128
+ this.onCancel = this.onCancel.bind(this);
129
+ this.onSubmit = this.onSubmit.bind(this);
130
+
131
+ if (config.blocks?.initialBlocks[props.type]) {
132
+ this.initialBlocksLayout = config.blocks.initialBlocks[
133
+ props.type
134
+ ].map((item) => uuid());
135
+ this.initialBlocks = this.initialBlocksLayout.reduce(
136
+ (acc, value, index) => ({
137
+ ...acc,
138
+ [value]: { '@type': config.blocks.initialBlocks[props.type][index] },
139
+ }),
140
+ {},
141
+ );
142
+ }
143
+ this.state = {
144
+ isClient: false,
145
+ error: null,
146
+ formSelected: 'addForm',
147
+ };
148
+ }
149
+
150
+ /**
151
+ * Component did mount
152
+ * @method componentDidMount
153
+ * @returns {undefined}
154
+ */
155
+ componentDidMount() {
156
+ this.props.getSchema(this.props.type, getBaseUrl(this.props.pathname));
157
+ this.setState({ isClient: true });
158
+ }
159
+
160
+ /**
161
+ * Component will receive props
162
+ * @method componentWillReceiveProps
163
+ * @param {Object} nextProps Next properties
164
+ * @returns {undefined}
165
+ */
166
+ UNSAFE_componentWillReceiveProps(nextProps) {
167
+ if (
168
+ this.props.createRequest.loading &&
169
+ nextProps.createRequest.loaded &&
170
+ nextProps.content['@type'] === this.props.type
171
+ ) {
172
+ this.props.history.push(
173
+ this.props.returnUrl || flattenToAppURL(nextProps.content['@id']),
174
+ );
175
+ }
176
+
177
+ if (this.props.createRequest.loading && nextProps.createRequest.error) {
178
+ const message =
179
+ nextProps.createRequest.error.response?.body?.message ||
180
+ nextProps.createRequest.error.response?.text;
181
+
182
+ const error =
183
+ new DOMParser().parseFromString(message, 'text/html')?.all[0]
184
+ ?.textContent || message;
185
+
186
+ const errorsList = tryParseJSON(error);
187
+ let erroMessage;
188
+ if (Array.isArray(errorsList)) {
189
+ const invariantErrors = errorsList
190
+ .filter((errorItem) => !('field' in errorItem))
191
+ .map((errorItem) => errorItem['message']);
192
+ if (invariantErrors.length > 0) {
193
+ // Plone invariant validation message.
194
+ erroMessage = invariantErrors.join(' - ');
195
+ } else {
196
+ // Error in specific field.
197
+ erroMessage = this.props.intl.formatMessage(messages.someErrors);
198
+ }
199
+ } else {
200
+ erroMessage = errorsList.error?.message || error;
201
+ }
202
+
203
+ this.setState({ error: error });
204
+
205
+ if (
206
+ document?.querySelector('.sidebar-container .tabs-wrapper a')?.click
207
+ ) {
208
+ document.querySelector('.sidebar-container .tabs-wrapper a').click();
209
+ }
210
+ toast.error(
211
+ <Toast
212
+ error
213
+ title={this.props.intl.formatMessage(messages.error)}
214
+ content={erroMessage}
215
+ />,
216
+ );
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Submit handler
222
+ * @method onSubmit
223
+ * @param {object} data Form data.
224
+ * @returns {undefined}
225
+ */
226
+ onSubmit(data) {
227
+ this.props.createContent(getBaseUrl(this.props.pathname), {
228
+ ...data,
229
+ '@static_behaviors': this.props.schema.definitions
230
+ ? keys(this.props.schema.definitions)
231
+ : null,
232
+ '@type': this.props.type,
233
+ ...(config.settings.isMultilingual &&
234
+ this.props.location?.state?.translationOf && {
235
+ translation_of: this.props.location.state.translationOf,
236
+ language: this.props.location.state.language,
237
+ }),
238
+ });
239
+ }
240
+
241
+ /**
242
+ * Cancel handler
243
+ * @method onCancel
244
+ * @returns {undefined}
245
+ */
246
+ onCancel() {
247
+ if (this.props.location?.state?.translationOf) {
248
+ const language = this.props.location.state.languageFrom;
249
+ const langFileName = toGettextLang(language);
250
+ import('@root/../locales/' + langFileName + '.json').then((locale) => {
251
+ this.props.changeLanguage(language, locale.default);
252
+ });
253
+ this.props.history.push(this.props.location?.state?.translationOf);
254
+ } else {
255
+ this.props.history.push(getBaseUrl(this.props.pathname));
256
+ }
257
+ }
258
+
259
+ form = React.createRef();
260
+
261
+ /**
262
+ * Render method.
263
+ * @method render
264
+ * @returns {string} Markup for the component.
265
+ */
266
+ render() {
267
+ if (this.props.schemaRequest.loaded) {
268
+ const visual = hasBlocksData(this.props.schema.properties);
269
+ const blocksFieldname = getBlocksFieldname(this.props.schema.properties);
270
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(
271
+ this.props.schema.properties,
272
+ );
273
+ const translationObject = this.props.location?.state?.translationObject;
274
+
275
+ const translateTo = translationObject
276
+ ? langmap?.[this.props.location?.state?.language]?.nativeName
277
+ : null;
278
+
279
+ // Lookup initialBlocks and initialBlocksLayout within schema
280
+ const schemaBlocks = this.props.schema.properties[blocksFieldname]
281
+ ?.default;
282
+ const schemaBlocksLayout = this.props.schema.properties[
283
+ blocksLayoutFieldname
284
+ ]?.default?.items;
285
+ let initialBlocks = this.initialBlocks;
286
+ let initialBlocksLayout = this.initialBlocksLayout;
287
+
288
+ if (!isEmpty(schemaBlocksLayout) && !isEmpty(schemaBlocks)) {
289
+ initialBlocks = {};
290
+ initialBlocksLayout = [];
291
+ schemaBlocksLayout.forEach((value) => {
292
+ if (!isEmpty(schemaBlocks[value])) {
293
+ let newUid = uuid();
294
+ initialBlocksLayout.push(newUid);
295
+ initialBlocks[newUid] = schemaBlocks[value];
296
+ initialBlocks[newUid].block = newUid;
297
+
298
+ // Layout ID - keep a reference to the original block id within layout
299
+ initialBlocks[newUid]['@layout'] = value;
300
+ }
301
+ });
302
+ }
303
+ //copy blocks from translationObject
304
+ if (translationObject && blocksFieldname && blocksLayoutFieldname) {
305
+ initialBlocks = {};
306
+ initialBlocksLayout = [];
307
+ const originalBlocks = JSON.parse(
308
+ JSON.stringify(translationObject[blocksFieldname]),
309
+ );
310
+ const originalBlocksLayout =
311
+ translationObject[blocksLayoutFieldname].items;
312
+
313
+ originalBlocksLayout.forEach((value) => {
314
+ if (!isEmpty(originalBlocks[value])) {
315
+ let newUid = uuid();
316
+ initialBlocksLayout.push(newUid);
317
+ initialBlocks[newUid] = originalBlocks[value];
318
+ initialBlocks[newUid].block = newUid;
319
+
320
+ // Layout ID - keep a reference to the original block id within layout
321
+ initialBlocks[newUid]['@canonical'] = value;
322
+ }
323
+ });
324
+ }
325
+
326
+ const lifData = () => {
327
+ const data = {};
328
+ if (translationObject) {
329
+ getLanguageIndependentFields(this.props.schema).forEach(
330
+ (lif) => (data[lif] = translationObject[lif]),
331
+ );
332
+ }
333
+ return data;
334
+ };
335
+
336
+ const pageAdd = (
337
+ <div id="page-add">
338
+ <Helmet
339
+ title={this.props.intl.formatMessage(messages.add, {
340
+ type: this.props.type,
341
+ })}
342
+ />
343
+ <Form
344
+ ref={this.form}
345
+ key="translated-or-new-content-form"
346
+ navRoot={
347
+ this.props.content?.['@components']?.navroot?.navroot || {}
348
+ }
349
+ schema={this.props.schema}
350
+ type={this.props.type}
351
+ formData={{
352
+ ...(blocksFieldname && {
353
+ [blocksFieldname]:
354
+ initialBlocks ||
355
+ this.props.schema.properties[blocksFieldname]?.default,
356
+ }),
357
+ ...(blocksLayoutFieldname && {
358
+ [blocksLayoutFieldname]: {
359
+ items:
360
+ initialBlocksLayout ||
361
+ this.props.schema.properties[blocksLayoutFieldname]?.default
362
+ ?.items,
363
+ },
364
+ }),
365
+ // Copy the Language Independent Fields values from the to-be translated content
366
+ // into the default values of the translated content Add form.
367
+ ...lifData(),
368
+ parent: {
369
+ '@id': this.props.content?.['@id'] || '',
370
+ },
371
+ }}
372
+ requestError={this.state.error}
373
+ onSubmit={this.onSubmit}
374
+ hideActions
375
+ pathname={this.props.pathname}
376
+ visual={visual}
377
+ title={
378
+ this.props?.schema?.title
379
+ ? this.props.intl.formatMessage(messages.add, {
380
+ type: this.props.schema.title,
381
+ })
382
+ : null
383
+ }
384
+ loading={this.props.createRequest.loading}
385
+ isFormSelected={this.state.formSelected === 'addForm'}
386
+ onSelectForm={() => {
387
+ this.setState({ formSelected: 'addForm' });
388
+ }}
389
+ global
390
+ />
391
+ {this.state.isClient && (
392
+ <Portal node={document.getElementById('toolbar')}>
393
+ <Toolbar
394
+ pathname={this.props.pathname}
395
+ hideDefaultViewButtons
396
+ inner={
397
+ <>
398
+ <Button
399
+ id="toolbar-save"
400
+ className="save"
401
+ aria-label={this.props.intl.formatMessage(messages.save)}
402
+ onClick={() => this.form.current.onSubmit()}
403
+ loading={this.props.createRequest.loading}
404
+ >
405
+ <Icon
406
+ name={saveSVG}
407
+ className="circled"
408
+ size="30px"
409
+ title={this.props.intl.formatMessage(messages.save)}
410
+ />
411
+ </Button>
412
+ <Button className="cancel" onClick={() => this.onCancel()}>
413
+ <Icon
414
+ name={clearSVG}
415
+ className="circled"
416
+ aria-label={this.props.intl.formatMessage(
417
+ messages.cancel,
418
+ )}
419
+ size="30px"
420
+ title={this.props.intl.formatMessage(messages.cancel)}
421
+ />
422
+ </Button>
423
+ </>
424
+ }
425
+ />
426
+ </Portal>
427
+ )}
428
+ {visual && this.state.isClient && (
429
+ <Portal node={document.getElementById('sidebar')}>
430
+ <Sidebar />
431
+ </Portal>
432
+ )}
433
+ </div>
434
+ );
435
+
436
+ return translationObject ? (
437
+ <>
438
+ <BodyClass className="babel-view" />
439
+ <Grid
440
+ celled="internally"
441
+ stackable
442
+ columns={2}
443
+ id="page-add-translation"
444
+ >
445
+ <Grid.Column className="source-object">
446
+ <TranslationObject
447
+ translationObject={translationObject}
448
+ schema={this.props.schema}
449
+ pathname={this.props.pathname}
450
+ visual={visual}
451
+ isFormSelected={
452
+ this.state.formSelected === 'translationObjectForm'
453
+ }
454
+ onSelectForm={() => {
455
+ this.setState({
456
+ formSelected: 'translationObjectForm',
457
+ });
458
+ }}
459
+ />
460
+ </Grid.Column>
461
+ <Grid.Column>
462
+ <div className="new-translation">
463
+ <Menu pointing secondary attached tabular>
464
+ <Menu.Item name={translateTo.toUpperCase()} active={true}>
465
+ {`${this.props.intl.formatMessage(messages.translateTo, {
466
+ lang: translateTo,
467
+ })}`}
468
+ </Menu.Item>
469
+ </Menu>
470
+ {pageAdd}
471
+ </div>
472
+ </Grid.Column>
473
+ </Grid>
474
+ </>
475
+ ) : (
476
+ pageAdd
477
+ );
478
+ }
479
+ return <div />;
480
+ }
481
+ }
482
+
483
+ export default compose(
484
+ injectIntl,
485
+ connect(
486
+ (state, props) => ({
487
+ createRequest: state.content.create,
488
+ schemaRequest: state.schema,
489
+ content: state.content.data,
490
+ schema: state.schema.schema,
491
+ pathname: props.location.pathname,
492
+ returnUrl: qs.parse(props.location.search).return_url,
493
+ type: qs.parse(props.location.search).type,
494
+ }),
495
+ { createContent, getSchema, changeLanguage },
496
+ ),
497
+ preloadLazyLibs('cms'),
498
+ )(Add);
@@ -0,0 +1 @@
1
+ This customization aims to resolve the issue of adding a page with an empty title. It is a temporary solution and should be removed upon upgrading to Volto 17. Please check this for more information: https://github.com/plone/volto/pull/5842