@plone/volto 14.2.1 → 14.2.2

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
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 14.2.2 (2022-01-13)
4
+
5
+ ### Bugfix
6
+
7
+ - Fix home URL item in Navigation, which was evaluating as non-internal @sneridagh
8
+ - Improve the request handling in `getAPIResourceWithAuth` and in `Api` helper. This fixes the "Cannot set headers once the content has being sent" @sneridagh
9
+ - Fix when you remove the time from DatetimeWidget @iRohitSingh
10
+
11
+ ### Internal
12
+
13
+ - Fix URL for Climate-Energy, a Volto website @tiberiuichim
14
+
3
15
  ## 14.2.1 (2022-01-12)
4
16
 
5
17
  ### Bugfix
package/README.md CHANGED
@@ -130,7 +130,7 @@ Volto is actively developed since 2017 and used in production since 2018 on the
130
130
  - [Excellence at Humboldt-Universität zu Berlin](https://www.alles-beginnt-mit-einer-frage.de) (Website for the excellence initiative of the [Humboldt University Berlin](https://hu-berlin.de), developed by [kitconcept GmbH](https://kitconcept.com), 2019)
131
131
  - [Forest Information System for Europe](https://forest.eea.europa.eu) (Thematic website focusing on European forests, developed by [Eau de Web](https://www.eaudeweb.ro), 2019)
132
132
  - [Industrial Emissions portal for Europe](https://industry.eea.europa.eu) (Thematic website focusing on European industrial emissions, developed by [Eau de Web](https://www.eaudeweb.ro), 2020)
133
- - [Energy Climate Union portal for Europe](https://demo-energy-union.eea.europa.eu) (Thematic website focusing on European strides towards mitigating climate change, developed by [Eau de Web](https://www.eaudeweb.ro), 2020)
133
+ - [Energy Climate Union portal for Europe](https://climate-energy.eea.europa.eu/) (Thematic website focusing on European strides towards mitigating climate change, developed by [Eau de Web](https://www.eaudeweb.ro), 2020)
134
134
  - [Talke Carrer Website](https://karriere.talke.com/) (Carrer website for [Talke](https://www.talke.com), one of the leading a chemical and petrochemical logistics companies in Germany, developed by [kitconcept GmbH](https://kitconcept.com), 2020)
135
135
  - [Stradanove](http://www.stradanove.it/) (Website of the Department of Youth Policies of the Municipality of Modena, developed by [RedTurtle](https://redturtle.it), 2020)
136
136
  - [VisitModena](https://www.visitmodena.it/) (Tourist website of the Municipality of Modena, developed by [RedTurtle](https://redturtle.it), 2020)
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "14.2.1",
12
+ "version": "14.2.2",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -34,7 +34,7 @@
34
34
  "start-spa": "razzle start --type=spa",
35
35
  "build": "razzle build",
36
36
  "build-spa": "razzle build --type=spa",
37
- "test": "razzle test --env=jest-environment-jsdom-sixteen",
37
+ "test": "razzle test --env=jest-environment-jsdom-sixteen --maxWorkers=50%",
38
38
  "test:ci": "CI=true razzle test --env=jest-environment-jsdom-sixteen",
39
39
  "test:husky": "CI=true yarn test --bail --findRelatedTests",
40
40
  "test:debug": "node --inspect node_modules/.bin/jest --runInBand",
@@ -148,8 +148,8 @@ export class DatetimeWidgetComponent extends Component {
148
148
  const moment = this.props.moment.default;
149
149
  if (time) {
150
150
  const base = (this.getInternalValue() || moment()).set({
151
- hours: time.hours(),
152
- minutes: time.minutes(),
151
+ hours: time?.hours() ?? 0,
152
+ minutes: time?.minutes() ?? 0,
153
153
  seconds: 0,
154
154
  });
155
155
  const dateValue = base.toISOString();
@@ -4,7 +4,6 @@ import { getAPIResourceWithAuth } from '@plone/volto/helpers';
4
4
  const HEADERS = ['content-type', 'content-disposition', 'cache-control'];
5
5
 
6
6
  function fileMiddleware(req, res, next) {
7
- const { errorHandler } = req.app.locals;
8
7
  getAPIResourceWithAuth(req)
9
8
  .then((resource) => {
10
9
  // Just forward the headers that we need
@@ -14,8 +13,8 @@ function fileMiddleware(req, res, next) {
14
13
  }
15
14
  });
16
15
  res.send(resource.body);
17
- }, errorHandler)
18
- .catch(errorHandler);
16
+ })
17
+ .catch(next);
19
18
  }
20
19
 
21
20
  export default function () {
@@ -4,7 +4,6 @@ import { getAPIResourceWithAuth } from '@plone/volto/helpers';
4
4
  const HEADERS = ['content-type', 'content-disposition', 'cache-control'];
5
5
 
6
6
  function imageMiddleware(req, res, next) {
7
- const { errorHandler } = req.app.locals;
8
7
  getAPIResourceWithAuth(req)
9
8
  .then((resource) => {
10
9
  // Just forward the headers that we need
@@ -13,10 +12,9 @@ function imageMiddleware(req, res, next) {
13
12
  res.set(header, resource.headers[header]);
14
13
  }
15
14
  });
16
-
17
15
  res.send(resource.body);
18
- }, errorHandler)
19
- .catch(errorHandler);
16
+ })
17
+ .catch(next);
20
18
  }
21
19
 
22
20
  export default function () {
@@ -34,11 +34,5 @@ export const getAPIResourceWithAuth = (req) =>
34
34
  if (authToken) {
35
35
  request.set('Authorization', `Bearer ${authToken}`);
36
36
  }
37
- request.end((error, res = {}) => {
38
- if (error) {
39
- reject(error);
40
- } else {
41
- resolve(res);
42
- }
43
- });
37
+ request.then(resolve).catch(reject);
44
38
  });
package/src/server.jsx CHANGED
@@ -72,6 +72,34 @@ const middleware = (config.settings.expressMiddleware || []).filter((m) => m);
72
72
  server.all('*', setupServer);
73
73
  if (middleware.length) server.use('/', middleware);
74
74
 
75
+ server.use(function (err, req, res, next) {
76
+ if (err) {
77
+ const { store } = req.app.locals;
78
+ const errorPage = (
79
+ <Provider store={store} onError={reactIntlErrorHandler}>
80
+ <StaticRouter context={{}} location={req.url}>
81
+ <ErrorPage message={err.message} />
82
+ </StaticRouter>
83
+ </Provider>
84
+ );
85
+
86
+ res.set({
87
+ 'Cache-Control': 'public, max-age=60, no-transform',
88
+ });
89
+
90
+ /* Displays error in console
91
+ * TODO:
92
+ * - get ignored codes from Plone error_log
93
+ */
94
+ const ignoredErrors = [301, 302, 401, 404];
95
+ if (!ignoredErrors.includes(err.status)) console.error(err);
96
+
97
+ res
98
+ .status(err.status || 500) // If error happens in Volto code itself error status is undefined
99
+ .send(`<!doctype html> ${renderToString(errorPage)}`);
100
+ }
101
+ });
102
+
75
103
  function setupServer(req, res, next) {
76
104
  const api = new Api(req);
77
105