@plone/volto 18.0.0-alpha.26 → 18.0.0-alpha.28

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 (166) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/cypress/support/commands.js +1 -4
  3. package/cypress/support/e2e.js +9 -0
  4. package/locales/pt_BR/LC_MESSAGES/volto.po +1 -1
  5. package/locales/pt_BR.json +1 -1
  6. package/package.json +21 -19
  7. package/src/components/index.js +104 -73
  8. package/src/components/manage/Actions/Actions.jsx +2 -1
  9. package/src/components/manage/Actions/Actions.test.jsx +1 -3
  10. package/src/components/manage/Add/Add.jsx +1 -1
  11. package/src/components/manage/Blocks/Block/DefaultEdit.jsx +1 -1
  12. package/src/components/manage/Blocks/Block/Settings.jsx +1 -1
  13. package/src/components/manage/Blocks/Block/Settings.test.jsx +2 -0
  14. package/src/components/manage/Blocks/Container/Data.jsx +1 -1
  15. package/src/components/manage/Blocks/Container/Edit.jsx +2 -1
  16. package/src/components/manage/Blocks/Image/ImageSidebar.jsx +2 -1
  17. package/src/components/manage/Blocks/Image/ImageSidebar.test.jsx +2 -0
  18. package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.jsx +2 -3
  19. package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.test.jsx +2 -0
  20. package/src/components/manage/Blocks/Listing/ListingData.jsx +1 -1
  21. package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +1 -1
  22. package/src/components/manage/Blocks/Maps/MapsSidebar.test.jsx +2 -0
  23. package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +2 -1
  24. package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +1 -1
  25. package/src/components/manage/Blocks/Teaser/Data.jsx +2 -1
  26. package/src/components/manage/Blocks/ToC/Edit.jsx +1 -1
  27. package/src/components/manage/Blocks/Video/VideoSidebar.jsx +1 -1
  28. package/src/components/manage/Blocks/Video/VideoSidebar.test.jsx +2 -0
  29. package/src/components/manage/ConditionalLink/ConditionalLink.jsx +1 -1
  30. package/src/components/manage/Contents/Contents.jsx +8 -8
  31. package/src/components/manage/Contents/ContentsIndexHeader.test.jsx +1 -1
  32. package/src/components/manage/Contents/ContentsPropertiesModal.jsx +1 -1
  33. package/src/components/manage/Contents/ContentsPropertiesModal.test.jsx +1 -1
  34. package/src/components/manage/Contents/ContentsRenameModal.jsx +1 -1
  35. package/src/components/manage/Contents/ContentsRenameModal.test.jsx +1 -1
  36. package/src/components/manage/Contents/ContentsTagsModal.jsx +1 -1
  37. package/src/components/manage/Contents/ContentsTagsModal.test.jsx +1 -1
  38. package/src/components/manage/Contents/ContentsWorkflowModal.jsx +1 -1
  39. package/src/components/manage/Contents/ContentsWorkflowModal.test.jsx +1 -1
  40. package/src/components/manage/Contents/__mocks__/index.tsx +5 -0
  41. package/src/components/manage/Contents/index.tsx +64 -0
  42. package/src/components/manage/Controlpanels/Aliases.jsx +1 -1
  43. package/src/components/manage/Controlpanels/Aliases.test.jsx +1 -0
  44. package/src/components/manage/Controlpanels/ContentType.jsx +2 -1
  45. package/src/components/manage/Controlpanels/ContentType.test.jsx +1 -1
  46. package/src/components/manage/Controlpanels/ContentTypeLayout.jsx +2 -8
  47. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +2 -1
  48. package/src/components/manage/Controlpanels/ContentTypes.jsx +3 -8
  49. package/src/components/manage/Controlpanels/Controlpanel.jsx +2 -1
  50. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +1 -2
  51. package/src/components/manage/Controlpanels/Controlpanels.jsx +12 -49
  52. package/src/components/manage/Controlpanels/Controlpanels.test.jsx +36 -32
  53. package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.jsx +2 -2
  54. package/src/components/manage/Controlpanels/ModerateComments.jsx +2 -6
  55. package/src/components/manage/Controlpanels/ModerateComments.test.jsx +1 -4
  56. package/src/components/manage/Controlpanels/Relations/RelationsListing.jsx +2 -2
  57. package/src/components/manage/Controlpanels/Relations/RelationsMatrix.jsx +2 -2
  58. package/src/components/manage/Controlpanels/Rules/AddRule.jsx +2 -2
  59. package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +1 -0
  60. package/src/components/manage/Controlpanels/Rules/EditRule.jsx +2 -2
  61. package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +2 -0
  62. package/src/components/manage/Controlpanels/Rules/components/VariableModal.jsx +1 -1
  63. package/src/components/manage/Controlpanels/UndoControlpanel.jsx +2 -1
  64. package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +1 -2
  65. package/src/components/manage/Controlpanels/UpgradeControlPanel.jsx +2 -1
  66. package/src/components/manage/Controlpanels/Users/RenderUsers.jsx +2 -1
  67. package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +1 -1
  68. package/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx +2 -2
  69. package/src/components/manage/Controlpanels/index.tsx +181 -0
  70. package/src/components/manage/Diff/Diff.jsx +1 -1
  71. package/src/components/manage/Display/Display.jsx +2 -1
  72. package/src/components/manage/Display/Display.test.jsx +1 -0
  73. package/src/components/manage/Edit/Edit.jsx +1 -1
  74. package/src/components/manage/Edit/Edit.test.jsx +1 -2
  75. package/src/components/manage/Form/BlockDataForm.jsx +1 -1
  76. package/src/components/manage/Form/BlockDataForm.test.jsx +2 -0
  77. package/src/components/manage/Form/Form.jsx +4 -2
  78. package/src/components/manage/Form/Form.test.jsx +1 -1
  79. package/src/components/manage/Form/InlineForm.jsx +2 -1
  80. package/src/components/manage/Form/InlineForm.test.jsx +2 -0
  81. package/src/components/manage/Form/ModalForm.jsx +2 -1
  82. package/src/components/manage/Form/ModalForm.test.jsx +1 -1
  83. package/src/components/manage/Form/__mocks__/index.tsx +74 -0
  84. package/src/components/manage/Form/index.tsx +50 -0
  85. package/src/components/manage/Multilingual/TranslationObject.jsx +2 -1
  86. package/src/components/manage/Preferences/ChangePassword.jsx +2 -1
  87. package/src/components/manage/Preferences/ChangePassword.test.jsx +1 -0
  88. package/src/components/manage/Preferences/PersonalInformation.jsx +2 -1
  89. package/src/components/manage/Preferences/PersonalPreferences.jsx +2 -1
  90. package/src/components/manage/Preferences/PersonalPreferences.test.jsx +3 -5
  91. package/src/components/manage/Rules/index.tsx +5 -0
  92. package/src/components/manage/Toolbar/PersonalTools.jsx +2 -2
  93. package/src/components/manage/Widgets/ArrayWidget.jsx +1 -1
  94. package/src/components/manage/Widgets/ButtonsWidget.jsx +1 -1
  95. package/src/components/manage/Widgets/CheckboxWidget.jsx +1 -1
  96. package/src/components/manage/Widgets/ColorPickerWidget.tsx +7 -7
  97. package/src/components/manage/Widgets/DatetimeWidget.jsx +2 -1
  98. package/src/components/manage/Widgets/EmailWidget.jsx +1 -1
  99. package/src/components/manage/Widgets/FileWidget.jsx +2 -1
  100. package/src/components/manage/Widgets/IdWidget.jsx +2 -1
  101. package/src/components/manage/Widgets/ImageSizeWidget.jsx +1 -1
  102. package/src/components/manage/Widgets/InternalUrlWidget.jsx +3 -3
  103. package/src/components/manage/Widgets/NumberWidget.jsx +1 -1
  104. package/src/components/manage/Widgets/ObjectListWidget.jsx +2 -1
  105. package/src/components/manage/Widgets/ObjectListWidget.test.js +2 -0
  106. package/src/components/manage/Widgets/ObjectWidget.jsx +1 -2
  107. package/src/components/manage/Widgets/ObjectWidget.test.jsx +2 -0
  108. package/src/components/manage/Widgets/PasswordWidget.jsx +1 -1
  109. package/src/components/manage/Widgets/QuerySortOnWidget.jsx +1 -1
  110. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +3 -2
  111. package/src/components/manage/Widgets/RecurrenceWidget/SelectInput.jsx +12 -3
  112. package/src/components/manage/Widgets/ReferenceWidget.jsx +1 -1
  113. package/src/components/manage/Widgets/RegistryImageWidget.jsx +2 -1
  114. package/src/components/manage/Widgets/SchemaWidget.jsx +2 -5
  115. package/src/components/manage/Widgets/SelectAutoComplete.jsx +1 -1
  116. package/src/components/manage/Widgets/SelectWidget.jsx +1 -1
  117. package/src/components/manage/Widgets/TextWidget.jsx +2 -1
  118. package/src/components/manage/Widgets/TextareaWidget.jsx +1 -1
  119. package/src/components/manage/Widgets/TokenWidget.jsx +1 -1
  120. package/src/components/manage/Widgets/UrlWidget.jsx +3 -3
  121. package/src/components/manage/Widgets/VocabularyTermsWidget.jsx +5 -8
  122. package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +2 -0
  123. package/src/components/manage/Widgets/__mocks__/index.tsx +43 -0
  124. package/src/components/manage/Widgets/index.tsx +232 -0
  125. package/src/components/manage/Workflow/Workflow.jsx +2 -1
  126. package/src/components/manage/Workflow/Workflow.test.jsx +2 -3
  127. package/src/components/theme/Comments/CommentEditModal.jsx +1 -1
  128. package/src/components/theme/Comments/CommentEditModal.test.jsx +1 -3
  129. package/src/components/theme/Comments/Comments.jsx +3 -1
  130. package/src/components/theme/Comments/Comments.test.jsx +2 -0
  131. package/src/components/theme/Comments/__mocks__/index.tsx +1 -0
  132. package/src/components/theme/Comments/index.tsx +5 -0
  133. package/src/components/theme/ContactForm/ContactForm.jsx +2 -1
  134. package/src/components/theme/ContactForm/ContactForm.test.jsx +2 -0
  135. package/src/components/theme/PasswordReset/PasswordReset.jsx +1 -1
  136. package/src/components/theme/PasswordReset/RequestPasswordReset.jsx +1 -1
  137. package/src/components/theme/PasswordReset/RequestPasswordReset.test.jsx +2 -0
  138. package/src/components/theme/Register/Register.jsx +2 -1
  139. package/src/components/theme/Register/Register.test.jsx +2 -0
  140. package/src/config/ControlPanels.js +1 -1
  141. package/src/config/Widgets.jsx +33 -46
  142. package/src/reducers/navigation/navigation.js +1 -2
  143. package/src/reducers/navigation/navigation.test.js +6 -0
  144. package/src/routes.js +22 -20
  145. package/theme/themes/pastanaga/elements/input.overrides +2 -0
  146. package/types/components/index.d.ts +11 -63
  147. package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +5 -0
  148. package/types/components/manage/ConditionalLink/ConditionalLink.d.ts +1 -1
  149. package/types/components/manage/Contents/__mocks__/index.d.ts +3 -0
  150. package/types/components/manage/Contents/index.d.ts +9 -0
  151. package/types/components/manage/Controlpanels/Controlpanels.d.ts +6 -2
  152. package/types/components/manage/Controlpanels/Relations/RelationsListing.d.ts +2 -2
  153. package/types/components/manage/Controlpanels/index.d.ts +32 -0
  154. package/types/components/manage/Form/__mocks__/index.d.ts +9 -0
  155. package/types/components/manage/Form/index.d.ts +14 -0
  156. package/types/components/manage/Rules/index.d.ts +1 -0
  157. package/types/components/manage/Widgets/ColorPickerWidget.d.ts +5 -5
  158. package/types/components/manage/Widgets/RecurrenceWidget/SelectInput.d.ts +2 -34
  159. package/types/components/manage/Widgets/__mocks__/index.d.ts +34 -0
  160. package/types/components/manage/Widgets/index.d.ts +120 -0
  161. package/types/components/theme/Comments/__mocks__/index.d.ts +1 -0
  162. package/types/components/theme/Comments/index.d.ts +1 -0
  163. package/types/config/ControlPanels.d.ts +1 -1
  164. package/types/config/Loadables.d.ts +151 -9
  165. package/types/config/Views.d.ts +1 -1
  166. package/types/config/Widgets.d.ts +33 -39
@@ -0,0 +1,181 @@
1
+ import loadable from '@loadable/component';
2
+ import { getSystemInformation, listControlpanels } from '@plone/volto/actions';
3
+ import { asyncConnect } from '@plone/volto/helpers';
4
+
5
+ // CONTROLPANELS
6
+
7
+ const LoadableControlpanels = loadable(
8
+ () =>
9
+ import(
10
+ /* webpackChunkName: "Controlpanels" */ '@plone/volto/components/manage/Controlpanels/Controlpanels'
11
+ ),
12
+ );
13
+
14
+ export const Controlpanels = asyncConnect([
15
+ {
16
+ key: 'controlpanels',
17
+ promise: async ({ store: { dispatch } }: any) =>
18
+ await dispatch(listControlpanels()),
19
+ },
20
+ {
21
+ key: 'systemInformation',
22
+ promise: async ({ store: { dispatch } }: any) =>
23
+ await dispatch(getSystemInformation()),
24
+ },
25
+ ])(LoadableControlpanels);
26
+
27
+ export const Controlpanel = loadable(
28
+ () =>
29
+ import(
30
+ /* webpackChunkName: "Controlpanels" */ '@plone/volto/components/manage/Controlpanels/Controlpanel'
31
+ ),
32
+ );
33
+
34
+ // RULES CONTROLPANELS
35
+
36
+ export const RulesControlpanel = loadable(
37
+ () =>
38
+ import(
39
+ /* webpackChunkName: "RulesControlpanel" */ '@plone/volto/components/manage/Controlpanels/Rules/Rules'
40
+ ),
41
+ );
42
+
43
+ export const AddRuleControlpanel = loadable(
44
+ () =>
45
+ import(
46
+ /* webpackChunkName: "RulesControlpanel" */ '@plone/volto/components/manage/Controlpanels/Rules/AddRule'
47
+ ),
48
+ );
49
+
50
+ export const EditRuleControlpanel = loadable(
51
+ () =>
52
+ import(
53
+ /* webpackChunkName: "RulesControlpanel" */ '@plone/volto/components/manage/Controlpanels/Rules/EditRule'
54
+ ),
55
+ );
56
+
57
+ export const ConfigureRuleControlpanel = loadable(
58
+ () =>
59
+ import(
60
+ /* webpackChunkName: "RulesControlpanel" */ '@plone/volto/components/manage/Controlpanels/Rules/ConfigureRule'
61
+ ),
62
+ );
63
+
64
+ // USERS CONTROLPANELS
65
+
66
+ export const UsersControlpanel = loadable(
67
+ () =>
68
+ import(
69
+ /* webpackChunkName: "UsersControlpanel" */ '@plone/volto/components/manage/Controlpanels/Users/UsersControlpanel'
70
+ ),
71
+ );
72
+
73
+ export const RenderUsers = loadable(
74
+ () =>
75
+ import(
76
+ /* webpackChunkName: "UsersControlpanel" */ '@plone/volto/components/manage/Controlpanels/Users/RenderUsers'
77
+ ),
78
+ );
79
+
80
+ export const UserGroupMembershipControlPanel = loadable(
81
+ () =>
82
+ import(
83
+ '@plone/volto/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel'
84
+ ),
85
+ );
86
+
87
+ export const GroupsControlpanel = loadable(
88
+ () =>
89
+ import(
90
+ /* webpackChunkName: "GroupsControlpanel" */ '@plone/volto/components/manage/Controlpanels/Groups/GroupsControlpanel'
91
+ ),
92
+ );
93
+
94
+ export const RenderGroups = loadable(
95
+ () =>
96
+ import(
97
+ /* webpackChunkName: "GroupsControlpanel" */ '@plone/volto/components/manage/Controlpanels/Groups/RenderGroups'
98
+ ),
99
+ );
100
+
101
+ // RELATIONS CONTROLPANEL
102
+
103
+ export const RelationsControlpanel = loadable(
104
+ () =>
105
+ import('@plone/volto/components/manage/Controlpanels/Relations/Relations'),
106
+ );
107
+
108
+ // ALIASES CONTROLPANEL
109
+
110
+ export const AliasesControlpanel = loadable(
111
+ () => import('@plone/volto/components/manage/Controlpanels/Aliases'),
112
+ );
113
+
114
+ // UNDO CONTROLPANEL
115
+
116
+ export const UndoControlpanel = loadable(
117
+ () => import('@plone/volto/components/manage/Controlpanels/UndoControlpanel'),
118
+ );
119
+
120
+ // ADDONS CONTROLPANEL
121
+
122
+ export const AddonsControlpanel = loadable(
123
+ () =>
124
+ import('@plone/volto/components/manage/Controlpanels/AddonsControlpanel'),
125
+ );
126
+
127
+ // CONTENT TYPES CONTROLPANEL
128
+
129
+ export const ContentType = loadable(
130
+ () =>
131
+ import(
132
+ /* webpackChunkName: "ContentTypesControlpanel" */ '@plone/volto/components/manage/Controlpanels/ContentType'
133
+ ),
134
+ );
135
+
136
+ export const ContentTypeLayout = loadable(
137
+ () =>
138
+ import(
139
+ /* webpackChunkName: "ContentTypesControlpanel" */ '@plone/volto/components/manage/Controlpanels/ContentTypeLayout'
140
+ ),
141
+ );
142
+
143
+ export const ContentTypeSchema = loadable(
144
+ () =>
145
+ import(
146
+ /* webpackChunkName: "ContentTypesControlpanel" */ '@plone/volto/components/manage/Controlpanels/ContentTypeSchema'
147
+ ),
148
+ );
149
+
150
+ export const ContentTypes = loadable(
151
+ () =>
152
+ import(
153
+ /* webpackChunkName: "ContentTypesControlpanel" */ '@plone/volto/components/manage/Controlpanels/ContentTypes'
154
+ ),
155
+ );
156
+
157
+ // VERSION OVERVIEW
158
+
159
+ export const VersionOverview = loadable(
160
+ () => import('@plone/volto/components/manage/Controlpanels/VersionOverview'),
161
+ );
162
+
163
+ // PLONE UPGRADES CONTROLPANELS
164
+
165
+ export const UpgradeControlPanel = loadable(
166
+ () =>
167
+ import('@plone/volto/components/manage/Controlpanels/UpgradeControlPanel'),
168
+ );
169
+
170
+ // MODERATE COMMENTS CONTROLPANEL
171
+
172
+ export const ModerateComments = loadable(
173
+ () => import('@plone/volto/components/manage/Controlpanels/ModerateComments'),
174
+ );
175
+
176
+ // DATABASE INFORMATION CONTROLPANELS
177
+
178
+ export const DatabaseInformation = loadable(
179
+ () =>
180
+ import('@plone/volto/components/manage/Controlpanels/DatabaseInformation'),
181
+ );
@@ -23,12 +23,12 @@ import {
23
23
  hasBlocksData,
24
24
  } from '@plone/volto/helpers';
25
25
  import {
26
- DiffField,
27
26
  FormattedDate,
28
27
  Icon,
29
28
  Toolbar,
30
29
  Unauthorized,
31
30
  } from '@plone/volto/components';
31
+ import DiffField from '@plone/volto/components/manage/Diff/DiffField';
32
32
 
33
33
  import backSVG from '@plone/volto/icons/back.svg';
34
34
 
@@ -6,7 +6,8 @@ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
6
6
 
7
7
  import { getSchema, updateContent, getContent } from '@plone/volto/actions';
8
8
  import { getLayoutFieldname } from '@plone/volto/helpers';
9
- import { FormFieldWrapper, Icon } from '@plone/volto/components';
9
+ import { Icon } from '@plone/volto/components';
10
+ import { FormFieldWrapper } from '@plone/volto/components/manage/Widgets';
10
11
  import { defineMessages, injectIntl } from 'react-intl';
11
12
  import config from '@plone/volto/registry';
12
13
 
@@ -8,6 +8,7 @@ import Display from './Display';
8
8
 
9
9
  const mockStore = configureStore();
10
10
 
11
+ jest.mock('@plone/volto/components/manage/Widgets');
11
12
  jest.mock('@plone/volto/helpers/Loadable/Loadable');
12
13
  beforeAll(
13
14
  async () =>
@@ -18,7 +18,6 @@ import { toast } from 'react-toastify';
18
18
 
19
19
  import {
20
20
  Forbidden,
21
- Form,
22
21
  Icon,
23
22
  Sidebar,
24
23
  Toast,
@@ -27,6 +26,7 @@ import {
27
26
  CompareLanguages,
28
27
  TranslationObject,
29
28
  } from '@plone/volto/components';
29
+ import { Form } from '@plone/volto/components/manage/Form';
30
30
  import {
31
31
  updateContent,
32
32
  getContent,
@@ -8,11 +8,10 @@ import { __test__ as Edit } from './Edit';
8
8
 
9
9
  const mockStore = configureStore();
10
10
 
11
+ jest.mock('@plone/volto/components/manage/Form');
11
12
  jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
12
13
  jest.mock('../Sidebar/Sidebar', () => jest.fn(() => <div id="Sidebar" />));
13
14
 
14
- jest.mock('../Form/Form', () => jest.fn(() => <div className="Form" />));
15
-
16
15
  describe('Edit', () => {
17
16
  it('renders an empty edit component', () => {
18
17
  const store = mockStore({
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { InlineForm } from '@plone/volto/components';
2
+ import { InlineForm } from '@plone/volto/components/manage/Form';
3
3
  import { withVariationSchemaEnhancer } from '@plone/volto/helpers';
4
4
 
5
5
  const EnhancedBlockDataForm = withVariationSchemaEnhancer(InlineForm);
@@ -5,6 +5,8 @@ import configureStore from 'redux-mock-store';
5
5
  import config from '@plone/volto/registry';
6
6
  import { Provider } from 'react-intl-redux';
7
7
 
8
+ jest.mock('@plone/volto/components/manage/Form');
9
+
8
10
  const mockStore = configureStore();
9
11
 
10
12
  const withStateManagement =
@@ -3,7 +3,10 @@
3
3
  * @module components/manage/Form/Form
4
4
  */
5
5
 
6
- import { BlocksForm, Field, Icon, Toast } from '@plone/volto/components';
6
+ import { Icon, Toast } from '@plone/volto/components';
7
+ import { Field, BlocksForm } from '@plone/volto/components/manage/Form';
8
+ import BlocksToolbar from '@plone/volto/components/manage/Form/BlocksToolbar';
9
+ import UndoToolbar from '@plone/volto/components/manage/Form/UndoToolbar';
7
10
  import {
8
11
  difference,
9
12
  FormValidation,
@@ -44,7 +47,6 @@ import {
44
47
  } from 'semantic-ui-react';
45
48
  import { v4 as uuid } from 'uuid';
46
49
  import { toast } from 'react-toastify';
47
- import { BlocksToolbar, UndoToolbar } from '@plone/volto/components';
48
50
  import {
49
51
  setMetadataFieldsets,
50
52
  resetMetadataFocus,
@@ -9,7 +9,7 @@ const mockStore = configureStore();
9
9
  const errorMessage =
10
10
  "[{'message': 'The specified email is not valid.', 'field': 'contact_email', 'error': 'ValidationError'}";
11
11
 
12
- jest.mock('./Field', () => jest.fn(() => <div className="Field" />));
12
+ jest.mock('@plone/volto/components/manage/Form');
13
13
 
14
14
  describe('Form', () => {
15
15
  it('renders a form component', () => {
@@ -11,7 +11,8 @@ import {
11
11
  removeFromArray,
12
12
  arrayRange,
13
13
  } from '@plone/volto/helpers/Utils/Utils';
14
- import { Field, Icon } from '@plone/volto/components';
14
+ import { Icon } from '@plone/volto/components';
15
+ import { Field } from '@plone/volto/components/manage/Form';
15
16
  import { applySchemaDefaults } from '@plone/volto/helpers';
16
17
 
17
18
  import upSVG from '@plone/volto/icons/up-key.svg';
@@ -6,6 +6,8 @@ import config from '@plone/volto/registry';
6
6
 
7
7
  import InlineForm from './InlineForm';
8
8
 
9
+ jest.mock('@plone/volto/components/manage/Form');
10
+
9
11
  const mockStore = configureStore();
10
12
 
11
13
  function NewBaseWidget(name) {
@@ -18,7 +18,8 @@ import {
18
18
  } from 'semantic-ui-react';
19
19
  import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
20
20
  import { FormValidation } from '@plone/volto/helpers';
21
- import { Field, Icon } from '@plone/volto/components';
21
+ import { Icon } from '@plone/volto/components';
22
+ import { Field } from '@plone/volto/components/manage/Form';
22
23
  import aheadSVG from '@plone/volto/icons/ahead.svg';
23
24
  import clearSVG from '@plone/volto/icons/clear.svg';
24
25
 
@@ -8,7 +8,7 @@ import ModalForm from './ModalForm';
8
8
 
9
9
  const mockStore = configureStore();
10
10
 
11
- jest.mock('./Field', () => jest.fn(() => <div className="Field" />));
11
+ jest.mock('@plone/volto/components/manage/Form');
12
12
 
13
13
  describe('ModalForm', () => {
14
14
  it('renders a modal form component', () => {
@@ -0,0 +1,74 @@
1
+ import type { JSONSchema } from '@plone/types';
2
+ import type { Ref } from 'react';
3
+ const { forwardRef } = jest.requireActual('react');
4
+
5
+ // Field descriptions can contain react elements and those are not JSON stringifiable
6
+ const cleanupSchema = (schema: JSONSchema | null): JSONSchema | null => {
7
+ if (!schema || !schema.properties) return schema;
8
+ return {
9
+ ...schema,
10
+ properties: Object.entries(schema.properties).reduce<Record<string, any>>(
11
+ (acc, [key, value]) => {
12
+ acc[key] = {
13
+ ...value,
14
+ description:
15
+ typeof value.description === 'string'
16
+ ? value.description
17
+ : undefined,
18
+ };
19
+ return acc;
20
+ },
21
+ {},
22
+ ),
23
+ };
24
+ };
25
+
26
+ export const Field = jest.fn((props) => (
27
+ <div className="Field" id={props.id}>
28
+ {props.title}
29
+ </div>
30
+ ));
31
+
32
+ export const InlineForm = jest.fn((props) => (
33
+ <div
34
+ id="InlineForm"
35
+ data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
36
+ />
37
+ ));
38
+
39
+ export const ModalForm = jest.fn((props) => (
40
+ <div
41
+ id="ModalForm"
42
+ data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
43
+ />
44
+ ));
45
+
46
+ export const UndoToolbar = jest.fn(() => <div id="UndoToolbar" />);
47
+
48
+ export const BlocksToolbar = jest.fn(() => <div id="BlocksToolbar" />);
49
+
50
+ export const BlockDataForm = jest.fn((props) => (
51
+ <div
52
+ id="BlockDataForm"
53
+ data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
54
+ />
55
+ ));
56
+
57
+ export const BlocksForm = jest.fn((props) => (
58
+ <div
59
+ id="BlocksForm"
60
+ data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
61
+ />
62
+ ));
63
+
64
+ const MockForm = forwardRef(
65
+ (props: { schema: JSONSchema | null }, ref: Ref<any>) => (
66
+ <div
67
+ id="Form"
68
+ data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
69
+ ref={ref}
70
+ />
71
+ ),
72
+ );
73
+
74
+ export const Form = jest.fn((props) => <MockForm {...props} />);
@@ -0,0 +1,50 @@
1
+ import loadable from '@loadable/component';
2
+
3
+ export const Field = loadable(
4
+ () =>
5
+ import(
6
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/Field'
7
+ ),
8
+ );
9
+ export const InlineForm = loadable(
10
+ () =>
11
+ import(
12
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/InlineForm'
13
+ ),
14
+ );
15
+ export const ModalForm = loadable(
16
+ () =>
17
+ import(
18
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/ModalForm'
19
+ ),
20
+ );
21
+ export const UndoToolbar = loadable(
22
+ () =>
23
+ import(
24
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/UndoToolbar'
25
+ ),
26
+ );
27
+ export const BlocksToolbar = loadable(
28
+ () =>
29
+ import(
30
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/BlocksToolbar'
31
+ ),
32
+ );
33
+ export const BlockDataForm = loadable(
34
+ () =>
35
+ import(
36
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/BlockDataForm'
37
+ ),
38
+ );
39
+ export const BlocksForm = loadable(
40
+ () =>
41
+ import(
42
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Blocks/Block/BlocksForm'
43
+ ),
44
+ );
45
+ export const Form = loadable(
46
+ () =>
47
+ import(
48
+ /* webpackChunkName: "Form" */ '@plone/volto/components/manage/Form/Form'
49
+ ),
50
+ );
@@ -3,7 +3,7 @@ import { map } from 'lodash';
3
3
  import { defineMessages, useIntl } from 'react-intl';
4
4
  import { Form as UiForm, Menu, Segment } from 'semantic-ui-react';
5
5
  import { Provider } from 'react-intl-redux';
6
- import { Form, Field } from '@plone/volto/components';
6
+ import { Form, Field } from '@plone/volto/components/manage/Form';
7
7
  import config from '@plone/volto/registry';
8
8
  import configureStore from '@plone/volto/store';
9
9
  import {
@@ -14,6 +14,7 @@ import {
14
14
  toReactIntlLang,
15
15
  } from '@plone/volto/helpers';
16
16
  import { createBrowserHistory } from 'history';
17
+
17
18
  const messages = defineMessages({
18
19
  document: {
19
20
  id: 'Document',
@@ -15,7 +15,8 @@ import { Container } from 'semantic-ui-react';
15
15
  import jwtDecode from 'jwt-decode';
16
16
  import { toast } from 'react-toastify';
17
17
 
18
- import { Form, Icon, Toast, Toolbar } from '@plone/volto/components';
18
+ import { Icon, Toast, Toolbar } from '@plone/volto/components';
19
+ import { Form } from '@plone/volto/components/manage/Form';
19
20
  import { updatePassword } from '@plone/volto/actions';
20
21
  import { getBaseUrl } from '@plone/volto/helpers';
21
22
 
@@ -9,6 +9,7 @@ import ChangePassword from './ChangePassword';
9
9
 
10
10
  const mockStore = configureStore();
11
11
 
12
+ jest.mock('@plone/volto/components/manage/Form');
12
13
  jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
13
14
 
14
15
  describe('ChangePassword', () => {
@@ -12,7 +12,8 @@ import { withRouter } from 'react-router-dom';
12
12
  import jwtDecode from 'jwt-decode';
13
13
  import { toast } from 'react-toastify';
14
14
  import { messages } from '@plone/volto/helpers';
15
- import { Form, Toast } from '@plone/volto/components';
15
+ import { Toast } from '@plone/volto/components';
16
+ import { Form } from '@plone/volto/components/manage/Form';
16
17
  import { getUser, updateUser, getUserSchema } from '@plone/volto/actions';
17
18
 
18
19
  /**
@@ -12,7 +12,8 @@ import { withCookies } from 'react-cookie';
12
12
  import { defineMessages, injectIntl } from 'react-intl';
13
13
  import { toast } from 'react-toastify';
14
14
 
15
- import { Form, Toast } from '@plone/volto/components';
15
+ import { Toast } from '@plone/volto/components';
16
+ import { Form } from '@plone/volto/components/manage/Form';
16
17
  import languages from '@plone/volto/constants/Languages';
17
18
  import { changeLanguage } from '@plone/volto/actions';
18
19
  import { toGettextLang } from '@plone/volto/helpers';
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Provider } from 'react-intl-redux';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { MemoryRouter } from 'react-router-dom';
5
- import { waitFor, render, screen } from '@testing-library/react';
5
+ import { render } from '@testing-library/react';
6
6
 
7
7
  import PersonalPreferences from './PersonalPreferences';
8
8
 
@@ -10,6 +10,7 @@ const mockStore = configureStore();
10
10
 
11
11
  jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
12
12
 
13
+ jest.mock('@plone/volto/components/manage/Form');
13
14
  jest.mock('@plone/volto/helpers/Loadable/Loadable');
14
15
  beforeAll(
15
16
  async () =>
@@ -17,7 +18,7 @@ beforeAll(
17
18
  );
18
19
 
19
20
  describe('PersonalPreferences', () => {
20
- it('renders a personal preferences component', async () => {
21
+ it('renders a personal preferences component', () => {
21
22
  const store = mockStore({
22
23
  intl: {
23
24
  locale: 'en',
@@ -47,9 +48,6 @@ describe('PersonalPreferences', () => {
47
48
  </MemoryRouter>
48
49
  </Provider>,
49
50
  );
50
- await waitFor(() => {
51
- screen.getByTitle('Cancel');
52
- });
53
51
  expect(container).toMatchSnapshot();
54
52
  });
55
53
  });
@@ -0,0 +1,5 @@
1
+ import loadable from '@loadable/component';
2
+
3
+ export const Rules = loadable(
4
+ () => import('@plone/volto/components/manage/Rules/Rules'),
5
+ );
@@ -10,7 +10,7 @@ import { Icon } from '@plone/volto/components';
10
10
  import { getUser } from '@plone/volto/actions';
11
11
  import { Pluggable } from '@plone/volto/components/manage/Pluggable';
12
12
  import {
13
- flattenToAppURL,
13
+ expandToBackendURL,
14
14
  getBaseUrl,
15
15
  userHasRoles,
16
16
  } from '@plone/volto/helpers';
@@ -97,7 +97,7 @@ const PersonalTools = (props) => {
97
97
  <div className={cx('avatar', { default: !user.portrait })}>
98
98
  {user.portrait ? (
99
99
  <img
100
- src={flattenToAppURL(user.portrait)}
100
+ src={expandToBackendURL(user.portrait)}
101
101
  alt={intl.formatMessage(messages.userAvatar)}
102
102
  />
103
103
  ) : (
@@ -30,7 +30,7 @@ import {
30
30
  MultiValueContainer,
31
31
  } from '@plone/volto/components/manage/Widgets/SelectStyling';
32
32
 
33
- import { FormFieldWrapper } from '@plone/volto/components';
33
+ import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
34
34
 
35
35
  const messages = defineMessages({
36
36
  select: {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { FormFieldWrapper } from '@plone/volto/components';
2
+ import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
3
3
  import { Icon } from '@plone/volto/components';
4
4
  import { Button } from 'semantic-ui-react';
5
5
 
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import { Checkbox } from 'semantic-ui-react';
9
9
 
10
10
  import { injectIntl } from 'react-intl';
11
- import { FormFieldWrapper } from '@plone/volto/components';
11
+ import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
12
12
 
13
13
  /**
14
14
  * CheckboxWidget component class.
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Form } from 'semantic-ui-react';
3
3
  import { Grid, Button } from 'semantic-ui-react';
4
- import { isEqual } from 'lodash';
4
+ import { isEmpty, isEqual } from 'lodash';
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
6
 
7
7
  const messages = defineMessages({
@@ -26,11 +26,11 @@ type Color =
26
26
  export type ColorPickerWidgetProps = {
27
27
  id: string;
28
28
  title: string;
29
- value: string;
30
- default: string;
31
- required: boolean;
32
- missing_value: unknown;
33
- className: string;
29
+ value?: string;
30
+ default?: string | object;
31
+ required?: boolean;
32
+ missing_value?: unknown;
33
+ className?: string;
34
34
  onChange: (id: string, value: any) => void;
35
35
  colors: Color[];
36
36
  };
@@ -41,7 +41,7 @@ const ColorPickerWidget = (props: ColorPickerWidgetProps) => {
41
41
  const intl = useIntl();
42
42
 
43
43
  React.useEffect(() => {
44
- if (!props.value && props.default) {
44
+ if (isEmpty(props.value) && props.default) {
45
45
  props.onChange(props.id, props.default);
46
46
  }
47
47
  // Yes, this is correct.
@@ -9,7 +9,8 @@ import { defineMessages, injectIntl } from 'react-intl';
9
9
  import { connect } from 'react-redux';
10
10
  import loadable from '@loadable/component';
11
11
  import cx from 'classnames';
12
- import { Icon, FormFieldWrapper } from '@plone/volto/components';
12
+ import { Icon } from '@plone/volto/components';
13
+ import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
13
14
  import { parseDateTime, toBackendLang } from '@plone/volto/helpers';
14
15
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
15
16