@plone/volto 16.14.0 → 16.16.0

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.draft CHANGED
@@ -1,6 +1,6 @@
1
- ## 16.14.0 (2023-03-03)
1
+ ## 16.16.0 (2023-03-09)
2
2
 
3
3
  ### Feature
4
4
 
5
- - Add `Teaser` block @sneridagh [#3706](https://github.com/plone/volto/issues/3706)
5
+ - - Add directive to cache stable resources in browser or intermediate server for 365 days by default directly in the SSR Express server, static resource that could change after a new deployment for 1 minute. @mamico [#2216](https://github.com/plone/volto/issues/2216)
6
6
 
Binary file
package/CHANGELOG.md CHANGED
@@ -8,6 +8,38 @@
8
8
 
9
9
  <!-- towncrier release notes start -->
10
10
 
11
+ ## 16.16.0 (2023-03-09)
12
+
13
+ ### Feature
14
+
15
+ - - Add directive to cache stable resources in browser or intermediate server for 365 days by default directly in the SSR Express server, static resource that could change after a new deployment for 1 minute. @mamico [#2216](https://github.com/plone/volto/issues/2216)
16
+
17
+
18
+ ## 16.15.0 (2023-03-08)
19
+
20
+ ### Feature
21
+
22
+ - Improvements to the dev API proxy:
23
+ - Prefer RAZZLE_INTERNAL_API_PATH over RAZZLE_API_PATH as the target of the proxy.
24
+ The target of the API proxy is now always logged on startup, even in production mode.
25
+ - Support proxying to a backend served over https. For this configuration it
26
+ might be necessary to set RAZZLE_DEV_PROXY_INSECURE=1 if the backend
27
+ certificate can't be verified.
28
+
29
+ [davisagli] [#4434](https://github.com/plone/volto/issues/4434)
30
+
31
+ ### Bugfix
32
+
33
+ - fix: newsitem and event views wrapper classNames @nzambello [#4443](https://github.com/plone/volto/issues/4443)
34
+ - Fix weird GHA failure on config option not supported @sneridagh [#4466](https://github.com/plone/volto/issues/4466)
35
+ - Fix history view dropdown for first entry, showing 'Revert to this version option' always @sneridagh [#4471](https://github.com/plone/volto/issues/4471)
36
+ - Fix order of row of long table in edit and view mode @iFlameing [#4473](https://github.com/plone/volto/issues/4473)
37
+
38
+ ### Documentation
39
+
40
+ - Complete teaser docs, add new section in `Blocks`: `Core Blocks developers notes` @sneridagh [#4461](https://github.com/plone/volto/issues/4461)
41
+
42
+
11
43
  ## 16.14.0 (2023-03-03)
12
44
 
13
45
  ### Feature
@@ -1062,8 +1094,6 @@ See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more informa
1062
1094
 
1063
1095
  ## 16.0.0-alpha.34 (2022-09-17)
1064
1096
 
1065
- ### Breaking
1066
-
1067
1097
  ### Feature
1068
1098
 
1069
1099
  - Added new components `Aliases` for aliases control in Volto. Alias management in both controlpanel and object view. @andreiggr @avoinea
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "16.14.0",
12
+ "version": "16.16.0",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plone/volto-slate",
3
- "version": "16.14.0",
3
+ "version": "16.16.0",
4
4
  "description": "Slate.js integration with Volto",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -33,13 +33,13 @@ const View = ({ data }) => {
33
33
  }, [data.table.rows]);
34
34
 
35
35
  const rows = useMemo(() => {
36
- const items = {};
37
- if (!data.table.rows) return {};
36
+ const items = [];
37
+ if (!data.table.rows) return [];
38
38
  data.table.rows.forEach((row, index) => {
39
39
  if (index > 0) {
40
- items[row.key] = [];
40
+ items[index] = [];
41
41
  row.cells.forEach((cell, cellIndex) => {
42
- items[row.key][cellIndex] = {
42
+ items[index][cellIndex] = {
43
43
  ...cell,
44
44
  value:
45
45
  cell.value && Node.string({ children: cell.value }).length > 0
@@ -116,22 +116,37 @@ class History extends Component {
116
116
  this.props.revertHistory(getBaseUrl(this.props.pathname), value);
117
117
  }
118
118
 
119
- /**
120
- * Render method.
121
- * @method render
122
- * @returns {string} Markup for the component.
123
- */
124
- render() {
119
+ processHistoryEntries = () => {
120
+ // Getting the history entries from the props
121
+ // No clue why the reverse(concat()) is necessary
125
122
  const entries = reverse(concat(this.props.entries));
126
123
  let title = entries.length > 0 ? entries[0].state_title : '';
127
124
  for (let x = 1; x < entries.length; x += 1) {
128
125
  entries[x].prev_state_title = title;
129
126
  title = entries[x].state_title || title;
130
127
  }
128
+ // We reverse them again
131
129
  reverse(entries);
130
+
131
+ // We identify the latest 'versioning' entry and mark it
132
+ const current_version = find(entries, (item) => item.type === 'versioning');
133
+ if (current_version) {
134
+ current_version.is_current = true;
135
+ }
136
+ return entries;
137
+ };
138
+
139
+ /**
140
+ * Render method.
141
+ * @method render
142
+ * @returns {string} Markup for the component.
143
+ */
144
+ render() {
132
145
  const historyAction = find(this.props.objectActions, {
133
146
  id: 'history',
134
147
  });
148
+ const entries = this.processHistoryEntries();
149
+
135
150
  return !historyAction ? (
136
151
  <>
137
152
  {this.props.token ? (
@@ -266,18 +281,20 @@ class History extends Component {
266
281
  />
267
282
  </Link>
268
283
  )}
269
- {'version' in entry && (
270
- <Dropdown.Item
271
- value={entry.version}
272
- onClick={this.onRevert}
273
- >
274
- <Icon name="undo" />{' '}
275
- <FormattedMessage
276
- id="Revert to this revision"
277
- defaultMessage="Revert to this revision"
278
- />
279
- </Dropdown.Item>
280
- )}
284
+ {'version' in entry &&
285
+ entry.may_revert &&
286
+ !entry.is_current && (
287
+ <Dropdown.Item
288
+ value={entry.version}
289
+ onClick={this.onRevert}
290
+ >
291
+ <Icon name="undo" />{' '}
292
+ <FormattedMessage
293
+ id="Revert to this revision"
294
+ defaultMessage="Revert to this revision"
295
+ />
296
+ </Dropdown.Item>
297
+ )}
281
298
  </Dropdown.Menu>
282
299
  </Dropdown>
283
300
  )}
@@ -43,7 +43,7 @@ const EventView = (props) => {
43
43
  const { content } = props;
44
44
 
45
45
  return (
46
- <div id="page-document" className="ui container viewwrapper event-view">
46
+ <div id="page-document" className="ui container view-wrapper event-view">
47
47
  <Grid>
48
48
  <Grid.Column width={7} className="mobile hidden">
49
49
  {hasBlocksData(content) ? (
@@ -21,7 +21,7 @@ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
21
21
  */
22
22
  const NewsItemView = ({ content }) =>
23
23
  hasBlocksData(content) ? (
24
- <div id="page-document" className="ui container viewwrapper event-view">
24
+ <div id="page-document" className="ui container view-wrapper newsitem-view">
25
25
  <RenderBlocks content={content} />
26
26
  </div>
27
27
  ) : (
@@ -89,6 +89,7 @@ let config = {
89
89
  // https://6.docs.plone.org/volto/deploying/seamless-mode.html
90
90
  devProxyToApiPath:
91
91
  process.env.RAZZLE_DEV_PROXY_API_PATH ||
92
+ process.env.RAZZLE_INTERNAL_API_PATH ||
92
93
  process.env.RAZZLE_API_PATH ||
93
94
  'http://localhost:8080/Plone', // Set it to '' for disabling the proxy
94
95
  // proxyRewriteTarget Set it for set a custom target for the proxy or overide the internal VHM rewrite
@@ -2,6 +2,7 @@ import imagesMiddleware from '@plone/volto/express-middleware/images';
2
2
  import filesMiddleware from '@plone/volto/express-middleware/files';
3
3
  import robotstxtMiddleware from '@plone/volto/express-middleware/robotstxt';
4
4
  import sitemapMiddleware from '@plone/volto/express-middleware/sitemap';
5
+ import staticsMiddleware from '@plone/volto/express-middleware/static';
5
6
  import devProxyMiddleware from '@plone/volto/express-middleware/devproxy';
6
7
 
7
8
  const settings = {
@@ -11,10 +12,28 @@ const settings = {
11
12
  imagesMiddleware(),
12
13
  robotstxtMiddleware(),
13
14
  sitemapMiddleware(),
15
+ staticsMiddleware(),
14
16
  ],
15
17
  criticalCssPath: 'public/critical.css',
16
18
  readCriticalCss: null, // so it will be defaultReadCriticalCss
17
19
  extractScripts: { errorPages: false },
20
+ staticFiles: [
21
+ {
22
+ id: 'root_static',
23
+ match: /^\/static\/.*/,
24
+ headers: {
25
+ // stable resources never change. 31536000 seconds == 365 days
26
+ 'Cache-Control': 'public, max-age=31536000',
27
+ },
28
+ },
29
+ {
30
+ id: 'all',
31
+ match: /.*/,
32
+ headers: {
33
+ 'Cache-Control': 'public, max-age=60',
34
+ },
35
+ },
36
+ ],
18
37
  };
19
38
 
20
39
  export default settings;
@@ -75,12 +75,14 @@ export default function () {
75
75
  const { apiPathURL, instancePath } = getEnv();
76
76
  const target =
77
77
  config.settings.proxyRewriteTarget ||
78
- `/VirtualHostBase/http/${apiPathURL.hostname}:${apiPathURL.port}${instancePath}/++api++/VirtualHostRoot`;
78
+ `/VirtualHostBase/${apiPathURL.protocol.slice(0, -1)}/${
79
+ apiPathURL.hostname
80
+ }:${apiPathURL.port}${instancePath}/++api++/VirtualHostRoot`;
79
81
 
80
82
  return `${target}${path.replace('/++api++', '')}`;
81
83
  },
82
84
  logLevel: process.env.DEBUG_HPM ? 'debug' : 'silent',
83
- ...(config.settings?.proxyRewriteTarget?.startsWith('https') && {
85
+ ...(process.env.RAZZLE_DEV_PROXY_INSECURE && {
84
86
  changeOrigin: true,
85
87
  secure: false,
86
88
  }),
@@ -0,0 +1,32 @@
1
+ import express from 'express';
2
+ import path from 'path';
3
+ import config from '@plone/volto/registry';
4
+
5
+ const staticMiddleware = express.static(
6
+ process.env.BUILD_DIR
7
+ ? path.join(process.env.BUILD_DIR, 'public')
8
+ : process.env.RAZZLE_PUBLIC_DIR,
9
+ {
10
+ setHeaders: function (res, path) {
11
+ const pathLib = require('path');
12
+ const base = pathLib.resolve(process.env.RAZZLE_PUBLIC_DIR);
13
+ const relpath = path.substr(base.length);
14
+ config.settings.serverConfig.staticFiles.some((elem) => {
15
+ if (relpath.match(elem.match)) {
16
+ for (const name in elem.headers) {
17
+ res.setHeader(name, elem.headers[name] || 'undefined');
18
+ }
19
+ return true;
20
+ }
21
+ return false;
22
+ });
23
+ },
24
+ },
25
+ );
26
+
27
+ export default function () {
28
+ const middleware = express.Router();
29
+ middleware.all('*', staticMiddleware);
30
+ middleware.id = 'staticResourcesProcessor';
31
+ return middleware;
32
+ }
package/src/server.jsx CHANGED
@@ -59,13 +59,6 @@ const supported = new locale.Locales(keys(languages), 'en');
59
59
 
60
60
  const server = express()
61
61
  .disable('x-powered-by')
62
- .use(
63
- express.static(
64
- process.env.BUILD_DIR
65
- ? path.join(process.env.BUILD_DIR, 'public')
66
- : process.env.RAZZLE_PUBLIC_DIR,
67
- ),
68
- )
69
62
  .head('/*', function (req, res) {
70
63
  // Support for HEAD requests. Required by start-test utility in CI.
71
64
  res.send('');
@@ -329,6 +322,7 @@ export const defaultReadCriticalCss = () => {
329
322
  // Exposed for the console bootstrap info messages
330
323
  server.apiPath = config.settings.apiPath;
331
324
  server.devProxyToApiPath = config.settings.devProxyToApiPath;
325
+ server.proxyRewriteTarget = config.settings.proxyRewriteTarget;
332
326
  server.publicURL = config.settings.publicURL;
333
327
 
334
328
  export default server;
@@ -19,9 +19,11 @@ export default () => {
19
19
  } else {
20
20
  console.log(`API server (API_PATH) is set to: ${app.apiPath}`);
21
21
  }
22
- if (__DEVELOPMENT__ && app.devProxyToApiPath)
22
+ if (app.devProxyToApiPath)
23
23
  console.log(
24
- `Using internal proxy: ${app.publicURL} -> ${app.devProxyToApiPath}`,
24
+ `Proxying API requests from ${app.publicURL}/++api++ to ${
25
+ app.devProxyToApiPath
26
+ }${app.proxyRewriteTarget || ''}`,
25
27
  );
26
28
  console.log(`🎭 Volto started at ${bind_address}:${port} 🚀`);
27
29