@eeacms/volto-eea-website-theme 2.3.0 → 3.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 (35) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/README.md +6 -0
  3. package/package.json +3 -1
  4. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx +45 -0
  5. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.test.jsx +88 -0
  6. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.jsx +14 -0
  7. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.test.jsx +71 -0
  8. package/src/components/manage/Blocks/ContextNavigation/index.js +30 -0
  9. package/src/components/manage/Blocks/ContextNavigation/schema.js +88 -0
  10. package/src/components/manage/Blocks/ContextNavigation/variations/Accordion.jsx +179 -0
  11. package/src/components/manage/Blocks/ContextNavigation/variations/Default.jsx +9 -0
  12. package/src/components/manage/Blocks/ContextNavigation/variations/index.js +18 -0
  13. package/src/components/manage/Blocks/Title/Edit.jsx +7 -4
  14. package/src/components/manage/Blocks/Title/View.jsx +14 -24
  15. package/src/components/manage/Blocks/Title/index.js +52 -0
  16. package/src/components/manage/Blocks/Title/variations/Default.jsx +43 -0
  17. package/src/components/manage/Blocks/Title/variations/WebReport.jsx +69 -0
  18. package/src/components/manage/Blocks/Title/variations/WebReportPage.jsx +59 -0
  19. package/src/components/manage/Blocks/Title/variations/styles.less +28 -0
  20. package/src/components/theme/Banner/View.jsx +5 -1
  21. package/src/components/theme/SubsiteClass.jsx +3 -1
  22. package/src/components/theme/WebReport/WebReportSectionView.jsx +49 -0
  23. package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx +20 -2
  24. package/src/customizations/volto/components/theme/Header/Header.jsx +3 -3
  25. package/src/customizations/volto/components/theme/View/DefaultView.jsx +190 -0
  26. package/src/hocs/withDeviceSize.test.jsx +79 -0
  27. package/src/index.js +20 -7
  28. package/src/customizations/volto/components/manage/Blocks/Block/BlocksForm.diff +0 -12
  29. package/src/customizations/volto/components/manage/Blocks/Block/BlocksForm.jsx +0 -289
  30. package/src/customizations/volto/components/manage/Blocks/Block/BlocksForm.txt +0 -2
  31. package/src/customizations/volto/components/manage/Diff/DiffField.jsx +0 -351
  32. package/src/customizations/volto/components/manage/Form/Form.diff +0 -2
  33. package/src/customizations/volto/components/manage/Form/Form.jsx +0 -952
  34. package/src/customizations/volto/components/manage/Form/Form.txt +0 -2
  35. package/src/customizations/volto/components/manage/Widgets/InternalUrlWidget.jsx +0 -189
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { render, act } from '@testing-library/react';
3
+ import withDeviceSize from './withDeviceSize.jsx';
4
+
5
+ describe('withDeviceSize HOC', () => {
6
+ // Mock the WrappedComponent
7
+ const WrappedComponent = ({ device }) => (
8
+ <div data-testid="device">{device}</div>
9
+ );
10
+
11
+ const mockResize = (width) => {
12
+ Object.defineProperty(document.documentElement, 'clientWidth', {
13
+ writable: true,
14
+ configurable: true,
15
+ value: width,
16
+ });
17
+ window.dispatchEvent(new Event('resize'));
18
+ };
19
+
20
+ it('should return mobile for screen width less than 768px', () => {
21
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
22
+
23
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
24
+
25
+ act(() => {
26
+ mockResize(500); // Simulating a mobile screen
27
+ });
28
+
29
+ expect(getByTestId('device').textContent).toBe('mobile');
30
+ });
31
+
32
+ it('should return tablet for screen width between 768px and 992px', () => {
33
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
34
+
35
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
36
+
37
+ act(() => {
38
+ mockResize(800); // Simulating a tablet screen
39
+ });
40
+
41
+ expect(getByTestId('device').textContent).toBe('tablet');
42
+ });
43
+
44
+ it('should return computer for screen width between 992px and 1200px', () => {
45
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
46
+
47
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
48
+
49
+ act(() => {
50
+ mockResize(1000); // Simulating a computer screen
51
+ });
52
+
53
+ expect(getByTestId('device').textContent).toBe('computer');
54
+ });
55
+
56
+ it('should return large for screen width between 1200px and 1920px', () => {
57
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
58
+
59
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
60
+
61
+ act(() => {
62
+ mockResize(1500); // Simulating a large screen
63
+ });
64
+
65
+ expect(getByTestId('device').textContent).toBe('large');
66
+ });
67
+
68
+ it('should return widescreen for screen width above 1920px', () => {
69
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
70
+
71
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
72
+
73
+ act(() => {
74
+ mockResize(2000); // Simulating a widescreen display
75
+ });
76
+
77
+ expect(getByTestId('device').textContent).toBe('widescreen');
78
+ });
79
+ });
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ import CustomCSS from '@eeacms/volto-eea-website-theme/components/theme/CustomCS
11
11
  import DraftBackground from '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground';
12
12
  import HomePageInverseView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView';
13
13
  import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView';
14
+ import WebReportSectionView from '@eeacms/volto-eea-website-theme/components/theme/WebReport/WebReportSectionView';
14
15
  import NotFound from '@eeacms/volto-eea-website-theme/components/theme/NotFound/NotFound';
15
16
  import { TokenWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TokenWidget';
16
17
  import { TopicsWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TopicsWidget';
@@ -26,6 +27,7 @@ import {
26
27
  } from '@eeacms/volto-eea-website-theme/helpers/schema-utils';
27
28
 
28
29
  import installLayoutSettingsBlock from '@eeacms/volto-eea-website-theme/components/manage/Blocks/LayoutSettings';
30
+ import installContextNavigationBlock from '@eeacms/volto-eea-website-theme/components/manage/Blocks/ContextNavigation';
29
31
  import installCustomTitle from '@eeacms/volto-eea-website-theme/components/manage/Blocks/Title';
30
32
 
31
33
  import FlexGroup from '@eeacms/volto-eea-website-theme/components/manage/Blocks/GroupBlockTemplate/FlexGroup/FlexGroup';
@@ -241,7 +243,14 @@ const applyConfig = (config) => {
241
243
  ...(config.views.layoutViewsNamesMapping || {}),
242
244
  homepage_view: 'Homepage view',
243
245
  homepage_inverse_view: 'Homepage white view',
246
+ web_report_section: 'Web report section',
244
247
  };
248
+
249
+ config.views.contentTypesViews = {
250
+ ...(config.views.contentTypesViews || {}),
251
+ web_report_section: WebReportSectionView,
252
+ };
253
+
245
254
  config.views.errorViews = {
246
255
  ...config.views.errorViews,
247
256
  404: NotFound,
@@ -486,11 +495,11 @@ const applyConfig = (config) => {
486
495
  // },
487
496
  };
488
497
 
489
- // layout settings
490
- config = [installLayoutSettingsBlock].reduce(
491
- (acc, apply) => apply(acc),
492
- config,
493
- );
498
+ //If you don't want to show the content type as a link in the breadcrumbs, you can set it to a number
499
+ // where 1 is the last item in the breadcrumbs, 2 is the second last, etc.
500
+ config.settings.contentTypeToAvoidAsLinks = {
501
+ web_report_section: 2,
502
+ };
494
503
 
495
504
  // Group
496
505
  if (config.blocks.blocksConfig.group) {
@@ -559,8 +568,12 @@ const applyConfig = (config) => {
559
568
  GET_CONTENT: ['breadcrumbs'], // 'navigation', 'actions', 'types'],
560
569
  });
561
570
 
562
- // Custom blocks: Title
563
- return [installCustomTitle].reduce((acc, apply) => apply(acc), config);
571
+ // Custom blocks: Title,Layout settings, Context navigation
572
+ return [
573
+ installCustomTitle,
574
+ installLayoutSettingsBlock,
575
+ installContextNavigationBlock,
576
+ ].reduce((acc, apply) => apply(acc), config);
564
577
  };
565
578
 
566
579
  export default applyConfig;
@@ -1,12 +0,0 @@
1
- 3c3
2
- < import EditBlock from './Edit';
3
- ---
4
- > import EditBlock from '@plone/volto/components/manage/Blocks/Block/Edit.jsx';
5
- 20c20
6
- < import EditBlockWrapper from './EditBlockWrapper';
7
- ---
8
- > import EditBlockWrapper from '@plone/volto/components/manage/Blocks/Block/EditBlockWrapper.jsx';
9
- 41a42
10
- > errors,
11
- 261a263
12
- > errors,
@@ -1,289 +0,0 @@
1
- import React from 'react';
2
- import { useIntl } from 'react-intl';
3
- import EditBlock from '@plone/volto/components/manage/Blocks/Block/Edit.jsx';
4
- import { DragDropList } from '@plone/volto/components';
5
- import {
6
- getBlocks,
7
- getBlocksFieldname,
8
- applyBlockDefaults,
9
- } from '@plone/volto/helpers';
10
- import {
11
- addBlock,
12
- insertBlock,
13
- changeBlock,
14
- deleteBlock,
15
- moveBlock,
16
- mutateBlock,
17
- nextBlockId,
18
- previousBlockId,
19
- } from '@plone/volto/helpers';
20
- import EditBlockWrapper from '@plone/volto/components/manage/Blocks/Block/EditBlockWrapper.jsx';
21
- import { setSidebarTab } from '@plone/volto/actions';
22
- import { useDispatch } from 'react-redux';
23
- import { useDetectClickOutside, useEvent } from '@plone/volto/helpers';
24
- import config from '@plone/volto/registry';
25
-
26
- const BlocksForm = (props) => {
27
- const {
28
- pathname,
29
- onChangeField,
30
- properties,
31
- type,
32
- navRoot,
33
- onChangeFormData,
34
- selectedBlock,
35
- multiSelected,
36
- onSelectBlock,
37
- allowedBlocks,
38
- showRestricted,
39
- title,
40
- description,
41
- metadata,
42
- errors,
43
- manage,
44
- children,
45
- isMainForm = true,
46
- isContainer,
47
- stopPropagation,
48
- disableAddBlockOnEnterKey,
49
- blocksConfig = config.blocks.blocksConfig,
50
- editable = true,
51
- direction = 'vertical',
52
- } = props;
53
-
54
- const blockList = getBlocks(properties);
55
-
56
- const dispatch = useDispatch();
57
- const intl = useIntl();
58
-
59
- const ClickOutsideListener = () => {
60
- onSelectBlock(null);
61
- dispatch(setSidebarTab(0));
62
- };
63
-
64
- const ref = useDetectClickOutside({
65
- onTriggered: ClickOutsideListener,
66
- triggerKeys: ['Escape'],
67
- // Disabled feature for now https://github.com/plone/volto/pull/2389#issuecomment-830027413
68
- disableClick: true,
69
- disableKeys: !isMainForm,
70
- });
71
-
72
- const handleKeyDown = (
73
- e,
74
- index,
75
- block,
76
- node,
77
- {
78
- disableEnter = false,
79
- disableArrowUp = false,
80
- disableArrowDown = false,
81
- } = {},
82
- ) => {
83
- const isMultipleSelection = e.shiftKey;
84
- if (e.key === 'ArrowUp' && !disableArrowUp) {
85
- onFocusPreviousBlock(block, node, isMultipleSelection);
86
- e.preventDefault();
87
- }
88
- if (e.key === 'ArrowDown' && !disableArrowDown) {
89
- onFocusNextBlock(block, node, isMultipleSelection);
90
- e.preventDefault();
91
- }
92
- if (e.key === 'Enter' && !disableEnter) {
93
- if (!disableAddBlockOnEnterKey) {
94
- onSelectBlock(onAddBlock(config.settings.defaultBlockType, index + 1));
95
- }
96
- e.preventDefault();
97
- }
98
- };
99
-
100
- const onFocusPreviousBlock = (
101
- currentBlock,
102
- blockNode,
103
- isMultipleSelection,
104
- ) => {
105
- const prev = previousBlockId(properties, currentBlock);
106
- if (prev === null) return;
107
-
108
- blockNode.blur();
109
-
110
- onSelectBlock(prev, isMultipleSelection);
111
- };
112
-
113
- const onFocusNextBlock = (currentBlock, blockNode, isMultipleSelection) => {
114
- const next = nextBlockId(properties, currentBlock);
115
- if (next === null) return;
116
-
117
- blockNode.blur();
118
-
119
- onSelectBlock(next, isMultipleSelection);
120
- };
121
-
122
- const onMutateBlock = (id, value) => {
123
- const newFormData = mutateBlock(properties, id, value);
124
- onChangeFormData(newFormData);
125
- };
126
-
127
- const onInsertBlock = (id, value, current) => {
128
- const [newId, newFormData] = insertBlock(
129
- properties,
130
- id,
131
- value,
132
- current,
133
- config.experimental.addBlockButton.enabled ? 1 : 0,
134
- );
135
-
136
- const blocksFieldname = getBlocksFieldname(newFormData);
137
- const blockData = newFormData[blocksFieldname][newId];
138
- newFormData[blocksFieldname][newId] = applyBlockDefaults({
139
- data: blockData,
140
- intl,
141
- metadata,
142
- properties,
143
- });
144
-
145
- onChangeFormData(newFormData);
146
- return newId;
147
- };
148
-
149
- const onAddBlock = (type, index) => {
150
- if (editable) {
151
- const [id, newFormData] = addBlock(properties, type, index);
152
- const blocksFieldname = getBlocksFieldname(newFormData);
153
- const blockData = newFormData[blocksFieldname][id];
154
- newFormData[blocksFieldname][id] = applyBlockDefaults({
155
- data: blockData,
156
- intl,
157
- metadata,
158
- properties,
159
- });
160
- onChangeFormData(newFormData);
161
- return id;
162
- }
163
- };
164
-
165
- const onChangeBlock = (id, value) => {
166
- const newFormData = changeBlock(properties, id, value);
167
- onChangeFormData(newFormData);
168
- };
169
-
170
- const onDeleteBlock = (id, selectPrev) => {
171
- const previous = previousBlockId(properties, id);
172
-
173
- const newFormData = deleteBlock(properties, id);
174
- onChangeFormData(newFormData);
175
-
176
- onSelectBlock(selectPrev ? previous : null);
177
- };
178
-
179
- const onMoveBlock = (dragIndex, hoverIndex) => {
180
- const newFormData = moveBlock(properties, dragIndex, hoverIndex);
181
- onChangeFormData(newFormData);
182
- };
183
-
184
- const defaultBlockWrapper = ({ draginfo }, editBlock, blockProps) => (
185
- <EditBlockWrapper draginfo={draginfo} blockProps={blockProps}>
186
- {editBlock}
187
- </EditBlockWrapper>
188
- );
189
-
190
- const editBlockWrapper = children || defaultBlockWrapper;
191
-
192
- // Remove invalid blocks on saving
193
- // Note they are alreaady filtered by DragDropList, but we also want them
194
- // to be removed when the user saves the page next. Otherwise the invalid
195
- // blocks would linger for ever.
196
- for (const [n, v] of blockList) {
197
- if (!v) {
198
- const newFormData = deleteBlock(properties, n);
199
- onChangeFormData(newFormData);
200
- }
201
- }
202
-
203
- useEvent('voltoClickBelowContent', () => {
204
- if (!config.experimental.addBlockButton.enabled || !isMainForm) return;
205
- onSelectBlock(
206
- onAddBlock(config.settings.defaultBlockType, blockList.length),
207
- );
208
- });
209
-
210
- return (
211
- <div
212
- className="blocks-form"
213
- role="presentation"
214
- ref={ref}
215
- onKeyDown={(e) => {
216
- if (stopPropagation) {
217
- e.stopPropagation();
218
- }
219
- }}
220
- >
221
- <fieldset className="invisible" disabled={!editable}>
222
- <DragDropList
223
- childList={blockList}
224
- onMoveItem={(result) => {
225
- const { source, destination } = result;
226
- if (!destination) {
227
- return;
228
- }
229
- const newFormData = moveBlock(
230
- properties,
231
- source.index,
232
- destination.index,
233
- );
234
- onChangeFormData(newFormData);
235
- return true;
236
- }}
237
- direction={direction}
238
- >
239
- {(dragProps) => {
240
- const { child, childId, index } = dragProps;
241
- const blockProps = {
242
- allowedBlocks,
243
- showRestricted,
244
- block: childId,
245
- data: child,
246
- handleKeyDown,
247
- id: childId,
248
- formTitle: title,
249
- formDescription: description,
250
- index,
251
- manage,
252
- onAddBlock,
253
- onInsertBlock,
254
- onChangeBlock,
255
- onChangeField,
256
- onChangeFormData,
257
- onDeleteBlock,
258
- onFocusNextBlock,
259
- onFocusPreviousBlock,
260
- onMoveBlock,
261
- onMutateBlock,
262
- onSelectBlock,
263
- errors,
264
- pathname,
265
- metadata,
266
- properties,
267
- contentType: type,
268
- navRoot,
269
- blocksConfig,
270
- selected: selectedBlock === childId,
271
- multiSelected: multiSelected?.includes(childId),
272
- type: child['@type'],
273
- editable,
274
- showBlockChooser: selectedBlock === childId,
275
- detached: isContainer,
276
- };
277
- return editBlockWrapper(
278
- dragProps,
279
- <EditBlock key={childId} {...blockProps} />,
280
- blockProps,
281
- );
282
- }}
283
- </DragDropList>
284
- </fieldset>
285
- </div>
286
- );
287
- };
288
-
289
- export default BlocksForm;
@@ -1,2 +0,0 @@
1
- Customize from @plone/volto 17.18.2 - refs https://taskman.eionet.europa.eu/issues/269086
2
- Should be safe to remove with @plone/volto 18.x - https://github.com/plone/volto/pull/6181