@plone/volto 17.0.0-alpha.18 → 17.0.0-alpha.19

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.
Files changed (45) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +20 -0
  3. package/locales/ca/LC_MESSAGES/volto.po +39 -0
  4. package/locales/ca.json +1 -1
  5. package/locales/de/LC_MESSAGES/volto.po +39 -0
  6. package/locales/de.json +1 -1
  7. package/locales/en/LC_MESSAGES/volto.po +39 -0
  8. package/locales/en.json +1 -1
  9. package/locales/es/LC_MESSAGES/volto.po +39 -0
  10. package/locales/es.json +1 -1
  11. package/locales/eu/LC_MESSAGES/volto.po +39 -0
  12. package/locales/eu.json +1 -1
  13. package/locales/fi/LC_MESSAGES/volto.po +39 -0
  14. package/locales/fi.json +1 -1
  15. package/locales/fr/LC_MESSAGES/volto.po +39 -0
  16. package/locales/fr.json +1 -1
  17. package/locales/it/LC_MESSAGES/volto.po +39 -0
  18. package/locales/it.json +1 -1
  19. package/locales/ja/LC_MESSAGES/volto.po +39 -0
  20. package/locales/ja.json +1 -1
  21. package/locales/nl/LC_MESSAGES/volto.po +39 -0
  22. package/locales/nl.json +1 -1
  23. package/locales/pt/LC_MESSAGES/volto.po +39 -0
  24. package/locales/pt.json +1 -1
  25. package/locales/pt_BR/LC_MESSAGES/volto.po +39 -0
  26. package/locales/pt_BR.json +1 -1
  27. package/locales/ro/LC_MESSAGES/volto.po +39 -0
  28. package/locales/ro.json +1 -1
  29. package/locales/volto.pot +39 -0
  30. package/locales/zh_CN/LC_MESSAGES/volto.po +39 -0
  31. package/locales/zh_CN.json +1 -1
  32. package/package.json +1 -1
  33. package/packages/volto-slate/package.json +1 -1
  34. package/src/components/index.js +1 -0
  35. package/src/components/manage/Blocks/Search/components/SearchInput.jsx +9 -2
  36. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +12 -1
  37. package/src/components/manage/LinksToItem/LinksToItem.jsx +209 -0
  38. package/src/components/manage/LinksToItem/LinksToItem.test.jsx +97 -0
  39. package/src/components/manage/Toolbar/More.jsx +15 -0
  40. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +1 -1
  41. package/src/config/NonContentRoutes.jsx +1 -0
  42. package/src/config/index.js +2 -0
  43. package/src/config/server.js +2 -0
  44. package/src/express-middleware/ok.js +16 -0
  45. package/src/routes.js +9 -0
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import { Provider } from 'react-intl-redux';
4
+ import configureMockStore from 'redux-mock-store';
5
+ import thunk from 'redux-thunk';
6
+
7
+ import LinksToItem from './LinksToItem';
8
+
9
+ const middlewares = [thunk];
10
+ const mockStore = configureMockStore(middlewares);
11
+
12
+ jest.mock('react-portal', () => ({
13
+ Portal: jest.fn(() => <div id="Portal" />),
14
+ }));
15
+ jest.mock('../Toolbar/More', () => jest.fn(() => <div className="More" />));
16
+
17
+ describe('LinksToItem', () => {
18
+ it('renders "links and references" view', () => {
19
+ const store = mockStore({
20
+ relations: {
21
+ subrequests: {
22
+ '/page-1': {
23
+ relations: {
24
+ isReferencing: {
25
+ items: [
26
+ {
27
+ source: {
28
+ '@id': 'http://localhost:3000/page-basil',
29
+ '@type': 'Document',
30
+ UID: 'SOMEUID008',
31
+ description: '',
32
+ review_state: 'published',
33
+ title: 'Basil',
34
+ type_title: 'Document',
35
+ },
36
+ target: {
37
+ '@id': 'http://localhost:3000/page-tomato',
38
+ '@type': 'Document',
39
+ UID: 'SOMEUID007',
40
+ description: '',
41
+ review_state: 'published',
42
+ title: 'Tomato',
43
+ type_title: 'Document',
44
+ },
45
+ },
46
+ ],
47
+ items_total: 1,
48
+ },
49
+ relatedItems: {
50
+ items: [
51
+ {
52
+ source: {
53
+ '@id': 'http://localhost:3000/page-cucumber',
54
+ '@type': 'Document',
55
+ UID: 'SOMEUID008',
56
+ description: '',
57
+ review_state: 'published',
58
+ title: 'Cucumber',
59
+ type_title: 'Document',
60
+ },
61
+ target: {
62
+ '@id': 'http://localhost:3000/page-tomato',
63
+ '@type': 'Document',
64
+ UID: 'SOMEUID007',
65
+ description: '',
66
+ review_state: 'published',
67
+ title: 'Tomato',
68
+ type_title: 'Document',
69
+ },
70
+ },
71
+ ],
72
+ items_total: 1,
73
+ },
74
+ },
75
+ },
76
+ },
77
+ },
78
+ content: {
79
+ data: {
80
+ UID: 'SOMEUID007',
81
+ title: 'page #1',
82
+ },
83
+ },
84
+ intl: {
85
+ locale: 'en',
86
+ messages: {},
87
+ },
88
+ });
89
+ const component = renderer.create(
90
+ <Provider store={store}>
91
+ <LinksToItem location={{ pathname: '/page-1/links-to-item' }} />
92
+ </Provider>,
93
+ );
94
+ const json = component.toJSON();
95
+ expect(json).toMatchSnapshot();
96
+ });
97
+ });
@@ -53,6 +53,10 @@ const messages = defineMessages({
53
53
  id: 'URL Management',
54
54
  defaultMessage: 'URL Management',
55
55
  },
56
+ linkstoitem: {
57
+ id: 'Links and references',
58
+ defaultMessage: 'Links and references',
59
+ },
56
60
  ManageTranslations: {
57
61
  id: 'Manage Translations',
58
62
  defaultMessage: 'Manage Translations',
@@ -227,6 +231,7 @@ class More extends Component {
227
231
  const aliasesAction = find(this.props.actions.object_buttons, {
228
232
  id: 'redirection',
229
233
  });
234
+
230
235
  const { content, intl } = this.props;
231
236
 
232
237
  const dateOptions = {
@@ -317,6 +322,16 @@ class More extends Component {
317
322
  </li>
318
323
  )}
319
324
  </Plug>
325
+ {path !== '' && !config.settings.excludeLinksAndReferencesMenuItem && (
326
+ <Plug pluggable="toolbar-more-menu-list" id="linkstoitems">
327
+ <li>
328
+ <Link to={`${path}/links-to-item`}>
329
+ {this.props.intl.formatMessage(messages.linkstoitem)}
330
+ <Icon name={rightArrowSVG} size="24px" />
331
+ </Link>
332
+ </li>
333
+ </Plug>
334
+ )}
320
335
  <Plug pluggable="toolbar-more-menu-list" id="rules">
321
336
  {rulesAction && (
322
337
  <li>
@@ -427,7 +427,7 @@ class RecurrenceWidget extends Component {
427
427
  break;
428
428
  }
429
429
 
430
- if (value) {
430
+ if (value === 0 || value) {
431
431
  //set value
432
432
  values[field] = value;
433
433
  } else {
@@ -12,6 +12,7 @@ export const nonContentRoutes = [
12
12
  '/diff',
13
13
  /\/edit$/,
14
14
  '/historyview',
15
+ '/links-to-item',
15
16
  '/layout',
16
17
  '/login',
17
18
  '/logout',
@@ -74,6 +74,7 @@ let config = {
74
74
  port,
75
75
  // The URL Volto is going to be served (see sensible defaults above)
76
76
  publicURL,
77
+ okRoute: '/ok',
77
78
  apiPath,
78
79
  apiExpanders: [
79
80
  // Add the following expanders for only issuing a single request.
@@ -183,6 +184,7 @@ let config = {
183
184
  styleClassNameExtenders,
184
185
  querystringSearchGet: false,
185
186
  blockSettingsTabFieldsetsInitialStateOpen: true,
187
+ excludeLinksAndReferencesMenuItem: false,
186
188
  },
187
189
  experimental: {
188
190
  addBlockButton: {
@@ -1,6 +1,7 @@
1
1
  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
+ import okMiddleware from '@plone/volto/express-middleware/ok';
4
5
  import sitemapMiddleware from '@plone/volto/express-middleware/sitemap';
5
6
  import staticsMiddleware from '@plone/volto/express-middleware/static';
6
7
  import devProxyMiddleware from '@plone/volto/express-middleware/devproxy';
@@ -11,6 +12,7 @@ const settings = {
11
12
  filesMiddleware(),
12
13
  imagesMiddleware(),
13
14
  robotstxtMiddleware(),
15
+ okMiddleware(),
14
16
  sitemapMiddleware(),
15
17
  staticsMiddleware(),
16
18
  ],
@@ -0,0 +1,16 @@
1
+ import express from 'express';
2
+ import config from '@plone/volto/registry';
3
+
4
+ const ok = function (req, res, next) {
5
+ res.type('text/plain');
6
+ res.set('Expires', 'Sat, 1 Jan 2000 00:00:00 GMT');
7
+ res.set('Cache-Control', 'max-age=0, must-revalidate, private');
8
+ res.send('ok');
9
+ };
10
+
11
+ export default function () {
12
+ const middleware = express.Router();
13
+ middleware.all(config?.settings?.okRoute || '/ok', ok);
14
+ middleware.id = 'ok';
15
+ return middleware;
16
+ }
package/src/routes.js CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  Diff,
24
24
  Edit,
25
25
  History,
26
+ LinksToItem,
26
27
  Login,
27
28
  Logout,
28
29
  ManageTranslations,
@@ -285,6 +286,14 @@ export const defaultRoutes = [
285
286
  path: '/**/manage-translations',
286
287
  component: ManageTranslations,
287
288
  },
289
+ {
290
+ path: '/links-to-item',
291
+ component: LinksToItem,
292
+ },
293
+ {
294
+ path: '/**/links-to-item',
295
+ component: LinksToItem,
296
+ },
288
297
  {
289
298
  path: '/register',
290
299
  component: Register,