@plone/volto 17.0.0-alpha.2 → 17.0.0-alpha.20

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 (297) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +530 -15
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +11 -14
  5. package/addon-registry.js +34 -0
  6. package/create-theme-addons-loader.js +79 -0
  7. package/cypress/support/commands.js +56 -4
  8. package/cypress/support/volto-slate.js +4 -5
  9. package/docker-compose.yml +1 -1
  10. package/locales/ca/LC_MESSAGES/volto.po +272 -6
  11. package/locales/ca.json +1 -1
  12. package/locales/de/LC_MESSAGES/volto.po +291 -25
  13. package/locales/de.json +1 -1
  14. package/locales/en/LC_MESSAGES/volto.po +271 -5
  15. package/locales/en.json +1 -1
  16. package/locales/es/LC_MESSAGES/volto.po +281 -15
  17. package/locales/es.json +1 -1
  18. package/locales/eu/LC_MESSAGES/volto.po +272 -6
  19. package/locales/eu.json +1 -1
  20. package/locales/fi/LC_MESSAGES/volto.po +4882 -0
  21. package/locales/fi.json +1 -1
  22. package/locales/fr/LC_MESSAGES/volto.po +272 -6
  23. package/locales/fr.json +1 -1
  24. package/locales/it/LC_MESSAGES/volto.po +273 -7
  25. package/locales/it.json +1 -1
  26. package/locales/ja/LC_MESSAGES/volto.po +272 -6
  27. package/locales/ja.json +1 -1
  28. package/locales/nl/LC_MESSAGES/volto.po +927 -649
  29. package/locales/nl.json +1 -1
  30. package/locales/pt/LC_MESSAGES/volto.po +272 -6
  31. package/locales/pt.json +1 -1
  32. package/locales/pt_BR/LC_MESSAGES/volto.po +281 -15
  33. package/locales/pt_BR.json +1 -1
  34. package/locales/ro/LC_MESSAGES/volto.po +272 -6
  35. package/locales/ro.json +1 -1
  36. package/locales/volto.pot +272 -6
  37. package/locales/zh_CN/LC_MESSAGES/volto.po +272 -6
  38. package/locales/zh_CN.json +1 -1
  39. package/package.json +5 -3
  40. package/packages/volto-slate/build/messages/src/blocks/Table/TableBlockEdit.json +1 -1
  41. package/packages/volto-slate/build/messages/src/blocks/Text/DefaultTextBlockEditor.json +1 -1
  42. package/packages/volto-slate/build/messages/src/blocks/Text/DetachedTextBlockEditor.json +1 -1
  43. package/packages/volto-slate/build/messages/src/blocks/Text/SlashMenu.json +1 -1
  44. package/packages/volto-slate/build/messages/src/editor/plugins/AdvancedLink/index.json +1 -1
  45. package/packages/volto-slate/build/messages/src/editor/plugins/Link/index.json +1 -1
  46. package/packages/volto-slate/build/messages/src/editor/plugins/Table/index.json +1 -1
  47. package/packages/volto-slate/build/messages/src/elementEditor/messages.json +1 -1
  48. package/packages/volto-slate/build/messages/src/widgets/HtmlSlateWidget.json +1 -1
  49. package/packages/volto-slate/build/messages/src/widgets/RichTextWidgetView.json +1 -1
  50. package/packages/volto-slate/package.json +1 -1
  51. package/packages/volto-slate/src/actions/index.js +1 -1
  52. package/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx +21 -212
  53. package/packages/volto-slate/src/blocks/Table/schema.js +122 -0
  54. package/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +8 -3
  55. package/packages/volto-slate/src/blocks/Text/SlashMenu.jsx +4 -3
  56. package/packages/volto-slate/src/blocks/Text/TextBlockView.jsx +20 -16
  57. package/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js +3 -1
  58. package/packages/volto-slate/src/blocks/Text/index.js +10 -2
  59. package/packages/volto-slate/src/editor/config.jsx +5 -4
  60. package/packages/volto-slate/src/editor/deserialize.js +0 -1
  61. package/packages/volto-slate/src/editor/index.js +4 -4
  62. package/packages/volto-slate/src/editor/less/slate.less +28 -0
  63. package/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx +14 -4
  64. package/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js +14 -5
  65. package/packages/volto-slate/src/editor/render.jsx +68 -8
  66. package/packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx +2 -2
  67. package/packages/volto-slate/src/editor/ui/index.js +15 -15
  68. package/packages/volto-slate/src/index.js +2 -2
  69. package/packages/volto-slate/src/utils/blocks.js +7 -0
  70. package/packages/volto-slate/src/widgets/RichTextWidget.jsx +15 -8
  71. package/razzle.config.js +28 -0
  72. package/src/actions/index.js +6 -0
  73. package/src/actions/language/language.js +9 -8
  74. package/src/actions/querystringsearch/querystringsearch.js +20 -14
  75. package/src/actions/relations/rebuild.js +25 -0
  76. package/src/actions/relations/relations.js +86 -0
  77. package/src/actions/relations/relations.test.js +15 -0
  78. package/src/components/index.js +2 -0
  79. package/src/components/manage/Add/Add.jsx +2 -2
  80. package/src/components/manage/AnchorPlugin/index.jsx +2 -2
  81. package/src/components/manage/AnchorPlugin/utils/EditorUtils.js +3 -1
  82. package/src/components/manage/BlockChooser/BlockChooser.jsx +14 -5
  83. package/src/components/manage/BlockChooser/BlockChooser.test.jsx +5 -0
  84. package/src/components/manage/Blocks/Block/BlocksForm.jsx +19 -2
  85. package/src/components/manage/Blocks/Block/Edit.jsx +1 -1
  86. package/src/components/manage/Blocks/Block/Style.jsx +2 -2
  87. package/src/components/manage/Blocks/Container/Data.jsx +32 -0
  88. package/src/components/manage/Blocks/Container/Edit.jsx +174 -0
  89. package/src/components/manage/Blocks/Container/EditBlockWrapper.jsx +120 -0
  90. package/src/components/manage/Blocks/Container/NewBlockAddButton.jsx +84 -0
  91. package/src/components/manage/Blocks/Container/SimpleContainerToolbar.jsx +54 -0
  92. package/src/components/manage/Blocks/Grid/Edit.jsx +33 -0
  93. package/src/components/manage/Blocks/Grid/View.jsx +43 -0
  94. package/src/components/manage/Blocks/Grid/adapter.js +14 -0
  95. package/src/components/manage/Blocks/Grid/grid-1.svg +6 -0
  96. package/src/components/manage/Blocks/Grid/grid-2.svg +9 -0
  97. package/src/components/manage/Blocks/Grid/grid-3.svg +10 -0
  98. package/src/components/manage/Blocks/Grid/grid-4.svg +11 -0
  99. package/src/components/manage/Blocks/Grid/schema.js +35 -0
  100. package/src/components/manage/Blocks/Grid/templates.js +47 -0
  101. package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +6 -1
  102. package/src/components/manage/Blocks/Image/Edit.jsx +11 -7
  103. package/src/components/manage/Blocks/Image/ImageSidebar.jsx +2 -1
  104. package/src/components/manage/Blocks/Image/schema.js +11 -0
  105. package/src/components/manage/Blocks/Listing/DefaultTemplate.jsx +18 -3
  106. package/src/components/manage/Blocks/Listing/Edit.jsx +0 -14
  107. package/src/components/manage/Blocks/Listing/ListingBody.jsx +30 -8
  108. package/src/components/manage/Blocks/Listing/ListingBody.test.jsx +20 -0
  109. package/src/components/manage/Blocks/Listing/getAsyncData.js +9 -3
  110. package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +26 -18
  111. package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +5 -4
  112. package/src/components/manage/Blocks/Search/SearchBlockView.jsx +2 -1
  113. package/src/components/manage/Blocks/Search/components/DateRangeFacet.jsx +4 -1
  114. package/src/components/manage/Blocks/Search/components/Facets.jsx +64 -4
  115. package/src/components/manage/Blocks/Search/components/SearchInput.jsx +9 -2
  116. package/src/components/manage/Blocks/Search/components/index.js +13 -13
  117. package/src/components/manage/Blocks/Search/hocs/index.js +2 -2
  118. package/src/components/manage/Blocks/Search/hocs/withQueryString.jsx +2 -2
  119. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +43 -15
  120. package/src/components/manage/Blocks/Search/layout/LeftColumnFacets.jsx +17 -5
  121. package/src/components/manage/Blocks/Search/layout/RightColumnFacets.jsx +17 -5
  122. package/src/components/manage/Blocks/Search/layout/TopSideFacets.jsx +21 -5
  123. package/src/components/manage/Blocks/Search/schema.js +16 -1
  124. package/src/components/manage/Blocks/Teaser/Body.jsx +0 -1
  125. package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +20 -15
  126. package/src/components/manage/Blocks/Teaser/schema.js +5 -0
  127. package/src/components/manage/Blocks/Title/View.jsx +15 -5
  128. package/src/components/manage/Blocks/Title/View.test.jsx +16 -1
  129. package/src/components/manage/Blocks/ToC/Schema.jsx +5 -1
  130. package/src/components/manage/Blocks/ToC/View.jsx +8 -1
  131. package/src/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +17 -4
  132. package/src/components/manage/Blocks/ToC/variations/HorizontalMenu.jsx +148 -10
  133. package/src/components/manage/Blocks/ToC/variations/index.js +3 -1
  134. package/src/components/manage/Contents/Contents.jsx +39 -26
  135. package/src/components/manage/Contents/ContentsItem.jsx +6 -0
  136. package/src/components/manage/Contents/ContentsUploadModal.jsx +10 -5
  137. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +3 -3
  138. package/src/components/manage/Controlpanels/Controlpanels.jsx +199 -224
  139. package/src/components/manage/Controlpanels/Controlpanels.test.jsx +46 -7
  140. package/src/components/manage/Controlpanels/Relations/BrokenRelations.jsx +66 -0
  141. package/src/components/manage/Controlpanels/Relations/Relations.jsx +114 -0
  142. package/src/components/manage/Controlpanels/Relations/RelationsListing.jsx +479 -0
  143. package/src/components/manage/Controlpanels/Relations/RelationsMatrix.jsx +531 -0
  144. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +3 -3
  145. package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +51 -82
  146. package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +79 -75
  147. package/src/components/manage/DragDropList/DragDropList.jsx +18 -13
  148. package/src/components/manage/Form/Form.jsx +5 -3
  149. package/src/components/manage/Form/InlineForm.jsx +39 -9
  150. package/src/components/manage/Form/InlineFormState.js +8 -0
  151. package/src/components/manage/History/History.jsx +11 -1
  152. package/src/components/manage/LinksToItem/LinksToItem.jsx +209 -0
  153. package/src/components/manage/LinksToItem/LinksToItem.test.jsx +97 -0
  154. package/src/components/manage/Multilingual/CreateTranslation.jsx +2 -2
  155. package/src/components/manage/Multilingual/TranslationObject.jsx +4 -3
  156. package/src/components/manage/Preferences/ChangePassword.jsx +2 -2
  157. package/src/components/manage/Preferences/PersonalPreferences.jsx +2 -2
  158. package/src/components/manage/Sharing/Sharing.jsx +5 -1
  159. package/src/components/manage/TemplateChooser/TemplateChooser.jsx +38 -0
  160. package/src/components/manage/TemplateChooser/TemplateChooser.test.jsx +34 -0
  161. package/src/components/manage/TemplateChooser/template.svg +10 -0
  162. package/src/components/manage/Toast/Toast.jsx +2 -2
  163. package/src/components/manage/Toolbar/More.jsx +15 -0
  164. package/src/components/manage/Toolbar/Types.jsx +2 -2
  165. package/src/components/manage/UniversalLink/UniversalLink.jsx +2 -6
  166. package/src/components/manage/UniversalLink/UniversalLink.test.jsx +36 -0
  167. package/src/components/manage/Widgets/ColorPickerWidget.jsx +6 -1
  168. package/src/components/manage/Widgets/DatetimeWidget.jsx +9 -5
  169. package/src/components/manage/Widgets/FileWidget.jsx +2 -1
  170. package/src/components/manage/Widgets/ObjectListWidget.jsx +3 -8
  171. package/src/components/manage/Widgets/RecurrenceWidget/ByDayField.jsx +2 -1
  172. package/src/components/manage/Widgets/RecurrenceWidget/MonthOfTheYearField.jsx +2 -1
  173. package/src/components/manage/Widgets/RecurrenceWidget/Occurences.jsx +2 -1
  174. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +8 -3
  175. package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthField.jsx +2 -1
  176. package/src/components/manage/Widgets/SelectUtils.js +1 -1
  177. package/src/components/manage/Widgets/SelectWidget.jsx +1 -1
  178. package/src/components/theme/Anontools/Anontools.jsx +44 -72
  179. package/src/components/theme/Anontools/Anontools.stories.jsx +16 -6
  180. package/src/components/theme/Anontools/Anontools.test.jsx +16 -2
  181. package/src/components/theme/Breadcrumbs/Breadcrumbs.jsx +52 -99
  182. package/src/components/theme/Breadcrumbs/Breadcrumbs.stories.jsx +14 -13
  183. package/src/components/theme/Comments/CommentEditModal.jsx +63 -115
  184. package/src/components/theme/Component/Component.jsx +1 -1
  185. package/src/components/theme/ContactForm/ContactForm.jsx +108 -192
  186. package/src/components/theme/ContactForm/ContactForm.stories.jsx +1 -1
  187. package/src/components/theme/ContactForm/ContactForm.test.jsx +2 -3
  188. package/src/components/theme/Footer/Footer.jsx +2 -13
  189. package/src/components/theme/Header/Header.jsx +37 -63
  190. package/src/components/theme/Header/Header.test.jsx +18 -0
  191. package/src/components/theme/Icon/Icon.jsx +2 -2
  192. package/src/components/theme/LanguageSelector/LanguageSelector.js +8 -3
  193. package/src/components/theme/Login/Login.jsx +1 -0
  194. package/src/components/theme/Logo/Logo.jsx +2 -1
  195. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +2 -2
  196. package/src/components/theme/Navigation/NavItem.jsx +4 -2
  197. package/src/components/theme/NotFound/NotFound.jsx +55 -41
  198. package/src/components/theme/PasswordReset/PasswordReset.jsx +7 -4
  199. package/src/components/theme/PasswordReset/RequestPasswordReset.jsx +1 -1
  200. package/src/components/theme/SearchWidget/SearchWidget.jsx +38 -98
  201. package/src/components/theme/Sitemap/Sitemap.jsx +5 -3
  202. package/src/components/theme/View/AlbumView.jsx +9 -1
  203. package/src/components/theme/View/DefaultView.jsx +1 -1
  204. package/src/components/theme/View/EventDatesInfo.jsx +2 -1
  205. package/src/components/theme/View/EventView.jsx +6 -2
  206. package/src/components/theme/View/FileView.jsx +23 -18
  207. package/src/components/theme/View/ImageView.jsx +37 -32
  208. package/src/components/theme/View/LinkView.jsx +53 -78
  209. package/src/components/theme/View/ListingView.jsx +33 -27
  210. package/src/components/theme/View/NewsItemView.jsx +10 -5
  211. package/src/components/theme/View/RenderBlocks.jsx +56 -21
  212. package/src/components/theme/View/RenderEmptyBlock.jsx +5 -0
  213. package/src/components/theme/View/SummaryView.jsx +47 -38
  214. package/src/components/theme/View/TabularView.jsx +59 -53
  215. package/src/components/theme/Widgets/DateWidget.jsx +2 -1
  216. package/src/components/theme/Widgets/DatetimeWidget.jsx +2 -1
  217. package/src/components/theme/Widgets/RelationsWidget.jsx +13 -11
  218. package/src/config/Blocks.jsx +44 -0
  219. package/src/config/ControlPanels.js +2 -0
  220. package/src/config/NonContentRoutes.jsx +1 -0
  221. package/src/config/RichTextEditor/Blocks.jsx +2 -2
  222. package/src/config/RichTextEditor/FromHTML.jsx +2 -2
  223. package/src/config/RichTextEditor/Styles.jsx +1 -1
  224. package/src/config/Widgets.jsx +2 -0
  225. package/src/config/index.js +24 -0
  226. package/src/config/server.js +2 -0
  227. package/src/constants/ActionTypes.js +4 -0
  228. package/src/constants/Indexes.js +3 -1
  229. package/src/constants/Languages.js +8 -4
  230. package/src/express-middleware/devproxy.js +1 -1
  231. package/src/express-middleware/files.js +3 -3
  232. package/src/express-middleware/images.js +4 -4
  233. package/src/express-middleware/ok.js +16 -0
  234. package/src/express-middleware/robotstxt.js +1 -1
  235. package/src/express-middleware/sitemap.js +37 -5
  236. package/src/express-middleware/static.js +3 -3
  237. package/src/helpers/Api/Api.js +1 -1
  238. package/src/helpers/Blocks/Blocks.js +48 -0
  239. package/src/helpers/Blocks/Blocks.test.js +79 -0
  240. package/src/helpers/Extensions/index.js +2 -1
  241. package/src/helpers/Extensions/withBlockSchemaEnhancer.js +15 -11
  242. package/src/helpers/Extensions/withBlockSchemaEnhancer.test.js +145 -0
  243. package/src/helpers/FormValidation/FormValidation.js +40 -2
  244. package/src/helpers/FormValidation/FormValidation.test.js +73 -0
  245. package/src/helpers/Html/Html.jsx +3 -1
  246. package/src/helpers/Html/Html.test.jsx +5 -0
  247. package/src/helpers/MessageLabels/MessageLabels.js +80 -0
  248. package/src/helpers/Robots/Robots.js +24 -6
  249. package/src/helpers/ScrollToTop/ScrollToTop.jsx +5 -3
  250. package/src/helpers/Sitemap/Sitemap.js +44 -2
  251. package/src/helpers/Url/Url.js +27 -6
  252. package/src/helpers/Url/Url.test.js +26 -0
  253. package/src/helpers/Utils/UseDetectClickOutside.stories.jsx +191 -0
  254. package/src/helpers/Utils/Utils.js +63 -13
  255. package/src/helpers/Utils/Utils.test.js +4 -4
  256. package/src/helpers/Utils/usePagination.js +67 -14
  257. package/src/helpers/Utils/usePagination.test.js +115 -0
  258. package/src/helpers/index.js +20 -10
  259. package/src/hooks/client/useClient.js +11 -0
  260. package/src/hooks/clipboard/useClipboard.js +26 -0
  261. package/src/hooks/index.js +2 -0
  262. package/src/icons/grid-block.svg +11 -0
  263. package/src/middleware/Api.test.js +54 -0
  264. package/src/middleware/api.js +24 -6
  265. package/src/middleware/index.js +2 -2
  266. package/src/reducers/actions/actions.js +8 -6
  267. package/src/reducers/actions/actions.test.js +70 -0
  268. package/src/reducers/breadcrumbs/breadcrumbs.js +1 -1
  269. package/src/reducers/index.js +2 -0
  270. package/src/reducers/navigation/navigation.js +1 -1
  271. package/src/reducers/relations/relations.js +173 -0
  272. package/src/reducers/types/types.js +1 -1
  273. package/src/routes.js +14 -0
  274. package/src/server.jsx +28 -23
  275. package/src/start-server.js +2 -2
  276. package/test-setup-config.js +2 -0
  277. package/theme/themes/pastanaga/extras/blocks.less +3 -1
  278. package/theme/themes/pastanaga/extras/contents.less +1 -0
  279. package/theme/themes/pastanaga/extras/grid.less +426 -0
  280. package/theme/themes/pastanaga/extras/main.less +3 -1
  281. package/theme/themes/pastanaga/extras/search.less +6 -0
  282. package/theme/themes/pastanaga/extras/sidebar.less +4 -0
  283. package/theme/themes/pastanaga/extras/toc.less +29 -0
  284. package/theme/themes/pastanaga/extras/userscontrolpanel.less +99 -76
  285. package/.changelog.draft +0 -31
  286. package/.editorconfig +0 -36
  287. package/.storybook/main.js +0 -127
  288. package/.storybook/manager.js +0 -15
  289. package/.storybook/preview.js +0 -21
  290. package/.storybook/static/previewImage.svg +0 -48
  291. package/.yarnrc.yml +0 -5
  292. package/jsdoc.json +0 -16
  293. package/netlify.toml +0 -5
  294. package/pyvenv.cfg +0 -3
  295. package/share/man/man1/ttx.1 +0 -225
  296. package/src/components/theme/Header/Header.md +0 -27
  297. package/towncrier.toml +0 -33
@@ -3,16 +3,16 @@
3
3
  * @module components/manage/Controlpanels/Controlpanels
4
4
  */
5
5
 
6
- import React, { Component } from 'react';
7
6
  import PropTypes from 'prop-types';
7
+ import { useState, useEffect } from 'react';
8
8
  import { connect } from 'react-redux';
9
9
  import { compose } from 'redux';
10
10
  import { Link } from 'react-router-dom';
11
11
  import { concat, filter, last, map, uniqBy } from 'lodash';
12
12
  import { Portal } from 'react-portal';
13
- import { Helmet } from '@plone/volto/helpers';
13
+ import { asyncConnect, Helmet } from '@plone/volto/helpers';
14
14
  import { Container, Grid, Header, Message, Segment } from 'semantic-ui-react';
15
- import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
15
+ import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
16
16
 
17
17
  import { listControlpanels, getSystemInformation } from '@plone/volto/actions';
18
18
  import { Error, Icon, Toolbar, VersionOverview } from '@plone/volto/components';
@@ -90,189 +90,139 @@ const messages = defineMessages({
90
90
  id: 'Content Rules',
91
91
  defaultMessage: 'Content Rules',
92
92
  },
93
+ relations: {
94
+ id: 'Relations',
95
+ defaultMessage: 'Relations',
96
+ },
93
97
  });
94
98
 
95
99
  /**
96
100
  * Controlpanels container class.
97
- * @class Controlpanels
98
- * @extends Component
99
101
  */
100
- class Controlpanels extends Component {
101
- /**
102
- * Property types.
103
- * @property {Object} propTypes Property types.
104
- * @static
105
- */
106
- static propTypes = {
107
- listControlpanels: PropTypes.func.isRequired,
108
- controlpanels: PropTypes.arrayOf(
109
- PropTypes.shape({
110
- '@id': PropTypes.string,
111
- group: PropTypes.string,
112
- title: PropTypes.string,
113
- }),
114
- ).isRequired,
115
- pathname: PropTypes.string.isRequired,
116
- };
102
+ function Controlpanels({
103
+ controlpanels,
104
+ controlpanelsRequest,
105
+ systemInformation,
106
+ pathname,
107
+ }) {
108
+ const intl = useIntl();
109
+ const [isClient, setIsClient] = useState(false);
117
110
 
118
- /**
119
- * Constructor
120
- * @method constructor
121
- * @param {Object} props Component properties
122
- * @constructs EditComponent
123
- */
124
- constructor(props) {
125
- super(props);
126
- this.state = {
127
- error: null,
128
- isClient: false,
129
- };
130
- }
111
+ useEffect(() => {
112
+ setIsClient(true);
113
+ }, []);
131
114
 
132
- /**
133
- * Component did mount
134
- * @method componentDidMount
135
- * @returns {undefined}
136
- */
137
- componentDidMount() {
138
- this.props.listControlpanels();
139
- this.props.getSystemInformation();
140
- this.setState({ isClient: true });
141
- }
115
+ const error = controlpanelsRequest?.error;
142
116
 
143
- UNSAFE_componentWillReceiveProps(nextProps) {
144
- // Error
145
- if (
146
- this.props.controlpanelsRequest.loading &&
147
- nextProps.controlpanelsRequest.error
148
- ) {
149
- this.setState({
150
- error: nextProps.controlpanelsRequest.error,
151
- });
152
- }
117
+ if (error) {
118
+ return <Error error={error} />;
153
119
  }
154
120
 
155
- /**
156
- * Render method.
157
- * @method render
158
- * @returns {string} Markup for the component.
159
- */
160
- render() {
161
- // Error
162
- if (this.state.error) {
163
- return <Error error={this.state.error} />;
164
- }
121
+ let customcontrolpanels = config.settings.controlpanels
122
+ ? config.settings.controlpanels.map((el) => {
123
+ el.group =
124
+ intl.formatMessage({
125
+ id: el.group,
126
+ defaultMessage: el.group,
127
+ }) || el.group;
128
+ return el;
129
+ })
130
+ : [];
131
+ const { filterControlPanels } = config.settings;
165
132
 
166
- let customcontrolpanels = config.settings.controlpanels
167
- ? config.settings.controlpanels.map((el) => {
168
- el.group =
169
- this.props.intl.formatMessage({
170
- id: el.group,
171
- defaultMessage: el.group,
172
- }) || el.group;
173
- return el;
174
- })
175
- : [];
176
- const { filterControlPanels } = config.settings;
177
- const controlpanels = map(
178
- concat(
179
- filterControlPanels(this.props.controlpanels),
180
- customcontrolpanels,
181
- [
182
- {
183
- '@id': '/addons',
184
- group: this.props.intl.formatMessage(messages.general),
185
- title: this.props.intl.formatMessage(messages.addons),
186
- },
187
- {
188
- '@id': '/database',
189
- group: this.props.intl.formatMessage(messages.general),
190
- title: this.props.intl.formatMessage(messages.database),
191
- },
192
- {
193
- '@id': '/rules',
194
- group: this.props.intl.formatMessage(messages.content),
195
- title: this.props.intl.formatMessage(messages.contentRules),
196
- },
197
- {
198
- '@id': '/undo',
199
- group: this.props.intl.formatMessage(messages.general),
200
- title: this.props.intl.formatMessage(messages.undo),
201
- },
202
- {
203
- '@id': '/aliases',
204
- group: this.props.intl.formatMessage(messages.general),
205
- title: this.props.intl.formatMessage(messages.urlmanagement),
206
- },
207
- {
208
- '@id': '/moderate-comments',
209
- group: this.props.intl.formatMessage(messages.content),
210
- title: this.props.intl.formatMessage(messages.moderatecomments),
211
- },
212
- {
213
- '@id': '/users',
214
- group: this.props.intl.formatMessage(
215
- messages.usersControlPanelCategory,
216
- ),
217
- title: this.props.intl.formatMessage(messages.users),
218
- },
219
- {
220
- '@id': '/usergroupmembership',
221
- group: this.props.intl.formatMessage(
222
- messages.usersControlPanelCategory,
223
- ),
224
- title: this.props.intl.formatMessage(
225
- messages.usergroupmemberbership,
226
- ),
227
- },
228
- {
229
- '@id': '/groups',
230
- group: this.props.intl.formatMessage(
231
- messages.usersControlPanelCategory,
232
- ),
233
- title: this.props.intl.formatMessage(messages.groups),
234
- },
235
- ],
236
- ),
237
- (controlpanel) => ({
238
- ...controlpanel,
239
- id: last(controlpanel['@id'].split('/')),
240
- }),
241
- );
242
- const groups = map(uniqBy(controlpanels, 'group'), 'group');
243
- const { controlPanelsIcons: icons } = config.settings;
133
+ const filteredControlPanels = map(
134
+ concat(filterControlPanels(controlpanels), customcontrolpanels, [
135
+ {
136
+ '@id': '/addons',
137
+ group: intl.formatMessage(messages.general),
138
+ title: intl.formatMessage(messages.addons),
139
+ },
140
+ {
141
+ '@id': '/database',
142
+ group: intl.formatMessage(messages.general),
143
+ title: intl.formatMessage(messages.database),
144
+ },
145
+ {
146
+ '@id': '/rules',
147
+ group: intl.formatMessage(messages.content),
148
+ title: intl.formatMessage(messages.contentRules),
149
+ },
150
+ {
151
+ '@id': '/undo',
152
+ group: intl.formatMessage(messages.general),
153
+ title: intl.formatMessage(messages.undo),
154
+ },
155
+ {
156
+ '@id': '/aliases',
157
+ group: intl.formatMessage(messages.general),
158
+ title: intl.formatMessage(messages.urlmanagement),
159
+ },
160
+ {
161
+ '@id': '/relations',
162
+ group: intl.formatMessage(messages.content),
163
+ title: intl.formatMessage(messages.relations),
164
+ },
165
+ {
166
+ '@id': '/moderate-comments',
167
+ group: intl.formatMessage(messages.content),
168
+ title: intl.formatMessage(messages.moderatecomments),
169
+ },
170
+ {
171
+ '@id': '/users',
172
+ group: intl.formatMessage(messages.usersControlPanelCategory),
173
+ title: intl.formatMessage(messages.users),
174
+ },
175
+ {
176
+ '@id': '/usergroupmembership',
177
+ group: intl.formatMessage(messages.usersControlPanelCategory),
178
+ title: intl.formatMessage(messages.usergroupmemberbership),
179
+ },
180
+ {
181
+ '@id': '/groups',
182
+ group: intl.formatMessage(messages.usersControlPanelCategory),
183
+ title: intl.formatMessage(messages.groups),
184
+ },
185
+ ]),
186
+ (controlpanel) => ({
187
+ ...controlpanel,
188
+ id: last(controlpanel['@id'].split('/')),
189
+ }),
190
+ );
191
+ const groups = map(uniqBy(filteredControlPanels, 'group'), 'group');
192
+ const { controlPanelsIcons: icons } = config.settings;
244
193
 
245
- return (
246
- <div className="view-wrapper">
247
- <Helmet title={this.props.intl.formatMessage(messages.sitesetup)} />
248
- <Container className="controlpanel">
249
- <Segment.Group raised>
250
- <Segment className="primary">
251
- <FormattedMessage id="Site Setup" defaultMessage="Site Setup" />
252
- </Segment>
253
- {this.props.systemInformation &&
254
- this.props.systemInformation.upgrade && (
255
- <Message attached warning>
256
- <FormattedMessage
257
- id="The site configuration is outdated and needs to be upgraded."
258
- defaultMessage="The site configuration is outdated and needs to be upgraded."
259
- />{' '}
260
- <Link to={`/controlpanel/plone-upgrade`}>
261
- <FormattedMessage
262
- id="Please continue with the upgrade."
263
- defaultMessage="Please continue with the upgrade."
264
- />
265
- </Link>
266
- </Message>
267
- )}
268
- {map(groups, (group) => [
269
- <Segment key={`header-${group}`} secondary>
270
- {group}
271
- </Segment>,
272
- <Segment key={`body-${group}`} attached>
273
- <Grid doubling columns={6}>
274
- <Grid.Row>
275
- {map(filter(controlpanels, { group }), (controlpanel) => (
194
+ return (
195
+ <div className="view-wrapper">
196
+ <Helmet title={intl.formatMessage(messages.sitesetup)} />
197
+ <Container className="controlpanel">
198
+ <Segment.Group raised>
199
+ <Segment className="primary">
200
+ <FormattedMessage id="Site Setup" defaultMessage="Site Setup" />
201
+ </Segment>
202
+ {systemInformation && systemInformation.upgrade && (
203
+ <Message attached warning>
204
+ <FormattedMessage
205
+ id="The site configuration is outdated and needs to be upgraded."
206
+ defaultMessage="The site configuration is outdated and needs to be upgraded."
207
+ />{' '}
208
+ <Link to={`/controlpanel/plone-upgrade`}>
209
+ <FormattedMessage
210
+ id="Please continue with the upgrade."
211
+ defaultMessage="Please continue with the upgrade."
212
+ />
213
+ </Link>
214
+ </Message>
215
+ )}
216
+ {map(groups, (group) => [
217
+ <Segment key={`header-${group}`} secondary>
218
+ {group}
219
+ </Segment>,
220
+ <Segment key={`body-${group}`} attached>
221
+ <Grid doubling columns={6}>
222
+ <Grid.Row>
223
+ {map(
224
+ filter(filteredControlPanels, { group }),
225
+ (controlpanel) => (
276
226
  <Grid.Column key={controlpanel.id}>
277
227
  <Link to={`/controlpanel/${controlpanel.id}`}>
278
228
  <Header as="h3" icon textAlign="center">
@@ -286,58 +236,83 @@ class Controlpanels extends Component {
286
236
  </Header>
287
237
  </Link>
288
238
  </Grid.Column>
289
- ))}
290
- </Grid.Row>
291
- </Grid>
292
- </Segment>,
293
- ])}
294
- </Segment.Group>
295
- <Segment.Group raised>
296
- <Segment className="primary">
297
- <FormattedMessage
298
- id="Version Overview"
299
- defaultMessage="Version Overview"
300
- />
301
- </Segment>
302
- <Segment attached>
303
- {this.props.systemInformation ? (
304
- <VersionOverview {...this.props.systemInformation} />
305
- ) : null}
306
- </Segment>
307
- </Segment.Group>
308
- </Container>
309
- {this.state.isClient && (
310
- <Portal node={document.getElementById('toolbar')}>
311
- <Toolbar
312
- pathname={this.props.pathname}
313
- hideDefaultViewButtons
314
- inner={
315
- <Link to="/" className="item">
316
- <Icon
317
- name={backSVG}
318
- className="contents circled"
319
- size="30px"
320
- title={this.props.intl.formatMessage(messages.back)}
321
- />
322
- </Link>
323
- }
239
+ ),
240
+ )}
241
+ </Grid.Row>
242
+ </Grid>
243
+ </Segment>,
244
+ ])}
245
+ </Segment.Group>
246
+ <Segment.Group raised>
247
+ <Segment className="primary">
248
+ <FormattedMessage
249
+ id="Version Overview"
250
+ defaultMessage="Version Overview"
324
251
  />
325
- </Portal>
326
- )}
327
- </div>
328
- );
329
- }
252
+ </Segment>
253
+ <Segment attached>
254
+ {systemInformation ? (
255
+ <VersionOverview {...systemInformation} />
256
+ ) : null}
257
+ </Segment>
258
+ </Segment.Group>
259
+ </Container>
260
+ {isClient && (
261
+ <Portal node={document.getElementById('toolbar')}>
262
+ <Toolbar
263
+ pathname={pathname}
264
+ hideDefaultViewButtons
265
+ inner={
266
+ <Link to="/" className="item">
267
+ <Icon
268
+ name={backSVG}
269
+ className="contents circled"
270
+ size="30px"
271
+ title={intl.formatMessage(messages.back)}
272
+ />
273
+ </Link>
274
+ }
275
+ />
276
+ </Portal>
277
+ )}
278
+ </div>
279
+ );
330
280
  }
331
281
 
332
- export default compose(
333
- injectIntl,
334
- connect(
335
- (state, props) => ({
336
- controlpanels: state.controlpanels.controlpanels,
337
- controlpanelsRequest: state.controlpanels.list,
338
- pathname: props.location.pathname,
339
- systemInformation: state.controlpanels.systeminformation,
282
+ /**
283
+ * Property types.
284
+ * @property {Object} propTypes Property types.
285
+ * @static
286
+ */
287
+ Controlpanels.propTypes = {
288
+ controlpanels: PropTypes.arrayOf(
289
+ PropTypes.shape({
290
+ '@id': PropTypes.string,
291
+ group: PropTypes.string,
292
+ title: PropTypes.string,
340
293
  }),
341
- { listControlpanels, getSystemInformation },
342
- ),
294
+ ).isRequired,
295
+ pathname: PropTypes.string.isRequired,
296
+ };
297
+
298
+ export default compose(
299
+ connect((state, props) => ({
300
+ controlpanels: state.controlpanels.controlpanels,
301
+ controlpanelsRequest: state.controlpanels.list,
302
+ pathname: props.location.pathname,
303
+ systemInformation: state.controlpanels.systeminformation,
304
+ })),
305
+
306
+ asyncConnect([
307
+ {
308
+ key: 'controlpanels',
309
+ promise: async ({ location, store: { dispatch } }) =>
310
+ await dispatch(listControlpanels()),
311
+ },
312
+ {
313
+ key: 'systemInformation',
314
+ promise: async ({ location, store: { dispatch } }) =>
315
+ await dispatch(getSystemInformation()),
316
+ },
317
+ ]),
343
318
  )(Controlpanels);
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import renderer from 'react-test-renderer';
3
- import configureStore from 'redux-mock-store';
4
2
  import { Provider } from 'react-intl-redux';
5
3
  import { MemoryRouter } from 'react-router-dom';
4
+ import renderer from 'react-test-renderer';
5
+ import configureStore from 'redux-mock-store';
6
6
 
7
- import Controlpanels from './Controlpanels';
8
7
  import config from '@plone/volto/registry';
8
+ import Controlpanels from './Controlpanels';
9
9
 
10
10
  const mockStore = configureStore();
11
11
 
@@ -20,7 +20,30 @@ jest.mock('./VersionOverview', () =>
20
20
  describe('Controlpanels', () => {
21
21
  it('renders a controlpanels component', () => {
22
22
  const store = mockStore({
23
- controlpanels: {
23
+ controlpanels: [
24
+ {
25
+ '@id': 'http://localhost:8080/Plone/@controlpanels/date-and-time',
26
+ group: 'General',
27
+ title: 'Date and Time',
28
+ },
29
+ {
30
+ '@id': 'http://localhost:8080/Plone/@controlpanels/lang',
31
+ group: 'General',
32
+ title: 'Language',
33
+ },
34
+ {
35
+ '@id': 'http://localhost:8080/Plone/@controlpanels/editing',
36
+ group: 'Content',
37
+ title: 'Editing',
38
+ },
39
+ {
40
+ '@id': 'http://localhost:8080/Plone/@controlpanels/security',
41
+ group: 'Security',
42
+ title: 'test',
43
+ },
44
+ ],
45
+ reduxAsyncConnect: {
46
+ // Mocked in redux async connect as it isn't fetch client-side.
24
47
  controlpanels: [
25
48
  {
26
49
  '@id': 'http://localhost:8080/Plone/@controlpanels/date-and-time',
@@ -40,10 +63,11 @@ describe('Controlpanels', () => {
40
63
  {
41
64
  '@id': 'http://localhost:8080/Plone/@controlpanels/security',
42
65
  group: 'Security',
43
- title: 'Security',
66
+ title: 'test',
44
67
  },
45
68
  ],
46
69
  },
70
+ router: { location: '/blog' },
47
71
  intl: {
48
72
  locale: 'en',
49
73
  messages: {},
@@ -62,9 +86,24 @@ describe('Controlpanels', () => {
62
86
 
63
87
  it('renders an additional control panel', () => {
64
88
  const store = mockStore({
65
- controlpanels: {
66
- controlpanels: [],
89
+ controlpanels: [
90
+ {
91
+ '@id': 'http://localhost:8080/Plone/@controlpanels/security',
92
+ group: 'Security',
93
+ title: 'test',
94
+ },
95
+ ],
96
+ reduxAsyncConnect: {
97
+ // Mocked in redux async connect as it isn't fetch client-side.
98
+ controlpanels: [
99
+ {
100
+ '@id': 'http://localhost:8080/Plone/@controlpanels/security',
101
+ group: 'Security',
102
+ title: 'test',
103
+ },
104
+ ],
67
105
  },
106
+ router: { location: '/blog' },
68
107
  intl: {
69
108
  locale: 'en',
70
109
  messages: {},
@@ -0,0 +1,66 @@
1
+ import React, { useEffect } from 'react';
2
+ import { uniqBy } from 'lodash';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { useSelector, useDispatch } from 'react-redux';
5
+ import { Divider, Segment, Table } from 'semantic-ui-react';
6
+ import { queryRelations } from '@plone/volto/actions';
7
+ import { flattenToAppURL } from '@plone/volto/helpers';
8
+ import { UniversalLink } from '@plone/volto/components';
9
+
10
+ const BrokenRelations = () => {
11
+ const dispatch = useDispatch();
12
+ const brokenRelationStats = useSelector(
13
+ (state) => state.relations?.stats?.broken || {},
14
+ );
15
+ const brokenRelations = useSelector(
16
+ (state) => state.relations?.subrequests?.broken?.relations,
17
+ );
18
+
19
+ useEffect(() => {
20
+ dispatch(queryRelations(null, true, 'broken'));
21
+ }, [dispatch]);
22
+
23
+ return brokenRelations && Object.keys(brokenRelations).length > 0 ? (
24
+ <>
25
+ <Divider section hidden />
26
+ <Segment>
27
+ <h3>
28
+ <FormattedMessage
29
+ id="Broken relations"
30
+ defaultMessage="Broken relations"
31
+ />
32
+ </h3>
33
+ {Object.keys(brokenRelations).map((relationname) => (
34
+ <div key={relationname}>
35
+ <Divider section hidden />
36
+ <h4>
37
+ {brokenRelationStats[relationname]} broken <i>{relationname}</i>{' '}
38
+ relations
39
+ </h4>
40
+ <Table>
41
+ <Table.Body>
42
+ {uniqBy(brokenRelations[relationname].items, function (el) {
43
+ return el[0];
44
+ }).map((el) => (
45
+ <Table.Row key={el[0]}>
46
+ <Table.Cell>
47
+ <UniversalLink
48
+ href={`${flattenToAppURL(el[0])}/edit`}
49
+ openLinkInNewTab={true}
50
+ >
51
+ {flattenToAppURL(el[0])}
52
+ </UniversalLink>
53
+ </Table.Cell>
54
+ <Table.Cell>{el[1]}</Table.Cell>
55
+ </Table.Row>
56
+ ))}
57
+ </Table.Body>
58
+ </Table>
59
+ </div>
60
+ ))}
61
+ </Segment>
62
+ </>
63
+ ) : null;
64
+ };
65
+
66
+ export default BrokenRelations;