@plone/volto 18.0.0-alpha.14 → 18.0.0-alpha.16

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 (177) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/jest-setup-afterenv.js +2 -0
  3. package/package.json +32 -29
  4. package/src/components/index.js +9 -8
  5. package/src/components/manage/Add/Add.jsx +9 -11
  6. package/src/components/manage/Add/Add.test.jsx +11 -13
  7. package/src/components/manage/Aliases/Aliases.jsx +6 -6
  8. package/src/components/manage/Aliases/Aliases.test.jsx +7 -7
  9. package/src/components/manage/BlockChooser/BlockChooser.test.jsx +0 -1
  10. package/src/components/manage/BlockChooser/BlockChooserButton.jsx +6 -6
  11. package/src/components/manage/BlockChooser/BlockChooserSearch.test.jsx +0 -1
  12. package/src/components/manage/Blocks/Block/Settings.test.jsx +0 -1
  13. package/src/components/manage/Blocks/Container/NewBlockAddButton.jsx +20 -19
  14. package/src/components/manage/Blocks/Image/Edit.jsx +12 -12
  15. package/src/components/manage/Blocks/Image/ImageSidebar.jsx +3 -3
  16. package/src/components/manage/Blocks/Image/View.jsx +14 -14
  17. package/src/components/manage/Blocks/Image/View.test.jsx +0 -1
  18. package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +6 -6
  19. package/src/components/manage/Blocks/Search/SelectStyling.jsx +2 -2
  20. package/src/components/manage/Blocks/Search/components/CheckboxFacet.jsx +2 -2
  21. package/src/components/manage/Blocks/Search/components/Facets.jsx +2 -2
  22. package/src/components/manage/Blocks/Search/components/SelectStyling.jsx +4 -4
  23. package/src/components/manage/Blocks/Table/Edit.jsx +7 -6
  24. package/src/components/manage/Contents/Contents.jsx +9 -9
  25. package/src/components/manage/Contents/Contents.test.jsx +7 -7
  26. package/src/components/manage/Contents/ContentsPropertiesModal.test.jsx +4 -4
  27. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +6 -6
  28. package/src/components/manage/Controlpanels/AddonsControlpanel.test.jsx +6 -7
  29. package/src/components/manage/Controlpanels/Aliases.jsx +6 -6
  30. package/src/components/manage/Controlpanels/Aliases.test.jsx +6 -7
  31. package/src/components/manage/Controlpanels/ContentType.jsx +6 -6
  32. package/src/components/manage/Controlpanels/ContentType.test.jsx +7 -7
  33. package/src/components/manage/Controlpanels/ContentTypeLayout.jsx +93 -85
  34. package/src/components/manage/Controlpanels/ContentTypeLayout.test.jsx +7 -7
  35. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +6 -6
  36. package/src/components/manage/Controlpanels/ContentTypes.jsx +6 -6
  37. package/src/components/manage/Controlpanels/ContentTypes.test.jsx +7 -7
  38. package/src/components/manage/Controlpanels/Controlpanel.jsx +6 -6
  39. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +7 -7
  40. package/src/components/manage/Controlpanels/Controlpanels.jsx +6 -6
  41. package/src/components/manage/Controlpanels/Controlpanels.test.jsx +10 -10
  42. package/src/components/manage/Controlpanels/DatabaseInformation.jsx +6 -6
  43. package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.jsx +10 -10
  44. package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +7 -7
  45. package/src/components/manage/Controlpanels/ModerateComments.jsx +6 -6
  46. package/src/components/manage/Controlpanels/ModerateComments.test.jsx +7 -7
  47. package/src/components/manage/Controlpanels/Relations/Relations.jsx +13 -7
  48. package/src/components/manage/Controlpanels/Rules/AddRule.jsx +6 -6
  49. package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +6 -7
  50. package/src/components/manage/Controlpanels/Rules/ConfigureRule.jsx +6 -6
  51. package/src/components/manage/Controlpanels/Rules/ConfigureRule.test.jsx +6 -7
  52. package/src/components/manage/Controlpanels/Rules/EditRule.jsx +6 -6
  53. package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +6 -7
  54. package/src/components/manage/Controlpanels/Rules/Rules.jsx +6 -6
  55. package/src/components/manage/Controlpanels/Rules/Rules.test.jsx +6 -7
  56. package/src/components/manage/Controlpanels/Rules/components/{VariableModal.test.jsx → VariableModal.test.jsx.removed} +6 -7
  57. package/src/components/manage/Controlpanels/UndoControlpanel.jsx +6 -6
  58. package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +7 -7
  59. package/src/components/manage/Controlpanels/UpgradeControlPanel.jsx +6 -6
  60. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +14 -8
  61. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.test.jsx +7 -7
  62. package/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx +8 -8
  63. package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +7 -7
  64. package/src/components/manage/Delete/Delete.jsx +6 -6
  65. package/src/components/manage/Delete/Delete.test.jsx +10 -10
  66. package/src/components/manage/Diff/Diff.jsx +6 -6
  67. package/src/components/manage/Diff/Diff.test.jsx +2 -3
  68. package/src/components/manage/Display/Display.jsx +2 -2
  69. package/src/components/manage/Edit/Edit.jsx +10 -11
  70. package/src/components/manage/Edit/Edit.test.jsx +14 -10
  71. package/src/components/manage/Form/BlockDataForm.test.jsx +0 -1
  72. package/src/components/manage/Form/Form.jsx +16 -8
  73. package/src/components/manage/Form/ModalForm.test.jsx +0 -1
  74. package/src/components/manage/History/History.jsx +6 -6
  75. package/src/components/manage/History/History.test.jsx +14 -13
  76. package/src/components/manage/LinksToItem/LinksToItem.jsx +78 -49
  77. package/src/components/manage/LinksToItem/LinksToItem.test.jsx +7 -7
  78. package/src/components/manage/Multilingual/ManageTranslations.jsx +13 -7
  79. package/src/components/manage/Multilingual/ManageTranslations.test.jsx +6 -7
  80. package/src/components/manage/Preferences/ChangePassword.jsx +6 -6
  81. package/src/components/manage/Preferences/ChangePassword.test.jsx +6 -7
  82. package/src/components/manage/Preferences/PersonalInformation.test.jsx +1 -3
  83. package/src/components/manage/Preferences/PersonalPreferences.test.jsx +1 -3
  84. package/src/components/manage/Rules/Rules.jsx +6 -6
  85. package/src/components/manage/Rules/Rules.test.jsx +7 -7
  86. package/src/components/manage/Sharing/Sharing.jsx +6 -6
  87. package/src/components/manage/Sharing/Sharing.test.jsx +7 -7
  88. package/src/components/manage/Sidebar/ObjectBrowser.jsx +1 -1
  89. package/src/components/manage/Sidebar/ObjectBrowserBody.jsx +10 -10
  90. package/src/components/manage/Sidebar/Sidebar.jsx +2 -0
  91. package/src/components/manage/Sidebar/SidebarPopup.jsx +28 -21
  92. package/src/components/manage/Sidebar/SidebarPortal.jsx +7 -6
  93. package/src/components/manage/Widgets/ArrayWidget.jsx +21 -21
  94. package/src/components/manage/Widgets/FileWidget.jsx +3 -3
  95. package/src/components/manage/Widgets/ObjectBrowserWidget.test.jsx +4 -4
  96. package/src/components/manage/Widgets/ObjectListWidget.test.js +0 -1
  97. package/src/components/manage/Widgets/ObjectWidget.test.jsx +0 -1
  98. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +2 -2
  99. package/src/components/manage/Widgets/ReferenceWidget.jsx +2 -2
  100. package/src/components/manage/Widgets/SchemaWidget.test.jsx +4 -4
  101. package/src/components/manage/Widgets/SchemaWidgetFieldset.test.jsx +5 -5
  102. package/src/components/manage/Widgets/SelectAutoComplete.jsx +6 -6
  103. package/src/components/manage/Widgets/SelectStyling.jsx +4 -4
  104. package/src/components/manage/Widgets/SelectUtils.js +2 -2
  105. package/src/components/manage/Widgets/UrlWidget.test.jsx +4 -4
  106. package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +4 -4
  107. package/src/components/manage/Workflow/Workflow.jsx +2 -2
  108. package/src/components/theme/Comments/Comments.jsx +7 -8
  109. package/src/components/theme/Component/Component.test.jsx +0 -1
  110. package/src/components/theme/ContactForm/ContactForm.jsx +6 -6
  111. package/src/components/theme/ContactForm/ContactForm.test.jsx +12 -10
  112. package/src/components/theme/Footer/Footer.test.jsx +0 -1
  113. package/src/components/theme/Logout/Logout.test.jsx +8 -5
  114. package/src/components/theme/Search/Search.jsx +6 -6
  115. package/src/components/theme/Search/Search.test.jsx +13 -10
  116. package/src/components/theme/SlotRenderer/SlotRenderer.test.jsx +0 -1
  117. package/src/components/theme/View/View.jsx +6 -6
  118. package/src/components/theme/View/View.test.jsx +25 -18
  119. package/src/components/theme/Widgets/BooleanWidget.jsx +2 -2
  120. package/src/config/Loadables.jsx +10 -10
  121. package/src/config/Views.jsx +2 -2
  122. package/src/config/Widgets.jsx +7 -6
  123. package/src/helpers/AsyncConnect/AsyncConnect.test.js +0 -2
  124. package/src/helpers/Blocks/Blocks.js +20 -20
  125. package/src/helpers/Html/Html.jsx +2 -2
  126. package/src/helpers/Utils/Date.js +6 -6
  127. package/src/helpers/Utils/UseDetectClickOutside.stories.jsx +8 -8
  128. package/src/helpers/Utils/Utils.js +2 -2
  129. package/src/start-client.jsx +3 -3
  130. package/src/store.js +1 -1
  131. package/types/components/manage/Add/Add.d.ts +1 -4
  132. package/types/components/manage/Aliases/Aliases.d.ts +1 -4
  133. package/types/components/manage/Blocks/Block/Edit.d.ts +1 -3
  134. package/types/components/manage/Blocks/HeroImageLeft/Edit.d.ts +1 -4
  135. package/types/components/manage/Blocks/Image/Edit.d.ts +1 -4
  136. package/types/components/manage/Contents/Contents.d.ts +2 -7
  137. package/types/components/manage/Contents/ContentsUploadModal.d.ts +1 -4
  138. package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +1 -4
  139. package/types/components/manage/Controlpanels/Aliases.d.ts +1 -4
  140. package/types/components/manage/Controlpanels/ContentType.d.ts +1 -4
  141. package/types/components/manage/Controlpanels/ContentTypeLayout.d.ts +1 -4
  142. package/types/components/manage/Controlpanels/ContentTypeSchema.d.ts +1 -4
  143. package/types/components/manage/Controlpanels/ContentTypes.d.ts +1 -4
  144. package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +1 -4
  145. package/types/components/manage/Controlpanels/Groups/GroupsControlpanel.d.ts +1 -4
  146. package/types/components/manage/Controlpanels/ModerateComments.d.ts +1 -4
  147. package/types/components/manage/Controlpanels/Rules/AddRule.d.ts +1 -4
  148. package/types/components/manage/Controlpanels/Rules/ConfigureRule.d.ts +1 -4
  149. package/types/components/manage/Controlpanels/Rules/EditRule.d.ts +1 -4
  150. package/types/components/manage/Controlpanels/Rules/Rules.d.ts +1 -4
  151. package/types/components/manage/Controlpanels/Rules/components/VariableModal.d.ts +1 -4
  152. package/types/components/manage/Controlpanels/UndoControlpanel.d.ts +1 -4
  153. package/types/components/manage/Controlpanels/UpgradeControlPanel.d.ts +1 -4
  154. package/types/components/manage/Controlpanels/Users/RenderUsers.d.ts +1 -4
  155. package/types/components/manage/Controlpanels/Users/UsersControlpanel.d.ts +1 -4
  156. package/types/components/manage/Display/Display.d.ts +1 -4
  157. package/types/components/manage/Edit/Edit.d.ts +2 -7
  158. package/types/components/manage/Form/BlocksToolbar.d.ts +1 -3
  159. package/types/components/manage/History/History.d.ts +1 -4
  160. package/types/components/manage/Preferences/PersonalPreferences.d.ts +1 -4
  161. package/types/components/manage/Rules/Rules.d.ts +1 -4
  162. package/types/components/manage/Sidebar/ObjectBrowserBody.d.ts +1 -4
  163. package/types/components/manage/Toolbar/Toolbar.d.ts +1 -4
  164. package/types/components/manage/Widgets/ArrayWidget.d.ts +1 -3
  165. package/types/components/manage/Widgets/IdWidget.d.ts +1 -4
  166. package/types/components/manage/Widgets/QueryWidget.d.ts +1 -3
  167. package/types/components/manage/Widgets/ReferenceWidget.d.ts +1 -4
  168. package/types/components/manage/Widgets/SchemaWidget.d.ts +1 -4
  169. package/types/components/manage/Widgets/SelectAutoComplete.d.ts +1 -3
  170. package/types/components/manage/Widgets/TokenWidget.d.ts +1 -4
  171. package/types/components/manage/Widgets/WysiwygWidget.d.ts +1 -4
  172. package/types/components/theme/Search/Search.d.ts +2 -7
  173. package/types/components/theme/Sitemap/Sitemap.d.ts +2 -6
  174. package/types/components/theme/View/View.d.ts +1 -4
  175. package/types/config/Widgets.d.ts +1 -3
  176. package/src/components/manage/Multilingual/CreateTranslation.test.jsx +0 -46
  177. package/src/helpers/Utils/usePagination.test.js +0 -115
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import jwt from 'jsonwebtoken';
@@ -8,9 +8,9 @@ import { __test__ as Edit } from './Edit';
8
8
 
9
9
  const mockStore = configureStore();
10
10
 
11
- jest.mock('react-portal', () => ({
12
- Portal: jest.fn(() => <div id="Portal" />),
13
- }));
11
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
12
+ jest.mock('../Sidebar/Sidebar', () => jest.fn(() => <div id="Sidebar" />));
13
+
14
14
  jest.mock('../Form/Form', () => jest.fn(() => <div className="Form" />));
15
15
 
16
16
  describe('Edit', () => {
@@ -50,13 +50,15 @@ describe('Edit', () => {
50
50
  messages: {},
51
51
  },
52
52
  });
53
- const component = renderer.create(
53
+ const { container } = render(
54
54
  <Provider store={store}>
55
+ <div id="toolbar"></div>
55
56
  <Edit location={{ pathname: '/blog', search: {} }} />
57
+ <div id="sidebar"></div>
56
58
  </Provider>,
57
59
  );
58
- const json = component.toJSON();
59
- expect(json).toMatchSnapshot();
60
+
61
+ expect(container).toMatchSnapshot();
60
62
  });
61
63
 
62
64
  it('renders an edit component', () => {
@@ -97,12 +99,14 @@ describe('Edit', () => {
97
99
  messages: {},
98
100
  },
99
101
  });
100
- const component = renderer.create(
102
+ const { container } = render(
101
103
  <Provider store={store}>
104
+ <div id="toolbar"></div>
102
105
  <Edit location={{ pathname: '/blog', search: {} }} />
106
+ <div id="sidebar"></div>
103
107
  </Provider>,
104
108
  );
105
- const json = component.toJSON();
106
- expect(json).toMatchSnapshot();
109
+
110
+ expect(container).toMatchSnapshot();
107
111
  });
108
112
  });
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import BlockDataForm from './BlockDataForm';
3
3
  import { render } from '@testing-library/react';
4
- import '@testing-library/jest-dom/extend-expect';
5
4
  import configureStore from 'redux-mock-store';
6
5
  import config from '@plone/volto/registry';
7
6
  import { Provider } from 'react-intl-redux';
@@ -31,7 +31,7 @@ import isBoolean from 'lodash/isBoolean';
31
31
  import PropTypes from 'prop-types';
32
32
  import React, { Component } from 'react';
33
33
  import { injectIntl } from 'react-intl';
34
- import { Portal } from 'react-portal';
34
+ import { createPortal } from 'react-dom';
35
35
  import { connect } from 'react-redux';
36
36
  import {
37
37
  Accordion,
@@ -238,6 +238,7 @@ class Form extends Component {
238
238
  isClient: false,
239
239
  // Ensure focus remain in field after change
240
240
  inFocus: {},
241
+ sidebarMetadataIsAvailable: false,
241
242
  };
242
243
  this.onChangeField = this.onChangeField.bind(this);
243
244
  this.onSelectBlock = this.onSelectBlock.bind(this);
@@ -313,6 +314,13 @@ class Form extends Component {
313
314
  // Reset focus field
314
315
  this.props.resetMetadataFocus();
315
316
  }
317
+
318
+ if (
319
+ !this.state.sidebarMetadataIsAvailable &&
320
+ document.getElementById('sidebar-metadata')
321
+ ) {
322
+ this.setState(() => ({ sidebarMetadataIsAvailable: true }));
323
+ }
316
324
  }
317
325
 
318
326
  /**
@@ -712,10 +720,10 @@ class Form extends Component {
712
720
  editable={this.props.editable}
713
721
  isMainForm={this.props.editable}
714
722
  />
715
- {this.state.isClient && this.props.editable && (
716
- <Portal
717
- node={__CLIENT__ && document.getElementById('sidebar-metadata')}
718
- >
723
+ {this.state.isClient &&
724
+ this.state.sidebarMetadataIsAvailable &&
725
+ this.props.editable &&
726
+ createPortal(
719
727
  <UiForm
720
728
  method="post"
721
729
  onSubmit={this.onSubmit}
@@ -772,9 +780,9 @@ class Form extends Component {
772
780
  </div>
773
781
  </Accordion>
774
782
  ))}
775
- </UiForm>
776
- </Portal>
777
- )}
783
+ </UiForm>,
784
+ document.getElementById('sidebar-metadata'),
785
+ )}
778
786
 
779
787
  <SlotRenderer
780
788
  name="belowContent"
@@ -3,7 +3,6 @@ import renderer from 'react-test-renderer';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import { render } from '@testing-library/react';
6
- import '@testing-library/jest-dom/extend-expect';
7
6
 
8
7
  import ModalForm from './ModalForm';
9
8
 
@@ -17,7 +17,7 @@ import {
17
17
  Table,
18
18
  } from 'semantic-ui-react';
19
19
  import { concat, map, reverse, find } from 'lodash';
20
- import { Portal } from 'react-portal';
20
+ import { createPortal } from 'react-dom';
21
21
  import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
22
22
  import { asyncConnect } from '@plone/volto/helpers';
23
23
 
@@ -314,8 +314,8 @@ class History extends Component {
314
314
  </Table.Body>
315
315
  </Table>
316
316
  </Segment.Group>
317
- {this.state.isClient && (
318
- <Portal node={document.getElementById('toolbar')}>
317
+ {this.state.isClient &&
318
+ createPortal(
319
319
  <Toolbar
320
320
  pathname={this.props.pathname}
321
321
  hideDefaultViewButtons
@@ -332,9 +332,9 @@ class History extends Component {
332
332
  />
333
333
  </Link>
334
334
  }
335
- />
336
- </Portal>
337
- )}
335
+ />,
336
+ document.getElementById('toolbar'),
337
+ )}
338
338
  </Container>
339
339
  );
340
340
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { StaticRouter } from 'react-router-dom';
5
5
  import { Provider } from 'react-intl-redux';
@@ -9,9 +9,7 @@ import FakeTimers from '@sinonjs/fake-timers';
9
9
  import History from './History';
10
10
 
11
11
  const mockStore = configureStore();
12
- jest.mock('react-portal', () => ({
13
- Portal: jest.fn(() => <div id="Portal" />),
14
- }));
12
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
15
13
 
16
14
  const FIXED_SYSTEM_TIME = '2017-04-23T15:38:00.000Z';
17
15
 
@@ -87,13 +85,14 @@ describe('History', () => {
87
85
  messages: {},
88
86
  },
89
87
  });
90
- const component = renderer.create(
88
+ const { container } = render(
91
89
  <Provider store={store}>
92
90
  <History location={{ pathname: '/blog' }} />
91
+ <div id="toolbar"></div>
93
92
  </Provider>,
94
93
  );
95
- const json = component.toJSON();
96
- expect(json).toMatchSnapshot();
94
+
95
+ expect(container).toMatchSnapshot();
97
96
  });
98
97
 
99
98
  it('redirects if unassigned', () => {
@@ -153,13 +152,14 @@ describe('History', () => {
153
152
  messages: {},
154
153
  },
155
154
  });
156
- const component = renderer.create(
155
+ const { container } = render(
157
156
  <Provider store={store}>
158
157
  <History location={{ pathname: '/blog' }} />
158
+ <div id="toolbar"></div>
159
159
  </Provider>,
160
160
  );
161
- const json = component.toJSON();
162
- expect(json).toMatchSnapshot();
161
+
162
+ expect(container).toMatchSnapshot();
163
163
  });
164
164
 
165
165
  it('redirects if unassigned, no token gives unauthorized', () => {
@@ -217,14 +217,15 @@ describe('History', () => {
217
217
  messages: {},
218
218
  },
219
219
  });
220
- const component = renderer.create(
220
+ const { container } = render(
221
221
  <Provider store={store}>
222
222
  <StaticRouter context={{}} location={'/blog'}>
223
223
  <History location={{ pathname: '/blog' }} />
224
+ <div id="toolbar"></div>
224
225
  </StaticRouter>
225
226
  </Provider>,
226
227
  );
227
- const json = component.toJSON();
228
- expect(json).toMatchSnapshot();
228
+
229
+ expect(container).toMatchSnapshot();
229
230
  });
230
231
  });
@@ -2,11 +2,11 @@
2
2
  * LinksToItem component
3
3
  * @module components/manage/LinksToItem/LinksToItem
4
4
  */
5
- import { useEffect } from 'react';
5
+ import React, { useEffect, useState } from 'react';
6
6
  import { find } from 'lodash';
7
7
  import { Helmet } from '@plone/volto/helpers';
8
8
  import { Link } from 'react-router-dom';
9
- import { Portal } from 'react-portal';
9
+ import { createPortal } from 'react-dom';
10
10
  import { Container, Segment, Table } from 'semantic-ui-react';
11
11
  import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
12
12
  import { useDispatch, useSelector } from 'react-redux';
@@ -19,7 +19,6 @@ import {
19
19
  UniversalLink,
20
20
  Unauthorized,
21
21
  } from '@plone/volto/components';
22
- import { compose } from 'redux';
23
22
 
24
23
  import { getBaseUrl } from '@plone/volto/helpers';
25
24
  import backSVG from '@plone/volto/icons/back.svg';
@@ -57,6 +56,12 @@ const LinksToItem = (props) => {
57
56
  id: 'plone_setup',
58
57
  });
59
58
 
59
+ const [isClient, setIsClient] = useState(false);
60
+
61
+ useEffect(() => {
62
+ setIsClient(true);
63
+ }, []);
64
+
60
65
  useEffect(() => {
61
66
  dispatch(queryRelations(null, false, itempath, null, [itempath]));
62
67
  }, [dispatch, itempath]);
@@ -101,41 +106,46 @@ const LinksToItem = (props) => {
101
106
  <Table selectable compact singleLine attached>
102
107
  {
103
108
  <Table.Body>
104
- {Object.keys(links_ordered).map((relationtype) => {
109
+ {Object.keys(links_ordered).map((relationtype, index) => {
110
+ // TODO: keys driven by links_ordered[relationtype][index]['@id'])
105
111
  return [].concat(
106
112
  [
107
- <Table.Row>
108
- <Table.HeaderCell>
109
- {relationtype === 'isReferencing' ? (
110
- <FormattedMessage
111
- id="Linking this item with hyperlink in text"
112
- defaultMessage="Linking this item with hyperlink in text"
113
- />
114
- ) : relationtype === 'relatedItems' ? (
115
- <FormattedMessage
116
- id="Referencing this item as related item"
117
- defaultMessage="Referencing this item as related item"
118
- />
119
- ) : (
120
- <>
113
+ <React.Fragment key={index}>
114
+ <Table.Row>
115
+ <Table.HeaderCell>
116
+ {relationtype === 'isReferencing' ? (
121
117
  <FormattedMessage
122
- id="Referencing this item with {relationship}"
123
- defaultMessage="Referencing this item with {relationship}"
124
- values={{ relationship: <q>{relationtype}</q> }}
118
+ id="Linking this item with hyperlink in text"
119
+ defaultMessage="Linking this item with hyperlink in text"
125
120
  />
126
- </>
127
- )}
128
- </Table.HeaderCell>
129
- <Table.HeaderCell>
130
- <FormattedMessage
131
- id="Review state"
132
- defaultMessage="Review state"
133
- />
134
- </Table.HeaderCell>
135
- <Table.HeaderCell>
136
- <FormattedMessage id="Type" defaultMessage="Type" />
137
- </Table.HeaderCell>
138
- </Table.Row>,
121
+ ) : relationtype === 'relatedItems' ? (
122
+ <FormattedMessage
123
+ id="Referencing this item as related item"
124
+ defaultMessage="Referencing this item as related item"
125
+ />
126
+ ) : (
127
+ <>
128
+ <FormattedMessage
129
+ id="Referencing this item with {relationship}"
130
+ defaultMessage="Referencing this item with {relationship}"
131
+ values={{
132
+ relationship: <q>{relationtype}</q>,
133
+ }}
134
+ />
135
+ </>
136
+ )}
137
+ </Table.HeaderCell>
138
+ <Table.HeaderCell>
139
+ <FormattedMessage
140
+ id="Review state"
141
+ defaultMessage="Review state"
142
+ />
143
+ </Table.HeaderCell>
144
+ <Table.HeaderCell>
145
+ <FormattedMessage id="Type" defaultMessage="Type" />
146
+ </Table.HeaderCell>
147
+ </Table.Row>
148
+ </React.Fragment>,
139
149
  ],
140
150
  links_ordered[relationtype].map((link) => {
141
151
  return (
@@ -173,8 +183,8 @@ const LinksToItem = (props) => {
173
183
  </Segment>
174
184
  )}
175
185
  </Segment.Group>
176
- {__CLIENT__ && (
177
- <Portal node={document.getElementById('toolbar')}>
186
+ {isClient &&
187
+ createPortal(
178
188
  <Toolbar
179
189
  pathname={pathname}
180
190
  hideDefaultViewButtons
@@ -208,22 +218,41 @@ const LinksToItem = (props) => {
208
218
  </>
209
219
  </>
210
220
  }
211
- />
212
- </Portal>
213
- )}
221
+ />,
222
+ document.getElementById('toolbar'),
223
+ )}
214
224
  </Container>
215
225
  );
216
226
  };
217
227
 
218
228
  export const __test__ = LinksToItem;
219
- export default compose(
220
- asyncConnect([
221
- {
222
- key: 'actions',
223
- // Dispatch async/await to make the operation synchronous, otherwise it returns
224
- // before the promise is resolved
225
- promise: async ({ location, store: { dispatch } }) =>
226
- await dispatch(listActions(getBaseUrl(location.pathname))),
229
+
230
+ export default asyncConnect([
231
+ {
232
+ key: 'content',
233
+ // Dispatch async/await to make the operation synchronous, otherwise it returns
234
+ // before the promise is resolved
235
+ promise: async ({ location, store: { dispatch } }) => {
236
+ const pathname = getBaseUrl(location.pathname);
237
+ return await dispatch(getContent(pathname));
227
238
  },
228
- ]),
229
- )(LinksToItem);
239
+ },
240
+ {
241
+ key: 'actions',
242
+ // Dispatch async/await to make the operation synchronous, otherwise it returns
243
+ // before the promise is resolved
244
+ promise: async ({ location, store: { dispatch } }) =>
245
+ await dispatch(listActions(getBaseUrl(location.pathname))),
246
+ },
247
+ {
248
+ key: 'relations',
249
+ // Dispatch async/await to make the operation synchronous, otherwise it returns
250
+ // before the promise is resolved
251
+ promise: async ({ location, store: { dispatch } }) => {
252
+ const pathname = getBaseUrl(location.pathname);
253
+ return await dispatch(
254
+ queryRelations(null, false, pathname, null, [pathname]),
255
+ );
256
+ },
257
+ },
258
+ ])(LinksToItem);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import { Provider } from 'react-intl-redux';
4
4
  import configureMockStore from 'redux-mock-store';
5
5
  import thunk from 'redux-thunk';
@@ -10,9 +10,8 @@ import { __test__ as LinksToItem } from './LinksToItem';
10
10
  const middlewares = [thunk];
11
11
  const mockStore = configureMockStore(middlewares);
12
12
 
13
- jest.mock('react-portal', () => ({
14
- Portal: jest.fn(() => <div id="Portal" />),
15
- }));
13
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
14
+
16
15
  jest.mock('../Toolbar/More', () => jest.fn(() => <div className="More" />));
17
16
 
18
17
  describe('LinksToItem', () => {
@@ -99,14 +98,15 @@ describe('LinksToItem', () => {
99
98
  messages: {},
100
99
  },
101
100
  });
102
- const component = renderer.create(
101
+ const { container } = render(
103
102
  <Provider store={store}>
104
103
  <MemoryRouter>
105
104
  <LinksToItem location={{ pathname: '/page-1/links-to-item' }} />
105
+ <div id="toolbar"></div>
106
106
  </MemoryRouter>
107
107
  </Provider>,
108
108
  );
109
- const json = component.toJSON();
110
- expect(json).toMatchSnapshot();
109
+
110
+ expect(container).toMatchSnapshot();
111
111
  });
112
112
  });
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { Button, Container, Segment, Table } from 'semantic-ui-react';
3
3
  import { Helmet } from '@plone/volto/helpers';
4
4
  import { flattenToAppURL, getBaseUrl, langmap } from '@plone/volto/helpers';
@@ -15,7 +15,7 @@ import {
15
15
  } from '@plone/volto/actions';
16
16
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
17
17
  import { useSelector, useDispatch } from 'react-redux';
18
- import { Portal } from 'react-portal';
18
+ import { createPortal } from 'react-dom';
19
19
  import { toast } from 'react-toastify';
20
20
 
21
21
  import addSVG from '@plone/volto/icons/add.svg';
@@ -64,6 +64,12 @@ const ManageTranslations = (props) => {
64
64
  const content = useSelector((state) => state.content.data);
65
65
  const dispatch = useDispatch();
66
66
 
67
+ const [isClient, setIsClient] = useState(false);
68
+
69
+ useEffect(() => {
70
+ setIsClient(true);
71
+ }, []);
72
+
67
73
  const { isObjectBrowserOpen, openObjectBrowser } = props;
68
74
 
69
75
  const currentSelectedItem = React.useRef(null);
@@ -269,8 +275,8 @@ const ManageTranslations = (props) => {
269
275
  </Table.Body>
270
276
  </Table>
271
277
  )}
272
- {__CLIENT__ && (
273
- <Portal node={document.getElementById('toolbar')}>
278
+ {isClient &&
279
+ createPortal(
274
280
  <Toolbar
275
281
  pathname={pathname}
276
282
  hideDefaultViewButtons
@@ -284,9 +290,9 @@ const ManageTranslations = (props) => {
284
290
  />
285
291
  </Link>
286
292
  }
287
- />
288
- </Portal>
289
- )}
293
+ />,
294
+ document.getElementById('toolbar'),
295
+ )}
290
296
  </Segment.Group>
291
297
  </Container>
292
298
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import { MemoryRouter } from 'react-router-dom';
@@ -12,9 +12,7 @@ beforeAll(() => {
12
12
  config.settings.supportedLanguages = ['de', 'es'];
13
13
  });
14
14
 
15
- jest.mock('react-portal', () => ({
16
- Portal: jest.fn(() => <div id="Portal" />),
17
- }));
15
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
18
16
 
19
17
  const mockStore = configureStore();
20
18
 
@@ -36,7 +34,7 @@ describe('ManageTranslations', () => {
36
34
  },
37
35
  },
38
36
  });
39
- const component = renderer.create(
37
+ const { container } = render(
40
38
  <Provider store={store}>
41
39
  <MemoryRouter>
42
40
  <ManageTranslations
@@ -48,10 +46,11 @@ describe('ManageTranslations', () => {
48
46
  },
49
47
  }}
50
48
  />
49
+ <div id="toolbar"></div>
51
50
  </MemoryRouter>
52
51
  </Provider>,
53
52
  );
54
- const json = component.toJSON();
55
- expect(json).toMatchSnapshot();
53
+
54
+ expect(container).toMatchSnapshot();
56
55
  });
57
56
  });
@@ -9,7 +9,7 @@ import { Helmet } from '@plone/volto/helpers';
9
9
  import { connect } from 'react-redux';
10
10
  import { compose } from 'redux';
11
11
  import { Link, withRouter } from 'react-router-dom';
12
- import { Portal } from 'react-portal';
12
+ import { createPortal } from 'react-dom';
13
13
  import { defineMessages, injectIntl } from 'react-intl';
14
14
  import { Container } from 'semantic-ui-react';
15
15
  import jwtDecode from 'jwt-decode';
@@ -195,8 +195,8 @@ class ChangePassword extends Component {
195
195
  onCancel={this.onCancel}
196
196
  loading={this.props.loading}
197
197
  />
198
- {this.state.isClient && (
199
- <Portal node={document.getElementById('toolbar')}>
198
+ {this.state.isClient &&
199
+ createPortal(
200
200
  <Toolbar
201
201
  pathname={this.props.pathname}
202
202
  hideDefaultViewButtons
@@ -213,9 +213,9 @@ class ChangePassword extends Component {
213
213
  />
214
214
  </Link>
215
215
  }
216
- />
217
- </Portal>
218
- )}
216
+ />,
217
+ document.getElementById('toolbar'),
218
+ )}
219
219
  </Container>
220
220
  );
221
221
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
2
+ import { render } from '@testing-library/react';
3
3
  import { Provider } from 'react-intl-redux';
4
4
  import configureStore from 'redux-mock-store';
5
5
  import jwt from 'jsonwebtoken';
@@ -9,9 +9,7 @@ import ChangePassword from './ChangePassword';
9
9
 
10
10
  const mockStore = configureStore();
11
11
 
12
- jest.mock('react-portal', () => ({
13
- Portal: jest.fn(() => <div id="Portal" />),
14
- }));
12
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
15
13
 
16
14
  describe('ChangePassword', () => {
17
15
  it('renders a change password component', () => {
@@ -36,14 +34,15 @@ describe('ChangePassword', () => {
36
34
  },
37
35
  },
38
36
  });
39
- const component = renderer.create(
37
+ const { container } = render(
40
38
  <Provider store={store}>
41
39
  <MemoryRouter>
42
40
  <ChangePassword location={{ pathname: '/blog' }} />
41
+ <div id="toolbar"></div>
43
42
  </MemoryRouter>
44
43
  </Provider>,
45
44
  );
46
- const json = component.toJSON();
47
- expect(json).toMatchSnapshot();
45
+
46
+ expect(container).toMatchSnapshot();
48
47
  });
49
48
  });
@@ -18,9 +18,7 @@ const userSchema = {
18
18
  loading: false,
19
19
  };
20
20
 
21
- jest.mock('react-portal', () => ({
22
- Portal: jest.fn(() => <div id="Portal" />),
23
- }));
21
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
24
22
 
25
23
  describe('PersonalInformation', () => {
26
24
  it('renders a personal information component', async () => {
@@ -8,9 +8,7 @@ import PersonalPreferences from './PersonalPreferences';
8
8
 
9
9
  const mockStore = configureStore();
10
10
 
11
- jest.mock('react-portal', () => ({
12
- Portal: jest.fn(() => <div id="Portal" />),
13
- }));
11
+ jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
14
12
 
15
13
  jest.mock('@plone/volto/helpers/Loadable/Loadable');
16
14
  beforeAll(