@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.
- package/CHANGELOG.md +114 -0
- package/finalreleasechangelog.py +48 -0
- package/locales/ca/LC_MESSAGES/volto.po +39 -13
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +40 -14
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +39 -13
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +40 -14
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +40 -14
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +40 -14
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +40 -14
- package/locales/fr.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +40 -14
- package/locales/hi.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +40 -14
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +39 -13
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +39 -13
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +39 -13
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +40 -14
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +39 -13
- package/locales/ro.json +1 -1
- package/locales/volto.pot +40 -14
- package/locales/zh_CN/LC_MESSAGES/volto.po +40 -14
- package/locales/zh_CN.json +1 -1
- package/package.json +5 -6
- package/razzle.config.js +3 -3
- package/src/components/index.js +0 -1
- package/src/components/manage/Actions/Actions.stories.jsx +138 -0
- package/src/components/manage/Add/Add.jsx +7 -4
- package/src/components/manage/BlockChooser/BlockChooser.jsx +9 -1
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +5 -0
- package/src/components/manage/Blocks/Block/Edit.jsx +24 -8
- package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +17 -1
- package/src/components/manage/Blocks/Block/Order/Item.jsx +8 -2
- package/src/components/manage/Blocks/Block/Order/Order.jsx +2 -0
- package/src/components/manage/Blocks/Container/Data.jsx +10 -2
- package/src/components/manage/Blocks/Grid/View.jsx +3 -0
- package/src/components/manage/Blocks/Image/ImageSidebar.jsx +10 -2
- package/src/components/manage/Blocks/LeadImage/Edit.jsx +74 -126
- package/src/components/manage/Blocks/Listing/ListingData.jsx +10 -2
- package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
- package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +2 -0
- package/src/components/manage/Blocks/Search/SearchBlockView.jsx +18 -2
- package/src/components/manage/Blocks/Search/components/SortOn.jsx +82 -55
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +1 -1
- package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +107 -176
- package/src/components/manage/Blocks/Teaser/Data.jsx +10 -2
- package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +15 -8
- package/src/components/manage/Blocks/ToC/Edit.jsx +36 -28
- package/src/components/manage/Blocks/Video/Edit.jsx +105 -172
- package/src/components/manage/Blocks/Video/Edit.stories.jsx +57 -0
- package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
- package/src/components/manage/Contents/Contents.jsx +4 -1
- package/src/components/manage/Contents/ContentsBreadcrumbs.stories.jsx +46 -0
- package/src/components/manage/Contents/ContentsPropertiesModal.jsx +85 -52
- package/src/components/manage/Contents/ContentsUploadModal.jsx +230 -323
- package/src/components/manage/Contents/ContentsUploadModal.stories.jsx +56 -0
- package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +323 -441
- package/src/components/manage/Controlpanels/Aliases.jsx +452 -580
- package/src/components/manage/Controlpanels/Aliases.stories.jsx +74 -0
- package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -0
- package/src/components/manage/Controlpanels/Controlpanel.jsx +41 -2
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +55 -24
- package/src/components/manage/Controlpanels/DatabaseInformation.jsx +162 -229
- package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +74 -122
- package/src/components/manage/Controlpanels/UndoControlpanel.jsx +3 -3
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +28 -12
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +12 -4
- package/src/components/manage/Display/Display.jsx +92 -148
- package/src/components/manage/Display/Display.stories.jsx +46 -0
- package/src/components/manage/Edit/Edit.jsx +2 -4
- package/src/components/manage/Form/Form.jsx +85 -20
- package/src/components/manage/Form/InlineForm.jsx +2 -4
- package/src/components/manage/Form/ModalForm.jsx +1 -1
- package/src/components/manage/History/History.jsx +1 -1
- package/src/components/manage/Pluggable/Pluggable.test.js +1 -1
- package/src/components/manage/Preferences/ChangePassword.jsx +94 -172
- package/src/components/manage/Preferences/ChangePassword.stories.jsx +41 -0
- package/src/components/manage/Preferences/PersonalInformation.jsx +50 -115
- package/src/components/manage/Preferences/PersonalPreferences.jsx +46 -100
- package/src/components/manage/Preferences/PersonalPreferences.stories.jsx +48 -0
- package/src/components/manage/Toolbar/More.jsx +308 -399
- package/src/components/manage/Toolbar/Toolbar.jsx +1 -1
- package/src/components/manage/Widgets/ArrayWidget.jsx +2 -2
- package/src/components/manage/Widgets/DatetimeWidget.jsx +121 -175
- package/src/components/manage/Widgets/ImageWidget.jsx +6 -5
- package/src/components/manage/Widgets/RecurrenceWidget/EndField.jsx +7 -1
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +80 -31
- package/src/components/manage/Widgets/ReferenceWidget.jsx +134 -210
- package/src/components/theme/Register/Register.jsx +70 -142
- package/src/components/theme/Register/Register.stories.jsx +49 -0
- package/src/components/theme/Search/Search.jsx +13 -5
- package/src/components/theme/Tags/Tags.jsx +19 -10
- package/src/components/theme/Tags/Tags.test.jsx +9 -11
- package/src/components/theme/View/AlbumView.jsx +122 -167
- package/src/components/theme/View/LinkView.jsx +4 -0
- package/src/components/theme/View/LinkView.test.jsx +2 -0
- package/src/components/theme/View/View.jsx +0 -13
- package/src/components/theme/View/View.test.jsx +0 -3
- package/src/config/ControlPanels.js +49 -43
- package/src/config/Widgets.jsx +1 -1
- package/src/config/config.test.js +1 -0
- package/src/config/index.js +23 -2
- package/src/config/slots.js +12 -0
- package/src/config/validation.ts +155 -0
- package/src/helpers/Blocks/Blocks.js +12 -7
- package/src/helpers/Blocks/Blocks.test.js +15 -0
- package/src/helpers/Blocks/cloneBlocks.ts +1 -1
- package/src/helpers/Extensions/withBlockExtensions.jsx +1 -1
- package/src/helpers/FormValidation/FormValidation.jsx +128 -172
- package/src/helpers/FormValidation/FormValidation.test.js +836 -8
- package/src/helpers/FormValidation/validators.ts +203 -0
- package/src/helpers/MessageLabels/MessageLabels.js +28 -0
- package/src/helpers/Url/Url.test.js +19 -6
- package/src/helpers/Url/urlRegex.js +1 -1
- package/src/helpers/User/User.js +1 -1
- package/src/helpers/index.js +2 -0
- package/src/hooks/client/useClient.js +1 -1
- package/src/middleware/api.js +4 -2
- package/src/middleware/index.js +1 -0
- package/src/middleware/userSessionReset.js +46 -0
- package/src/store.js +2 -0
- package/test-setup-config.jsx +10 -0
- package/theme/themes/default/modules/embed.variables +1 -1
- package/theme/themes/pastanaga/collections/form.overrides +34 -0
- package/theme/themes/pastanaga/extras/blocks.less +6 -0
- package/theme/themes/pastanaga/extras/sidebar.less +4 -0
- package/theme/themes/pastanaga/extras/toolbar.less +10 -3
- package/tsconfig.declarations.json +3 -2
- package/types/components/index.d.ts +0 -1
- package/types/components/manage/Actions/Actions.stories.d.ts +8 -0
- package/types/components/manage/Blocks/Block/Order/Order.d.ts +2 -1
- package/types/components/manage/Blocks/LeadImage/Edit.d.ts +14 -5
- package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +0 -5
- package/types/components/manage/Blocks/ToC/Edit.d.ts +1 -6
- package/types/components/manage/Blocks/Video/Edit.d.ts +1 -1
- package/types/components/manage/Blocks/Video/Edit.stories.d.ts +8 -0
- package/types/components/manage/Contents/ContentsBreadcrumbs.stories.d.ts +8 -0
- package/types/components/manage/Contents/ContentsUploadModal.d.ts +14 -2
- package/types/components/manage/Contents/ContentsUploadModal.stories.d.ts +8 -0
- package/types/components/manage/Contents/index.d.ts +1 -1
- package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +2 -2
- package/types/components/manage/Controlpanels/Aliases.d.ts +2 -2
- package/types/components/manage/Controlpanels/Aliases.stories.d.ts +8 -0
- package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +2 -2
- package/types/components/manage/Controlpanels/Groups/RenderGroups.d.ts +10 -5
- package/types/components/manage/Controlpanels/index.d.ts +4 -4
- package/types/components/manage/Display/Display.stories.d.ts +8 -0
- package/types/components/manage/Preferences/ChangePassword.d.ts +2 -2
- package/types/components/manage/Preferences/ChangePassword.stories.d.ts +8 -0
- package/types/components/manage/Preferences/PersonalInformation.d.ts +7 -2
- package/types/components/manage/Preferences/PersonalPreferences.d.ts +5 -1
- package/types/components/manage/Preferences/PersonalPreferences.stories.d.ts +8 -0
- package/types/components/manage/Toolbar/More.d.ts +8 -5
- package/types/components/manage/Widgets/DatetimeWidget.d.ts +0 -85
- package/types/components/manage/Widgets/DatetimeWidget.stories.d.ts +0 -1
- package/types/components/manage/Widgets/ReferenceWidget.d.ts +27 -2
- package/types/components/manage/Widgets/index.d.ts +1 -1
- package/types/components/theme/Register/Register.d.ts +2 -2
- package/types/components/theme/Register/Register.stories.d.ts +9 -0
- package/types/components/theme/Tags/Tags.d.ts +15 -7
- package/types/components/theme/View/AlbumView.d.ts +3 -17
- package/types/config/ControlPanels.d.ts +8 -0
- package/types/config/RichTextEditor/ToHTML.d.ts +1 -1
- package/types/config/Widgets.d.ts +3 -3
- package/types/config/slots.d.ts +21 -0
- package/types/config/validation.d.ts +3 -0
- package/types/helpers/Blocks/Blocks.d.ts +6 -0
- package/types/helpers/Extensions/withBlockExtensions.d.ts +1 -1
- package/types/helpers/FormValidation/FormValidation.d.ts +2 -0
- package/types/helpers/FormValidation/validators.d.ts +29 -0
- package/types/helpers/MessageLabels/MessageLabels.d.ts +36 -0
- package/types/helpers/User/User.d.ts +1 -1
- package/types/helpers/index.d.ts +2 -2
- package/types/middleware/index.d.ts +1 -0
- package/types/middleware/userSessionReset.d.ts +5 -0
- package/src/components/theme/SocialSharing/SocialSharing.jsx +0 -48
- package/src/components/theme/SocialSharing/SocialSharing.test.jsx +0 -14
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* ReferenceWidget component.
|
|
3
|
-
* @module components/manage/Widgets/ReferenceWidget
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { Component } from 'react';
|
|
1
|
+
import { useState, 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 { Label, Dropdown, Popup, Icon } from 'semantic-ui-react';
|
|
11
5
|
import { compact, concat, fromPairs, map, values, uniqBy } from 'lodash';
|
|
12
|
-
import { defineMessages,
|
|
6
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
13
7
|
|
|
14
8
|
import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
|
|
15
9
|
import { resetSearchContent, searchContent } from '@plone/volto/actions';
|
|
@@ -26,130 +20,16 @@ const messages = defineMessages({
|
|
|
26
20
|
},
|
|
27
21
|
});
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*/
|
|
40
|
-
static propTypes = {
|
|
41
|
-
id: PropTypes.string.isRequired,
|
|
42
|
-
title: PropTypes.string.isRequired,
|
|
43
|
-
description: PropTypes.string,
|
|
44
|
-
required: PropTypes.bool,
|
|
45
|
-
multiple: PropTypes.bool,
|
|
46
|
-
error: PropTypes.arrayOf(PropTypes.string),
|
|
47
|
-
value: PropTypes.oneOfType([
|
|
48
|
-
PropTypes.arrayOf(PropTypes.object),
|
|
49
|
-
PropTypes.object,
|
|
50
|
-
]),
|
|
51
|
-
onChange: PropTypes.func.isRequired,
|
|
52
|
-
resetSearchContent: PropTypes.func.isRequired,
|
|
53
|
-
searchContent: PropTypes.func.isRequired,
|
|
54
|
-
search: PropTypes.arrayOf(
|
|
55
|
-
PropTypes.shape({
|
|
56
|
-
'@id': PropTypes.string,
|
|
57
|
-
'@type': PropTypes.string,
|
|
58
|
-
title: PropTypes.string,
|
|
59
|
-
description: PropTypes.string,
|
|
60
|
-
}),
|
|
61
|
-
),
|
|
62
|
-
wrapped: PropTypes.bool,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Default properties
|
|
67
|
-
* @property {Object} defaultProps Default properties.
|
|
68
|
-
* @static
|
|
69
|
-
*/
|
|
70
|
-
static defaultProps = {
|
|
71
|
-
description: null,
|
|
72
|
-
required: false,
|
|
73
|
-
error: [],
|
|
74
|
-
search: [],
|
|
75
|
-
value: null,
|
|
76
|
-
multiple: true,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Constructor
|
|
81
|
-
* @method constructor
|
|
82
|
-
* @param {Object} props Component properties
|
|
83
|
-
* @constructs Actions
|
|
84
|
-
*/
|
|
85
|
-
constructor(props) {
|
|
86
|
-
super(props);
|
|
87
|
-
this.onSearchChange = this.onSearchChange.bind(this);
|
|
88
|
-
|
|
89
|
-
this.state = {
|
|
90
|
-
choices: props.value
|
|
91
|
-
? props.multiple
|
|
92
|
-
? fromPairs(
|
|
93
|
-
map(props.value, (value) => [
|
|
94
|
-
value['@id'],
|
|
95
|
-
{
|
|
96
|
-
key: value['@id'],
|
|
97
|
-
text: flattenToAppURL(value['@id']),
|
|
98
|
-
value: value['@id'],
|
|
99
|
-
label: {
|
|
100
|
-
content: value.title,
|
|
101
|
-
},
|
|
102
|
-
data: value,
|
|
103
|
-
},
|
|
104
|
-
]),
|
|
105
|
-
)
|
|
106
|
-
: {
|
|
107
|
-
[props.value['@id']]: {
|
|
108
|
-
key: props.value['@id'],
|
|
109
|
-
text: flattenToAppURL(props.value),
|
|
110
|
-
value: props.value['@id'],
|
|
111
|
-
label: {
|
|
112
|
-
content: props.value.title,
|
|
113
|
-
},
|
|
114
|
-
data: props.value,
|
|
115
|
-
},
|
|
116
|
-
novalue: {
|
|
117
|
-
key: 'novalue',
|
|
118
|
-
text: this.props.intl.formatMessage(messages.no_value),
|
|
119
|
-
value: 'novalue',
|
|
120
|
-
data: null,
|
|
121
|
-
},
|
|
122
|
-
}
|
|
123
|
-
: {},
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
componentDidMount() {
|
|
128
|
-
this.props.resetSearchContent();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Component will receive props
|
|
133
|
-
* @method componentWillReceiveProps
|
|
134
|
-
* @param {Object} nextProps Next properties
|
|
135
|
-
* @returns {undefined}
|
|
136
|
-
*/
|
|
137
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
138
|
-
this.setState({
|
|
139
|
-
choices: {
|
|
140
|
-
...fromPairs(
|
|
141
|
-
map(
|
|
142
|
-
uniqBy(
|
|
143
|
-
map(
|
|
144
|
-
compact(concat(nextProps.value, nextProps.search)),
|
|
145
|
-
(item) => ({
|
|
146
|
-
...item,
|
|
147
|
-
'@id': flattenToAppURL(item['@id']),
|
|
148
|
-
}),
|
|
149
|
-
),
|
|
150
|
-
'@id',
|
|
151
|
-
),
|
|
152
|
-
(value) => [
|
|
23
|
+
const ReferenceWidget = (props) => {
|
|
24
|
+
const { id, title, value, multiple, onChange } = props;
|
|
25
|
+
const intl = useIntl();
|
|
26
|
+
const dispatch = useDispatch();
|
|
27
|
+
const search = useSelector((state) => state.search.items);
|
|
28
|
+
const [choices, setChoices] = useState(
|
|
29
|
+
value
|
|
30
|
+
? multiple
|
|
31
|
+
? fromPairs(
|
|
32
|
+
map(value, (value) => [
|
|
153
33
|
value['@id'],
|
|
154
34
|
{
|
|
155
35
|
key: value['@id'],
|
|
@@ -160,37 +40,78 @@ class ReferenceWidget extends Component {
|
|
|
160
40
|
},
|
|
161
41
|
data: value,
|
|
162
42
|
},
|
|
163
|
-
],
|
|
43
|
+
]),
|
|
44
|
+
)
|
|
45
|
+
: {
|
|
46
|
+
[value['@id']]: {
|
|
47
|
+
key: value['@id'],
|
|
48
|
+
text: flattenToAppURL(value),
|
|
49
|
+
value: value['@id'],
|
|
50
|
+
label: {
|
|
51
|
+
content: value.title,
|
|
52
|
+
},
|
|
53
|
+
data: value,
|
|
54
|
+
},
|
|
55
|
+
novalue: {
|
|
56
|
+
key: 'novalue',
|
|
57
|
+
text: intl.formatMessage(messages.no_value),
|
|
58
|
+
value: 'novalue',
|
|
59
|
+
data: null,
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
: {},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
dispatch(resetSearchContent());
|
|
67
|
+
}, [dispatch]);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setChoices({
|
|
71
|
+
...fromPairs(
|
|
72
|
+
map(
|
|
73
|
+
uniqBy(
|
|
74
|
+
map(compact(concat(value, search)), (item) => ({
|
|
75
|
+
...item,
|
|
76
|
+
'@id': flattenToAppURL(item['@id']),
|
|
77
|
+
})),
|
|
78
|
+
'@id',
|
|
164
79
|
),
|
|
80
|
+
(value) => [
|
|
81
|
+
value['@id'],
|
|
82
|
+
{
|
|
83
|
+
key: value['@id'],
|
|
84
|
+
text: flattenToAppURL(value['@id']),
|
|
85
|
+
value: value['@id'],
|
|
86
|
+
label: {
|
|
87
|
+
content: value.title,
|
|
88
|
+
},
|
|
89
|
+
data: value,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
165
92
|
),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
93
|
+
),
|
|
94
|
+
novalue: {
|
|
95
|
+
key: 'novalue',
|
|
96
|
+
text: intl.formatMessage(messages.no_value),
|
|
97
|
+
value: 'novalue',
|
|
98
|
+
data: null,
|
|
172
99
|
},
|
|
173
100
|
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* On search change handler
|
|
178
|
-
* @method onSearchChange
|
|
179
|
-
* @param {object} event Event object.
|
|
180
|
-
* @param {object} data Event data.
|
|
181
|
-
* @returns {undefined}
|
|
182
|
-
*/
|
|
101
|
+
}, [intl, search, value]);
|
|
183
102
|
|
|
184
|
-
onSearchChange(event, data) {
|
|
103
|
+
const onSearchChange = (event, data) => {
|
|
185
104
|
if (data.searchQuery && data.searchQuery !== '') {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
105
|
+
dispatch(
|
|
106
|
+
searchContent('', {
|
|
107
|
+
Title: `*${data.searchQuery}*`,
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
189
110
|
} else {
|
|
190
|
-
|
|
111
|
+
dispatch(resetSearchContent());
|
|
191
112
|
}
|
|
192
|
-
}
|
|
193
|
-
renderLabel = (item, index, defaultProps) => {
|
|
113
|
+
};
|
|
114
|
+
const renderLabel = (item, index, defaultProps) => {
|
|
194
115
|
return (
|
|
195
116
|
<Popup
|
|
196
117
|
key={item.value}
|
|
@@ -216,59 +137,62 @@ class ReferenceWidget extends Component {
|
|
|
216
137
|
);
|
|
217
138
|
};
|
|
218
139
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
140
|
+
return (
|
|
141
|
+
<FormFieldWrapper {...props}>
|
|
142
|
+
<Dropdown
|
|
143
|
+
options={values(choices)}
|
|
144
|
+
placeholder={title}
|
|
145
|
+
search
|
|
146
|
+
selection
|
|
147
|
+
fluid
|
|
148
|
+
noResultsMessage={intl.formatMessage(messages.no_results_found)}
|
|
149
|
+
multiple={multiple}
|
|
150
|
+
value={
|
|
151
|
+
multiple
|
|
152
|
+
? value
|
|
153
|
+
? map(value, (item) =>
|
|
154
|
+
item && item['@id'] ? flattenToAppURL(item['@id']) : item,
|
|
155
|
+
)
|
|
156
|
+
: []
|
|
157
|
+
: value
|
|
158
|
+
? flattenToAppURL(value['@id'])
|
|
159
|
+
: ''
|
|
160
|
+
}
|
|
161
|
+
onChange={(event, data) => {
|
|
162
|
+
return onChange(
|
|
163
|
+
id,
|
|
240
164
|
multiple
|
|
241
|
-
? value
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
165
|
+
? map(data.value, (item) => choices[item].data)
|
|
166
|
+
: choices[data.value].data,
|
|
167
|
+
);
|
|
168
|
+
}}
|
|
169
|
+
onSearchChange={onSearchChange}
|
|
170
|
+
renderLabel={renderLabel}
|
|
171
|
+
/>
|
|
172
|
+
</FormFieldWrapper>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
ReferenceWidget.propTypes = {
|
|
177
|
+
id: PropTypes.string.isRequired,
|
|
178
|
+
title: PropTypes.string.isRequired,
|
|
179
|
+
description: PropTypes.string,
|
|
180
|
+
required: PropTypes.bool,
|
|
181
|
+
multiple: PropTypes.bool,
|
|
182
|
+
error: PropTypes.arrayOf(PropTypes.string),
|
|
183
|
+
value: PropTypes.oneOfType([
|
|
184
|
+
PropTypes.arrayOf(PropTypes.object),
|
|
185
|
+
PropTypes.object,
|
|
186
|
+
]),
|
|
187
|
+
onChange: PropTypes.func.isRequired,
|
|
188
|
+
wrapped: PropTypes.bool,
|
|
189
|
+
};
|
|
265
190
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
)(ReferenceWidget);
|
|
191
|
+
ReferenceWidget.defaultProps = {
|
|
192
|
+
description: null,
|
|
193
|
+
required: false,
|
|
194
|
+
error: [],
|
|
195
|
+
value: null,
|
|
196
|
+
multiple: true,
|
|
197
|
+
};
|
|
198
|
+
export default ReferenceWidget;
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import React, { Component } from 'react';
|
|
7
|
-
import { Helmet } from '@plone/volto/helpers';
|
|
8
|
-
import { connect } from 'react-redux';
|
|
9
|
-
import { compose } from 'redux';
|
|
10
|
-
import { defineMessages, injectIntl } from 'react-intl';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import { withRouter } from 'react-router-dom';
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
3
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
4
|
+
import { useHistory } from 'react-router-dom';
|
|
13
5
|
import { toast } from 'react-toastify';
|
|
14
6
|
|
|
7
|
+
import { Helmet, usePrevious } from '@plone/volto/helpers';
|
|
15
8
|
import { Toast } from '@plone/volto/components';
|
|
16
9
|
import { Form } from '@plone/volto/components/manage/Form';
|
|
17
10
|
import { createUser } from '@plone/volto/actions';
|
|
@@ -56,146 +49,81 @@ const messages = defineMessages({
|
|
|
56
49
|
defaultMessage: 'Register',
|
|
57
50
|
},
|
|
58
51
|
});
|
|
52
|
+
const useUsers = () => {
|
|
53
|
+
const error = useSelector((state) => state.users.create.error);
|
|
54
|
+
const loading = useSelector((state) => state.users.create.loading);
|
|
55
|
+
const loaded = useSelector((state) => state.users.create.loaded);
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
* @property {Object} propTypes Property types.
|
|
69
|
-
* @static
|
|
70
|
-
*/
|
|
71
|
-
static propTypes = {
|
|
72
|
-
createUser: PropTypes.func.isRequired,
|
|
73
|
-
loading: PropTypes.bool.isRequired,
|
|
74
|
-
loaded: PropTypes.bool.isRequired,
|
|
75
|
-
error: PropTypes.shape({
|
|
76
|
-
message: PropTypes.string,
|
|
77
|
-
}),
|
|
78
|
-
};
|
|
57
|
+
return { error, loaded, loading };
|
|
58
|
+
};
|
|
59
|
+
const Register = () => {
|
|
60
|
+
const dispatch = useDispatch();
|
|
61
|
+
const intl = useIntl();
|
|
62
|
+
const history = useHistory();
|
|
63
|
+
const [errors, setError] = useState(null);
|
|
64
|
+
const { loaded, loading, error } = useUsers();
|
|
79
65
|
|
|
80
|
-
|
|
81
|
-
* Default properties.
|
|
82
|
-
* @property {Object} defaultProps Default properties.
|
|
83
|
-
* @static
|
|
84
|
-
*/
|
|
85
|
-
static defaultProps = {
|
|
86
|
-
error: null,
|
|
87
|
-
};
|
|
66
|
+
const prevloading = usePrevious(loading);
|
|
88
67
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* @method constructor
|
|
92
|
-
* @param {Object} props Component properties
|
|
93
|
-
* @constructs WysiwygEditor
|
|
94
|
-
*/
|
|
95
|
-
constructor(props) {
|
|
96
|
-
super(props);
|
|
97
|
-
this.onSubmit = this.onSubmit.bind(this);
|
|
98
|
-
this.state = {
|
|
99
|
-
error: null,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Component will receive props
|
|
105
|
-
* @method componentWillReceiveProps
|
|
106
|
-
* @param {Object} nextProps Next properties
|
|
107
|
-
* @returns {undefined}
|
|
108
|
-
*/
|
|
109
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
110
|
-
if (this.props.loading && nextProps.loaded) {
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (prevloading && loaded) {
|
|
111
70
|
toast.success(
|
|
112
71
|
<Toast
|
|
113
72
|
success
|
|
114
|
-
title={
|
|
115
|
-
|
|
116
|
-
)}
|
|
117
|
-
content={this.props.intl.formatMessage(
|
|
118
|
-
messages.successRegisterCompletedBody,
|
|
119
|
-
)}
|
|
73
|
+
title={intl.formatMessage(messages.successRegisterCompletedTitle)}
|
|
74
|
+
content={intl.formatMessage(messages.successRegisterCompletedBody)}
|
|
120
75
|
/>,
|
|
121
76
|
);
|
|
122
|
-
|
|
77
|
+
history.push('/login');
|
|
123
78
|
}
|
|
124
|
-
}
|
|
79
|
+
}, [intl, history, loaded, prevloading]);
|
|
125
80
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
this.setState({
|
|
139
|
-
error: null,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
81
|
+
const onSubmit = (data) => {
|
|
82
|
+
const { fullname, email } = data;
|
|
83
|
+
dispatch(
|
|
84
|
+
createUser({
|
|
85
|
+
fullname: fullname,
|
|
86
|
+
email: email,
|
|
87
|
+
sendPasswordReset: true,
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
setError(null);
|
|
91
|
+
};
|
|
142
92
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
schema={{
|
|
159
|
-
fieldsets: [
|
|
160
|
-
{
|
|
161
|
-
id: 'default',
|
|
162
|
-
title: this.props.intl.formatMessage(messages.default),
|
|
163
|
-
fields: ['fullname', 'email'],
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
properties: {
|
|
167
|
-
fullname: {
|
|
168
|
-
type: 'string',
|
|
169
|
-
title: this.props.intl.formatMessage(messages.fullnameTitle),
|
|
170
|
-
description: this.props.intl.formatMessage(
|
|
171
|
-
messages.fullnameDescription,
|
|
172
|
-
),
|
|
173
|
-
},
|
|
174
|
-
email: {
|
|
175
|
-
type: 'string',
|
|
176
|
-
title: this.props.intl.formatMessage(messages.emailTitle),
|
|
177
|
-
description: this.props.intl.formatMessage(
|
|
178
|
-
messages.emailDescription,
|
|
179
|
-
),
|
|
180
|
-
},
|
|
93
|
+
return (
|
|
94
|
+
<div id="page-register">
|
|
95
|
+
<Helmet title={intl.formatMessage(messages.register)} />
|
|
96
|
+
<Form
|
|
97
|
+
onSubmit={onSubmit}
|
|
98
|
+
title={intl.formatMessage(messages.title)}
|
|
99
|
+
error={errors || error}
|
|
100
|
+
loading={loading}
|
|
101
|
+
submitLabel={intl.formatMessage(messages.register)}
|
|
102
|
+
schema={{
|
|
103
|
+
fieldsets: [
|
|
104
|
+
{
|
|
105
|
+
id: 'default',
|
|
106
|
+
title: intl.formatMessage(messages.default),
|
|
107
|
+
fields: ['fullname', 'email'],
|
|
181
108
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
109
|
+
],
|
|
110
|
+
properties: {
|
|
111
|
+
fullname: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
title: intl.formatMessage(messages.fullnameTitle),
|
|
114
|
+
description: intl.formatMessage(messages.fullnameDescription),
|
|
115
|
+
},
|
|
116
|
+
email: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
title: intl.formatMessage(messages.emailTitle),
|
|
119
|
+
description: intl.formatMessage(messages.emailDescription),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
required: ['fullname', 'email'],
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
189
128
|
|
|
190
|
-
export default
|
|
191
|
-
withRouter,
|
|
192
|
-
injectIntl,
|
|
193
|
-
connect(
|
|
194
|
-
(state) => ({
|
|
195
|
-
loading: state.users.create.loading,
|
|
196
|
-
loaded: state.users.create.loaded,
|
|
197
|
-
error: state.users.create.error,
|
|
198
|
-
}),
|
|
199
|
-
{ createUser },
|
|
200
|
-
),
|
|
201
|
-
)(Register);
|
|
129
|
+
export default Register;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { injectIntl } from 'react-intl';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import RegisterComponent from './Register';
|
|
4
|
+
import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook';
|
|
5
|
+
|
|
6
|
+
const IntlRegister = injectIntl(RegisterComponent);
|
|
7
|
+
|
|
8
|
+
function StoryComponent(args) {
|
|
9
|
+
return (
|
|
10
|
+
<Wrapper
|
|
11
|
+
customStore={{
|
|
12
|
+
users: {
|
|
13
|
+
create: {
|
|
14
|
+
loading: false,
|
|
15
|
+
loaded: true,
|
|
16
|
+
...args,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
intl: {
|
|
20
|
+
locale: 'en',
|
|
21
|
+
messages: {},
|
|
22
|
+
},
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<div id="toolbar" style={{ display: 'none' }} />
|
|
26
|
+
<IntlRegister />
|
|
27
|
+
</Wrapper>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const Default = StoryComponent.bind({});
|
|
32
|
+
Default.args = {
|
|
33
|
+
error: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
title: 'Public components/Register',
|
|
38
|
+
component: RegisterComponent,
|
|
39
|
+
|
|
40
|
+
decorators: [
|
|
41
|
+
(Story) => (
|
|
42
|
+
<div className="ui segment form attached" style={{ width: '600px' }}>
|
|
43
|
+
<Story />
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
argTypes: {},
|
|
49
|
+
};
|