@plone/volto 18.0.0-alpha.42 → 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 (137) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/finalreleasechangelog.py +48 -0
  3. package/locales/ca/LC_MESSAGES/volto.po +8 -12
  4. package/locales/ca.json +1 -1
  5. package/locales/de/LC_MESSAGES/volto.po +9 -13
  6. package/locales/de.json +1 -1
  7. package/locales/en/LC_MESSAGES/volto.po +8 -12
  8. package/locales/en.json +1 -1
  9. package/locales/es/LC_MESSAGES/volto.po +9 -13
  10. package/locales/es.json +1 -1
  11. package/locales/eu/LC_MESSAGES/volto.po +9 -13
  12. package/locales/eu.json +1 -1
  13. package/locales/fi/LC_MESSAGES/volto.po +9 -13
  14. package/locales/fi.json +1 -1
  15. package/locales/fr/LC_MESSAGES/volto.po +9 -13
  16. package/locales/fr.json +1 -1
  17. package/locales/hi/LC_MESSAGES/volto.po +9 -13
  18. package/locales/hi.json +1 -1
  19. package/locales/it/LC_MESSAGES/volto.po +9 -13
  20. package/locales/it.json +1 -1
  21. package/locales/ja/LC_MESSAGES/volto.po +8 -12
  22. package/locales/ja.json +1 -1
  23. package/locales/nl/LC_MESSAGES/volto.po +8 -12
  24. package/locales/nl.json +1 -1
  25. package/locales/pt/LC_MESSAGES/volto.po +8 -12
  26. package/locales/pt.json +1 -1
  27. package/locales/pt_BR/LC_MESSAGES/volto.po +9 -13
  28. package/locales/pt_BR.json +1 -1
  29. package/locales/ro/LC_MESSAGES/volto.po +8 -12
  30. package/locales/ro.json +1 -1
  31. package/locales/volto.pot +9 -13
  32. package/locales/zh_CN/LC_MESSAGES/volto.po +9 -13
  33. package/locales/zh_CN.json +1 -1
  34. package/package.json +3 -3
  35. package/razzle.config.js +1 -1
  36. package/src/components/manage/Actions/Actions.stories.jsx +138 -0
  37. package/src/components/manage/Add/Add.jsx +7 -4
  38. package/src/components/manage/BlockChooser/BlockChooser.jsx +9 -1
  39. package/src/components/manage/Blocks/Block/Edit.jsx +24 -8
  40. package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +17 -1
  41. package/src/components/manage/Blocks/Block/Order/Item.jsx +3 -1
  42. package/src/components/manage/Blocks/Grid/View.jsx +3 -0
  43. package/src/components/manage/Blocks/LeadImage/Edit.jsx +74 -126
  44. package/src/components/manage/Blocks/Search/components/SortOn.jsx +82 -55
  45. package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +107 -176
  46. package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +15 -8
  47. package/src/components/manage/Blocks/ToC/Edit.jsx +36 -29
  48. package/src/components/manage/Blocks/Video/Edit.jsx +105 -172
  49. package/src/components/manage/Blocks/Video/Edit.stories.jsx +57 -0
  50. package/src/components/manage/Contents/Contents.jsx +3 -0
  51. package/src/components/manage/Contents/ContentsBreadcrumbs.stories.jsx +46 -0
  52. package/src/components/manage/Contents/ContentsPropertiesModal.jsx +85 -52
  53. package/src/components/manage/Contents/ContentsUploadModal.jsx +230 -323
  54. package/src/components/manage/Contents/ContentsUploadModal.stories.jsx +56 -0
  55. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +323 -441
  56. package/src/components/manage/Controlpanels/Aliases.jsx +452 -580
  57. package/src/components/manage/Controlpanels/Aliases.stories.jsx +74 -0
  58. package/src/components/manage/Controlpanels/Controlpanel.jsx +41 -2
  59. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +55 -24
  60. package/src/components/manage/Controlpanels/DatabaseInformation.jsx +162 -229
  61. package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +74 -122
  62. package/src/components/manage/Display/Display.jsx +92 -148
  63. package/src/components/manage/Display/Display.stories.jsx +46 -0
  64. package/src/components/manage/Edit/Edit.jsx +2 -4
  65. package/src/components/manage/Preferences/ChangePassword.jsx +94 -172
  66. package/src/components/manage/Preferences/ChangePassword.stories.jsx +41 -0
  67. package/src/components/manage/Preferences/PersonalInformation.jsx +50 -115
  68. package/src/components/manage/Preferences/PersonalPreferences.jsx +46 -100
  69. package/src/components/manage/Preferences/PersonalPreferences.stories.jsx +48 -0
  70. package/src/components/manage/Toolbar/More.jsx +308 -399
  71. package/src/components/manage/Widgets/DatetimeWidget.jsx +121 -175
  72. package/src/components/manage/Widgets/ReferenceWidget.jsx +134 -210
  73. package/src/components/theme/Register/Register.jsx +70 -142
  74. package/src/components/theme/Register/Register.stories.jsx +49 -0
  75. package/src/components/theme/Tags/Tags.jsx +19 -10
  76. package/src/components/theme/Tags/Tags.test.jsx +9 -11
  77. package/src/components/theme/View/AlbumView.jsx +122 -167
  78. package/src/components/theme/View/LinkView.jsx +4 -0
  79. package/src/components/theme/View/LinkView.test.jsx +2 -0
  80. package/src/components/theme/View/View.jsx +0 -6
  81. package/src/config/ControlPanels.js +49 -43
  82. package/src/config/config.test.js +1 -0
  83. package/src/config/index.js +16 -0
  84. package/src/config/slots.js +12 -0
  85. package/src/helpers/Blocks/Blocks.js +12 -7
  86. package/src/helpers/Blocks/Blocks.test.js +15 -0
  87. package/src/helpers/Blocks/cloneBlocks.ts +1 -1
  88. package/src/helpers/FormValidation/FormValidation.jsx +19 -2
  89. package/src/helpers/FormValidation/validators.ts +1 -1
  90. package/src/helpers/Url/Url.test.js +15 -2
  91. package/src/helpers/Url/urlRegex.js +1 -1
  92. package/src/helpers/index.js +2 -0
  93. package/src/middleware/api.js +4 -2
  94. package/src/middleware/index.js +1 -0
  95. package/src/middleware/userSessionReset.js +46 -0
  96. package/src/store.js +2 -0
  97. package/test-setup-config.jsx +3 -0
  98. package/theme/themes/pastanaga/extras/blocks.less +6 -0
  99. package/types/components/manage/Actions/Actions.stories.d.ts +8 -0
  100. package/types/components/manage/Blocks/LeadImage/Edit.d.ts +14 -5
  101. package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +0 -5
  102. package/types/components/manage/Blocks/ToC/Edit.d.ts +1 -6
  103. package/types/components/manage/Blocks/Video/Edit.d.ts +1 -1
  104. package/types/components/manage/Blocks/Video/Edit.stories.d.ts +8 -0
  105. package/types/components/manage/Contents/ContentsBreadcrumbs.stories.d.ts +8 -0
  106. package/types/components/manage/Contents/ContentsUploadModal.d.ts +14 -2
  107. package/types/components/manage/Contents/ContentsUploadModal.stories.d.ts +8 -0
  108. package/types/components/manage/Contents/index.d.ts +1 -1
  109. package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +2 -2
  110. package/types/components/manage/Controlpanels/Aliases.d.ts +2 -2
  111. package/types/components/manage/Controlpanels/Aliases.stories.d.ts +8 -0
  112. package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +2 -2
  113. package/types/components/manage/Controlpanels/Groups/RenderGroups.d.ts +10 -5
  114. package/types/components/manage/Controlpanels/index.d.ts +4 -4
  115. package/types/components/manage/Display/Display.stories.d.ts +8 -0
  116. package/types/components/manage/Preferences/ChangePassword.d.ts +2 -2
  117. package/types/components/manage/Preferences/ChangePassword.stories.d.ts +8 -0
  118. package/types/components/manage/Preferences/PersonalInformation.d.ts +7 -2
  119. package/types/components/manage/Preferences/PersonalPreferences.d.ts +5 -1
  120. package/types/components/manage/Preferences/PersonalPreferences.stories.d.ts +8 -0
  121. package/types/components/manage/Toolbar/More.d.ts +8 -5
  122. package/types/components/manage/Widgets/DatetimeWidget.d.ts +0 -85
  123. package/types/components/manage/Widgets/DatetimeWidget.stories.d.ts +0 -1
  124. package/types/components/manage/Widgets/ReferenceWidget.d.ts +27 -2
  125. package/types/components/manage/Widgets/index.d.ts +1 -1
  126. package/types/components/theme/Register/Register.d.ts +2 -2
  127. package/types/components/theme/Register/Register.stories.d.ts +9 -0
  128. package/types/components/theme/Tags/Tags.d.ts +15 -7
  129. package/types/components/theme/View/AlbumView.d.ts +3 -17
  130. package/types/config/ControlPanels.d.ts +8 -0
  131. package/types/config/Widgets.d.ts +1 -1
  132. package/types/config/slots.d.ts +21 -0
  133. package/types/helpers/Blocks/Blocks.d.ts +6 -0
  134. package/types/helpers/FormValidation/FormValidation.d.ts +1 -0
  135. package/types/helpers/index.d.ts +2 -2
  136. package/types/middleware/index.d.ts +1 -0
  137. package/types/middleware/userSessionReset.d.ts +5 -0
@@ -1,12 +1,14 @@
1
- import React, { useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useDispatch, useSelector } from 'react-redux';
4
4
  import { isEmpty, map } from 'lodash';
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
6
 
7
7
  import { usePrevious } from '@plone/volto/helpers';
8
+ import { cloneDeepSchema } from '@plone/volto/helpers/Utils/Utils';
8
9
  import { updateContent } from '@plone/volto/actions';
9
10
  import { ModalForm } from '@plone/volto/components/manage/Form';
11
+ import config from '@plone/volto/registry';
10
12
 
11
13
  const messages = defineMessages({
12
14
  properties: {
@@ -65,12 +67,83 @@ const messages = defineMessages({
65
67
  });
66
68
 
67
69
  const ContentsPropertiesModal = (props) => {
68
- const { onCancel, onOk, open, items } = props;
70
+ const { onCancel, onOk, open, items, values } = props;
69
71
  const intl = useIntl();
70
72
  const dispatch = useDispatch();
71
73
  const request = useSelector((state) => state.content.update);
72
74
  const prevrequestloading = usePrevious(request.loading);
73
75
 
76
+ const baseSchema = {
77
+ fieldsets: [
78
+ {
79
+ id: 'default',
80
+ title: intl.formatMessage(messages.default),
81
+ fields: [
82
+ 'effective',
83
+ 'expires',
84
+ 'rights',
85
+ 'creators',
86
+ 'exclude_from_nav',
87
+ ],
88
+ },
89
+ ],
90
+ properties: {
91
+ effective: {
92
+ description: intl.formatMessage(messages.effectiveDescription),
93
+ title: intl.formatMessage(messages.effectiveTitle),
94
+ type: 'string',
95
+ widget: 'datetime',
96
+ },
97
+ expires: {
98
+ description: intl.formatMessage(messages.expiresDescription),
99
+ title: intl.formatMessage(messages.expiresTitle),
100
+ type: 'string',
101
+ widget: 'datetime',
102
+ },
103
+ rights: {
104
+ description: intl.formatMessage(messages.rightsDescription),
105
+ title: intl.formatMessage(messages.rightsTitle),
106
+ type: 'string',
107
+ widget: 'textarea',
108
+ },
109
+ creators: {
110
+ description: intl.formatMessage(messages.creatorsDescription),
111
+ title: intl.formatMessage(messages.creatorsTitle),
112
+ type: 'array',
113
+ },
114
+ exclude_from_nav: {
115
+ description: intl.formatMessage(messages.excludeFromNavDescription),
116
+ title: intl.formatMessage(messages.excludeFromNavTitle),
117
+ type: 'boolean',
118
+ },
119
+ },
120
+ required: [],
121
+ };
122
+ const schemaEnhancer = config.settings.contentPropertiesSchemaEnhancer;
123
+ let schema = schemaEnhancer
124
+ ? schemaEnhancer({
125
+ schema: cloneDeepSchema(baseSchema),
126
+ intl,
127
+ })
128
+ : baseSchema;
129
+
130
+ const initialData = {};
131
+ if (values?.length) {
132
+ for (const name of Object.keys(schema.properties)) {
133
+ const firstValue = values[0][name];
134
+ // should not show floor or ceiling dates
135
+ if (
136
+ (name === 'effective' && firstValue && firstValue <= '1970') ||
137
+ (name === 'expires' && firstValue && firstValue >= '2499')
138
+ ) {
139
+ continue;
140
+ }
141
+ if (values.every((item) => item[name] === firstValue)) {
142
+ initialData[name] = firstValue;
143
+ }
144
+ }
145
+ }
146
+
74
147
  useEffect(() => {
75
148
  if (prevrequestloading && request.loaded) {
76
149
  onOk();
@@ -78,13 +151,19 @@ const ContentsPropertiesModal = (props) => {
78
151
  }, [onOk, prevrequestloading, request.loaded]);
79
152
 
80
153
  const onSubmit = (data) => {
81
- if (isEmpty(data)) {
154
+ let changes = {};
155
+ for (const name of Object.keys(data)) {
156
+ if (data[name] !== initialData[name]) {
157
+ changes[name] = data[name];
158
+ }
159
+ }
160
+ if (isEmpty(changes)) {
82
161
  onOk();
83
162
  } else {
84
163
  dispatch(
85
164
  updateContent(
86
165
  items,
87
- map(items, () => data),
166
+ map(items, () => changes),
88
167
  ),
89
168
  );
90
169
  }
@@ -97,54 +176,8 @@ const ContentsPropertiesModal = (props) => {
97
176
  onSubmit={onSubmit}
98
177
  onCancel={onCancel}
99
178
  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',
144
- },
145
- },
146
- required: [],
147
- }}
179
+ schema={schema}
180
+ formData={initialData}
148
181
  />
149
182
  )
150
183
  );