@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.
- package/.eslintrc +26 -3
- package/.yarn/install-state.gz +0 -0
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
- package/.yarn/releases/yarn-3.6.3.cjs +874 -0
- package/CHANGELOG.md +60 -0
- package/addon-registry.js +10 -1
- package/create-addons-loader.js +1 -1
- package/locales/ca/LC_MESSAGES/volto.po +57 -31
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +58 -32
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +57 -31
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +65 -39
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +57 -31
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +57 -31
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +57 -31
- package/locales/fr.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +57 -31
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +57 -31
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +57 -31
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +57 -31
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +57 -31
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +57 -31
- package/locales/ro.json +1 -1
- package/locales/volto.pot +62 -32
- package/locales/zh_CN/LC_MESSAGES/volto.po +57 -31
- package/locales/zh_CN.json +1 -1
- package/package.json +35 -26
- package/packages/volto-slate/package.json +1 -1
- package/packages/volto-slate/src/blocks/Text/TextBlockView.jsx +2 -1
- package/packages/volto-slate/src/blocks/Text/index.js +0 -5
- package/packages/volto-slate/src/editor/plugins/Link/render.jsx +5 -6
- package/packages/volto-slate/src/editor/render.jsx +11 -1
- package/razzle.config.js +4 -6
- package/src/components/index.js +194 -194
- package/src/components/manage/Add/Add.jsx +7 -8
- package/src/components/manage/Blocks/Block/Settings.test.jsx +17 -15
- package/src/components/manage/Blocks/HTML/Edit.jsx +8 -8
- package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +30 -25
- package/src/components/manage/Blocks/Listing/ListingBody.jsx +6 -4
- package/src/components/manage/Blocks/Maps/Edit.test.jsx +1 -2
- package/src/components/manage/Blocks/Maps/View.test.jsx +1 -2
- package/src/components/manage/Blocks/Search/components/Facets.jsx +2 -3
- package/src/components/manage/Blocks/Search/components/FilterList.jsx +4 -6
- package/src/components/manage/Blocks/Search/components/SelectFacet.jsx +2 -9
- package/src/components/manage/Blocks/Search/hocs/withQueryString.jsx +3 -0
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +8 -6
- package/src/components/manage/Blocks/Search/schema.js +13 -13
- package/src/components/manage/Blocks/Table/Cell.jsx +2 -3
- package/src/components/manage/Blocks/Text/Edit.jsx +2 -3
- package/src/components/manage/Blocks/Title/View.jsx +4 -37
- package/src/components/manage/Blocks/ToC/View.jsx +1 -0
- package/src/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +3 -2
- package/src/components/manage/Blocks/ToC/variations/HorizontalMenu.jsx +3 -2
- package/src/components/manage/Contents/Contents.jsx +252 -114
- package/src/components/manage/Contents/ContentsPropertiesModal.jsx +90 -154
- package/src/components/manage/Contents/ContentsRenameModal.jsx +88 -139
- package/src/components/manage/Contents/ContentsRenameModal.stories.jsx +61 -0
- package/src/components/manage/Contents/ContentsTagsModal.jsx +83 -130
- package/src/components/manage/Contents/ContentsTagsModal.stories.jsx +68 -0
- package/src/components/manage/Contents/ContentsUploadModal.jsx +1 -2
- package/src/components/manage/Contents/ContentsWorkflowModal.jsx +87 -154
- package/src/components/manage/Controlpanels/Aliases.jsx +4 -12
- package/src/components/manage/Controlpanels/Rules/AddRule.jsx +2 -9
- package/src/components/manage/Controlpanels/UndoControlpanel.jsx +6 -9
- package/src/components/manage/Form/BlockDataForm.test.jsx +17 -15
- package/src/components/manage/Form/Form.jsx +2 -3
- package/src/components/manage/Form/InlineForm.test.jsx +16 -14
- package/src/components/manage/LockingToastsFactory/LockingToastsFactory.jsx +1 -2
- package/src/components/manage/Sharing/Sharing.jsx +7 -0
- package/src/components/manage/Sidebar/Sidebar.jsx +139 -220
- package/src/components/manage/Toolbar/More.jsx +12 -12
- package/src/components/manage/Toolbar/PersonalTools.jsx +97 -155
- package/src/components/manage/Toolbar/Toolbar.jsx +2 -2
- package/src/components/manage/UniversalLink/UniversalLink.test.jsx +2 -1
- package/src/components/manage/Widgets/AlignWidget.jsx +2 -4
- package/src/components/manage/Widgets/ColorPickerWidget.test.jsx +9 -7
- package/src/components/manage/Widgets/DatetimeWidget.jsx +2 -8
- package/src/components/manage/Widgets/IdWidget.jsx +1 -2
- package/src/components/manage/Widgets/ObjectBrowserWidget.jsx +2 -9
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +2 -9
- package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthIndexField.jsx +4 -4
- package/src/components/manage/Widgets/SchemaWidget.jsx +6 -9
- package/src/components/manage/Widgets/WysiwygWidget.jsx +2 -9
- package/src/components/theme/Comments/Comments.jsx +3 -10
- package/src/components/theme/ContentMetadataTags/ContentMetadataTags.jsx +4 -0
- package/src/components/theme/Login/Login.jsx +1 -2
- package/src/components/theme/PasswordReset/PasswordReset.jsx +1 -2
- package/src/components/theme/PreviewImage/PreviewImage.jsx +10 -5
- package/src/components/theme/PreviewImage/PreviewImage.test.js +17 -0
- package/src/components/theme/Register/Register.jsx +2 -4
- package/src/components/theme/TsTest/TsTest.test.tsx +11 -0
- package/src/components/theme/TsTest/TsTest.tsx +15 -0
- package/src/components/theme/View/AlbumView.jsx +3 -2
- package/src/components/theme/Widgets/ImageWidget.stories.jsx +1 -2
- package/src/config/Loadables.jsx +1 -1
- package/src/config/RichTextEditor/Blocks.jsx +2 -3
- package/src/config/RichTextEditor/Plugins.jsx +2 -3
- package/src/config/RichTextEditor/ToHTML.jsx +12 -10
- package/src/config/RichTextEditor/index.js +2 -3
- package/src/config/Views.jsx +5 -5
- package/src/express-middleware/ok.js +1 -1
- package/src/helpers/Blocks/Blocks.js +4 -6
- package/src/helpers/Blocks/Blocks.test.js +35 -35
- package/src/helpers/Extensions/withBlockSchemaEnhancer.js +48 -50
- package/src/helpers/FormValidation/FormValidation.js +7 -6
- package/src/helpers/Html/Html.jsx +2 -8
- package/src/helpers/Loadable/__mocks__/Loadable.js +18 -18
- package/src/helpers/MessageLabels/MessageLabels.js +2 -3
- package/src/helpers/Utils/UseDetectClickOutside.stories.jsx +2 -3
- package/src/helpers/Utils/Utils.js +10 -0
- package/src/helpers/Utils/Utils.test.js +13 -0
- package/src/helpers/index.js +1 -0
- package/src/hooks/index.js +1 -1
- package/src/middleware/api.js +194 -190
- package/src/middleware/blacklistRoutes.js +25 -22
- package/src/middleware/storeProtectLoadUtils.js +61 -62
- package/src/middleware/storeProtectLoadUtils.test.js +47 -43
- package/src/reducers/content/content.test.js +4 -4
- package/src/reducers/navigation/navigation.js +5 -5
- package/src/reducers/navigation/navigation.test.js +30 -0
- package/src/registry.js +2 -2
- package/src/storybook.jsx +24 -38
- package/theme/themes/pastanaga/collections/menu.overrides +3 -2
- package/theme/themes/pastanaga/elements/container.overrides +5 -2
- package/theme/themes/pastanaga/elements/input.overrides +1 -1
- package/theme/themes/pastanaga/elements/step.overrides +2 -1
- package/theme/themes/pastanaga/extras/blocks.less +20 -14
- package/theme/themes/pastanaga/extras/color-picker-widget.less +1 -1
- package/theme/themes/pastanaga/extras/contents.less +5 -1
- package/theme/themes/pastanaga/extras/draftjs.less +4 -4
- package/theme/themes/pastanaga/extras/grid.less +5 -4
- package/theme/themes/pastanaga/extras/main.less +6 -6
- package/theme/themes/pastanaga/extras/react-dates-overrides.less +4 -2
- package/theme/themes/pastanaga/extras/search.less +2 -2
- package/theme/themes/pastanaga/extras/sidebar.less +5 -4
- package/theme/themes/pastanaga/extras/time-picker-overrides.less +5 -3
- package/theme/themes/pastanaga/extras/toolbar.less +6 -2
- package/theme/themes/pastanaga/extras/userscontrolpanel.less +17 -9
- package/theme/themes/pastanaga/extras/widgets.less +1 -1
- package/theme/themes/pastanaga/modules/rating.overrides +2 -1
- package/theme/themes/pastanaga-cms-ui/elements/container.overrides +2 -1
- package/theme/themes/pastanaga-cms-ui/extras/cms-ui.elements.container.less +6 -2
- package/theme/themes/pastanaga-cms-ui/extras/cms-ui.site.less +2 -2
- 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 {
|
|
9
|
-
import { compose } from 'redux';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
10
4
|
import { isEmpty, map } from 'lodash';
|
|
11
|
-
import { defineMessages,
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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
|
-
|
|
82
|
+
onOk();
|
|
130
83
|
} else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
84
|
+
dispatch(
|
|
85
|
+
updateContent(
|
|
86
|
+
items,
|
|
87
|
+
map(items, () => data),
|
|
88
|
+
),
|
|
134
89
|
);
|
|
135
90
|
}
|
|
136
|
-
}
|
|
91
|
+
};
|
|
137
92
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
}
|
|
145
|
+
},
|
|
146
|
+
required: [],
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
};
|
|
214
152
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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 {
|
|
9
|
-
import { compose } from 'redux';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
10
4
|
import { concat, merge, map } from 'lodash';
|
|
11
|
-
import { defineMessages,
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
};
|