@plone/volto 17.0.0-alpha.17 → 17.0.0-alpha.19

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 (74) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +57 -0
  3. package/cypress/support/commands.js +17 -0
  4. package/locales/ca/LC_MESSAGES/volto.po +39 -0
  5. package/locales/ca.json +1 -1
  6. package/locales/de/LC_MESSAGES/volto.po +39 -0
  7. package/locales/de.json +1 -1
  8. package/locales/en/LC_MESSAGES/volto.po +39 -0
  9. package/locales/en.json +1 -1
  10. package/locales/es/LC_MESSAGES/volto.po +39 -0
  11. package/locales/es.json +1 -1
  12. package/locales/eu/LC_MESSAGES/volto.po +39 -0
  13. package/locales/eu.json +1 -1
  14. package/locales/fi/LC_MESSAGES/volto.po +39 -0
  15. package/locales/fi.json +1 -1
  16. package/locales/fr/LC_MESSAGES/volto.po +39 -0
  17. package/locales/fr.json +1 -1
  18. package/locales/it/LC_MESSAGES/volto.po +40 -1
  19. package/locales/it.json +1 -1
  20. package/locales/ja/LC_MESSAGES/volto.po +39 -0
  21. package/locales/ja.json +1 -1
  22. package/locales/nl/LC_MESSAGES/volto.po +39 -0
  23. package/locales/nl.json +1 -1
  24. package/locales/pt/LC_MESSAGES/volto.po +39 -0
  25. package/locales/pt.json +1 -1
  26. package/locales/pt_BR/LC_MESSAGES/volto.po +39 -0
  27. package/locales/pt_BR.json +1 -1
  28. package/locales/ro/LC_MESSAGES/volto.po +39 -0
  29. package/locales/ro.json +1 -1
  30. package/locales/volto.pot +39 -0
  31. package/locales/zh_CN/LC_MESSAGES/volto.po +39 -0
  32. package/locales/zh_CN.json +1 -1
  33. package/package.json +2 -2
  34. package/packages/volto-slate/package.json +1 -1
  35. package/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx +21 -212
  36. package/packages/volto-slate/src/blocks/Table/schema.js +122 -0
  37. package/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js +14 -5
  38. package/packages/volto-slate/src/utils/blocks.js +7 -0
  39. package/packages/volto-slate/src/widgets/RichTextWidget.jsx +15 -8
  40. package/src/components/index.js +1 -0
  41. package/src/components/manage/Blocks/Search/components/Facets.jsx +6 -2
  42. package/src/components/manage/Blocks/Search/components/SearchInput.jsx +9 -2
  43. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +12 -1
  44. package/src/components/manage/Blocks/ToC/Schema.jsx +5 -1
  45. package/src/components/manage/Blocks/ToC/variations/HorizontalMenu.jsx +142 -8
  46. package/src/components/manage/LinksToItem/LinksToItem.jsx +209 -0
  47. package/src/components/manage/LinksToItem/LinksToItem.test.jsx +97 -0
  48. package/src/components/manage/Toolbar/More.jsx +15 -0
  49. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +1 -1
  50. package/src/components/theme/Breadcrumbs/Breadcrumbs.jsx +52 -99
  51. package/src/components/theme/Breadcrumbs/Breadcrumbs.stories.jsx +14 -13
  52. package/src/components/theme/Comments/CommentEditModal.jsx +63 -115
  53. package/src/components/theme/ContactForm/ContactForm.jsx +108 -192
  54. package/src/components/theme/ContactForm/ContactForm.stories.jsx +1 -1
  55. package/src/components/theme/ContactForm/ContactForm.test.jsx +2 -3
  56. package/src/components/theme/Login/Login.jsx +1 -1
  57. package/src/components/theme/SearchWidget/SearchWidget.jsx +38 -98
  58. package/src/components/theme/View/LinkView.jsx +51 -79
  59. package/src/config/NonContentRoutes.jsx +1 -0
  60. package/src/config/index.js +2 -0
  61. package/src/config/server.js +2 -0
  62. package/src/express-middleware/ok.js +16 -0
  63. package/src/hooks/client/useClient.js +11 -0
  64. package/src/hooks/index.js +1 -0
  65. package/src/routes.js +9 -0
  66. package/theme/themes/pastanaga/extras/main.less +2 -1
  67. package/theme/themes/pastanaga/extras/toc.less +29 -0
  68. package/news/4351.bugfix +0 -1
  69. package/news/4725.bugfix +0 -1
  70. package/news/4932.bugfix +0 -1
  71. package/news/4941.documentation +0 -1
  72. package/news/4951.breaking +0 -1
  73. package/news/4962.feature +0 -1
  74. package/news/4964.bugfix +0 -1
@@ -1,14 +1,9 @@
1
- /**
2
- * Comment edit modal.
3
- * @module components/theme/Comments/CommentEditModal
4
- */
5
-
6
- import React, { Component } from 'react';
1
+ import { useEffect } from 'react';
7
2
  import PropTypes from 'prop-types';
8
- import { connect } from 'react-redux';
9
- import { compose } from 'redux';
10
- import { defineMessages, injectIntl } from 'react-intl';
3
+ import { useDispatch, useSelector, shallowEqual } from 'react-redux';
4
+ import { defineMessages, useIntl } from 'react-intl';
11
5
 
6
+ import { usePrevious } from '@plone/volto/helpers';
12
7
  import { updateComment } from '@plone/volto/actions';
13
8
  import { ModalForm } from '@plone/volto/components';
14
9
 
@@ -27,116 +22,69 @@ const messages = defineMessages({
27
22
  },
28
23
  });
29
24
 
30
- /**
31
- * CommentEditModal class.
32
- * @class CommentEditModal
33
- * @extends Component
34
- */
35
- class CommentEditModal extends Component {
36
- /**
37
- * Property types.
38
- * @property {Object} propTypes Property types.
39
- * @static
40
- */
41
- static propTypes = {
42
- updateComment: PropTypes.func.isRequired,
43
- id: PropTypes.string,
44
- text: PropTypes.string,
45
- request: PropTypes.shape({
46
- loading: PropTypes.bool,
47
- loaded: PropTypes.bool,
48
- }).isRequired,
49
- open: PropTypes.bool.isRequired,
50
- onOk: PropTypes.func.isRequired,
51
- onCancel: PropTypes.func.isRequired,
52
- };
53
-
54
- /**
55
- * Default properties.
56
- * @property {Object} defaultProps Default properties.
57
- * @static
58
- */
59
- static defaultProps = {
60
- id: '',
61
- text: '',
62
- };
25
+ const CommentEditModal = (props) => {
26
+ const intl = useIntl();
27
+ const dispatch = useDispatch();
28
+ const { onOk, open, onCancel } = props;
29
+ const request = useSelector((state) => state.comments.update, shallowEqual);
63
30
 
64
- /**
65
- * Constructor
66
- * @method constructor
67
- * @param {Object} props Component properties
68
- * @constructs CommentEditModal
69
- */
70
- constructor(props) {
71
- super(props);
72
- this.onSubmit = this.onSubmit.bind(this);
73
- }
31
+ const prevRequestLoading = usePrevious(request.loading);
74
32
 
75
- /**
76
- * Component will receive props
77
- * @method componentWillReceiveProps
78
- * @param {Object} nextProps Next properties
79
- * @returns {undefined}
80
- */
81
- UNSAFE_componentWillReceiveProps(nextProps) {
82
- if (this.props.request.loading && nextProps.request.loaded) {
83
- this.props.onOk();
33
+ useEffect(() => {
34
+ if (prevRequestLoading && request.loaded) {
35
+ onOk();
84
36
  }
85
- }
37
+ }, [onOk, prevRequestLoading, request.loaded]);
86
38
 
87
- /**
88
- * Submit handler
89
- * @method onSubmit
90
- * @param {Object} data Form data
91
- * @returns {undefined}
92
- */
93
- onSubmit(data) {
94
- this.props.updateComment(this.props.id, data.text);
95
- }
39
+ const onSubmit = (data) => {
40
+ dispatch(updateComment(props.id, data.text));
41
+ };
96
42
 
97
- /**
98
- * Render method.
99
- * @method render
100
- * @returns {string} Markup for the component.
101
- */
102
- render() {
103
- return (
104
- this.props.open && (
105
- <ModalForm
106
- open={this.props.open}
107
- onSubmit={this.onSubmit}
108
- onCancel={this.props.onCancel}
109
- formData={{ text: this.props.text }}
110
- title={this.props.intl.formatMessage(messages.editComment)}
111
- schema={{
112
- fieldsets: [
113
- {
114
- id: 'default',
115
- title: this.props.intl.formatMessage(messages.default),
116
- fields: ['text'],
117
- },
118
- ],
119
- properties: {
120
- text: {
121
- title: this.props.intl.formatMessage(messages.comment),
122
- type: 'string',
123
- description: '',
124
- },
43
+ return (
44
+ props.open && (
45
+ <ModalForm
46
+ open={open}
47
+ onSubmit={onSubmit}
48
+ onCancel={onCancel}
49
+ formData={{ text: props.text }}
50
+ title={intl.formatMessage(messages.editComment)}
51
+ schema={{
52
+ fieldsets: [
53
+ {
54
+ id: 'default',
55
+ title: intl.formatMessage(messages.default),
56
+ fields: ['text'],
57
+ },
58
+ ],
59
+ properties: {
60
+ text: {
61
+ title: intl.formatMessage(messages.comment),
62
+ type: 'string',
63
+ description: '',
125
64
  },
126
- required: ['text'],
127
- }}
128
- />
129
- )
130
- );
131
- }
132
- }
65
+ },
66
+ required: ['text'],
67
+ }}
68
+ />
69
+ )
70
+ );
71
+ };
72
+
73
+ CommentEditModal.propTypes = {
74
+ id: PropTypes.string.isRequired,
75
+ text: PropTypes.string.isRequired,
76
+ request: PropTypes.shape({
77
+ loading: PropTypes.bool,
78
+ loaded: PropTypes.bool,
79
+ }),
80
+ open: PropTypes.bool.isRequired,
81
+ onOk: PropTypes.func.isRequired,
82
+ onCancel: PropTypes.func.isRequired,
83
+ };
84
+
85
+ CommentEditModal.defaultProps = {
86
+ id: '',
87
+ text: '',
88
+ };
133
89
 
134
- export default compose(
135
- injectIntl,
136
- connect(
137
- (state) => ({
138
- request: state.comments.update,
139
- }),
140
- { updateComment },
141
- ),
142
- )(CommentEditModal);
90
+ export default CommentEditModal;
@@ -1,22 +1,15 @@
1
- /**
2
- * Contact Form container.
3
- * @module components/theme/ContactForm/ContactForm
4
- */
5
-
6
- import React, { Component } from 'react';
7
- import PropTypes from 'prop-types';
8
- import { Helmet } from '@plone/volto/helpers';
9
- import { connect } from 'react-redux';
10
- import { compose } from 'redux';
1
+ import { useCallback, useEffect } from 'react';
11
2
  import { Portal } from 'react-portal';
12
3
  import { Container, Message, Icon } from 'semantic-ui-react';
13
- import { defineMessages, injectIntl } from 'react-intl';
14
- import { Link, withRouter } from 'react-router-dom';
4
+ import { defineMessages, useIntl } from 'react-intl';
5
+ import { Link, useHistory, useLocation } from 'react-router-dom';
15
6
  import { toast } from 'react-toastify';
16
7
 
17
- import { Form, Toolbar, Toast } from '@plone/volto/components';
18
8
  import { emailNotification } from '@plone/volto/actions';
19
- import { getBaseUrl } from '@plone/volto/helpers';
9
+ import { useDispatch, useSelector } from 'react-redux';
10
+ import { Form, Toolbar, Toast } from '@plone/volto/components';
11
+ import { getBaseUrl, Helmet, usePrevious } from '@plone/volto/helpers';
12
+ import { useClient } from '@plone/volto/hooks';
20
13
 
21
14
  const messages = defineMessages({
22
15
  send: {
@@ -65,195 +58,118 @@ const messages = defineMessages({
65
58
  },
66
59
  });
67
60
 
68
- /**
69
- * ContactForm class.
70
- * @class ContactForm
71
- * @extends Component
72
- */
73
- export class ContactFormComponent extends Component {
74
- /**
75
- * Property types.
76
- * @property {Object} propTypes Property types.
77
- * @static
78
- */
79
- static propTypes = {
80
- emailNotification: PropTypes.func.isRequired,
81
- error: PropTypes.shape({
82
- message: PropTypes.string,
83
- }),
84
- loading: PropTypes.bool,
85
- loaded: PropTypes.bool,
86
- pathname: PropTypes.string.isRequired,
87
- };
61
+ const useEmailNotification = () => {
62
+ const loading = useSelector((state) => state.emailNotification.loading);
63
+ const loaded = useSelector((state) => state.emailNotification.loaded);
64
+ const error = useSelector((state) => state.emailNotification.error);
88
65
 
89
- /**
90
- * Default properties.
91
- * @property {Object} defaultProps Default properties.
92
- * @static
93
- */
94
- static defaultProps = {
95
- error: null,
96
- loading: null,
97
- loaded: null,
98
- };
66
+ return { loading, loaded, error };
67
+ };
68
+
69
+ const ContactFormComponent = () => {
70
+ const history = useHistory();
71
+ const { pathname } = useLocation();
72
+ const dispatch = useDispatch();
73
+ const intl = useIntl();
74
+ const isClient = useClient();
99
75
 
100
- /**
101
- * Constructor
102
- * @method constructor
103
- * @param {Object} props Component properties
104
- * @constructs WysiwygEditor
105
- */
106
- constructor(props) {
107
- super(props);
108
- this.onSubmit = this.onSubmit.bind(this);
109
- this.onCancel = this.onCancel.bind(this);
110
- this.state = { isClient: false };
111
- }
76
+ const { loaded, loading, error } = useEmailNotification();
112
77
 
113
- /**
114
- * Component will receive props
115
- * @method componentWillReceiveProps
116
- * @param {Object} nextProps Next properties
117
- * @returns {undefined}
118
- */
119
- UNSAFE_componentWillReceiveProps(nextProps) {
120
- if (this.props.loading && nextProps.loaded) {
78
+ const prevloading = usePrevious(loading);
79
+
80
+ useEffect(() => {
81
+ if (prevloading && loaded) {
121
82
  toast.success(
122
83
  <Toast
123
84
  success
124
- title={this.props.intl.formatMessage(messages.success)}
125
- content={this.props.intl.formatMessage(messages.messageSent)}
85
+ title={intl.formatMessage(messages.success)}
86
+ content={intl.formatMessage(messages.messageSent)}
126
87
  />,
127
88
  );
128
89
  }
129
- }
90
+ }, [intl, loaded, prevloading]);
130
91
 
131
- /**
132
- * Component did mount
133
- * @method componentDidMount
134
- * @returns {undefined}
135
- */
136
- componentDidMount() {
137
- this.setState({ isClient: true });
138
- }
92
+ const onSubmit = (data) => {
93
+ const { from, message, name, subject } = data;
94
+ dispatch(emailNotification(from, message, name, subject));
95
+ };
139
96
 
140
- /**
141
- * On submit handler
142
- * @method onSubmit
143
- * @param {Object} data Data object.
144
- * @returns {undefined}
145
- */
146
- onSubmit(data) {
147
- this.props.emailNotification(
148
- data.from,
149
- data.message,
150
- data.name,
151
- data.subject,
152
- );
153
- }
97
+ const onCancel = useCallback(() => {
98
+ history.goBack();
99
+ }, [history]);
154
100
 
155
- /**
156
- * Cancel handler
157
- * @method onCancel
158
- * @returns {undefined}
159
- */
160
- onCancel() {
161
- this.props.history.goBack();
162
- }
163
- /**
164
- * Render method.
165
- * @method render
166
- * @returns {string} Markup for the component.
167
- */
168
- render() {
169
- return (
170
- <div id="contact-form">
171
- <Container id="view">
172
- <Helmet title={this.props.intl.formatMessage(messages.contactForm)} />
173
- {this.props.error && (
174
- <Message
175
- icon="warning"
176
- negative
177
- attached
178
- header={this.props.intl.formatMessage(messages.error)}
179
- content={this.props.error.message}
180
- />
181
- )}
182
- <Form
183
- onSubmit={this.onSubmit}
184
- onCancel={this.onCancel}
185
- formData={{ blocksLayoutFieldname: {} }}
186
- submitLabel={this.props.intl.formatMessage(messages.send)}
187
- resetAfterSubmit
188
- title={this.props.intl.formatMessage(messages.contactForm)}
189
- loading={this.props.loading}
190
- schema={{
191
- fieldsets: [
192
- {
193
- fields: ['name', 'from', 'subject', 'message'],
194
- id: 'default',
195
- title: this.props.intl.formatMessage(messages.default),
196
- },
197
- ],
198
- properties: {
199
- name: {
200
- title: this.props.intl.formatMessage(messages.name),
201
- type: 'string',
202
- },
203
- from: {
204
- title: this.props.intl.formatMessage(messages.from),
205
- type: 'email',
206
- },
207
- subject: {
208
- title: this.props.intl.formatMessage(messages.subject),
209
- type: 'string',
210
- },
211
- message: {
212
- title: this.props.intl.formatMessage(messages.message),
213
- type: 'string',
214
- widget: 'textarea',
215
- },
216
- },
217
- required: ['from', 'message'],
218
- }}
101
+ return (
102
+ <div id="contact-form">
103
+ <Container id="view">
104
+ <Helmet title={intl.formatMessage(messages.contactForm)} />
105
+ {error && (
106
+ <Message
107
+ icon="warning"
108
+ negative
109
+ attached
110
+ header={intl.formatMessage(messages.error)}
111
+ content={error.message}
219
112
  />
220
- {this.state.isClient && (
221
- <Portal node={document.getElementById('toolbar')}>
222
- <Toolbar
223
- pathname={this.props.pathname}
224
- hideDefaultViewButtons
225
- inner={
226
- <Link
227
- to={`${getBaseUrl(this.props.pathname)}`}
228
- className="item"
229
- >
230
- <Icon
231
- name="arrow left"
232
- size="big"
233
- color="blue"
234
- title={this.props.intl.formatMessage(messages.back)}
235
- />
236
- </Link>
237
- }
238
- />
239
- </Portal>
240
- )}
241
- </Container>
242
- </div>
243
- );
244
- }
245
- }
113
+ )}
114
+ <Form
115
+ onSubmit={onSubmit}
116
+ onCancel={onCancel}
117
+ formData={{ blocksLayoutFieldname: {} }}
118
+ submitLabel={intl.formatMessage(messages.send)}
119
+ resetAfterSubmit
120
+ title={intl.formatMessage(messages.contactForm)}
121
+ loading={loading}
122
+ schema={{
123
+ fieldsets: [
124
+ {
125
+ fields: ['name', 'from', 'subject', 'message'],
126
+ id: 'default',
127
+ title: intl.formatMessage(messages.default),
128
+ },
129
+ ],
130
+ properties: {
131
+ name: {
132
+ title: intl.formatMessage(messages.name),
133
+ type: 'string',
134
+ },
135
+ from: {
136
+ title: intl.formatMessage(messages.from),
137
+ type: 'email',
138
+ },
139
+ subject: {
140
+ title: intl.formatMessage(messages.subject),
141
+ type: 'string',
142
+ },
143
+ message: {
144
+ title: intl.formatMessage(messages.message),
145
+ type: 'string',
146
+ widget: 'textarea',
147
+ },
148
+ },
149
+ required: ['from', 'message'],
150
+ }}
151
+ />
152
+ {isClient && (
153
+ <Portal node={document.getElementById('toolbar')}>
154
+ <Toolbar
155
+ pathname={pathname}
156
+ hideDefaultViewButtons
157
+ inner={
158
+ <Link to={`${getBaseUrl(pathname)}`} className="item">
159
+ <Icon
160
+ name="arrow left"
161
+ size="big"
162
+ color="blue"
163
+ title={intl.formatMessage(messages.back)}
164
+ />
165
+ </Link>
166
+ }
167
+ />
168
+ </Portal>
169
+ )}
170
+ </Container>
171
+ </div>
172
+ );
173
+ };
246
174
 
247
- export default compose(
248
- withRouter,
249
- injectIntl,
250
- connect(
251
- (state, props) => ({
252
- loading: state.emailNotification.loading,
253
- loaded: state.emailNotification.loaded,
254
- error: state.emailNotification.error,
255
- pathname: props.location.pathname,
256
- }),
257
- { emailNotification },
258
- ),
259
- )(ContactFormComponent);
175
+ export default ContactFormComponent;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ContactFormComponent } from './ContactForm';
2
+ import ContactFormComponent from './ContactForm';
3
3
  import { injectIntl } from 'react-intl';
4
4
  import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook';
5
5
 
@@ -10,7 +10,6 @@ jest.mock('react-portal', () => ({
10
10
  }));
11
11
 
12
12
  const mockStore = configureStore();
13
-
14
13
  describe('Contact form', () => {
15
14
  it('renders a contact form', () => {
16
15
  const store = mockStore({
@@ -29,7 +28,7 @@ describe('Contact form', () => {
29
28
  const component = renderer.create(
30
29
  <Provider store={store}>
31
30
  <MemoryRouter>
32
- <ContactForm location={{ pathname: '/blog' }} />
31
+ <ContactForm />
33
32
  </MemoryRouter>
34
33
  </Provider>,
35
34
  );
@@ -56,7 +55,7 @@ describe('Contact form', () => {
56
55
  const component = renderer.create(
57
56
  <Provider store={store}>
58
57
  <MemoryRouter>
59
- <ContactForm location={{ pathname: '/' }} />
58
+ <ContactForm />
60
59
  </MemoryRouter>
61
60
  </Provider>,
62
61
  );
@@ -239,7 +239,7 @@ class Login extends Component {
239
239
  <Input
240
240
  type="password"
241
241
  id="password"
242
- autocomplete="current-password"
242
+ autoComplete="current-password"
243
243
  name="password"
244
244
  placeholder={this.props.intl.formatMessage(
245
245
  messages.password,