@plone/volto 18.0.0-alpha.41 → 18.0.0-alpha.43

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 (187) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/finalreleasechangelog.py +48 -0
  3. package/locales/ca/LC_MESSAGES/volto.po +39 -13
  4. package/locales/ca.json +1 -1
  5. package/locales/de/LC_MESSAGES/volto.po +40 -14
  6. package/locales/de.json +1 -1
  7. package/locales/en/LC_MESSAGES/volto.po +39 -13
  8. package/locales/en.json +1 -1
  9. package/locales/es/LC_MESSAGES/volto.po +40 -14
  10. package/locales/es.json +1 -1
  11. package/locales/eu/LC_MESSAGES/volto.po +40 -14
  12. package/locales/eu.json +1 -1
  13. package/locales/fi/LC_MESSAGES/volto.po +40 -14
  14. package/locales/fi.json +1 -1
  15. package/locales/fr/LC_MESSAGES/volto.po +40 -14
  16. package/locales/fr.json +1 -1
  17. package/locales/hi/LC_MESSAGES/volto.po +40 -14
  18. package/locales/hi.json +1 -1
  19. package/locales/it/LC_MESSAGES/volto.po +40 -14
  20. package/locales/it.json +1 -1
  21. package/locales/ja/LC_MESSAGES/volto.po +39 -13
  22. package/locales/ja.json +1 -1
  23. package/locales/nl/LC_MESSAGES/volto.po +39 -13
  24. package/locales/nl.json +1 -1
  25. package/locales/pt/LC_MESSAGES/volto.po +39 -13
  26. package/locales/pt.json +1 -1
  27. package/locales/pt_BR/LC_MESSAGES/volto.po +40 -14
  28. package/locales/pt_BR.json +1 -1
  29. package/locales/ro/LC_MESSAGES/volto.po +39 -13
  30. package/locales/ro.json +1 -1
  31. package/locales/volto.pot +40 -14
  32. package/locales/zh_CN/LC_MESSAGES/volto.po +40 -14
  33. package/locales/zh_CN.json +1 -1
  34. package/package.json +5 -6
  35. package/razzle.config.js +3 -3
  36. package/src/components/index.js +0 -1
  37. package/src/components/manage/Actions/Actions.stories.jsx +138 -0
  38. package/src/components/manage/Add/Add.jsx +7 -4
  39. package/src/components/manage/BlockChooser/BlockChooser.jsx +9 -1
  40. package/src/components/manage/Blocks/Block/BlocksForm.jsx +5 -0
  41. package/src/components/manage/Blocks/Block/Edit.jsx +24 -8
  42. package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +17 -1
  43. package/src/components/manage/Blocks/Block/Order/Item.jsx +8 -2
  44. package/src/components/manage/Blocks/Block/Order/Order.jsx +2 -0
  45. package/src/components/manage/Blocks/Container/Data.jsx +10 -2
  46. package/src/components/manage/Blocks/Grid/View.jsx +3 -0
  47. package/src/components/manage/Blocks/Image/ImageSidebar.jsx +10 -2
  48. package/src/components/manage/Blocks/LeadImage/Edit.jsx +74 -126
  49. package/src/components/manage/Blocks/Listing/ListingData.jsx +10 -2
  50. package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
  51. package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +2 -0
  52. package/src/components/manage/Blocks/Search/SearchBlockView.jsx +18 -2
  53. package/src/components/manage/Blocks/Search/components/SortOn.jsx +82 -55
  54. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +1 -1
  55. package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +107 -176
  56. package/src/components/manage/Blocks/Teaser/Data.jsx +10 -2
  57. package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +15 -8
  58. package/src/components/manage/Blocks/ToC/Edit.jsx +36 -28
  59. package/src/components/manage/Blocks/Video/Edit.jsx +105 -172
  60. package/src/components/manage/Blocks/Video/Edit.stories.jsx +57 -0
  61. package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
  62. package/src/components/manage/Contents/Contents.jsx +4 -1
  63. package/src/components/manage/Contents/ContentsBreadcrumbs.stories.jsx +46 -0
  64. package/src/components/manage/Contents/ContentsPropertiesModal.jsx +85 -52
  65. package/src/components/manage/Contents/ContentsUploadModal.jsx +230 -323
  66. package/src/components/manage/Contents/ContentsUploadModal.stories.jsx +56 -0
  67. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +323 -441
  68. package/src/components/manage/Controlpanels/Aliases.jsx +452 -580
  69. package/src/components/manage/Controlpanels/Aliases.stories.jsx +74 -0
  70. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -0
  71. package/src/components/manage/Controlpanels/Controlpanel.jsx +41 -2
  72. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +55 -24
  73. package/src/components/manage/Controlpanels/DatabaseInformation.jsx +162 -229
  74. package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +74 -122
  75. package/src/components/manage/Controlpanels/UndoControlpanel.jsx +3 -3
  76. package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +28 -12
  77. package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +12 -4
  78. package/src/components/manage/Display/Display.jsx +92 -148
  79. package/src/components/manage/Display/Display.stories.jsx +46 -0
  80. package/src/components/manage/Edit/Edit.jsx +2 -4
  81. package/src/components/manage/Form/Form.jsx +85 -20
  82. package/src/components/manage/Form/InlineForm.jsx +2 -4
  83. package/src/components/manage/Form/ModalForm.jsx +1 -1
  84. package/src/components/manage/History/History.jsx +1 -1
  85. package/src/components/manage/Pluggable/Pluggable.test.js +1 -1
  86. package/src/components/manage/Preferences/ChangePassword.jsx +94 -172
  87. package/src/components/manage/Preferences/ChangePassword.stories.jsx +41 -0
  88. package/src/components/manage/Preferences/PersonalInformation.jsx +50 -115
  89. package/src/components/manage/Preferences/PersonalPreferences.jsx +46 -100
  90. package/src/components/manage/Preferences/PersonalPreferences.stories.jsx +48 -0
  91. package/src/components/manage/Toolbar/More.jsx +308 -399
  92. package/src/components/manage/Toolbar/Toolbar.jsx +1 -1
  93. package/src/components/manage/Widgets/ArrayWidget.jsx +2 -2
  94. package/src/components/manage/Widgets/DatetimeWidget.jsx +121 -175
  95. package/src/components/manage/Widgets/ImageWidget.jsx +6 -5
  96. package/src/components/manage/Widgets/RecurrenceWidget/EndField.jsx +7 -1
  97. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +80 -31
  98. package/src/components/manage/Widgets/ReferenceWidget.jsx +134 -210
  99. package/src/components/theme/Register/Register.jsx +70 -142
  100. package/src/components/theme/Register/Register.stories.jsx +49 -0
  101. package/src/components/theme/Search/Search.jsx +13 -5
  102. package/src/components/theme/Tags/Tags.jsx +19 -10
  103. package/src/components/theme/Tags/Tags.test.jsx +9 -11
  104. package/src/components/theme/View/AlbumView.jsx +122 -167
  105. package/src/components/theme/View/LinkView.jsx +4 -0
  106. package/src/components/theme/View/LinkView.test.jsx +2 -0
  107. package/src/components/theme/View/View.jsx +0 -13
  108. package/src/components/theme/View/View.test.jsx +0 -3
  109. package/src/config/ControlPanels.js +49 -43
  110. package/src/config/Widgets.jsx +1 -1
  111. package/src/config/config.test.js +1 -0
  112. package/src/config/index.js +23 -2
  113. package/src/config/slots.js +12 -0
  114. package/src/config/validation.ts +155 -0
  115. package/src/helpers/Blocks/Blocks.js +12 -7
  116. package/src/helpers/Blocks/Blocks.test.js +15 -0
  117. package/src/helpers/Blocks/cloneBlocks.ts +1 -1
  118. package/src/helpers/Extensions/withBlockExtensions.jsx +1 -1
  119. package/src/helpers/FormValidation/FormValidation.jsx +128 -172
  120. package/src/helpers/FormValidation/FormValidation.test.js +836 -8
  121. package/src/helpers/FormValidation/validators.ts +203 -0
  122. package/src/helpers/MessageLabels/MessageLabels.js +28 -0
  123. package/src/helpers/Url/Url.test.js +19 -6
  124. package/src/helpers/Url/urlRegex.js +1 -1
  125. package/src/helpers/User/User.js +1 -1
  126. package/src/helpers/index.js +2 -0
  127. package/src/hooks/client/useClient.js +1 -1
  128. package/src/middleware/api.js +4 -2
  129. package/src/middleware/index.js +1 -0
  130. package/src/middleware/userSessionReset.js +46 -0
  131. package/src/store.js +2 -0
  132. package/test-setup-config.jsx +10 -0
  133. package/theme/themes/default/modules/embed.variables +1 -1
  134. package/theme/themes/pastanaga/collections/form.overrides +34 -0
  135. package/theme/themes/pastanaga/extras/blocks.less +6 -0
  136. package/theme/themes/pastanaga/extras/sidebar.less +4 -0
  137. package/theme/themes/pastanaga/extras/toolbar.less +10 -3
  138. package/tsconfig.declarations.json +3 -2
  139. package/types/components/index.d.ts +0 -1
  140. package/types/components/manage/Actions/Actions.stories.d.ts +8 -0
  141. package/types/components/manage/Blocks/Block/Order/Order.d.ts +2 -1
  142. package/types/components/manage/Blocks/LeadImage/Edit.d.ts +14 -5
  143. package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +0 -5
  144. package/types/components/manage/Blocks/ToC/Edit.d.ts +1 -6
  145. package/types/components/manage/Blocks/Video/Edit.d.ts +1 -1
  146. package/types/components/manage/Blocks/Video/Edit.stories.d.ts +8 -0
  147. package/types/components/manage/Contents/ContentsBreadcrumbs.stories.d.ts +8 -0
  148. package/types/components/manage/Contents/ContentsUploadModal.d.ts +14 -2
  149. package/types/components/manage/Contents/ContentsUploadModal.stories.d.ts +8 -0
  150. package/types/components/manage/Contents/index.d.ts +1 -1
  151. package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +2 -2
  152. package/types/components/manage/Controlpanels/Aliases.d.ts +2 -2
  153. package/types/components/manage/Controlpanels/Aliases.stories.d.ts +8 -0
  154. package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +2 -2
  155. package/types/components/manage/Controlpanels/Groups/RenderGroups.d.ts +10 -5
  156. package/types/components/manage/Controlpanels/index.d.ts +4 -4
  157. package/types/components/manage/Display/Display.stories.d.ts +8 -0
  158. package/types/components/manage/Preferences/ChangePassword.d.ts +2 -2
  159. package/types/components/manage/Preferences/ChangePassword.stories.d.ts +8 -0
  160. package/types/components/manage/Preferences/PersonalInformation.d.ts +7 -2
  161. package/types/components/manage/Preferences/PersonalPreferences.d.ts +5 -1
  162. package/types/components/manage/Preferences/PersonalPreferences.stories.d.ts +8 -0
  163. package/types/components/manage/Toolbar/More.d.ts +8 -5
  164. package/types/components/manage/Widgets/DatetimeWidget.d.ts +0 -85
  165. package/types/components/manage/Widgets/DatetimeWidget.stories.d.ts +0 -1
  166. package/types/components/manage/Widgets/ReferenceWidget.d.ts +27 -2
  167. package/types/components/manage/Widgets/index.d.ts +1 -1
  168. package/types/components/theme/Register/Register.d.ts +2 -2
  169. package/types/components/theme/Register/Register.stories.d.ts +9 -0
  170. package/types/components/theme/Tags/Tags.d.ts +15 -7
  171. package/types/components/theme/View/AlbumView.d.ts +3 -17
  172. package/types/config/ControlPanels.d.ts +8 -0
  173. package/types/config/RichTextEditor/ToHTML.d.ts +1 -1
  174. package/types/config/Widgets.d.ts +3 -3
  175. package/types/config/slots.d.ts +21 -0
  176. package/types/config/validation.d.ts +3 -0
  177. package/types/helpers/Blocks/Blocks.d.ts +6 -0
  178. package/types/helpers/Extensions/withBlockExtensions.d.ts +1 -1
  179. package/types/helpers/FormValidation/FormValidation.d.ts +2 -0
  180. package/types/helpers/FormValidation/validators.d.ts +29 -0
  181. package/types/helpers/MessageLabels/MessageLabels.d.ts +36 -0
  182. package/types/helpers/User/User.d.ts +1 -1
  183. package/types/helpers/index.d.ts +2 -2
  184. package/types/middleware/index.d.ts +1 -0
  185. package/types/middleware/userSessionReset.d.ts +5 -0
  186. package/src/components/theme/SocialSharing/SocialSharing.jsx +0 -48
  187. package/src/components/theme/SocialSharing/SocialSharing.test.jsx +0 -14
@@ -1,13 +1,8 @@
1
- /**
2
- * Users controlpanel container.
3
- * @module components/manage/Controlpanels/AddonsControlpanel
4
- */
5
- import React, { Component } from 'react';
6
- import PropTypes from 'prop-types';
7
- import { connect } from 'react-redux';
8
- import { compose } from 'redux';
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
+ import { useDispatch, useSelector, shallowEqual } from 'react-redux';
9
3
  import { Link } from 'react-router-dom';
10
4
  import { createPortal } from 'react-dom';
5
+ import { useClient } from '@plone/volto/hooks';
11
6
  import {
12
7
  Accordion,
13
8
  Button,
@@ -20,7 +15,7 @@ import {
20
15
  Dimmer,
21
16
  Loader,
22
17
  } from 'semantic-ui-react';
23
- import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
18
+ import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
24
19
 
25
20
  import {
26
21
  installAddon,
@@ -131,461 +126,348 @@ const messages = defineMessages({
131
126
  },
132
127
  });
133
128
 
134
- /**
135
- * AddonsControlpanel class.
136
- * @class AddonsControlpanel
137
- * @extends Component
138
- */
139
- class AddonsControlpanel extends Component {
140
- /**
141
- * Property types.
142
- * @property {Object} propTypes Property types.
143
- * @static
144
- */
145
- static propTypes = {
146
- listAddons: PropTypes.func.isRequired,
147
- installAddon: PropTypes.func.isRequired,
148
- uninstallAddon: PropTypes.func.isRequired,
149
- installedAddons: PropTypes.arrayOf(
150
- PropTypes.shape({
151
- '@id': PropTypes.string,
152
- id: PropTypes.string,
153
- title: PropTypes.string,
154
- version: PropTypes.string,
155
- description: PropTypes.string,
156
- uninstall_profile_id: PropTypes.string,
157
- upgrade_info: PropTypes.shape({
158
- available: PropTypes.boolean,
159
- }),
160
- }),
161
- ).isRequired,
162
- availableAddons: PropTypes.arrayOf(
163
- PropTypes.shape({
164
- '@id': PropTypes.string,
165
- id: PropTypes.string,
166
- title: PropTypes.string,
167
- version: PropTypes.string,
168
- description: PropTypes.string,
169
- uninstall_profile_id: PropTypes.string,
170
- upgrade_info: PropTypes.shape({
171
- available: PropTypes.boolean,
172
- }),
173
- }),
174
- ).isRequired,
175
- upgradableAddons: PropTypes.arrayOf(
176
- PropTypes.shape({
177
- '@id': PropTypes.string,
178
- id: PropTypes.string,
179
- title: PropTypes.string,
180
- version: PropTypes.string,
181
- description: PropTypes.string,
182
- uninstall_profile_id: PropTypes.string,
183
- upgrade_info: PropTypes.shape({
184
- available: PropTypes.boolean,
185
- }),
186
- }),
187
- ).isRequired,
188
- };
129
+ const AddonsControlpanel = (props) => {
130
+ const { title } = props;
131
+ const intl = useIntl();
132
+ const dispatch = useDispatch();
133
+ const pathname = props.location.pathname;
134
+ const [activeIndex, setactiveIndex] = useState(-1);
135
+ const isClient = useClient();
136
+ const installedAddons = useSelector(
137
+ (state) => state.addons.installedAddons,
138
+ shallowEqual,
139
+ );
140
+ const availableAddons = useSelector(
141
+ (state) => state.addons.availableAddons,
142
+ shallowEqual,
143
+ );
144
+ const upgradableAddons = useSelector(
145
+ (state) => state.addons.upgradableAddons,
146
+ shallowEqual,
147
+ );
148
+ const loadingAddons = useSelector((state) => state.addons.loading);
189
149
 
190
- /**
191
- * Constructor
192
- * @method constructor
193
- * @param {Object} props Component properties
194
- * @constructs Sharing
195
- */
196
- constructor(props) {
197
- super(props);
198
- this.onAccordionClick = this.onAccordionClick.bind(this);
199
- this.onInstall = this.onInstall.bind(this);
200
- this.onUninstall = this.onUninstall.bind(this);
201
- this.onUpgrade = this.onUpgrade.bind(this);
202
- this.state = {
203
- activeIndex: -1,
204
- installedAddons: [],
205
- availableAddons: [],
206
- upgradableAddons: [],
207
- isClient: false,
208
- };
209
- }
150
+ useEffect(() => {
151
+ dispatch(listAddons());
152
+ }, [dispatch]);
210
153
 
211
- /**
212
- * Component did mount
213
- * @method componentDidMount
214
- * @returns {undefined}
215
- */
216
- componentDidMount() {
217
- this.props.listAddons();
218
- this.setState({ isClient: true });
219
- }
154
+ const onInstall = useCallback(
155
+ (event, { value }) => {
156
+ event.preventDefault();
220
157
 
221
- /**
222
- * Install handler
223
- * @method onInstall
224
- * @param {Object} event Event object.
225
- * @param {string} value Id of package to install.
226
- * @returns {undefined}
227
- */
228
- onInstall(event, { value }) {
229
- event.preventDefault();
230
- this.props
231
- .installAddon(value)
232
- .then(() => {
233
- toast.success(
234
- <Toast
235
- success
236
- title={this.props.intl.formatMessage(messages.success)}
237
- content={this.props.intl.formatMessage(messages.addonInstalled, {
238
- title: this.props.title,
239
- })}
240
- />,
241
- );
242
- })
243
- .catch(() => {
244
- toast.error(
245
- <Toast
246
- error
247
- title={this.props.intl.formatMessage(messages.error)}
248
- content={this.props.intl.formatMessage(messages.addonNotInstalled)}
249
- />,
250
- );
251
- })
252
- .finally(() => this.props.listAddons());
253
- }
158
+ dispatch(installAddon(value))
159
+ .then(() => {
160
+ toast.success(
161
+ <Toast
162
+ success
163
+ title={intl.formatMessage(messages.success)}
164
+ content={intl.formatMessage(messages.addonInstalled, {
165
+ title: title,
166
+ })}
167
+ />,
168
+ );
169
+ })
170
+ .catch(() => {
171
+ toast.error(
172
+ <Toast
173
+ error
174
+ title={intl.formatMessage(messages.error)}
175
+ content={intl.formatMessage(messages.addonNotInstalled)}
176
+ />,
177
+ );
178
+ })
179
+ .finally(() => dispatch(listAddons()));
180
+ },
181
+ [dispatch, title, intl],
182
+ );
254
183
 
255
- /**
256
- * Uninstall handler
257
- * @method onUninstall
258
- * @param {Object} event Event object.
259
- * @param {string} value Id of package to uninstall.
260
- * @returns {undefined}
261
- */
262
- onUninstall(event, { value }) {
263
- event.preventDefault();
264
- this.props
265
- .uninstallAddon(value)
266
- .then(() => {
267
- toast.success(
268
- <Toast
269
- success
270
- title={this.props.intl.formatMessage(messages.success)}
271
- content={this.props.intl.formatMessage(messages.addonUninstalled)}
272
- />,
273
- );
274
- })
275
- .catch(() => {
276
- toast.error(
277
- <Toast
278
- error
279
- title={this.props.intl.formatMessage(messages.error)}
280
- content={this.props.intl.formatMessage(
281
- messages.addonNotUninstalled,
282
- {
283
- title: this.props.title,
284
- },
285
- )}
286
- />,
287
- );
288
- })
289
- .finally(() => this.props.listAddons());
290
- }
184
+ const onUninstall = useCallback(
185
+ (event, { value }) => {
186
+ event.preventDefault();
187
+ dispatch(uninstallAddon(value))
188
+ .then(() => {
189
+ toast.success(
190
+ <Toast
191
+ success
192
+ title={intl.formatMessage(messages.success)}
193
+ content={intl.formatMessage(messages.addonUninstalled)}
194
+ />,
195
+ );
196
+ })
197
+ .catch(() => {
198
+ toast.error(
199
+ <Toast
200
+ error
201
+ title={intl.formatMessage(messages.error)}
202
+ content={intl.formatMessage(messages.addonNotUninstalled, {
203
+ title: title,
204
+ })}
205
+ />,
206
+ );
207
+ })
208
+ .finally(() => dispatch(listAddons()));
209
+ },
210
+ [dispatch, intl, title],
211
+ );
291
212
 
292
- /**
293
- * Unpgrade handler
294
- * @method onUpgrade
295
- * @param {Object} event Event object.
296
- * @param {string} value Id of package to update.
297
- * @returns {undefined}
298
- */
299
- onUpgrade(event, { value }) {
300
- event.preventDefault();
301
- this.props
302
- .upgradeAddon(value)
303
- .then(() => {
304
- toast.success(
305
- <Toast
306
- success
307
- title={this.props.intl.formatMessage(messages.success)}
308
- content={this.props.intl.formatMessage(messages.addonUpgraded)}
309
- />,
310
- );
311
- })
312
- .catch(() => {
313
- toast.error(
314
- <Toast
315
- error
316
- title={this.props.intl.formatMessage(messages.error)}
317
- content={this.props.intl.formatMessage(messages.addonNotUpgraded)}
318
- />,
319
- );
320
- })
321
- .finally(() => this.props.listAddons());
322
- }
213
+ const onUpgrade = useCallback(
214
+ (event, { value }) => {
215
+ event.preventDefault();
323
216
 
324
- /**
325
- * On accordion click handler
326
- * @method onAccordionClick
327
- * @param {object} event Event object.
328
- * @param {object} index Index of the accordion element being clicked
329
- * @returns {undefined}
330
- */
331
- onAccordionClick(event, item) {
332
- const { activeIndex } = this.state;
217
+ dispatch(upgradeAddon(value))
218
+ .then(() => {
219
+ toast.success(
220
+ <Toast
221
+ success
222
+ title={intl.formatMessage(messages.success)}
223
+ content={intl.formatMessage(messages.addonUpgraded)}
224
+ />,
225
+ );
226
+ })
227
+ .catch(() => {
228
+ toast.error(
229
+ <Toast
230
+ error
231
+ title={intl.formatMessage(messages.error)}
232
+ content={intl.formatMessage(messages.addonNotUpgraded)}
233
+ />,
234
+ );
235
+ })
236
+ .finally(() => dispatch(listAddons()));
237
+ },
238
+ [dispatch, intl],
239
+ );
240
+
241
+ const onAccordionClick = (event, item) => {
333
242
  const newIndex = activeIndex === item.index ? -1 : item.index;
334
- this.setState({ activeIndex: newIndex });
335
- }
243
+ setactiveIndex(newIndex);
244
+ };
336
245
 
337
- /**
338
- * Render method.
339
- * @method render
340
- * @returns {string} Markup for the component.
341
- */
342
- render() {
343
- return (
344
- <Container id="page-addons" className="controlpanel-addons">
345
- <Helmet title={this.props.intl.formatMessage(messages.addOns)} />
346
- <Segment.Group raised>
347
- <Segment className="primary">
348
- <FormattedMessage
349
- id="Add-ons Settings"
350
- defaultMessage="Add-ons Settings"
351
- />
352
- </Segment>
246
+ return (
247
+ <Container id="page-addons" className="controlpanel-addons">
248
+ <Helmet title={intl.formatMessage(messages.addOns)} />
249
+ <Segment.Group raised>
250
+ <Segment className="primary">
251
+ <FormattedMessage
252
+ id="Add-ons Settings"
253
+ defaultMessage="Add-ons Settings"
254
+ />
255
+ </Segment>
353
256
 
354
- {this.props.loadingAddons ? (
355
- <Dimmer active>
356
- <Loader />
357
- </Dimmer>
358
- ) : (
359
- <>
360
- {this.props.upgradableAddons.length > 0 && (
361
- <Message attached>
362
- <Message.Header>
363
- <FormattedMessage
364
- id="Updates available"
365
- defaultMessage="Updates available"
366
- />
367
- </Message.Header>
257
+ {loadingAddons ? (
258
+ <Dimmer active>
259
+ <Loader />
260
+ </Dimmer>
261
+ ) : (
262
+ <>
263
+ {upgradableAddons.length > 0 && (
264
+ <Message attached>
265
+ <Message.Header>
368
266
  <FormattedMessage
369
- id="Update installed addons"
370
- defaultMessage="Update installed addons"
267
+ id="Updates available"
268
+ defaultMessage="Updates available"
371
269
  />
372
- </Message>
373
- )}
374
- <Segment>
375
- <Header as="h3">
376
- <FormattedMessage
377
- id="Activate and deactivate"
378
- defaultMessage="Activate and deactivate add-ons in the lists below."
379
- />
380
- </Header>
270
+ </Message.Header>
271
+ <FormattedMessage
272
+ id="Update installed addons"
273
+ defaultMessage="Update installed addons"
274
+ />
275
+ </Message>
276
+ )}
277
+ <Segment>
278
+ <Header as="h3">
381
279
  <FormattedMessage
382
- id="Add Addons"
383
- defaultMessage="To make new add-ons show up here, add them to your configuration, build, and restart the server process. For detailed instructions see"
280
+ id="Activate and deactivate"
281
+ defaultMessage="Activate and deactivate add-ons in the lists below."
384
282
  />
385
- &nbsp;
386
- <a
387
- href="https://6.docs.plone.org/install/"
388
- target="_blank"
389
- rel="noopener noreferrer"
390
- >
391
- {this.props.intl.formatMessage(messages.installingAnAddon)}
392
- </a>
393
- .
394
- </Segment>
395
- <Segment key="header-available" secondary>
396
- <FormattedMessage id="Available" defaultMessage="Available" />:
397
- <Label circular>{this.props.availableAddons.length}</Label>
398
- </Segment>
399
- <Segment key="body-available" attached>
400
- <Accordion>
401
- <Divider />
402
- {this.props.availableAddons.map((item) => (
403
- <div key={item.id}>
404
- <Accordion.Title
405
- active={this.state.activeIndex === item.id}
406
- index={item.id}
407
- onClick={this.onAccordionClick}
408
- >
409
- {item.title}
410
- <Icon
411
- name={
412
- this.state.activeIndex === item.id
413
- ? circleTopSVG
414
- : circleBottomSVG
415
- }
416
- size="23px"
417
- className={`accordionToggle ${item.title}`}
283
+ </Header>
284
+ <FormattedMessage
285
+ id="Add Addons"
286
+ defaultMessage="To make new add-ons show up here, add them to your configuration, build, and restart the server process. For detailed instructions see"
287
+ />
288
+ &nbsp;
289
+ <a
290
+ href="https://6.docs.plone.org/install/"
291
+ target="_blank"
292
+ rel="noopener noreferrer"
293
+ >
294
+ {intl.formatMessage(messages.installingAnAddon)}
295
+ </a>
296
+ .
297
+ </Segment>
298
+ <Segment key="header-available" secondary>
299
+ <FormattedMessage id="Available" defaultMessage="Available" />:
300
+ <Label circular>{availableAddons.length}</Label>
301
+ </Segment>
302
+ <Segment key="body-available" attached>
303
+ <Accordion>
304
+ <Divider />
305
+ {availableAddons.map((item) => (
306
+ <div key={item.id}>
307
+ <Accordion.Title
308
+ active={activeIndex === item.id}
309
+ index={item.id}
310
+ onClick={onAccordionClick}
311
+ >
312
+ {item.title}
313
+ <Icon
314
+ name={
315
+ activeIndex === item.id
316
+ ? circleTopSVG
317
+ : circleBottomSVG
318
+ }
319
+ size="23px"
320
+ className={`accordionToggle ${item.title}`}
321
+ />
322
+ </Accordion.Title>
323
+ <Accordion.Content active={activeIndex === item.id}>
324
+ <div className="description">{item.description}</div>
325
+ {item.uninstall_profile_id === '' && (
326
+ <div>
327
+ <Message icon="warning" warning>
328
+ <FormattedMessage
329
+ id="No uninstall profile"
330
+ defaultMessage="This addon does not provide an uninstall profile."
331
+ />
332
+ </Message>
333
+ </div>
334
+ )}
335
+ <Button.Group floated="right">
336
+ <Button
337
+ primary
338
+ onClick={onInstall}
339
+ value={item.id}
340
+ className="installAction"
341
+ >
342
+ <FormattedMessage
343
+ id="Install"
344
+ defaultMessage="Install"
345
+ className="button-label"
346
+ />
347
+ </Button>
348
+ </Button.Group>
349
+ <div className="version">
350
+ <FormattedMessage
351
+ id="Latest version"
352
+ defaultMessage="Latest version"
418
353
  />
419
- </Accordion.Title>
420
- <Accordion.Content
421
- active={this.state.activeIndex === item.id}
422
- >
423
- <div className="description">{item.description}</div>
424
- {item.uninstall_profile_id === '' && (
425
- <div>
426
- <Message icon="warning" warning>
427
- <FormattedMessage
428
- id="No uninstall profile"
429
- defaultMessage="This addon does not provide an uninstall profile."
430
- />
431
- </Message>
432
- </div>
354
+ : &nbsp;
355
+ {item.version}
356
+ </div>
357
+ </Accordion.Content>
358
+ <Divider />
359
+ </div>
360
+ ))}
361
+ </Accordion>
362
+ </Segment>
363
+ <Segment key="header-installed" secondary>
364
+ <FormattedMessage id="Installed" defaultMessage="Installed" />:
365
+ <Label circular>{installedAddons.length}</Label>
366
+ </Segment>
367
+ <Segment key="body-installed" attached>
368
+ <Accordion>
369
+ <Divider />
370
+ {installedAddons.map((item) => (
371
+ <div key={item.id}>
372
+ <Accordion.Title
373
+ active={activeIndex === item.id}
374
+ index={item.id}
375
+ onClick={onAccordionClick}
376
+ className={
377
+ item.upgrade_info.available ? 'updateAvailable' : ''
378
+ }
379
+ >
380
+ {item.title}
381
+
382
+ {item.upgrade_info.available && (
383
+ <Label>
384
+ <FormattedMessage
385
+ id="Update"
386
+ defaultMessage="Update"
387
+ />
388
+ </Label>
389
+ )}
390
+ <Icon
391
+ name={
392
+ activeIndex === item.id
393
+ ? circleTopSVG
394
+ : circleBottomSVG
395
+ }
396
+ size="24px"
397
+ className={`accordionToggle ${item.title}`}
398
+ color="#878f93"
399
+ />
400
+ </Accordion.Title>
401
+ <Accordion.Content active={activeIndex === item.id}>
402
+ <div className="description">{item.description}</div>
403
+ <Button.Group floated="right">
404
+ {item.upgrade_info.available && (
405
+ <Button primary onClick={onUpgrade} value={item.id}>
406
+ <FormattedMessage
407
+ id="upgradeVersions"
408
+ defaultMessage="Update from version {origin} to {destination}"
409
+ values={{
410
+ origin: item.upgrade_info.installedVersion,
411
+ destination: item.upgrade_info.newVersion,
412
+ }}
413
+ />
414
+ </Button>
433
415
  )}
434
- <Button.Group floated="right">
416
+ {item.uninstall_profile_id && (
435
417
  <Button
436
- primary
437
- onClick={this.onInstall}
418
+ negative
419
+ onClick={onUninstall}
438
420
  value={item.id}
439
- className="installAction"
421
+ className="uninstallAction"
440
422
  >
441
423
  <FormattedMessage
442
- id="Install"
443
- defaultMessage="Install"
424
+ id="Uninstall"
425
+ defaultMessage="Uninstall"
444
426
  className="button-label"
445
427
  />
446
428
  </Button>
447
- </Button.Group>
448
- <div className="version">
449
- <FormattedMessage
450
- id="Latest version"
451
- defaultMessage="Latest version"
452
- />
453
- : &nbsp;
454
- {item.version}
455
- </div>
456
- </Accordion.Content>
457
- <Divider />
458
- </div>
459
- ))}
460
- </Accordion>
461
- </Segment>
462
- <Segment key="header-installed" secondary>
463
- <FormattedMessage id="Installed" defaultMessage="Installed" />:
464
- <Label circular>{this.props.installedAddons.length}</Label>
465
- </Segment>
466
- <Segment key="body-installed" attached>
467
- <Accordion>
468
- <Divider />
469
- {this.props.installedAddons.map((item) => (
470
- <div key={item.id}>
471
- <Accordion.Title
472
- active={this.state.activeIndex === item.id}
473
- index={item.id}
474
- onClick={this.onAccordionClick}
475
- className={
476
- item.upgrade_info.available ? 'updateAvailable' : ''
477
- }
478
- >
479
- {item.title}
480
-
481
- {item.upgrade_info.available && (
482
- <Label>
483
- <FormattedMessage
484
- id="Update"
485
- defaultMessage="Update"
486
- />
487
- </Label>
488
429
  )}
489
- <Icon
490
- name={
491
- this.state.activeIndex === item.id
492
- ? circleTopSVG
493
- : circleBottomSVG
494
- }
495
- size="24px"
496
- className={`accordionToggle ${item.title}`}
497
- color="#878f93"
430
+ </Button.Group>
431
+ <div className="version">
432
+ <FormattedMessage
433
+ id="Installed version"
434
+ defaultMessage="Installed version"
498
435
  />
499
- </Accordion.Title>
500
- <Accordion.Content
501
- active={this.state.activeIndex === item.id}
502
- >
503
- <div className="description">{item.description}</div>
504
- <Button.Group floated="right">
505
- {item.upgrade_info.available && (
506
- <Button
507
- primary
508
- onClick={this.onUpgrade}
509
- value={item.id}
510
- >
511
- <FormattedMessage
512
- id="upgradeVersions"
513
- defaultMessage="Update from version {origin} to {destination}"
514
- values={{
515
- origin: item.upgrade_info.installedVersion,
516
- destination: item.upgrade_info.newVersion,
517
- }}
518
- />
519
- </Button>
520
- )}
521
- {item.uninstall_profile_id && (
522
- <Button
523
- negative
524
- onClick={this.onUninstall}
525
- value={item.id}
526
- className="uninstallAction"
527
- >
528
- <FormattedMessage
529
- id="Uninstall"
530
- defaultMessage="Uninstall"
531
- className="button-label"
532
- />
533
- </Button>
534
- )}
535
- </Button.Group>
536
- <div className="version">
537
- <FormattedMessage
538
- id="Installed version"
539
- defaultMessage="Installed version"
540
- />
541
- : &nbsp; {item.version}
542
- </div>
543
- </Accordion.Content>
544
- <Divider />
545
- </div>
546
- ))}
547
- </Accordion>
548
- </Segment>
549
- </>
550
- )}
551
- </Segment.Group>
436
+ : &nbsp; {item.version}
437
+ </div>
438
+ </Accordion.Content>
439
+ <Divider />
440
+ </div>
441
+ ))}
442
+ </Accordion>
443
+ </Segment>
444
+ </>
445
+ )}
446
+ </Segment.Group>
552
447
 
553
- {this.state.isClient &&
554
- createPortal(
555
- <Toolbar
556
- pathname={this.props.pathname}
557
- hideDefaultViewButtons
558
- inner={
559
- <>
560
- <Link to="/controlpanel" className="item">
561
- <Icon
562
- name={backSVG}
563
- aria-label={this.props.intl.formatMessage(messages.back)}
564
- className="contents circled"
565
- size="30px"
566
- title={this.props.intl.formatMessage(messages.back)}
567
- />
568
- </Link>
569
- </>
570
- }
571
- />,
572
- document.getElementById('toolbar'),
573
- )}
574
- </Container>
575
- );
576
- }
577
- }
448
+ {isClient &&
449
+ createPortal(
450
+ <Toolbar
451
+ pathname={pathname}
452
+ hideDefaultViewButtons
453
+ inner={
454
+ <>
455
+ <Link to="/controlpanel" className="item">
456
+ <Icon
457
+ name={backSVG}
458
+ aria-label={intl.formatMessage(messages.back)}
459
+ className="contents circled"
460
+ size="30px"
461
+ title={intl.formatMessage(messages.back)}
462
+ />
463
+ </Link>
464
+ </>
465
+ }
466
+ />,
467
+ document.getElementById('toolbar'),
468
+ )}
469
+ </Container>
470
+ );
471
+ };
578
472
 
579
- export default compose(
580
- injectIntl,
581
- connect(
582
- (state, props) => ({
583
- installedAddons: state.addons.installedAddons,
584
- availableAddons: state.addons.availableAddons,
585
- upgradableAddons: state.addons.upgradableAddons,
586
- loadingAddons: state.addons.loading,
587
- pathname: props.location.pathname,
588
- }),
589
- { installAddon, listAddons, uninstallAddon, upgradeAddon },
590
- ),
591
- )(AddonsControlpanel);
473
+ export default AddonsControlpanel;