@plone/volto 19.0.0 → 19.1.1

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 (146) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/locales/af/LC_MESSAGES/volto.po +5 -5
  3. package/locales/af.json +1 -1
  4. package/locales/ar/LC_MESSAGES/volto.po +5 -5
  5. package/locales/ar.json +1 -1
  6. package/locales/bg/LC_MESSAGES/volto.po +5 -5
  7. package/locales/bg.json +1 -1
  8. package/locales/bn/LC_MESSAGES/volto.po +5 -5
  9. package/locales/bn.json +1 -1
  10. package/locales/ca/LC_MESSAGES/volto.po +5 -5
  11. package/locales/ca.json +1 -1
  12. package/locales/cs/LC_MESSAGES/volto.po +5 -5
  13. package/locales/cs.json +1 -1
  14. package/locales/cy/LC_MESSAGES/volto.po +5 -5
  15. package/locales/cy.json +1 -1
  16. package/locales/da/LC_MESSAGES/volto.po +5 -5
  17. package/locales/da.json +1 -1
  18. package/locales/de/LC_MESSAGES/volto.po +5 -5
  19. package/locales/de.json +1 -1
  20. package/locales/el/LC_MESSAGES/volto.po +5 -5
  21. package/locales/el.json +1 -1
  22. package/locales/en/LC_MESSAGES/volto.po +5 -5
  23. package/locales/en.json +1 -1
  24. package/locales/en_AU/LC_MESSAGES/volto.po +5 -5
  25. package/locales/en_AU.json +1 -1
  26. package/locales/en_GB/LC_MESSAGES/volto.po +5 -5
  27. package/locales/en_GB.json +1 -1
  28. package/locales/eo/LC_MESSAGES/volto.po +5 -5
  29. package/locales/eo.json +1 -1
  30. package/locales/es/LC_MESSAGES/volto.po +5 -5
  31. package/locales/es.json +1 -1
  32. package/locales/et/LC_MESSAGES/volto.po +5 -5
  33. package/locales/et.json +1 -1
  34. package/locales/eu/LC_MESSAGES/volto.po +5 -5
  35. package/locales/eu.json +1 -1
  36. package/locales/fa/LC_MESSAGES/volto.po +5 -5
  37. package/locales/fa.json +1 -1
  38. package/locales/fi/LC_MESSAGES/volto.po +5 -5
  39. package/locales/fi.json +1 -1
  40. package/locales/fr/LC_MESSAGES/volto.po +5 -5
  41. package/locales/fr.json +1 -1
  42. package/locales/fu/LC_MESSAGES/volto.po +5 -5
  43. package/locales/fu.json +1 -1
  44. package/locales/gl/LC_MESSAGES/volto.po +5 -5
  45. package/locales/gl.json +1 -1
  46. package/locales/he/LC_MESSAGES/volto.po +5 -5
  47. package/locales/he.json +1 -1
  48. package/locales/hi/LC_MESSAGES/volto.po +5 -5
  49. package/locales/hi.json +1 -1
  50. package/locales/hr/LC_MESSAGES/volto.po +5 -5
  51. package/locales/hr.json +1 -1
  52. package/locales/hu/LC_MESSAGES/volto.po +5 -5
  53. package/locales/hu.json +1 -1
  54. package/locales/hy/LC_MESSAGES/volto.po +5 -5
  55. package/locales/hy.json +1 -1
  56. package/locales/id/LC_MESSAGES/volto.po +5 -5
  57. package/locales/id.json +1 -1
  58. package/locales/it/LC_MESSAGES/volto.po +5 -5
  59. package/locales/it.json +1 -1
  60. package/locales/ja/LC_MESSAGES/volto.po +5 -5
  61. package/locales/ja.json +1 -1
  62. package/locales/ka/LC_MESSAGES/volto.po +5 -5
  63. package/locales/ka.json +1 -1
  64. package/locales/kn/LC_MESSAGES/volto.po +5 -5
  65. package/locales/kn.json +1 -1
  66. package/locales/ko/LC_MESSAGES/volto.po +5 -5
  67. package/locales/ko.json +1 -1
  68. package/locales/lt/LC_MESSAGES/volto.po +5 -5
  69. package/locales/lt.json +1 -1
  70. package/locales/lv/LC_MESSAGES/volto.po +5 -5
  71. package/locales/lv.json +1 -1
  72. package/locales/mi/LC_MESSAGES/volto.po +5 -5
  73. package/locales/mi.json +1 -1
  74. package/locales/mk/LC_MESSAGES/volto.po +5 -5
  75. package/locales/mk.json +1 -1
  76. package/locales/my/LC_MESSAGES/volto.po +5 -5
  77. package/locales/my.json +1 -1
  78. package/locales/nb_NO/LC_MESSAGES/volto.po +5 -5
  79. package/locales/nb_NO.json +1 -1
  80. package/locales/nl/LC_MESSAGES/volto.po +5 -5
  81. package/locales/nl.json +1 -1
  82. package/locales/nn/LC_MESSAGES/volto.po +5 -5
  83. package/locales/nn.json +1 -1
  84. package/locales/pl/LC_MESSAGES/volto.po +5 -5
  85. package/locales/pl.json +1 -1
  86. package/locales/pt/LC_MESSAGES/volto.po +5 -5
  87. package/locales/pt.json +1 -1
  88. package/locales/pt_BR/LC_MESSAGES/volto.po +5 -5
  89. package/locales/pt_BR.json +1 -1
  90. package/locales/rm/LC_MESSAGES/volto.po +5 -5
  91. package/locales/rm.json +1 -1
  92. package/locales/ro/LC_MESSAGES/volto.po +5 -5
  93. package/locales/ro.json +1 -1
  94. package/locales/ru/LC_MESSAGES/volto.po +5 -5
  95. package/locales/ru.json +1 -1
  96. package/locales/sk/LC_MESSAGES/volto.po +5 -5
  97. package/locales/sk.json +1 -1
  98. package/locales/sl/LC_MESSAGES/volto.po +5 -5
  99. package/locales/sl.json +1 -1
  100. package/locales/sm/LC_MESSAGES/volto.po +5 -5
  101. package/locales/sm.json +1 -1
  102. package/locales/sq/LC_MESSAGES/volto.po +5 -5
  103. package/locales/sq.json +1 -1
  104. package/locales/sr/LC_MESSAGES/volto.po +5 -5
  105. package/locales/sr.json +1 -1
  106. package/locales/sr@cyrl/LC_MESSAGES/volto.po +5 -5
  107. package/locales/sr@cyrl.json +1 -1
  108. package/locales/sr@latn/LC_MESSAGES/volto.po +5 -5
  109. package/locales/sr@latn.json +1 -1
  110. package/locales/sv/LC_MESSAGES/volto.po +5 -5
  111. package/locales/sv.json +1 -1
  112. package/locales/ta/LC_MESSAGES/volto.po +5 -5
  113. package/locales/ta.json +1 -1
  114. package/locales/te/LC_MESSAGES/volto.po +5 -5
  115. package/locales/te.json +1 -1
  116. package/locales/th/LC_MESSAGES/volto.po +5 -5
  117. package/locales/th.json +1 -1
  118. package/locales/to/LC_MESSAGES/volto.po +5 -5
  119. package/locales/to.json +1 -1
  120. package/locales/tr/LC_MESSAGES/volto.po +5 -5
  121. package/locales/tr.json +1 -1
  122. package/locales/uk/LC_MESSAGES/volto.po +5 -5
  123. package/locales/uk.json +1 -1
  124. package/locales/vi/LC_MESSAGES/volto.po +5 -5
  125. package/locales/vi.json +1 -1
  126. package/locales/volto.pot +5 -5
  127. package/locales/zh_CN/LC_MESSAGES/volto.po +5 -5
  128. package/locales/zh_CN.json +1 -1
  129. package/locales/zh_Hant/LC_MESSAGES/volto.po +5 -5
  130. package/locales/zh_Hant.json +1 -1
  131. package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +5 -5
  132. package/locales/zh_Hant_HK.json +1 -1
  133. package/package.json +12 -13
  134. package/src/components/manage/Blocks/Image/View.test.jsx +8 -8
  135. package/src/components/manage/Blocks/Maps/Body.jsx +37 -0
  136. package/src/components/manage/Blocks/Maps/Edit.jsx +6 -21
  137. package/src/components/manage/Blocks/Maps/View.jsx +16 -25
  138. package/src/components/manage/Controlpanels/BlockTypes.tsx +3 -3
  139. package/src/components/manage/Controlpanels/VersionOverview.jsx +19 -6
  140. package/src/components/manage/History/History.jsx +209 -300
  141. package/src/components/manage/History/History.test.jsx +9 -5
  142. package/src/components/manage/Toolbar/Toolbar.jsx +7 -2
  143. package/types/components/manage/Blocks/Maps/Body.d.ts +9 -0
  144. package/types/components/manage/Blocks/Maps/View.d.ts +1 -1
  145. package/types/components/manage/Controlpanels/VersionOverview.d.ts +2 -1
  146. package/types/components/manage/Controlpanels/index.d.ts +1 -0
@@ -1,13 +1,7 @@
1
- /**
2
- * History component.
3
- * @module components/manage/History/History
4
- */
5
-
6
- import React, { Component } from 'react';
7
- import PropTypes from 'prop-types';
1
+ import { useEffect, useMemo, useCallback } from 'react';
8
2
  import Helmet from '@plone/volto/helpers/Helmet/Helmet';
9
- import { Link } from 'react-router-dom';
10
- import { connect } from 'react-redux';
3
+ import { Link, useLocation } from 'react-router-dom';
4
+ import { useDispatch, useSelector } from 'react-redux';
11
5
  import { compose } from 'redux';
12
6
  import {
13
7
  Container as SemanticContainer,
@@ -21,7 +15,7 @@ import map from 'lodash/map';
21
15
  import reverse from 'lodash/reverse';
22
16
  import find from 'lodash/find';
23
17
  import { createPortal } from 'react-dom';
24
- import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
18
+ import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
25
19
  import { asyncConnect } from '@plone/volto/helpers/AsyncConnect';
26
20
 
27
21
  import FormattedDate from '@plone/volto/components/theme/FormattedDate/FormattedDate';
@@ -35,6 +29,7 @@ import {
35
29
  } from '@plone/volto/actions/history/history';
36
30
  import { listActions } from '@plone/volto/actions/actions/actions';
37
31
  import { getBaseUrl } from '@plone/volto/helpers/Url/Url';
32
+ import { useClient } from '@plone/volto/hooks/client/useClient';
38
33
  import config from '@plone/volto/registry';
39
34
 
40
35
  import backSVG from '@plone/volto/icons/back.svg';
@@ -50,321 +45,235 @@ const messages = defineMessages({
50
45
  },
51
46
  });
52
47
 
53
- /**
54
- * History class.
55
- * @class History
56
- * @extends Component
57
- */
58
- class History extends Component {
59
- /**
60
- * Property types.
61
- * @property {Object} propTypes Property types.
62
- * @static
63
- */
64
- static propTypes = {
65
- getHistory: PropTypes.func.isRequired,
66
- revertHistory: PropTypes.func.isRequired,
67
- revertRequest: PropTypes.shape({
68
- loaded: PropTypes.bool,
69
- loading: PropTypes.bool,
70
- }).isRequired,
71
- pathname: PropTypes.string.isRequired,
72
- entries: PropTypes.arrayOf(
73
- PropTypes.shape({
74
- transition_title: PropTypes.string,
75
- type: PropTypes.string,
76
- action: PropTypes.string,
77
- state_title: PropTypes.string,
78
- time: PropTypes.string,
79
- comments: PropTypes.string,
80
- actor: PropTypes.shape({ fullname: PropTypes.string }),
81
- }),
82
- ).isRequired,
83
- title: PropTypes.string.isRequired,
84
- };
85
-
86
- /**
87
- * Constructor
88
- * @method constructor
89
- * @param {Object} props Component properties
90
- * @constructs Workflow
91
- */
92
- constructor(props) {
93
- super(props);
94
- this.onRevert = this.onRevert.bind(this);
95
- this.state = { isClient: false };
96
- }
48
+ const History = (props) => {
49
+ const { staticContext } = props;
50
+ const isClient = useClient();
51
+ const dispatch = useDispatch();
52
+ const location = useLocation();
53
+ const pathname = location.pathname;
54
+ const intl = useIntl();
97
55
 
98
- /**
99
- * Component did mount
100
- * @method componentDidMount
101
- * @returns {undefined}
102
- */
103
- componentDidMount() {
104
- this.props.getHistory(getBaseUrl(this.props.pathname));
105
- this.setState({ isClient: true });
106
- }
56
+ const objectActions = useSelector((state) => state.actions.actions.object);
57
+ const token = useSelector((state) => state.userSession.token);
58
+ const entries = useSelector((state) => state.history.entries);
59
+ const title = useSelector((state) => state.content.data?.title);
107
60
 
108
- /**
109
- * Component will receive props
110
- * @method componentWillReceiveProps
111
- * @param {Object} nextProps Next properties
112
- * @returns {undefined}
113
- */
114
- UNSAFE_componentWillReceiveProps(nextProps) {
115
- if (this.props.revertRequest.loading && nextProps.revertRequest.loaded) {
116
- this.props.getHistory(getBaseUrl(this.props.pathname));
117
- }
118
- }
61
+ const onRevert = useCallback(
62
+ (event, { value }) => {
63
+ const baseUrl = getBaseUrl(pathname);
64
+ dispatch(revertHistory(baseUrl, value)).then(() => {
65
+ dispatch(getHistory(baseUrl));
66
+ });
67
+ },
68
+ [dispatch, pathname],
69
+ );
119
70
 
120
- /**
121
- * On revert
122
- * @method onRevert
123
- * @param {object} event Event object
124
- * @param {number} value Value
125
- * @returns {undefined}
126
- */
127
- onRevert(event, { value }) {
128
- this.props.revertHistory(getBaseUrl(this.props.pathname), value);
129
- }
71
+ useEffect(() => {
72
+ dispatch(getHistory(getBaseUrl(pathname)));
73
+ }, [dispatch, pathname]);
130
74
 
131
- processHistoryEntries = () => {
132
- // Getting the history entries from the props
133
- // No clue why the reverse(concat()) is necessary
134
- const entries = reverse(concat(this.props.entries));
135
- let title = entries.length > 0 ? entries[0].state_title : '';
136
- for (let x = 1; x < entries.length; x += 1) {
137
- entries[x].prev_state_title = title;
138
- title = entries[x].state_title || title;
75
+ const processedEntries = useMemo(() => {
76
+ const result = reverse(concat(entries));
77
+ let title = result.length > 0 ? result[0].state_title : '';
78
+ for (let x = 1; x < result.length; x += 1) {
79
+ result[x].prev_state_title = title;
80
+ title = result[x].state_title || title;
139
81
  }
140
- // We reverse them again
141
- reverse(entries);
82
+ reverse(result);
142
83
 
143
- // We identify the latest 'versioning' entry and mark it
144
- const current_version = find(entries, (item) => item.type === 'versioning');
84
+ const current_version = find(result, (item) => item.type === 'versioning');
145
85
  if (current_version) {
146
86
  current_version.is_current = true;
147
87
  }
148
- return entries;
149
- };
88
+ return result;
89
+ }, [entries]);
150
90
 
151
- /**
152
- * Render method.
153
- * @method render
154
- * @returns {string} Markup for the component.
155
- */
156
- render() {
157
- const historyAction = find(this.props.objectActions, {
158
- id: 'history',
159
- });
160
- const entries = this.processHistoryEntries();
91
+ const historyAction = find(objectActions, {
92
+ id: 'history',
93
+ });
161
94
 
162
- const Container =
163
- config.getComponent({ name: 'Container' }).component || SemanticContainer;
95
+ const Container =
96
+ config.getComponent({ name: 'Container' }).component || SemanticContainer;
164
97
 
165
- return !historyAction ? (
166
- <>
167
- {this.props.token ? (
168
- <Forbidden
169
- pathname={this.props.pathname}
170
- staticContext={this.props.staticContext}
98
+ return !historyAction ? (
99
+ <>
100
+ {token ? (
101
+ <Forbidden pathname={pathname} staticContext={staticContext} />
102
+ ) : (
103
+ <Unauthorized pathname={pathname} staticContext={staticContext} />
104
+ )}
105
+ </>
106
+ ) : (
107
+ <Container id="page-history">
108
+ <Helmet title={intl.formatMessage(messages.history)} />
109
+ <Segment.Group raised>
110
+ <Segment className="primary">
111
+ <FormattedMessage
112
+ id="History of {title}"
113
+ defaultMessage="History of {title}"
114
+ values={{
115
+ title: <q>{title}</q>,
116
+ }}
171
117
  />
172
- ) : (
173
- <Unauthorized
174
- pathname={this.props.pathname}
175
- staticContext={this.props.staticContext}
118
+ </Segment>
119
+ <Segment secondary>
120
+ <FormattedMessage
121
+ id="You can view the history of your item below."
122
+ defaultMessage="You can view the history of your item below."
176
123
  />
177
- )}
178
- </>
179
- ) : (
180
- <Container id="page-history">
181
- <Helmet title={this.props.intl.formatMessage(messages.history)} />
182
- <Segment.Group raised>
183
- <Segment className="primary">
184
- <FormattedMessage
185
- id="History of {title}"
186
- defaultMessage="History of {title}"
187
- values={{
188
- title: <q>{this.props.title}</q>,
189
- }}
190
- />
191
- </Segment>
192
- <Segment secondary>
193
- <FormattedMessage
194
- id="You can view the history of your item below."
195
- defaultMessage="You can view the history of your item below."
196
- />
197
- </Segment>
198
- <Table selectable compact singleLine attached>
199
- <Table.Header>
200
- <Table.Row>
201
- <Table.HeaderCell width={1}>
202
- <FormattedMessage
203
- id="History Version Number"
204
- defaultMessage="#"
205
- />
206
- </Table.HeaderCell>
207
- <Table.HeaderCell width={4}>
208
- <FormattedMessage id="What" defaultMessage="What" />
209
- </Table.HeaderCell>
210
- <Table.HeaderCell width={4}>
211
- <FormattedMessage id="Who" defaultMessage="Who" />
212
- </Table.HeaderCell>
213
- <Table.HeaderCell width={4}>
214
- <FormattedMessage id="When" defaultMessage="When" />
215
- </Table.HeaderCell>
216
- <Table.HeaderCell width={4}>
217
- <FormattedMessage
218
- id="Change Note"
219
- defaultMessage="Change Note"
220
- />
221
- </Table.HeaderCell>
222
- <Table.HeaderCell />
223
- </Table.Row>
224
- </Table.Header>
225
- <Table.Body>
226
- {map(entries, (entry) => (
227
- <Table.Row key={entry.time}>
228
- <Table.Cell>
229
- {('version' in entry && entry.version > 0 && (
230
- <Link
231
- className="item"
232
- to={`${getBaseUrl(this.props.pathname)}/diff?one=${
233
- entry.version - 1
234
- }&two=${entry.version}`}
235
- >
236
- {entry.version}
237
- </Link>
238
- )) || <span>{entry.version}</span>}
239
- </Table.Cell>
240
- <Table.Cell>
241
- {('version' in entry && entry.version > 0 && (
242
- <Link
243
- className="item"
244
- to={`${getBaseUrl(this.props.pathname)}/diff?one=${
245
- entry.version - 1
246
- }&two=${entry.version}`}
247
- >
248
- {entry.transition_title}
249
- </Link>
250
- )) || (
251
- <span>
252
- {entry.transition_title}
253
- {entry.type === 'workflow' &&
254
- ` (${
255
- entry.action ? `${entry.prev_state_title} → ` : ''
256
- }${entry.state_title})`}
257
- </span>
258
- )}
259
- </Table.Cell>
260
- <Table.Cell>{entry.actor.fullname}</Table.Cell>
261
- <Table.Cell>
262
- <FormattedDate date={entry.time} />
263
- </Table.Cell>
264
- <Table.Cell>{entry.comments}</Table.Cell>
265
- <Table.Cell>
266
- {entry.type === 'versioning' && (
267
- <Dropdown icon="ellipsis horizontal">
268
- <Dropdown.Menu className="left">
269
- {'version' in entry && entry.version > 0 && (
270
- <Link
271
- className="item"
272
- to={`${getBaseUrl(
273
- this.props.pathname,
274
- )}/diff?one=${entry.version - 1}&two=${
275
- entry.version
276
- }`}
124
+ </Segment>
125
+ <Table selectable compact singleLine attached>
126
+ <Table.Header>
127
+ <Table.Row>
128
+ <Table.HeaderCell width={1}>
129
+ <FormattedMessage
130
+ id="History Version Number"
131
+ defaultMessage="#"
132
+ />
133
+ </Table.HeaderCell>
134
+ <Table.HeaderCell width={4}>
135
+ <FormattedMessage id="What" defaultMessage="What" />
136
+ </Table.HeaderCell>
137
+ <Table.HeaderCell width={4}>
138
+ <FormattedMessage id="Who" defaultMessage="Who" />
139
+ </Table.HeaderCell>
140
+ <Table.HeaderCell width={4}>
141
+ <FormattedMessage id="When" defaultMessage="When" />
142
+ </Table.HeaderCell>
143
+ <Table.HeaderCell width={4}>
144
+ <FormattedMessage
145
+ id="Change Note"
146
+ defaultMessage="Change Note"
147
+ />
148
+ </Table.HeaderCell>
149
+ <Table.HeaderCell />
150
+ </Table.Row>
151
+ </Table.Header>
152
+ <Table.Body>
153
+ {map(processedEntries, (entry) => (
154
+ <Table.Row key={entry.version ?? entry.time}>
155
+ <Table.Cell>
156
+ {('version' in entry && entry.version > 0 && (
157
+ <Link
158
+ className="item"
159
+ to={`${getBaseUrl(pathname)}/diff?one=${
160
+ entry.version - 1
161
+ }&two=${entry.version}`}
162
+ >
163
+ {entry.version}
164
+ </Link>
165
+ )) || <span>{entry.version}</span>}
166
+ </Table.Cell>
167
+ <Table.Cell>
168
+ {('version' in entry && entry.version > 0 && (
169
+ <Link
170
+ className="item"
171
+ to={`${getBaseUrl(pathname)}/diff?one=${
172
+ entry.version - 1
173
+ }&two=${entry.version}`}
174
+ >
175
+ {entry.transition_title}
176
+ </Link>
177
+ )) || (
178
+ <span>
179
+ {entry.transition_title}
180
+ {entry.type === 'workflow' &&
181
+ ` (${
182
+ entry.action ? `${entry.prev_state_title} → ` : ''
183
+ }${entry.state_title})`}
184
+ </span>
185
+ )}
186
+ </Table.Cell>
187
+ <Table.Cell>{entry.actor.fullname}</Table.Cell>
188
+ <Table.Cell>
189
+ <FormattedDate date={entry.time} />
190
+ </Table.Cell>
191
+ <Table.Cell>{entry.comments}</Table.Cell>
192
+ <Table.Cell>
193
+ {entry.type === 'versioning' && (
194
+ <Dropdown icon="ellipsis horizontal">
195
+ <Dropdown.Menu className="left">
196
+ {'version' in entry && entry.version > 0 && (
197
+ <Link
198
+ className="item"
199
+ to={`${getBaseUrl(
200
+ pathname,
201
+ )}/diff?one=${entry.version - 1}&two=${
202
+ entry.version
203
+ }`}
204
+ >
205
+ <Icon name="copy" />{' '}
206
+ <FormattedMessage
207
+ id="View changes"
208
+ defaultMessage="View changes"
209
+ />
210
+ </Link>
211
+ )}
212
+ {'version' in entry && (
213
+ <Link
214
+ className="item"
215
+ to={`${getBaseUrl(pathname)}?version=${
216
+ entry.version
217
+ }`}
218
+ >
219
+ <Icon name="eye" />{' '}
220
+ <FormattedMessage
221
+ id="View this revision"
222
+ defaultMessage="View this revision"
223
+ />
224
+ </Link>
225
+ )}
226
+ {'version' in entry &&
227
+ entry.may_revert &&
228
+ !entry.is_current && (
229
+ <Dropdown.Item
230
+ value={entry.version}
231
+ onClick={onRevert}
277
232
  >
278
- <Icon name="copy" />{' '}
233
+ <Icon name="undo" />{' '}
279
234
  <FormattedMessage
280
- id="View changes"
281
- defaultMessage="View changes"
235
+ id="Revert to this revision"
236
+ defaultMessage="Revert to this revision"
282
237
  />
283
- </Link>
238
+ </Dropdown.Item>
284
239
  )}
285
- {'version' in entry && (
286
- <Link
287
- className="item"
288
- to={`${getBaseUrl(this.props.pathname)}?version=${
289
- entry.version
290
- }`}
291
- >
292
- <Icon name="eye" />{' '}
293
- <FormattedMessage
294
- id="View this revision"
295
- defaultMessage="View this revision"
296
- />
297
- </Link>
298
- )}
299
- {'version' in entry &&
300
- entry.may_revert &&
301
- !entry.is_current && (
302
- <Dropdown.Item
303
- value={entry.version}
304
- onClick={this.onRevert}
305
- >
306
- <Icon name="undo" />{' '}
307
- <FormattedMessage
308
- id="Revert to this revision"
309
- defaultMessage="Revert to this revision"
310
- />
311
- </Dropdown.Item>
312
- )}
313
- </Dropdown.Menu>
314
- </Dropdown>
315
- )}
316
- </Table.Cell>
317
- </Table.Row>
318
- ))}
319
- </Table.Body>
320
- </Table>
321
- </Segment.Group>
322
- {this.state.isClient &&
323
- createPortal(
324
- <Toolbar
325
- pathname={this.props.pathname}
326
- hideDefaultViewButtons
327
- inner={
328
- <Link
329
- to={`${getBaseUrl(this.props.pathname)}`}
330
- className="item"
331
- >
332
- <IconNext
333
- name={backSVG}
334
- className="contents circled"
335
- size="30px"
336
- title={this.props.intl.formatMessage(messages.back)}
337
- />
338
- </Link>
339
- }
340
- />,
341
- document.getElementById('toolbar'),
342
- )}
343
- </Container>
344
- );
345
- }
346
- }
240
+ </Dropdown.Menu>
241
+ </Dropdown>
242
+ )}
243
+ </Table.Cell>
244
+ </Table.Row>
245
+ ))}
246
+ </Table.Body>
247
+ </Table>
248
+ </Segment.Group>
249
+ {isClient &&
250
+ createPortal(
251
+ <Toolbar
252
+ pathname={pathname}
253
+ hideDefaultViewButtons
254
+ inner={
255
+ <Link to={`${getBaseUrl(pathname)}`} className="item">
256
+ <IconNext
257
+ name={backSVG}
258
+ className="contents circled"
259
+ size="30px"
260
+ title={intl.formatMessage(messages.back)}
261
+ />
262
+ </Link>
263
+ }
264
+ />,
265
+ document.getElementById('toolbar'),
266
+ )}
267
+ </Container>
268
+ );
269
+ };
347
270
 
348
271
  export default compose(
349
- injectIntl,
350
272
  asyncConnect([
351
273
  {
352
274
  key: 'actions',
353
- // Dispatch async/await to make the operation synchronous, otherwise it returns
354
- // before the promise is resolved
355
275
  promise: async ({ location, store: { dispatch } }) =>
356
276
  await dispatch(listActions(getBaseUrl(location.pathname))),
357
277
  },
358
278
  ]),
359
- connect(
360
- (state, props) => ({
361
- objectActions: state.actions.actions.object,
362
- token: state.userSession.token,
363
- entries: state.history.entries,
364
- pathname: props.location.pathname,
365
- title: state.content.data?.title,
366
- revertRequest: state.history.revert,
367
- }),
368
- { getHistory, revertHistory },
369
- ),
370
279
  )(History);
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
3
  import configureStore from 'redux-mock-store';
4
- import { StaticRouter } from 'react-router-dom';
4
+ import { MemoryRouter, StaticRouter } from 'react-router-dom';
5
5
  import { CookiesProvider } from 'react-cookie';
6
6
  import { Provider } from 'react-intl-redux';
7
7
  import jwt from 'jsonwebtoken';
@@ -91,8 +91,10 @@ describe('History', () => {
91
91
  const { container } = render(
92
92
  <Provider store={store}>
93
93
  <CookiesProvider>
94
- <History location={{ pathname: '/blog' }} />
95
- <div id="toolbar"></div>
94
+ <MemoryRouter initialEntries={['/blog']}>
95
+ <History />
96
+ <div id="toolbar"></div>
97
+ </MemoryRouter>
96
98
  </CookiesProvider>
97
99
  </Provider>,
98
100
  );
@@ -160,8 +162,10 @@ describe('History', () => {
160
162
  const { container } = render(
161
163
  <Provider store={store}>
162
164
  <CookiesProvider>
163
- <History location={{ pathname: '/blog' }} />
164
- <div id="toolbar"></div>
165
+ <MemoryRouter initialEntries={['/blog']}>
166
+ <History />
167
+ <div id="toolbar"></div>
168
+ </MemoryRouter>
165
169
  </CookiesProvider>
166
170
  </Provider>,
167
171
  );
@@ -399,7 +399,9 @@ class Toolbar extends Component {
399
399
  const button =
400
400
  doesNodeContainClick(this.toolbarRef.current, e) &&
401
401
  this.findAncestor(target, 'button');
402
- if (button && button === this.buttonRef.current) return;
402
+ if (button && button === this.buttonRef.current) {
403
+ return;
404
+ }
403
405
 
404
406
  this.closeMenu();
405
407
  };
@@ -445,7 +447,10 @@ class Toolbar extends Component {
445
447
  }
446
448
  ref={this.toolbarWindow}
447
449
  onBlur={(e) => {
448
- if (!this.toolbarWindow.current?.contains(e.relatedTarget)) {
450
+ if (
451
+ e.relatedTarget &&
452
+ !this.toolbarWindow.current?.contains(e.relatedTarget)
453
+ ) {
449
454
  this.toolbarRef.current
450
455
  ?.querySelector('button.toolbar-handler-button')
451
456
  ?.focus();
@@ -0,0 +1,9 @@
1
+ export default Body;
2
+ declare function Body({ data }: {
3
+ data: any;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ declare namespace Body {
6
+ namespace propTypes {
7
+ let data: any;
8
+ }
9
+ }
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
2
  export default _default;
@@ -1,5 +1,6 @@
1
1
  export default VersionOverview;
2
- declare function VersionOverview({ cmf_version, debug_mode, pil_version, plone_version, plone_restapi_version, python_version, zope_version, }: {
2
+ declare function VersionOverview({ cmf_version, debug_mode, pil_version, plone_version, plone_restapi_version, python_version, zope_version, ...rest }: {
3
+ [x: string]: any;
3
4
  cmf_version: any;
4
5
  debug_mode: any;
5
6
  pil_version: any;
@@ -18,6 +18,7 @@ export declare const ContentTypeLayout: import("@loadable/component").LoadableCl
18
18
  export declare const ContentTypeSchema: import("@loadable/component").LoadableClassComponent<any>;
19
19
  export declare const ContentTypes: import("@loadable/component").LoadableClassComponent<any>;
20
20
  export declare const VersionOverview: import("@loadable/component").LoadableComponent<{
21
+ [x: string]: any;
21
22
  cmf_version: any;
22
23
  debug_mode: any;
23
24
  pil_version: any;