@eeacms/volto-eea-website-theme 1.28.3 → 1.29.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.
- package/CHANGELOG.md +24 -0
- package/package.json +1 -1
- package/src/actions/index.js +1 -1
- package/src/actions/print.js +13 -0
- package/src/components/theme/Banner/View.jsx +95 -11
- package/src/components/theme/Homepage/HomePageInverseView.test.jsx +16 -0
- package/src/components/theme/Homepage/HomePageView.test.jsx +16 -0
- package/src/components/theme/Logo.test.jsx +31 -0
- package/src/components/theme/Widgets/TokenWidget.test.jsx +54 -0
- package/src/components/theme/Widgets/TopicsWidget.test.jsx +54 -0
- package/src/constants/ActionTypes.js +6 -0
- package/src/index.js +7 -1
- package/src/index.test.js +5 -0
- package/src/reducers/index.js +1 -0
- package/src/reducers/print.js +21 -0
- package/src/actions/schema.js +0 -5
package/CHANGELOG.md
CHANGED
@@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
4
4
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
6
6
|
|
7
|
+
### [1.29.0](https://github.com/eea/volto-eea-website-theme/compare/1.28.3...1.29.0) - 7 March 2024
|
8
|
+
|
9
|
+
#### :rocket: New Features
|
10
|
+
|
11
|
+
- feat: set isPrint redux state when window.print() is triggered [laszlocseh - [`4d07b9a`](https://github.com/eea/volto-eea-website-theme/commit/4d07b9a76af0e43340e100db10ad1051c61f3a89)]
|
12
|
+
|
13
|
+
#### :bug: Bug Fixes
|
14
|
+
|
15
|
+
- fix: smaller timeout in window.print [laszlocseh - [`808d7e9`](https://github.com/eea/volto-eea-website-theme/commit/808d7e9ef406f38e008a718fd4883fe735c296de)]
|
16
|
+
|
17
|
+
#### :house: Internal changes
|
18
|
+
|
19
|
+
- chore: cleanup unused RemoveSchema code [laszlocseh - [`6d8de0a`](https://github.com/eea/volto-eea-website-theme/commit/6d8de0a27dd6bfd5645bb730d2c66f2d4784c158)]
|
20
|
+
- chore: cleanup unused RemoveSchema code [laszlocseh - [`c1f2650`](https://github.com/eea/volto-eea-website-theme/commit/c1f2650f0f7ffb27c168399fabcbf69d0299235b)]
|
21
|
+
|
22
|
+
#### :hammer_and_wrench: Others
|
23
|
+
|
24
|
+
- test: TokenWidget.test.jsx and TopicsWidget.test.jsx cover more conditions [laszlocseh - [`dd154bb`](https://github.com/eea/volto-eea-website-theme/commit/dd154bb520237f458be563280cac1545eb381bdf)]
|
25
|
+
- Bump version to 1.29.0 from 1.28.4 [Claudia Ifrim - [`7bc8eab`](https://github.com/eea/volto-eea-website-theme/commit/7bc8eabd4b0462fc5afc07ed131d074af642cc89)]
|
26
|
+
- test: added TokenWidget.test.jsx and TopicsWidget.test.jsx [laszlocseh - [`f7292bb`](https://github.com/eea/volto-eea-website-theme/commit/f7292bb426591f758dcc7bc159b5dbd75b7afb36)]
|
27
|
+
- test: added HomePageView.test.jsx and HomePageInverseView.test.jsx [laszlocseh - [`2076651`](https://github.com/eea/volto-eea-website-theme/commit/2076651820693825b5e20b0a7774307cd78eeb57)]
|
28
|
+
- test: fix in Logo.test.jsx [laszlocseh - [`6d552f8`](https://github.com/eea/volto-eea-website-theme/commit/6d552f89d5aff6e47ef3032d4862a1bcbe364c01)]
|
29
|
+
- test: add Logo.test.jsx [laszlocseh - [`752c562`](https://github.com/eea/volto-eea-website-theme/commit/752c5629840d906382858f088b97d33147684ca8)]
|
30
|
+
- add isPrint missing files [laszlocseh - [`d995789`](https://github.com/eea/volto-eea-website-theme/commit/d995789f337a00455d45b5ec26de9c4c0c898ce6)]
|
7
31
|
### [1.28.3](https://github.com/eea/volto-eea-website-theme/compare/1.28.2...1.28.3) - 5 March 2024
|
8
32
|
|
9
33
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
package/src/actions/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from './
|
1
|
+
export * from './print';
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React, { useCallback, useMemo, useRef } from 'react';
|
2
2
|
import { Helmet } from '@plone/volto/helpers';
|
3
3
|
import { compose } from 'redux';
|
4
|
-
import { connect } from 'react-redux';
|
4
|
+
import { connect, useDispatch } from 'react-redux';
|
5
5
|
import { withRouter } from 'react-router';
|
6
6
|
import { defineMessages, injectIntl } from 'react-intl';
|
7
7
|
import startCase from 'lodash/startCase';
|
8
|
-
import { Icon } from 'semantic-ui-react';
|
8
|
+
import { Icon, Loader } from 'semantic-ui-react';
|
9
9
|
import Popup from '@eeacms/volto-eea-design-system/ui/Popup/Popup';
|
10
10
|
import config from '@plone/volto/registry';
|
11
11
|
import Banner from '@eeacms/volto-eea-design-system/ui/Banner/Banner';
|
@@ -14,7 +14,8 @@ import {
|
|
14
14
|
sharePage,
|
15
15
|
} from '@eeacms/volto-eea-design-system/ui/Banner/Banner';
|
16
16
|
import Copyright from '@eeacms/volto-eea-design-system/ui/Copyright/Copyright';
|
17
|
-
|
17
|
+
import { setIsPrint } from '@eeacms/volto-eea-website-theme/actions/print';
|
18
|
+
import cx from 'classnames';
|
18
19
|
import './styles.less';
|
19
20
|
|
20
21
|
const messages = defineMessages({
|
@@ -65,6 +66,7 @@ const Title = ({ config = {}, properties }) => {
|
|
65
66
|
};
|
66
67
|
|
67
68
|
const View = (props) => {
|
69
|
+
const dispatch = useDispatch();
|
68
70
|
const { banner = {}, intl } = props;
|
69
71
|
const metadata = props.metadata || props.properties;
|
70
72
|
const popupRef = useRef(null);
|
@@ -164,14 +166,95 @@ const View = (props) => {
|
|
164
166
|
</>
|
165
167
|
)}
|
166
168
|
{!hideDownloadButton && (
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
169
|
+
<>
|
170
|
+
<Banner.Action
|
171
|
+
icon="ri-download-2-fill"
|
172
|
+
title={intl.formatMessage(messages.download)}
|
173
|
+
className="download"
|
174
|
+
onClick={() => {
|
175
|
+
// set tabs to be visible
|
176
|
+
const tabs = document.getElementsByClassName('ui tab');
|
177
|
+
Array.from(tabs).forEach((tab) => {
|
178
|
+
tab.style.display = 'block';
|
179
|
+
});
|
180
|
+
|
181
|
+
dispatch(setIsPrint(true));
|
182
|
+
// display loader
|
183
|
+
const printLoader = document.getElementById(
|
184
|
+
'download-print-loader',
|
185
|
+
);
|
186
|
+
printLoader.style.display = 'flex';
|
187
|
+
|
188
|
+
let timeoutValue = 1000;
|
189
|
+
// if we have plotlycharts increase timeout
|
190
|
+
setTimeout(() => {
|
191
|
+
const plotlyCharts = document.getElementsByClassName(
|
192
|
+
'visualization-wrapper',
|
193
|
+
);
|
194
|
+
if (plotlyCharts.length > 0) {
|
195
|
+
timeoutValue = timeoutValue + 1000;
|
196
|
+
}
|
197
|
+
}, timeoutValue);
|
198
|
+
|
199
|
+
// scroll to iframes to make them be in the viewport
|
200
|
+
// use timeout to wait for load
|
201
|
+
setTimeout(() => {
|
202
|
+
const iframes = document.getElementsByTagName('iframe');
|
203
|
+
if (iframes.length > 0) {
|
204
|
+
timeoutValue = timeoutValue + 2000;
|
205
|
+
Array.from(iframes).forEach((element, index) => {
|
206
|
+
setTimeout(() => {
|
207
|
+
element.scrollIntoView({
|
208
|
+
behavior: 'instant',
|
209
|
+
block: 'nearest',
|
210
|
+
inline: 'center',
|
211
|
+
});
|
212
|
+
}, timeoutValue);
|
213
|
+
timeoutValue = timeoutValue + 3000;
|
214
|
+
});
|
215
|
+
timeoutValue = timeoutValue + 1000;
|
216
|
+
}
|
217
|
+
|
218
|
+
setTimeout(() => {
|
219
|
+
window.scrollTo({
|
220
|
+
top: 0,
|
221
|
+
});
|
222
|
+
Array.from(tabs).forEach((tab) => {
|
223
|
+
tab.style.display = '';
|
224
|
+
});
|
225
|
+
printLoader.style.display = 'none';
|
226
|
+
dispatch(setIsPrint(false));
|
227
|
+
window.print();
|
228
|
+
}, timeoutValue);
|
229
|
+
}, timeoutValue);
|
230
|
+
}}
|
231
|
+
/>
|
232
|
+
<div
|
233
|
+
id="download-print-loader"
|
234
|
+
className={cx('ui warning message')}
|
235
|
+
style={{
|
236
|
+
position: 'fixed',
|
237
|
+
left: '40%',
|
238
|
+
right: '40%',
|
239
|
+
backgroundColor: '#fff',
|
240
|
+
padding: '1em',
|
241
|
+
display: 'none',
|
242
|
+
flexDirection: 'column',
|
243
|
+
alignItems: 'center',
|
244
|
+
top: '40%',
|
245
|
+
zIndex: '9999',
|
246
|
+
}}
|
247
|
+
>
|
248
|
+
<Loader
|
249
|
+
disabled={false}
|
250
|
+
indeterminate
|
251
|
+
active
|
252
|
+
inline
|
253
|
+
size="medium"
|
254
|
+
></Loader>
|
255
|
+
<div>Preparing download</div>
|
256
|
+
</div>
|
257
|
+
</>
|
175
258
|
)}
|
176
259
|
{rssLinks?.map((rssLink, index) => (
|
177
260
|
<>
|
@@ -253,6 +336,7 @@ export default compose(
|
|
253
336
|
connect((state) => {
|
254
337
|
return {
|
255
338
|
types: state.types.types,
|
339
|
+
isPrint: state.isPrint,
|
256
340
|
};
|
257
341
|
}),
|
258
342
|
)(View);
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import HomePageInverseView from './HomePageInverseView';
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
5
|
+
|
6
|
+
describe('HomePageInverseView Component', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
const mockContent = (
|
9
|
+
<body>
|
10
|
+
<div>Mock content</div>
|
11
|
+
</body>
|
12
|
+
);
|
13
|
+
const { container } = render(<HomePageInverseView content={mockContent} />);
|
14
|
+
expect(container).toBeTruthy();
|
15
|
+
});
|
16
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import HomePageView from './HomePageView';
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
5
|
+
|
6
|
+
describe('HomePageView Component', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
const mockContent = (
|
9
|
+
<body>
|
10
|
+
<div>Mock content</div>
|
11
|
+
</body>
|
12
|
+
);
|
13
|
+
const { container } = render(<HomePageView content={mockContent} />);
|
14
|
+
expect(container).toBeTruthy();
|
15
|
+
});
|
16
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { Provider } from 'react-intl-redux';
|
4
|
+
import configureStore from 'redux-mock-store';
|
5
|
+
import { Router } from 'react-router-dom';
|
6
|
+
import { createMemoryHistory } from 'history';
|
7
|
+
import EEALogo from './Logo';
|
8
|
+
|
9
|
+
const mockStore = configureStore();
|
10
|
+
let history = createMemoryHistory();
|
11
|
+
|
12
|
+
describe('EEALogo Component', () => {
|
13
|
+
it('renders without crashing', () => {
|
14
|
+
const store = mockStore({
|
15
|
+
intl: {
|
16
|
+
locale: 'en',
|
17
|
+
messages: {},
|
18
|
+
},
|
19
|
+
});
|
20
|
+
|
21
|
+
const { container } = render(
|
22
|
+
<Provider store={store}>
|
23
|
+
<Router history={history}>
|
24
|
+
<EEALogo />
|
25
|
+
</Router>
|
26
|
+
</Provider>,
|
27
|
+
);
|
28
|
+
|
29
|
+
expect(container).toBeTruthy();
|
30
|
+
});
|
31
|
+
});
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { Provider } from 'react-intl-redux';
|
4
|
+
import configureStore from 'redux-mock-store';
|
5
|
+
import { Router } from 'react-router-dom';
|
6
|
+
import { createMemoryHistory } from 'history';
|
7
|
+
import { TokenWidget } from './TokenWidget';
|
8
|
+
|
9
|
+
const mockStore = configureStore();
|
10
|
+
let history = createMemoryHistory();
|
11
|
+
|
12
|
+
describe('TokenWidget Component', () => {
|
13
|
+
it('renders without crashing', () => {
|
14
|
+
const store = mockStore({
|
15
|
+
intl: {
|
16
|
+
locale: 'en',
|
17
|
+
messages: {},
|
18
|
+
},
|
19
|
+
});
|
20
|
+
|
21
|
+
const { container } = render(
|
22
|
+
<Provider store={store}>
|
23
|
+
<Router history={history}>
|
24
|
+
<TokenWidget
|
25
|
+
value={['Value1', 'Value2']}
|
26
|
+
children={''}
|
27
|
+
className={'test'}
|
28
|
+
/>
|
29
|
+
</Router>
|
30
|
+
</Provider>,
|
31
|
+
);
|
32
|
+
|
33
|
+
expect(container).toBeTruthy();
|
34
|
+
});
|
35
|
+
|
36
|
+
it('renders without crashing, without value', () => {
|
37
|
+
const store = mockStore({
|
38
|
+
intl: {
|
39
|
+
locale: 'en',
|
40
|
+
messages: {},
|
41
|
+
},
|
42
|
+
});
|
43
|
+
|
44
|
+
const { container } = render(
|
45
|
+
<Provider store={store}>
|
46
|
+
<Router history={history}>
|
47
|
+
<TokenWidget value={null} children={''} className={'test'} />
|
48
|
+
</Router>
|
49
|
+
</Provider>,
|
50
|
+
);
|
51
|
+
|
52
|
+
expect(container).toBeTruthy();
|
53
|
+
});
|
54
|
+
});
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import { Provider } from 'react-intl-redux';
|
4
|
+
import configureStore from 'redux-mock-store';
|
5
|
+
import { Router } from 'react-router-dom';
|
6
|
+
import { createMemoryHistory } from 'history';
|
7
|
+
import { TopicsWidget } from './TopicsWidget';
|
8
|
+
|
9
|
+
const mockStore = configureStore();
|
10
|
+
let history = createMemoryHistory();
|
11
|
+
|
12
|
+
describe('TopicsWidget Component', () => {
|
13
|
+
it('renders without crashing, with value', () => {
|
14
|
+
const store = mockStore({
|
15
|
+
intl: {
|
16
|
+
locale: 'en',
|
17
|
+
messages: {},
|
18
|
+
},
|
19
|
+
});
|
20
|
+
|
21
|
+
const { container } = render(
|
22
|
+
<Provider store={store}>
|
23
|
+
<Router history={history}>
|
24
|
+
<TopicsWidget
|
25
|
+
value={['Value1', 'Value2']}
|
26
|
+
children={''}
|
27
|
+
className={'test'}
|
28
|
+
/>
|
29
|
+
</Router>
|
30
|
+
</Provider>,
|
31
|
+
);
|
32
|
+
|
33
|
+
expect(container).toBeTruthy();
|
34
|
+
});
|
35
|
+
|
36
|
+
it('renders without crashing, without value', () => {
|
37
|
+
const store = mockStore({
|
38
|
+
intl: {
|
39
|
+
locale: 'en',
|
40
|
+
messages: {},
|
41
|
+
},
|
42
|
+
});
|
43
|
+
|
44
|
+
const { container } = render(
|
45
|
+
<Provider store={store}>
|
46
|
+
<Router history={history}>
|
47
|
+
<TopicsWidget value={null} children={''} className={'test'} />
|
48
|
+
</Router>
|
49
|
+
</Provider>,
|
50
|
+
);
|
51
|
+
|
52
|
+
expect(container).toBeTruthy();
|
53
|
+
});
|
54
|
+
});
|
package/src/index.js
CHANGED
@@ -27,7 +27,7 @@ import contentBoxSVG from './icons/content-box.svg';
|
|
27
27
|
import okMiddleware from './middleware/ok';
|
28
28
|
import voltoCustomMiddleware from './middleware/voltoCustom';
|
29
29
|
import installSlate from './slate';
|
30
|
-
|
30
|
+
import { print } from './reducers';
|
31
31
|
import { nanoid } from '@plone/volto-slate/utils';
|
32
32
|
import { v4 as uuid } from 'uuid';
|
33
33
|
|
@@ -534,6 +534,12 @@ const applyConfig = (config) => {
|
|
534
534
|
};
|
535
535
|
}
|
536
536
|
|
537
|
+
// addonReducers
|
538
|
+
config.addonReducers = {
|
539
|
+
...(config.addonReducers || {}),
|
540
|
+
print,
|
541
|
+
};
|
542
|
+
|
537
543
|
// Breadcrumbs
|
538
544
|
config.settings.apiExpanders.push({
|
539
545
|
match: '',
|
package/src/index.test.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export print from './print';
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* Print reducer.
|
3
|
+
* @module reducers/print
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { SET_ISPRINT } from '@eeacms/volto-eea-website-theme/constants/ActionTypes';
|
7
|
+
|
8
|
+
const initialState = {
|
9
|
+
isPrint: false,
|
10
|
+
};
|
11
|
+
|
12
|
+
export default function print(state = initialState, action) {
|
13
|
+
if (action.type === SET_ISPRINT) {
|
14
|
+
return {
|
15
|
+
...state,
|
16
|
+
isPrint: action.payload,
|
17
|
+
};
|
18
|
+
} else {
|
19
|
+
return state;
|
20
|
+
}
|
21
|
+
}
|