@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,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* Personal information component.
|
|
3
|
-
* @module components/manage/Preferences/PersonalInformation
|
|
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 {
|
|
10
|
-
import {
|
|
11
|
-
import { withRouter } from 'react-router-dom';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
+
import { useIntl } from 'react-intl';
|
|
5
|
+
import { useHistory } from 'react-router-dom';
|
|
12
6
|
import jwtDecode from 'jwt-decode';
|
|
13
7
|
import { toast } from 'react-toastify';
|
|
14
8
|
import { messages } from '@plone/volto/helpers';
|
|
@@ -16,117 +10,58 @@ import { Toast } from '@plone/volto/components';
|
|
|
16
10
|
import { Form } from '@plone/volto/components/manage/Form';
|
|
17
11
|
import { getUser, updateUser, getUserSchema } from '@plone/volto/actions';
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
static propTypes = {
|
|
31
|
-
user: PropTypes.shape({
|
|
32
|
-
fullname: PropTypes.string,
|
|
33
|
-
email: PropTypes.string,
|
|
34
|
-
home_page: PropTypes.string,
|
|
35
|
-
location: PropTypes.string,
|
|
36
|
-
}).isRequired,
|
|
37
|
-
updateUser: PropTypes.func.isRequired,
|
|
38
|
-
getUser: PropTypes.func.isRequired,
|
|
39
|
-
userId: PropTypes.string.isRequired,
|
|
40
|
-
loaded: PropTypes.bool.isRequired,
|
|
41
|
-
loading: PropTypes.bool,
|
|
42
|
-
closeMenu: PropTypes.func,
|
|
43
|
-
getUserSchema: PropTypes.func.isRequired,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Constructor
|
|
48
|
-
* @method constructor
|
|
49
|
-
* @param {Object} props Component properties
|
|
50
|
-
* @constructs ChangePassword
|
|
51
|
-
*/
|
|
52
|
-
constructor(props) {
|
|
53
|
-
super(props);
|
|
54
|
-
this.onCancel = this.onCancel.bind(this);
|
|
55
|
-
this.onSubmit = this.onSubmit.bind(this);
|
|
56
|
-
}
|
|
13
|
+
const PersonalInformation = (props) => {
|
|
14
|
+
const intl = useIntl();
|
|
15
|
+
const dispatch = useDispatch();
|
|
16
|
+
const history = useHistory();
|
|
17
|
+
const user = useSelector((state) => state.users.user);
|
|
18
|
+
const userId = useSelector((state) =>
|
|
19
|
+
state.userSession.token ? jwtDecode(state.userSession.token).sub : '',
|
|
20
|
+
);
|
|
21
|
+
const loading = useSelector((state) => state.users.update.loading);
|
|
22
|
+
const userschema = useSelector((state) => state.userschema);
|
|
57
23
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
dispatch(getUser(userId));
|
|
26
|
+
dispatch(getUserSchema());
|
|
27
|
+
}, [dispatch, userId]);
|
|
62
28
|
|
|
63
|
-
|
|
64
|
-
* Submit handler
|
|
65
|
-
* @method onSubmit
|
|
66
|
-
* @param {object} data Form data.
|
|
67
|
-
* @returns {undefined}
|
|
68
|
-
*/
|
|
69
|
-
onSubmit(data) {
|
|
70
|
-
// We don't want the user to change his login name/username or the roles
|
|
71
|
-
// from this form
|
|
72
|
-
// Backend will complain anyways, but we clean the data here before it does
|
|
29
|
+
const onSubmit = (data) => {
|
|
73
30
|
delete data.id;
|
|
74
31
|
delete data.username;
|
|
75
32
|
delete data.roles;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
33
|
+
dispatch(updateUser(userId, data)).then(() =>
|
|
34
|
+
toast.success(
|
|
35
|
+
<Toast
|
|
36
|
+
success
|
|
37
|
+
title={intl.formatMessage(messages.success)}
|
|
38
|
+
content={intl.formatMessage(messages.saved)}
|
|
39
|
+
/>,
|
|
40
|
+
),
|
|
83
41
|
);
|
|
84
|
-
if (
|
|
85
|
-
}
|
|
42
|
+
if (props.closeMenu) props.closeMenu();
|
|
43
|
+
};
|
|
86
44
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
*/
|
|
92
|
-
onCancel() {
|
|
93
|
-
if (this.props.closeMenu) this.props.closeMenu();
|
|
94
|
-
else this.props.history.goBack();
|
|
95
|
-
}
|
|
45
|
+
const onCancel = () => {
|
|
46
|
+
if (props.closeMenu) props.closeMenu();
|
|
47
|
+
else history.goBack();
|
|
48
|
+
};
|
|
96
49
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
50
|
+
return (
|
|
51
|
+
userschema?.loaded && (
|
|
52
|
+
<Form
|
|
53
|
+
formData={user}
|
|
54
|
+
schema={userschema.userschema}
|
|
55
|
+
onSubmit={onSubmit}
|
|
56
|
+
onCancel={onCancel}
|
|
57
|
+
loading={loading}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
PersonalInformation.propTypes = {
|
|
64
|
+
closeMenu: PropTypes.func,
|
|
65
|
+
};
|
|
116
66
|
|
|
117
|
-
export default
|
|
118
|
-
withRouter,
|
|
119
|
-
injectIntl,
|
|
120
|
-
connect(
|
|
121
|
-
(state, props) => ({
|
|
122
|
-
user: state.users.user,
|
|
123
|
-
userId: state.userSession.token
|
|
124
|
-
? jwtDecode(state.userSession.token).sub
|
|
125
|
-
: '',
|
|
126
|
-
loaded: state.users.get.loaded,
|
|
127
|
-
loading: state.users.update.loading,
|
|
128
|
-
userschema: state.userschema,
|
|
129
|
-
}),
|
|
130
|
-
{ getUser, updateUser, getUserSchema },
|
|
131
|
-
),
|
|
132
|
-
)(PersonalInformation);
|
|
67
|
+
export default PersonalInformation;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Personal preferences component.
|
|
3
|
-
* @module components/manage/Preferences/PersonalPreferences
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { Component } from 'react';
|
|
7
1
|
import PropTypes from 'prop-types';
|
|
8
|
-
import {
|
|
9
|
-
import { compose } from 'redux';
|
|
2
|
+
import { useDispatch } from 'react-redux';
|
|
10
3
|
import { map, keys } from 'lodash';
|
|
11
|
-
import {
|
|
12
|
-
import { defineMessages, injectIntl } from 'react-intl';
|
|
4
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
13
5
|
import { toast } from 'react-toastify';
|
|
6
|
+
import { compose } from 'redux';
|
|
7
|
+
import { withCookies } from 'react-cookie';
|
|
14
8
|
|
|
15
9
|
import { Toast } from '@plone/volto/components';
|
|
16
10
|
import { Form } from '@plone/volto/components/manage/Form';
|
|
@@ -50,104 +44,56 @@ const messages = defineMessages({
|
|
|
50
44
|
},
|
|
51
45
|
});
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class PersonalPreferences extends Component {
|
|
59
|
-
/**
|
|
60
|
-
* Property types.
|
|
61
|
-
* @property {Object} propTypes Property types.
|
|
62
|
-
* @static
|
|
63
|
-
*/
|
|
64
|
-
static propTypes = {
|
|
65
|
-
changeLanguage: PropTypes.func.isRequired,
|
|
66
|
-
closeMenu: PropTypes.func.isRequired,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Constructor
|
|
71
|
-
* @method constructor
|
|
72
|
-
* @param {Object} props Component properties
|
|
73
|
-
* @constructs PersonalPreferences
|
|
74
|
-
*/
|
|
75
|
-
constructor(props) {
|
|
76
|
-
super(props);
|
|
77
|
-
this.onCancel = this.onCancel.bind(this);
|
|
78
|
-
this.onSubmit = this.onSubmit.bind(this);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Submit handler
|
|
83
|
-
* @method onSubmit
|
|
84
|
-
* @param {object} data Form data.
|
|
85
|
-
* @returns {undefined}
|
|
86
|
-
*/
|
|
87
|
-
onSubmit(data) {
|
|
47
|
+
const PersonalPreferences = (props) => {
|
|
48
|
+
const intl = useIntl();
|
|
49
|
+
const dispatch = useDispatch();
|
|
50
|
+
const { closeMenu } = props;
|
|
51
|
+
const onSubmit = (data) => {
|
|
88
52
|
let language = data.language || 'en';
|
|
89
53
|
if (config.settings.supportedLanguages.includes(language)) {
|
|
90
54
|
const langFileName = toGettextLang(language);
|
|
91
55
|
import(
|
|
92
56
|
/* @vite-ignore */ '@root/../locales/' + langFileName + '.json'
|
|
93
57
|
).then((locale) => {
|
|
94
|
-
|
|
58
|
+
dispatch(changeLanguage(language, locale.default));
|
|
95
59
|
});
|
|
96
60
|
}
|
|
97
|
-
toast.success(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.props.closeMenu();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Cancel handler
|
|
105
|
-
* @method onCancel
|
|
106
|
-
* @returns {undefined}
|
|
107
|
-
*/
|
|
108
|
-
onCancel() {
|
|
109
|
-
this.props.closeMenu();
|
|
110
|
-
}
|
|
61
|
+
toast.success(<Toast success title={intl.formatMessage(messages.saved)} />);
|
|
62
|
+
closeMenu();
|
|
63
|
+
};
|
|
111
64
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
messages.languageDescription,
|
|
134
|
-
),
|
|
135
|
-
title: this.props.intl.formatMessage(messages.language),
|
|
136
|
-
type: 'string',
|
|
137
|
-
choices: map(keys(languages), (lang) => [lang, languages[lang]]),
|
|
138
|
-
},
|
|
65
|
+
const onCancel = () => {
|
|
66
|
+
closeMenu();
|
|
67
|
+
};
|
|
68
|
+
const { cookies } = props;
|
|
69
|
+
return (
|
|
70
|
+
<Form
|
|
71
|
+
formData={{ language: cookies.get('I18N_LANGUAGE') || '' }}
|
|
72
|
+
schema={{
|
|
73
|
+
fieldsets: [
|
|
74
|
+
{
|
|
75
|
+
id: 'default',
|
|
76
|
+
title: intl.formatMessage(messages.default),
|
|
77
|
+
fields: ['language'],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
properties: {
|
|
81
|
+
language: {
|
|
82
|
+
description: intl.formatMessage(messages.languageDescription),
|
|
83
|
+
title: intl.formatMessage(messages.language),
|
|
84
|
+
type: 'string',
|
|
85
|
+
choices: map(keys(languages), (lang) => [lang, languages[lang]]),
|
|
139
86
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
87
|
+
},
|
|
88
|
+
required: [],
|
|
89
|
+
}}
|
|
90
|
+
onSubmit={onSubmit}
|
|
91
|
+
onCancel={onCancel}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
148
95
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
)(PersonalPreferences);
|
|
96
|
+
PersonalPreferences.propTypes = {
|
|
97
|
+
closeMenu: PropTypes.func.isRequired,
|
|
98
|
+
};
|
|
99
|
+
export default compose(withCookies)(PersonalPreferences);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { injectIntl } from 'react-intl';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PersonalPreferencesComponent from './PersonalPreferences';
|
|
4
|
+
import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook';
|
|
5
|
+
const IntlPersonalPreferencesComponent = injectIntl(
|
|
6
|
+
PersonalPreferencesComponent,
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
function StoryComponent(args) {
|
|
10
|
+
return (
|
|
11
|
+
<Wrapper
|
|
12
|
+
customStore={{
|
|
13
|
+
intl: {
|
|
14
|
+
locale: 'en',
|
|
15
|
+
messages: {},
|
|
16
|
+
},
|
|
17
|
+
vocabularies: {
|
|
18
|
+
'plone.app.vocabularies.Keywords': {
|
|
19
|
+
items: [{ title: 'My item', value: 'myitem' }],
|
|
20
|
+
itemsTotal: 1,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<div id="toolbar" style={{ display: 'none' }} />
|
|
26
|
+
<IntlPersonalPreferencesComponent
|
|
27
|
+
{...args}
|
|
28
|
+
location={{ pathname: '/blog' }}
|
|
29
|
+
closeMenu={() => {}}
|
|
30
|
+
/>
|
|
31
|
+
</Wrapper>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const PersonalPreferences = StoryComponent.bind({});
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
title: 'Public components/PersonalPreferences',
|
|
39
|
+
component: PersonalPreferences,
|
|
40
|
+
decorators: [
|
|
41
|
+
(Story) => (
|
|
42
|
+
<div className="ui segment form attached" style={{ width: '400px' }}>
|
|
43
|
+
<Story />
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
argTypes: {},
|
|
48
|
+
};
|