@plone/volto 17.0.0-alpha.26 → 17.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 (154) hide show
  1. package/.eslintrc +26 -3
  2. package/.yarn/install-state.gz +0 -0
  3. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
  4. package/.yarn/releases/yarn-3.6.3.cjs +874 -0
  5. package/CHANGELOG.md +60 -0
  6. package/addon-registry.js +10 -1
  7. package/create-addons-loader.js +1 -1
  8. package/locales/ca/LC_MESSAGES/volto.po +57 -31
  9. package/locales/ca.json +1 -1
  10. package/locales/de/LC_MESSAGES/volto.po +58 -32
  11. package/locales/de.json +1 -1
  12. package/locales/en/LC_MESSAGES/volto.po +57 -31
  13. package/locales/en.json +1 -1
  14. package/locales/es/LC_MESSAGES/volto.po +65 -39
  15. package/locales/es.json +1 -1
  16. package/locales/eu/LC_MESSAGES/volto.po +57 -31
  17. package/locales/eu.json +1 -1
  18. package/locales/fi/LC_MESSAGES/volto.po +57 -31
  19. package/locales/fi.json +1 -1
  20. package/locales/fr/LC_MESSAGES/volto.po +57 -31
  21. package/locales/fr.json +1 -1
  22. package/locales/it/LC_MESSAGES/volto.po +57 -31
  23. package/locales/it.json +1 -1
  24. package/locales/ja/LC_MESSAGES/volto.po +57 -31
  25. package/locales/ja.json +1 -1
  26. package/locales/nl/LC_MESSAGES/volto.po +57 -31
  27. package/locales/nl.json +1 -1
  28. package/locales/pt/LC_MESSAGES/volto.po +57 -31
  29. package/locales/pt.json +1 -1
  30. package/locales/pt_BR/LC_MESSAGES/volto.po +57 -31
  31. package/locales/pt_BR.json +1 -1
  32. package/locales/ro/LC_MESSAGES/volto.po +57 -31
  33. package/locales/ro.json +1 -1
  34. package/locales/volto.pot +62 -32
  35. package/locales/zh_CN/LC_MESSAGES/volto.po +57 -31
  36. package/locales/zh_CN.json +1 -1
  37. package/package.json +35 -26
  38. package/packages/volto-slate/package.json +1 -1
  39. package/packages/volto-slate/src/blocks/Text/TextBlockView.jsx +2 -1
  40. package/packages/volto-slate/src/blocks/Text/index.js +0 -5
  41. package/packages/volto-slate/src/editor/plugins/Link/render.jsx +5 -6
  42. package/packages/volto-slate/src/editor/render.jsx +11 -1
  43. package/razzle.config.js +4 -6
  44. package/src/components/index.js +194 -194
  45. package/src/components/manage/Add/Add.jsx +7 -8
  46. package/src/components/manage/Blocks/Block/Settings.test.jsx +17 -15
  47. package/src/components/manage/Blocks/HTML/Edit.jsx +8 -8
  48. package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +30 -25
  49. package/src/components/manage/Blocks/Listing/ListingBody.jsx +6 -4
  50. package/src/components/manage/Blocks/Maps/Edit.test.jsx +1 -2
  51. package/src/components/manage/Blocks/Maps/View.test.jsx +1 -2
  52. package/src/components/manage/Blocks/Search/components/Facets.jsx +2 -3
  53. package/src/components/manage/Blocks/Search/components/FilterList.jsx +4 -6
  54. package/src/components/manage/Blocks/Search/components/SelectFacet.jsx +2 -9
  55. package/src/components/manage/Blocks/Search/hocs/withQueryString.jsx +3 -0
  56. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +8 -6
  57. package/src/components/manage/Blocks/Search/schema.js +13 -13
  58. package/src/components/manage/Blocks/Table/Cell.jsx +2 -3
  59. package/src/components/manage/Blocks/Text/Edit.jsx +2 -3
  60. package/src/components/manage/Blocks/Title/View.jsx +4 -37
  61. package/src/components/manage/Blocks/ToC/View.jsx +1 -0
  62. package/src/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +3 -2
  63. package/src/components/manage/Blocks/ToC/variations/HorizontalMenu.jsx +3 -2
  64. package/src/components/manage/Contents/Contents.jsx +252 -114
  65. package/src/components/manage/Contents/ContentsPropertiesModal.jsx +90 -154
  66. package/src/components/manage/Contents/ContentsRenameModal.jsx +88 -139
  67. package/src/components/manage/Contents/ContentsRenameModal.stories.jsx +61 -0
  68. package/src/components/manage/Contents/ContentsTagsModal.jsx +83 -130
  69. package/src/components/manage/Contents/ContentsTagsModal.stories.jsx +68 -0
  70. package/src/components/manage/Contents/ContentsUploadModal.jsx +1 -2
  71. package/src/components/manage/Contents/ContentsWorkflowModal.jsx +87 -154
  72. package/src/components/manage/Controlpanels/Aliases.jsx +4 -12
  73. package/src/components/manage/Controlpanels/Rules/AddRule.jsx +2 -9
  74. package/src/components/manage/Controlpanels/UndoControlpanel.jsx +6 -9
  75. package/src/components/manage/Form/BlockDataForm.test.jsx +17 -15
  76. package/src/components/manage/Form/Form.jsx +2 -3
  77. package/src/components/manage/Form/InlineForm.test.jsx +16 -14
  78. package/src/components/manage/LockingToastsFactory/LockingToastsFactory.jsx +1 -2
  79. package/src/components/manage/Sharing/Sharing.jsx +7 -0
  80. package/src/components/manage/Sidebar/Sidebar.jsx +139 -220
  81. package/src/components/manage/Toolbar/More.jsx +12 -12
  82. package/src/components/manage/Toolbar/PersonalTools.jsx +97 -155
  83. package/src/components/manage/Toolbar/Toolbar.jsx +2 -2
  84. package/src/components/manage/UniversalLink/UniversalLink.test.jsx +2 -1
  85. package/src/components/manage/Widgets/AlignWidget.jsx +2 -4
  86. package/src/components/manage/Widgets/ColorPickerWidget.test.jsx +9 -7
  87. package/src/components/manage/Widgets/DatetimeWidget.jsx +2 -8
  88. package/src/components/manage/Widgets/IdWidget.jsx +1 -2
  89. package/src/components/manage/Widgets/ObjectBrowserWidget.jsx +2 -9
  90. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +2 -9
  91. package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthIndexField.jsx +4 -4
  92. package/src/components/manage/Widgets/SchemaWidget.jsx +6 -9
  93. package/src/components/manage/Widgets/WysiwygWidget.jsx +2 -9
  94. package/src/components/theme/Comments/Comments.jsx +3 -10
  95. package/src/components/theme/ContentMetadataTags/ContentMetadataTags.jsx +4 -0
  96. package/src/components/theme/Login/Login.jsx +1 -2
  97. package/src/components/theme/PasswordReset/PasswordReset.jsx +1 -2
  98. package/src/components/theme/PreviewImage/PreviewImage.jsx +10 -5
  99. package/src/components/theme/PreviewImage/PreviewImage.test.js +17 -0
  100. package/src/components/theme/Register/Register.jsx +2 -4
  101. package/src/components/theme/TsTest/TsTest.test.tsx +11 -0
  102. package/src/components/theme/TsTest/TsTest.tsx +15 -0
  103. package/src/components/theme/View/AlbumView.jsx +3 -2
  104. package/src/components/theme/Widgets/ImageWidget.stories.jsx +1 -2
  105. package/src/config/Loadables.jsx +1 -1
  106. package/src/config/RichTextEditor/Blocks.jsx +2 -3
  107. package/src/config/RichTextEditor/Plugins.jsx +2 -3
  108. package/src/config/RichTextEditor/ToHTML.jsx +12 -10
  109. package/src/config/RichTextEditor/index.js +2 -3
  110. package/src/config/Views.jsx +5 -5
  111. package/src/express-middleware/ok.js +1 -1
  112. package/src/helpers/Blocks/Blocks.js +4 -6
  113. package/src/helpers/Blocks/Blocks.test.js +35 -35
  114. package/src/helpers/Extensions/withBlockSchemaEnhancer.js +48 -50
  115. package/src/helpers/FormValidation/FormValidation.js +7 -6
  116. package/src/helpers/Html/Html.jsx +2 -8
  117. package/src/helpers/Loadable/__mocks__/Loadable.js +18 -18
  118. package/src/helpers/MessageLabels/MessageLabels.js +2 -3
  119. package/src/helpers/Utils/UseDetectClickOutside.stories.jsx +2 -3
  120. package/src/helpers/Utils/Utils.js +10 -0
  121. package/src/helpers/Utils/Utils.test.js +13 -0
  122. package/src/helpers/index.js +1 -0
  123. package/src/hooks/index.js +1 -1
  124. package/src/middleware/api.js +194 -190
  125. package/src/middleware/blacklistRoutes.js +25 -22
  126. package/src/middleware/storeProtectLoadUtils.js +61 -62
  127. package/src/middleware/storeProtectLoadUtils.test.js +47 -43
  128. package/src/reducers/content/content.test.js +4 -4
  129. package/src/reducers/navigation/navigation.js +5 -5
  130. package/src/reducers/navigation/navigation.test.js +30 -0
  131. package/src/registry.js +2 -2
  132. package/src/storybook.jsx +24 -38
  133. package/theme/themes/pastanaga/collections/menu.overrides +3 -2
  134. package/theme/themes/pastanaga/elements/container.overrides +5 -2
  135. package/theme/themes/pastanaga/elements/input.overrides +1 -1
  136. package/theme/themes/pastanaga/elements/step.overrides +2 -1
  137. package/theme/themes/pastanaga/extras/blocks.less +20 -14
  138. package/theme/themes/pastanaga/extras/color-picker-widget.less +1 -1
  139. package/theme/themes/pastanaga/extras/contents.less +5 -1
  140. package/theme/themes/pastanaga/extras/draftjs.less +4 -4
  141. package/theme/themes/pastanaga/extras/grid.less +5 -4
  142. package/theme/themes/pastanaga/extras/main.less +6 -6
  143. package/theme/themes/pastanaga/extras/react-dates-overrides.less +4 -2
  144. package/theme/themes/pastanaga/extras/search.less +2 -2
  145. package/theme/themes/pastanaga/extras/sidebar.less +5 -4
  146. package/theme/themes/pastanaga/extras/time-picker-overrides.less +5 -3
  147. package/theme/themes/pastanaga/extras/toolbar.less +6 -2
  148. package/theme/themes/pastanaga/extras/userscontrolpanel.less +17 -9
  149. package/theme/themes/pastanaga/extras/widgets.less +1 -1
  150. package/theme/themes/pastanaga/modules/rating.overrides +2 -1
  151. package/theme/themes/pastanaga-cms-ui/elements/container.overrides +2 -1
  152. package/theme/themes/pastanaga-cms-ui/extras/cms-ui.elements.container.less +6 -2
  153. package/theme/themes/pastanaga-cms-ui/extras/cms-ui.site.less +2 -2
  154. package/tsconfig.json +33 -0
@@ -1,15 +1,10 @@
1
- /**
2
- * Contents properties modal.
3
- * @module components/manage/Contents/ContentsPropertiesModal
4
- */
5
-
6
- import React, { Component } from 'react';
1
+ import React, { useEffect } from 'react';
7
2
  import PropTypes from 'prop-types';
8
- import { connect } from 'react-redux';
9
- import { compose } from 'redux';
3
+ import { useDispatch, useSelector } from 'react-redux';
10
4
  import { isEmpty, map } from 'lodash';
11
- import { defineMessages, injectIntl } from 'react-intl';
5
+ import { defineMessages, useIntl } from 'react-intl';
12
6
 
7
+ import { usePrevious } from '@plone/volto/helpers';
13
8
  import { updateContent } from '@plone/volto/actions';
14
9
  import { ModalForm } from '@plone/volto/components';
15
10
 
@@ -27,8 +22,7 @@ const messages = defineMessages({
27
22
  defaultMessage: 'Publishing Date',
28
23
  },
29
24
  effectiveDescription: {
30
- id:
31
- 'If this date is in the future, the content will not show up in listings and searches until this date.',
25
+ id: 'If this date is in the future, the content will not show up in listings and searches until this date.',
32
26
  defaultMessage:
33
27
  'If this date is in the future, the content will not show up in listings and searches until this date.',
34
28
  },
@@ -37,8 +31,7 @@ const messages = defineMessages({
37
31
  defaultMessage: 'Expiration Date',
38
32
  },
39
33
  expiresDescription: {
40
- id:
41
- 'When this date is reached, the content will nolonger be visible in listings and searches.',
34
+ id: 'When this date is reached, the content will nolonger be visible in listings and searches.',
42
35
  defaultMessage:
43
36
  'When this date is reached, the content will nolonger be visible in listings and searches.',
44
37
  },
@@ -56,8 +49,7 @@ const messages = defineMessages({
56
49
  defaultMessage: 'Creators',
57
50
  },
58
51
  creatorsDescription: {
59
- id:
60
- 'Persons responsible for creating the content of this item. Please enter a list of user names, one per line. The principal creator should come first.',
52
+ id: 'Persons responsible for creating the content of this item. Please enter a list of user names, one per line. The principal creator should come first.',
61
53
  defaultMessage:
62
54
  'Persons responsible for creating the content of this item. Please enter a list of user names, one per line. The principal creator should come first.',
63
55
  },
@@ -72,152 +64,96 @@ const messages = defineMessages({
72
64
  },
73
65
  });
74
66
 
75
- /**
76
- * ContentsPropertiesModal class.
77
- * @class ContentsPropertiesModal
78
- * @extends Component
79
- */
80
- class ContentsPropertiesModal extends Component {
81
- /**
82
- * Property types.
83
- * @property {Object} propTypes Property types.
84
- * @static
85
- */
86
- static propTypes = {
87
- updateContent: PropTypes.func.isRequired,
88
- items: PropTypes.arrayOf(PropTypes.string).isRequired,
89
- request: PropTypes.shape({
90
- loading: PropTypes.bool,
91
- loaded: PropTypes.bool,
92
- }).isRequired,
93
- open: PropTypes.bool.isRequired,
94
- onOk: PropTypes.func.isRequired,
95
- onCancel: PropTypes.func.isRequired,
96
- };
97
-
98
- /**
99
- * Constructor
100
- * @method constructor
101
- * @param {Object} props Component properties
102
- * @constructs ContentsUploadModal
103
- */
104
- constructor(props) {
105
- super(props);
106
- this.onSubmit = this.onSubmit.bind(this);
107
- }
67
+ const ContentsPropertiesModal = (props) => {
68
+ const { onCancel, onOk, open, items } = props;
69
+ const intl = useIntl();
70
+ const dispatch = useDispatch();
71
+ const request = useSelector((state) => state.content.update);
72
+ const prevrequestloading = usePrevious(request.loading);
108
73
 
109
- /**
110
- * Component will receive props
111
- * @method componentWillReceiveProps
112
- * @param {Object} nextProps Next properties
113
- * @returns {undefined}
114
- */
115
- UNSAFE_componentWillReceiveProps(nextProps) {
116
- if (this.props.request.loading && nextProps.request.loaded) {
117
- this.props.onOk();
74
+ useEffect(() => {
75
+ if (prevrequestloading && request.loaded) {
76
+ onOk();
118
77
  }
119
- }
78
+ }, [onOk, prevrequestloading, request.loaded]);
120
79
 
121
- /**
122
- * Submit handler
123
- * @method onSubmit
124
- * @param {Object} data Form data
125
- * @returns {undefined}
126
- */
127
- onSubmit(data) {
80
+ const onSubmit = (data) => {
128
81
  if (isEmpty(data)) {
129
- this.props.onOk();
82
+ onOk();
130
83
  } else {
131
- this.props.updateContent(
132
- this.props.items,
133
- map(this.props.items, () => data),
84
+ dispatch(
85
+ updateContent(
86
+ items,
87
+ map(items, () => data),
88
+ ),
134
89
  );
135
90
  }
136
- }
91
+ };
137
92
 
138
- /**
139
- * Render method.
140
- * @method render
141
- * @returns {string} Markup for the component.
142
- */
143
- render() {
144
- return (
145
- this.props.open && (
146
- <ModalForm
147
- open={this.props.open}
148
- onSubmit={this.onSubmit}
149
- onCancel={this.props.onCancel}
150
- title={this.props.intl.formatMessage(messages.properties)}
151
- schema={{
152
- fieldsets: [
153
- {
154
- id: 'default',
155
- title: this.props.intl.formatMessage(messages.default),
156
- fields: [
157
- 'effective',
158
- 'expires',
159
- 'rights',
160
- 'creators',
161
- 'exclude_from_nav',
162
- ],
163
- },
164
- ],
165
- properties: {
166
- effective: {
167
- description: this.props.intl.formatMessage(
168
- messages.effectiveDescription,
169
- ),
170
- title: this.props.intl.formatMessage(messages.effectiveTitle),
171
- type: 'string',
172
- widget: 'datetime',
173
- },
174
- expires: {
175
- description: this.props.intl.formatMessage(
176
- messages.expiresDescription,
177
- ),
178
- title: this.props.intl.formatMessage(messages.expiresTitle),
179
- type: 'string',
180
- widget: 'datetime',
181
- },
182
- rights: {
183
- description: this.props.intl.formatMessage(
184
- messages.rightsDescription,
185
- ),
186
- title: this.props.intl.formatMessage(messages.rightsTitle),
187
- type: 'string',
188
- widget: 'textarea',
189
- },
190
- creators: {
191
- description: this.props.intl.formatMessage(
192
- messages.creatorsDescription,
193
- ),
194
- title: this.props.intl.formatMessage(messages.creatorsTitle),
195
- type: 'array',
196
- },
197
- exclude_from_nav: {
198
- description: this.props.intl.formatMessage(
199
- messages.excludeFromNavDescription,
200
- ),
201
- title: this.props.intl.formatMessage(
202
- messages.excludeFromNavTitle,
203
- ),
204
- type: 'boolean',
205
- },
93
+ return (
94
+ open && (
95
+ <ModalForm
96
+ open={open}
97
+ onSubmit={onSubmit}
98
+ onCancel={onCancel}
99
+ title={intl.formatMessage(messages.properties)}
100
+ schema={{
101
+ fieldsets: [
102
+ {
103
+ id: 'default',
104
+ title: intl.formatMessage(messages.default),
105
+ fields: [
106
+ 'effective',
107
+ 'expires',
108
+ 'rights',
109
+ 'creators',
110
+ 'exclude_from_nav',
111
+ ],
112
+ },
113
+ ],
114
+ properties: {
115
+ effective: {
116
+ description: intl.formatMessage(messages.effectiveDescription),
117
+ title: intl.formatMessage(messages.effectiveTitle),
118
+ type: 'string',
119
+ widget: 'datetime',
120
+ },
121
+ expires: {
122
+ description: intl.formatMessage(messages.expiresDescription),
123
+ title: intl.formatMessage(messages.expiresTitle),
124
+ type: 'string',
125
+ widget: 'datetime',
126
+ },
127
+ rights: {
128
+ description: intl.formatMessage(messages.rightsDescription),
129
+ title: intl.formatMessage(messages.rightsTitle),
130
+ type: 'string',
131
+ widget: 'textarea',
132
+ },
133
+ creators: {
134
+ description: intl.formatMessage(messages.creatorsDescription),
135
+ title: intl.formatMessage(messages.creatorsTitle),
136
+ type: 'array',
137
+ },
138
+ exclude_from_nav: {
139
+ description: intl.formatMessage(
140
+ messages.excludeFromNavDescription,
141
+ ),
142
+ title: intl.formatMessage(messages.excludeFromNavTitle),
143
+ type: 'boolean',
206
144
  },
207
- required: [],
208
- }}
209
- />
210
- )
211
- );
212
- }
213
- }
145
+ },
146
+ required: [],
147
+ }}
148
+ />
149
+ )
150
+ );
151
+ };
214
152
 
215
- export default compose(
216
- injectIntl,
217
- connect(
218
- (state) => ({
219
- request: state.content.update,
220
- }),
221
- { updateContent },
222
- ),
223
- )(ContentsPropertiesModal);
153
+ ContentsPropertiesModal.propTypes = {
154
+ items: PropTypes.arrayOf(PropTypes.string).isRequired,
155
+ open: PropTypes.bool.isRequired,
156
+ onOk: PropTypes.func.isRequired,
157
+ onCancel: PropTypes.func.isRequired,
158
+ };
159
+ export default ContentsPropertiesModal;
@@ -1,15 +1,10 @@
1
- /**
2
- * Contents rename modal.
3
- * @module components/manage/Contents/ContentsRenameModal
4
- */
5
-
6
- import React, { Component } from 'react';
1
+ import React, { useCallback, useEffect } from 'react';
7
2
  import PropTypes from 'prop-types';
8
- import { connect } from 'react-redux';
9
- import { compose } from 'redux';
3
+ import { useDispatch, useSelector } from 'react-redux';
10
4
  import { concat, merge, map } from 'lodash';
11
- import { defineMessages, injectIntl } from 'react-intl';
5
+ import { defineMessages, useIntl } from 'react-intl';
12
6
 
7
+ import { usePrevious } from '@plone/volto/helpers';
13
8
  import { updateContent } from '@plone/volto/actions';
14
9
  import { ModalForm } from '@plone/volto/components';
15
10
 
@@ -40,140 +35,94 @@ const messages = defineMessages({
40
35
  },
41
36
  });
42
37
 
43
- /**
44
- * ContentsRenameModal class.
45
- * @class ContentsRenameModal
46
- * @extends Component
47
- */
48
- class ContentsRenameModal extends Component {
49
- /**
50
- * Property types.
51
- * @property {Object} propTypes Property types.
52
- * @static
53
- */
54
- static propTypes = {
55
- updateContent: PropTypes.func.isRequired,
56
- items: PropTypes.arrayOf(
57
- PropTypes.shape({
58
- id: PropTypes.string,
59
- title: PropTypes.string,
60
- url: PropTypes.string,
61
- }),
62
- ).isRequired,
63
- request: PropTypes.shape({
64
- loading: PropTypes.bool,
65
- loaded: PropTypes.bool,
66
- }).isRequired,
67
- open: PropTypes.bool.isRequired,
68
- onOk: PropTypes.func.isRequired,
69
- onCancel: PropTypes.func.isRequired,
70
- };
71
-
72
- /**
73
- * Constructor
74
- * @method constructor
75
- * @param {Object} props Component properties
76
- * @constructs ContentsUploadModal
77
- */
78
- constructor(props) {
79
- super(props);
80
- this.onSubmit = this.onSubmit.bind(this);
81
- }
38
+ const ContentsRenameModal = (props) => {
39
+ const { onOk, open, items, onCancel } = props;
40
+ const intl = useIntl();
41
+ const dispatch = useDispatch();
42
+ const request = useSelector((state) => state.content.update);
43
+ const prevrequestloading = usePrevious(request.loading);
82
44
 
83
- /**
84
- * Component will receive props
85
- * @method componentWillReceiveProps
86
- * @param {Object} nextProps Next properties
87
- * @returns {undefined}
88
- */
89
- UNSAFE_componentWillReceiveProps(nextProps) {
90
- if (this.props.request.loading && nextProps.request.loaded) {
91
- this.props.onOk();
45
+ useEffect(() => {
46
+ if (prevrequestloading && request.loaded) {
47
+ onOk();
92
48
  }
93
- }
49
+ }, [onOk, prevrequestloading, request.loaded]);
94
50
 
95
- /**
96
- * Submit handler
97
- * @method onSubmit
98
- * @param {Object} data Form data
99
- * @returns {undefined}
100
- */
101
- onSubmit(data) {
102
- this.props.updateContent(
103
- map(this.props.items, (item) => item.url),
104
- map(this.props.items, (item, index) => ({
105
- id: data[`${index}_id`],
106
- title: data[`${index}_title`],
107
- })),
108
- );
109
- }
51
+ const onSubmit = useCallback(
52
+ (data) => {
53
+ dispatch(
54
+ updateContent(
55
+ map(items, (item) => item.url),
56
+ map(items, (item, index) => ({
57
+ id: data[`${index}_id`],
58
+ title: data[`${index}_title`],
59
+ })),
60
+ ),
61
+ );
62
+ },
63
+ [items, dispatch],
64
+ );
110
65
 
111
- /**
112
- * Render method.
113
- * @method render
114
- * @returns {string} Markup for the component.
115
- */
116
- render() {
117
- return (
118
- this.props.open && (
119
- <ModalForm
120
- open={this.props.open}
121
- loading={this.props.request.loading}
122
- loadingMessage={this.props.intl.formatMessage(
123
- messages.loadingMessage,
124
- )}
125
- onSubmit={this.onSubmit}
126
- onCancel={this.props.onCancel}
127
- formData={merge(
128
- ...map(this.props.items, (item, index) => ({
129
- [`${index}_title`]: item.title,
130
- [`${index}_id`]: item.id,
131
- })),
132
- )}
133
- title={this.props.intl.formatMessage(messages.renameItems)}
134
- schema={{
135
- fieldsets: [
136
- {
137
- id: 'default',
138
- title: this.props.intl.formatMessage(messages.default),
139
- fields: concat(
140
- ...map(this.props.items, (item, index) => [
141
- `${index}_title`,
142
- `${index}_id`,
143
- ]),
144
- ),
66
+ return (
67
+ open && (
68
+ <ModalForm
69
+ open={open}
70
+ loading={request.loading}
71
+ loadingMessage={intl.formatMessage(messages.loadingMessage)}
72
+ onSubmit={onSubmit}
73
+ onCancel={onCancel}
74
+ formData={merge(
75
+ ...map(items, (item, index) => ({
76
+ [`${index}_title`]: item.title,
77
+ [`${index}_id`]: item.id,
78
+ })),
79
+ )}
80
+ title={intl.formatMessage(messages.renameItems)}
81
+ schema={{
82
+ fieldsets: [
83
+ {
84
+ id: 'default',
85
+ title: intl.formatMessage(messages.default),
86
+ fields: concat(
87
+ ...map(items, (item, index) => [
88
+ `${index}_title`,
89
+ `${index}_id`,
90
+ ]),
91
+ ),
92
+ },
93
+ ],
94
+ properties: merge(
95
+ ...map(items, (item, index) => ({
96
+ [`${index}_title`]: {
97
+ title: intl.formatMessage(messages.title),
98
+ type: 'string',
99
+ description: '',
145
100
  },
146
- ],
147
- properties: merge(
148
- ...map(this.props.items, (item, index) => ({
149
- [`${index}_title`]: {
150
- title: this.props.intl.formatMessage(messages.title),
151
- type: 'string',
152
- description: '',
153
- },
154
- [`${index}_id`]: {
155
- title: this.props.intl.formatMessage(messages.shortName),
156
- type: 'id',
157
- description: this.props.intl.formatMessage(
158
- messages.shortNameDescription,
159
- ),
160
- },
161
- })),
162
- ),
163
- required: [],
164
- }}
165
- />
166
- )
167
- );
168
- }
169
- }
101
+ [`${index}_id`]: {
102
+ title: intl.formatMessage(messages.shortName),
103
+ type: 'id',
104
+ description: intl.formatMessage(messages.shortNameDescription),
105
+ },
106
+ })),
107
+ ),
108
+ required: [],
109
+ }}
110
+ />
111
+ )
112
+ );
113
+ };
170
114
 
171
- export default compose(
172
- injectIntl,
173
- connect(
174
- (state) => ({
175
- request: state.content.update,
115
+ ContentsRenameModal.propTypes = {
116
+ items: PropTypes.arrayOf(
117
+ PropTypes.shape({
118
+ id: PropTypes.string,
119
+ title: PropTypes.string,
120
+ url: PropTypes.string,
176
121
  }),
177
- { updateContent },
178
- ),
179
- )(ContentsRenameModal);
122
+ ).isRequired,
123
+ open: PropTypes.bool.isRequired,
124
+ onOk: PropTypes.func.isRequired,
125
+ onCancel: PropTypes.func.isRequired,
126
+ };
127
+
128
+ export default ContentsRenameModal;
@@ -0,0 +1,61 @@
1
+ import { injectIntl } from 'react-intl';
2
+ import React from 'react';
3
+ import ContentsRenameModalComponent from './ContentsRenameModal';
4
+ import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook';
5
+
6
+ const IntlContentRenameModalComponent = injectIntl(
7
+ ContentsRenameModalComponent,
8
+ );
9
+
10
+ function StoryComponent(args) {
11
+ return (
12
+ <Wrapper
13
+ customStore={{
14
+ content: {
15
+ update: {
16
+ loading: false,
17
+ loaded: true,
18
+ },
19
+ },
20
+ intl: {
21
+ locale: 'en',
22
+ messages: {},
23
+ },
24
+ }}
25
+ >
26
+ <div id="toolbar" style={{ display: 'none' }} />
27
+ <IntlContentRenameModalComponent
28
+ {...args}
29
+ onOk={() => {}}
30
+ onCancel={() => {}}
31
+ items={[
32
+ {
33
+ ...args,
34
+ url: '/blog',
35
+ },
36
+ ]}
37
+ />
38
+ </Wrapper>
39
+ );
40
+ }
41
+
42
+ export const ContentRenameModal = StoryComponent.bind({});
43
+
44
+ ContentRenameModal.args = {
45
+ open: true,
46
+ id: 'blogs',
47
+ title: 'Plone Blog',
48
+ };
49
+
50
+ export default {
51
+ title: 'Public components/Contents/Content Rename Modal',
52
+ component: ContentRenameModal,
53
+ decorators: [
54
+ (Story) => (
55
+ <div className="ui segment form attached" style={{ width: '400px' }}>
56
+ <Story />
57
+ </div>
58
+ ),
59
+ ],
60
+ argTypes: {},
61
+ };