@eeacms/volto-eea-website-theme 1.34.0 → 2.0.0

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 (54) hide show
  1. package/.eslintrc.js +7 -2
  2. package/CHANGELOG.md +44 -20
  3. package/docker-compose.yml +1 -1
  4. package/jest-addon.config.js +3 -0
  5. package/package.json +2 -1
  6. package/src/components/manage/Blocks/LayoutSettings/index.js +3 -1
  7. package/src/components/manage/Blocks/Title/index.js +3 -1
  8. package/src/components/manage/Blocks/Title/schema.js +3 -1
  9. package/src/components/theme/Banner/View.jsx +12 -5
  10. package/src/components/theme/DraftBackground/DraftBackground.jsx +1 -0
  11. package/src/components/theme/DraftBackground/DraftBackground.test.jsx +85 -0
  12. package/src/config.js +2 -0
  13. package/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx +32 -0
  14. package/src/customizations/@plone/volto-slate/editor/render.jsx +75 -0
  15. package/src/customizations/@plone/volto-slate/elementEditor/utils.js +76 -75
  16. package/src/customizations/volto/components/manage/Blocks/Grid/Edit.jsx +70 -0
  17. package/src/customizations/volto/components/manage/Blocks/Grid/View.jsx +61 -0
  18. package/src/customizations/volto/components/manage/Blocks/Grid/readme.md +1 -0
  19. package/src/customizations/volto/components/manage/Blocks/Image/Edit.jsx +82 -23
  20. package/src/customizations/volto/components/manage/Blocks/Image/Edit.test.jsx +10 -3
  21. package/src/customizations/volto/components/manage/Blocks/Image/View.jsx +110 -111
  22. package/src/customizations/volto/components/manage/Blocks/Image/schema.js +17 -2
  23. package/src/customizations/volto/components/manage/Blocks/LeadImage/Edit.jsx +35 -14
  24. package/src/customizations/volto/components/manage/Blocks/LeadImage/View.jsx +65 -79
  25. package/src/customizations/volto/components/manage/Display/Display.jsx +306 -0
  26. package/src/customizations/volto/components/manage/Display/Readme.md +1 -0
  27. package/src/customizations/volto/components/manage/Sidebar/SidebarPopup copy.jsx +82 -0
  28. package/src/customizations/volto/components/manage/Toolbar/More.jsx +541 -0
  29. package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +3 -1
  30. package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.jsx +24 -14
  31. package/src/customizations/volto/components/manage/Widgets/README.md +1 -0
  32. package/src/customizations/volto/components/manage/Workflow/README.txt +1 -0
  33. package/src/customizations/volto/components/manage/Workflow/Workflow.jsx +324 -0
  34. package/src/customizations/volto/components/manage/Workflow/Workflow.test.jsx +81 -0
  35. package/src/customizations/volto/components/theme/Comments/Comments.jsx +1 -2
  36. package/src/customizations/volto/components/theme/ContactForm/ContactForm.jsx +1 -1
  37. package/src/customizations/volto/components/theme/EventDetails/EventDetails.jsx +1 -0
  38. package/src/index.js +21 -16
  39. package/src/middleware/ok.js +4 -2
  40. package/src/middleware/voltoCustom.js +4 -2
  41. package/src/slate.js +10 -8
  42. package/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/README.txt +0 -1
  43. package/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/StyleMenu.jsx +0 -157
  44. package/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/utils.js +0 -168
  45. package/src/customizations/volto/components/manage/Add/Add.jsx +0 -498
  46. package/src/customizations/volto/components/manage/Add/readme.md +0 -1
  47. package/src/customizations/volto/components/manage/Contents/ContentsPropertiesModal.jsx +0 -232
  48. package/src/customizations/volto/components/manage/Form/Form.jsx +0 -810
  49. package/src/customizations/volto/components/manage/Form/Form.test.jsx +0 -1124
  50. package/src/customizations/volto/components/manage/Form/ModalForm.jsx +0 -326
  51. package/src/customizations/volto/components/manage/Sharing/Sharing.jsx +0 -528
  52. package/src/customizations/volto/components/manage/Sharing/Sharing.test.jsx +0 -72
  53. package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.test.jsx +0 -193
  54. package/src/customizations/volto/components/theme/AppExtras/AppExtras.jsx +0 -27
@@ -0,0 +1,306 @@
1
+ import React, { Component, Fragment } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { connect } from 'react-redux';
4
+ import { compose } from 'redux';
5
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
6
+
7
+ import jwtDecode from 'jwt-decode';
8
+ import {
9
+ getSchema,
10
+ getUser,
11
+ updateContent,
12
+ getContent,
13
+ } from '@plone/volto/actions';
14
+ import { getLayoutFieldname } from '@plone/volto/helpers';
15
+ import { FormFieldWrapper, Icon } from '@plone/volto/components';
16
+ import { defineMessages, injectIntl } from 'react-intl';
17
+ import config from '@plone/volto/registry';
18
+
19
+ import downSVG from '@plone/volto/icons/down-key.svg';
20
+ import upSVG from '@plone/volto/icons/up-key.svg';
21
+ import checkSVG from '@plone/volto/icons/check.svg';
22
+
23
+ const messages = defineMessages({
24
+ Viewmode: {
25
+ id: 'Viewmode',
26
+ defaultMessage: 'View',
27
+ },
28
+ });
29
+
30
+ const Option = injectLazyLibs('reactSelect')((props) => {
31
+ const { Option } = props.reactSelect.components;
32
+ return (
33
+ <Option {...props}>
34
+ <div>{props.label}</div>
35
+ {props.isFocused && !props.isSelected && (
36
+ <Icon name={checkSVG} size="18px" color="#b8c6c8" />
37
+ )}
38
+ {props.isSelected && <Icon name={checkSVG} size="18px" color="#007bc1" />}
39
+ </Option>
40
+ );
41
+ });
42
+
43
+ const DropdownIndicator = injectLazyLibs('reactSelect')((props) => {
44
+ const { DropdownIndicator } = props.reactSelect.components;
45
+ return (
46
+ <DropdownIndicator {...props}>
47
+ {props.selectProps.menuIsOpen ? (
48
+ <Icon name={upSVG} size="24px" color="#007bc1" />
49
+ ) : (
50
+ <Icon name={downSVG} size="24px" color="#007bc1" />
51
+ )}
52
+ </DropdownIndicator>
53
+ );
54
+ });
55
+
56
+ const selectTheme = (theme) => ({
57
+ ...theme,
58
+ borderRadius: 0,
59
+ colors: {
60
+ ...theme.colors,
61
+ primary25: 'hotpink',
62
+ primary: '#b8c6c8',
63
+ },
64
+ });
65
+
66
+ const customSelectStyles = {
67
+ control: (styles, state) => ({
68
+ ...styles,
69
+ border: 'none',
70
+ borderBottom: '2px solid #b8c6c8',
71
+ boxShadow: 'none',
72
+ borderBottomStyle: state.menuIsOpen ? 'dotted' : 'solid',
73
+ }),
74
+ menu: (styles, state) => ({
75
+ ...styles,
76
+ top: null,
77
+ marginTop: 0,
78
+ boxShadow: 'none',
79
+ borderBottom: '2px solid #b8c6c8',
80
+ }),
81
+ menuList: (styles, state) => ({
82
+ ...styles,
83
+ maxHeight: '400px',
84
+ }),
85
+ indicatorSeparator: (styles) => ({
86
+ ...styles,
87
+ width: null,
88
+ }),
89
+ valueContainer: (styles) => ({
90
+ ...styles,
91
+ padding: 0,
92
+ }),
93
+ option: (styles, state) => ({
94
+ ...styles,
95
+ backgroundColor: null,
96
+ minHeight: '50px',
97
+ display: 'flex',
98
+ justifyContent: 'space-between',
99
+ alignItems: 'center',
100
+ padding: '12px 12px',
101
+ color: state.isSelected
102
+ ? '#007bc1'
103
+ : state.isFocused
104
+ ? '#4a4a4a'
105
+ : 'inherit',
106
+ ':active': {
107
+ backgroundColor: null,
108
+ },
109
+ span: {
110
+ flex: '0 0 auto',
111
+ },
112
+ svg: {
113
+ flex: '0 0 auto',
114
+ },
115
+ }),
116
+ };
117
+
118
+ /**
119
+ * Display container class.
120
+ * @class Display
121
+ * @extends Component
122
+ */
123
+ class DisplaySelect extends Component {
124
+ /**
125
+ * Property types.
126
+ * @property {Object} propTypes Property types.
127
+ * @static
128
+ */
129
+ static propTypes = {
130
+ getSchema: PropTypes.func.isRequired,
131
+ updateContent: PropTypes.func.isRequired,
132
+ getContent: PropTypes.func.isRequired,
133
+ loaded: PropTypes.bool.isRequired,
134
+ pathname: PropTypes.string.isRequired,
135
+ layouts: PropTypes.arrayOf(PropTypes.string),
136
+ layout: PropTypes.string,
137
+ type: PropTypes.string.isRequired,
138
+ };
139
+
140
+ /**
141
+ * Default properties
142
+ * @property {Object} defaultProps Default properties.
143
+ * @static
144
+ */
145
+ static defaultProps = {
146
+ layouts: [],
147
+ layout: '',
148
+ rolesWhoCanChangeLayout: [],
149
+ };
150
+
151
+ state = {
152
+ hasMatchingRole: false,
153
+ selectedOption: {
154
+ value: this.props.layout,
155
+ label: config.views.layoutViewsNamesMapping?.[this.props.layout]
156
+ ? this.props.intl.formatMessage({
157
+ id: config.views.layoutViewsNamesMapping?.[this.props.layout],
158
+ defaultMessage:
159
+ config.views.layoutViewsNamesMapping?.[this.props.layout],
160
+ })
161
+ : this.props.layout,
162
+ },
163
+ };
164
+
165
+ componentDidMount() {
166
+ this.props.getSchema(this.props.type);
167
+ }
168
+
169
+ UNSAFE_componentWillMount() {
170
+ if (!this.props.rolesWhoCanChangeLayout.length) {
171
+ this.props.rolesWhoCanChangeLayout.push(
172
+ ...(config?.settings?.eea?.rolesWhoCanChangeLayout || []),
173
+ );
174
+ }
175
+ if (!this.props.layouts.length) {
176
+ this.props.getSchema(this.props.type);
177
+ }
178
+ if (Object.keys(this.props.user).length === 0) {
179
+ this.props.getUser(this.props.userId);
180
+ } else {
181
+ const hasMatchingRole = this.props.user.roles.some((role) =>
182
+ this.props.rolesWhoCanChangeLayout.includes(role),
183
+ );
184
+ if (hasMatchingRole !== this.state.hasMatchingRole) {
185
+ this.setState({ hasMatchingRole });
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Component will receive props
192
+ * @method componentWillReceiveProps
193
+ * @param {Object} nextProps Next properties
194
+ * @returns {undefined}
195
+ */
196
+ UNSAFE_componentWillReceiveProps(nextProps) {
197
+ if (nextProps.pathname !== this.props.pathname) {
198
+ this.props.getSchema(nextProps.type);
199
+ }
200
+ if (!this.props.loaded && nextProps.loaded) {
201
+ this.props.getContent(nextProps.pathname);
202
+ }
203
+
204
+ if (Object.keys(nextProps.user).length !== 0) {
205
+ const hasMatchingRole = nextProps.user.roles.some((role) =>
206
+ this.props.rolesWhoCanChangeLayout.includes(role),
207
+ );
208
+ if (hasMatchingRole !== this.state.hasMatchingRole) {
209
+ this.setState({ hasMatchingRole });
210
+ }
211
+ }
212
+ }
213
+
214
+ /**
215
+ * On set layout handler
216
+ * @method setLayout
217
+ * @param {Object} event Event object
218
+ * @returns {undefined}
219
+ */
220
+ setLayout = (selectedOption) => {
221
+ this.props.updateContent(this.props.pathname, {
222
+ layout: selectedOption.value,
223
+ });
224
+ this.setState({ selectedOption });
225
+ };
226
+
227
+ selectValue = (option) => (
228
+ <Fragment>
229
+ <span className="Select-value-label">{option.label}</span>
230
+ </Fragment>
231
+ );
232
+
233
+ optionRenderer = (option) => (
234
+ <Fragment>
235
+ <span style={{ marginRight: 'auto' }}>{option.label}</span>
236
+ <Icon name={checkSVG} size="24px" />
237
+ </Fragment>
238
+ );
239
+
240
+ render() {
241
+ if (!this.state.hasMatchingRole) {
242
+ return null;
243
+ }
244
+ const { selectedOption } = this.state;
245
+ const Select = this.props.reactSelect.default;
246
+ const layoutsNames = config.views.layoutViewsNamesMapping;
247
+ const layoutOptions = this.props.layouts
248
+ .filter(
249
+ (layout) =>
250
+ Object.keys(config.views.contentTypesViews).includes(layout) ||
251
+ Object.keys(config.views.layoutViews).includes(layout),
252
+ )
253
+ .map((item) => ({
254
+ value: item,
255
+ label:
256
+ this.props.intl.formatMessage({
257
+ id: layoutsNames[item],
258
+ defaultMessage: layoutsNames[item],
259
+ }) || item,
260
+ }));
261
+
262
+ return layoutOptions?.length > 1 ? (
263
+ <FormFieldWrapper
264
+ id="display-select"
265
+ title={this.props.intl.formatMessage(messages.Viewmode)}
266
+ {...this.props}
267
+ >
268
+ <Select
269
+ name="display-select"
270
+ className="react-select-container"
271
+ classNamePrefix="react-select"
272
+ options={layoutOptions}
273
+ styles={customSelectStyles}
274
+ theme={selectTheme}
275
+ components={{ DropdownIndicator, Option }}
276
+ onChange={this.setLayout}
277
+ defaultValue={selectedOption}
278
+ isSearchable={false}
279
+ />
280
+ </FormFieldWrapper>
281
+ ) : null;
282
+ }
283
+ }
284
+
285
+ export default compose(
286
+ injectIntl,
287
+ injectLazyLibs('reactSelect'),
288
+ connect(
289
+ (state) => ({
290
+ loaded: state.content.update.loaded,
291
+ layouts: state.schema.schema ? state.schema.schema.layouts : [],
292
+ layout: state.content.data
293
+ ? state.content.data[getLayoutFieldname(state.content.data)]
294
+ : '',
295
+ layout_fieldname: state.content.data
296
+ ? getLayoutFieldname(state.content.data)
297
+ : '',
298
+ type: state.content.data ? state.content.data['@type'] : '',
299
+ user: state.users.user,
300
+ userId: state.userSession.token
301
+ ? jwtDecode(state.userSession.token).sub
302
+ : '',
303
+ }),
304
+ { getSchema, getUser, updateContent, getContent },
305
+ ),
306
+ )(DisplaySelect);
@@ -0,0 +1 @@
1
+ Added customization to condition the display of the layout options based on the user's roles.
@@ -0,0 +1,82 @@
1
+ // Check this https://github.com/plone/volto/pull/5520
2
+ import React from 'react';
3
+ import { Portal } from 'react-portal';
4
+ import { CSSTransition } from 'react-transition-group';
5
+ import PropTypes from 'prop-types';
6
+ import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
7
+
8
+ const DEFAULT_TIMEOUT = 500;
9
+
10
+ const SidebarPopup = (props) => {
11
+ const { children, open, onClose, overlay } = props;
12
+
13
+ const asideElement = React.useRef();
14
+
15
+ const handleClickOutside = (e) => {
16
+ if (asideElement && doesNodeContainClick(asideElement.current, e)) return;
17
+ onClose();
18
+ };
19
+
20
+ React.useEffect(() => {
21
+ document.addEventListener('mousedown', handleClickOutside, false);
22
+ return () => {
23
+ document.removeEventListener('mousedown', handleClickOutside, false);
24
+ };
25
+ });
26
+
27
+ return (
28
+ <>
29
+ {overlay && (
30
+ <CSSTransition
31
+ in={open}
32
+ timeout={DEFAULT_TIMEOUT}
33
+ classNames="overlay-container"
34
+ unmountOnExit
35
+ >
36
+ <Portal node={document?.body}>
37
+ <div className="overlay-container"></div>
38
+ </Portal>
39
+ </CSSTransition>
40
+ )}
41
+ <CSSTransition
42
+ in={open}
43
+ timeout={DEFAULT_TIMEOUT}
44
+ classNames="sidebar-container"
45
+ unmountOnExit
46
+ >
47
+ <Portal>
48
+ <aside
49
+ id="test"
50
+ role="presentation"
51
+ onClick={(e) => {
52
+ e.stopPropagation();
53
+ }}
54
+ onKeyDown={(e) => {
55
+ e.stopPropagation();
56
+ }}
57
+ ref={asideElement}
58
+ key="sidebarpopup"
59
+ className="sidebar-container"
60
+ style={{ overflowY: 'auto' }}
61
+ >
62
+ {children}
63
+ </aside>
64
+ </Portal>
65
+ </CSSTransition>
66
+ </>
67
+ );
68
+ };
69
+
70
+ SidebarPopup.propTypes = {
71
+ open: PropTypes.bool,
72
+ onClose: PropTypes.func,
73
+ overlay: PropTypes.bool,
74
+ };
75
+
76
+ SidebarPopup.defaultProps = {
77
+ open: false,
78
+ onClose: () => {},
79
+ overlay: false,
80
+ };
81
+
82
+ export default SidebarPopup;