@eeacms/volto-tableau 8.0.6 → 8.0.7
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
CHANGED
|
@@ -4,18 +4,48 @@ 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
|
+
### [8.0.7](https://github.com/eea/volto-tableau/compare/8.0.6...8.0.7) - 9 September 2024
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- style: Automated code fix [eea-jenkins - [`ef00271`](https://github.com/eea/volto-tableau/commit/ef00271928ae63ba0d22485f9343fc304e090b03)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- Update View.test.jsx [dobri1408 - [`984f762`](https://github.com/eea/volto-tableau/commit/984f76249550287ef297526d3962a61fd498a0be)]
|
|
16
|
+
- increase code coverage [dobri1408 - [`4a0b444`](https://github.com/eea/volto-tableau/commit/4a0b4449f244c4deacc4015b0d2373d0baa49e2f)]
|
|
17
|
+
- increase code coverage [dobri1408 - [`0a036f4`](https://github.com/eea/volto-tableau/commit/0a036f4d45401da63e71104cae57f7378a4d3624)]
|
|
18
|
+
- increase code coverage [dobri1408 - [`0438558`](https://github.com/eea/volto-tableau/commit/0438558970650d3a01d74802e622cd9d27ebda81)]
|
|
19
|
+
- double check preview [dobri1408 - [`85e0689`](https://github.com/eea/volto-tableau/commit/85e0689f800064e98937be6f74bfdd9959ccd1da)]
|
|
20
|
+
- double check preview [dobri1408 - [`1671a45`](https://github.com/eea/volto-tableau/commit/1671a45608c765f832b48789721dbe7b06b65ed4)]
|
|
21
|
+
- Update preview_image.js [dobri1408 - [`87925c5`](https://github.com/eea/volto-tableau/commit/87925c5c45d8395c9c5b956ead2a7d988823233a)]
|
|
22
|
+
- double check preview [dobri1408 - [`1579659`](https://github.com/eea/volto-tableau/commit/1579659822d56993dd147a6256013b0e7c12bbb5)]
|
|
23
|
+
- Create preview_image.test.js [dobri1408 - [`c562940`](https://github.com/eea/volto-tableau/commit/c562940a2f0bb7ae34ef98a62d2c95f4fe2506c0)]
|
|
24
|
+
- Update preview_image.js [dobri1408 - [`aa3b15e`](https://github.com/eea/volto-tableau/commit/aa3b15edd95d64c8ca969a8252f7d9371e142a6d)]
|
|
25
|
+
- merge [dobri1408 - [`ba63a8f`](https://github.com/eea/volto-tableau/commit/ba63a8f95349d00e5782ebff31870e96891362ca)]
|
|
26
|
+
- manage redux and action right [dobri1408 - [`85be516`](https://github.com/eea/volto-tableau/commit/85be51613a3789adbebd3a517f6b87f600ed3e92)]
|
|
27
|
+
- Update preview_image.js [dobri1408 - [`bb20a02`](https://github.com/eea/volto-tableau/commit/bb20a0204292ef9f94734b343eea9f2fd3e5a96a)]
|
|
28
|
+
- Update VisualizationWidget.jsx [dobri1408 - [`e5ee11c`](https://github.com/eea/volto-tableau/commit/e5ee11ca4f5ee10a42f28e7087582744628aa144)]
|
|
29
|
+
- Update VisualizationWidget.jsx [dobri1408 - [`f0d3bdf`](https://github.com/eea/volto-tableau/commit/f0d3bdf6edff339a037a64453eea714496c39d92)]
|
|
30
|
+
- fix multiple rerenders [dobri1408 - [`6cc0ef0`](https://github.com/eea/volto-tableau/commit/6cc0ef0b8d1bb7f3a0770666c6e60bb3c28df0d4)]
|
|
31
|
+
- Update VisualizationWidget.jsx [dobri1408 - [`56d94fd`](https://github.com/eea/volto-tableau/commit/56d94fdf9bd26db1512d2ae5ee5f65e743b795b5)]
|
|
32
|
+
- fix eslint [dobri1408 - [`d7d754e`](https://github.com/eea/volto-tableau/commit/d7d754e9d89b60951ac7da27b14db93389832216)]
|
|
33
|
+
- fix eslint [dobri1408 - [`58b50d9`](https://github.com/eea/volto-tableau/commit/58b50d995059eea0cc31a0bb6e8e80b48ace99ea)]
|
|
34
|
+
- middleware to save preview image [dobri1408 - [`4b9d1b3`](https://github.com/eea/volto-tableau/commit/4b9d1b3efc5c1cc04d273ce91ccc0621cb60b324)]
|
|
35
|
+
- Update package.json [dobri1408 - [`12a1c94`](https://github.com/eea/volto-tableau/commit/12a1c9478591ba4729f00a55932858b5ef616ff2)]
|
|
36
|
+
- middleware to save preview image [dobri1408 - [`9fe3dd7`](https://github.com/eea/volto-tableau/commit/9fe3dd795842f40e2f0d91475df04b7b97de922e)]
|
|
7
37
|
### [8.0.6](https://github.com/eea/volto-tableau/compare/8.0.5...8.0.6) - 25 July 2024
|
|
8
38
|
|
|
9
39
|
#### :hammer_and_wrench: Others
|
|
10
40
|
|
|
11
41
|
- Update Jenkinsfile [Alexandru Ghica - [`d5e7d48`](https://github.com/eea/volto-tableau/commit/d5e7d48a52e494ebf139b14ea06d0cac8cce82f3)]
|
|
12
|
-
- more checks [Miu Razvan - [`575a1d5`](https://github.com/eea/volto-tableau/commit/575a1d5db3310f9b2dec343adca7c9b912316414)]
|
|
13
42
|
### [8.0.5](https://github.com/eea/volto-tableau/compare/8.0.4...8.0.5) - 23 July 2024
|
|
14
43
|
|
|
15
44
|
### [8.0.4](https://github.com/eea/volto-tableau/compare/8.0.3...8.0.4) - 22 July 2024
|
|
16
45
|
|
|
17
46
|
#### :hammer_and_wrench: Others
|
|
18
47
|
|
|
48
|
+
- Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`22eeee9`](https://github.com/eea/volto-tableau/commit/22eeee93cfa8516261bb037a4bffef654af7a179)]
|
|
19
49
|
- Revert "Add fullwidth property" [Miu Razvan - [`ea36e3c`](https://github.com/eea/volto-tableau/commit/ea36e3c4be0ff20999a5ea7ced69cc77f287ced5)]
|
|
20
50
|
- Add fullwidth property [Miu Razvan - [`8d21ed0`](https://github.com/eea/volto-tableau/commit/8d21ed0b219f94d18998155a77acf2a0c50c9338)]
|
|
21
51
|
### [8.0.3](https://github.com/eea/volto-tableau/compare/8.0.2...8.0.3) - 14 June 2024
|
|
@@ -147,12 +177,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
147
177
|
- test [Dobricean Ioan Dorian - [`48505ca`](https://github.com/eea/volto-tableau/commit/48505caef84d12091035fdd79cf64067e7f819e2)]
|
|
148
178
|
- split the view and edit [Dobricean Ioan Dorian - [`7227bb1`](https://github.com/eea/volto-tableau/commit/7227bb1fb70e5d895f15872ed6533e089be99836)]
|
|
149
179
|
- update embed tableau so it can work with serialized data [Dobricean Ioan Dorian - [`59d958c`](https://github.com/eea/volto-tableau/commit/59d958c7a1a5055ea62e04abcbf34ee93f52e23a)]
|
|
180
|
+
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`c452d70`](https://github.com/eea/volto-tableau/commit/c452d704819fb485e3cd3b39c2501361d20e8559)]
|
|
150
181
|
### [6.0.6](https://github.com/eea/volto-tableau/compare/6.0.5...6.0.6) - 17 November 2023
|
|
151
182
|
|
|
152
183
|
#### :hammer_and_wrench: Others
|
|
153
184
|
|
|
154
185
|
- tests: add cypress for tableau [nileshgulia1 - [`6eca683`](https://github.com/eea/volto-tableau/commit/6eca6834b85cdab4ed82367fee32fdbbb35b0f5e)]
|
|
155
186
|
- tests: update unit tests [nileshgulia1 - [`96cae09`](https://github.com/eea/volto-tableau/commit/96cae09eab2e737f032c97eb401a3efa88e68ec6)]
|
|
187
|
+
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`c7e81cb`](https://github.com/eea/volto-tableau/commit/c7e81cb0768f755dd4107a4998253d9bccc33809)]
|
|
156
188
|
- comment test [Miu Razvan - [`a459525`](https://github.com/eea/volto-tableau/commit/a459525fdccf8ee61651d4cb2e04eb253e841c61)]
|
|
157
189
|
### [6.0.5](https://github.com/eea/volto-tableau/compare/6.0.4...6.0.5) - 15 November 2023
|
|
158
190
|
|
|
@@ -179,6 +211,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
179
211
|
|
|
180
212
|
#### :house: Internal changes
|
|
181
213
|
|
|
214
|
+
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`903b90a`](https://github.com/eea/volto-tableau/commit/903b90a2df0abc183aa68d99a89bb688de3a0c73)]
|
|
182
215
|
|
|
183
216
|
#### :hammer_and_wrench: Others
|
|
184
217
|
|
|
@@ -188,6 +221,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
188
221
|
- tests: increase coverage [kreafox - [`ecb9262`](https://github.com/eea/volto-tableau/commit/ecb92625a44365faf4c39f0ff3f02ccc4ca21656)]
|
|
189
222
|
- Fix tableau height [kreafox - [`6194c24`](https://github.com/eea/volto-tableau/commit/6194c2405e2bd93aba9865caed76292cd55193d3)]
|
|
190
223
|
- Show share & download button on widget view [kreafox - [`a66e253`](https://github.com/eea/volto-tableau/commit/a66e2537d08dc7129e249c28e1daa27246c88815)]
|
|
224
|
+
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`9d2189d`](https://github.com/eea/volto-tableau/commit/9d2189d4edb13dd449d75cd6dd9052bbed67304d)]
|
|
225
|
+
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`f2fa3f9`](https://github.com/eea/volto-tableau/commit/f2fa3f9ccabab918586179ac16ead44e2eba8498)]
|
|
226
|
+
- test: [JENKINS] Improve cypress time [valentinab25 - [`5748183`](https://github.com/eea/volto-tableau/commit/5748183c27dae18a4ebbc067d659cbc24cad8f71)]
|
|
191
227
|
- use toolbar from volto-embed [Miu Razvan - [`1a232a1`](https://github.com/eea/volto-tableau/commit/1a232a15f2bbe05da75307800590d0a0a1c4996b)]
|
|
192
228
|
## [6.0.0](https://github.com/eea/volto-tableau/compare/5.0.2...6.0.0) - 30 October 2023
|
|
193
229
|
|
|
@@ -245,6 +281,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
245
281
|
- test: change volto version in Jenkinsfile [ana-oprea - [`347aceb`](https://github.com/eea/volto-tableau/commit/347aceb07d152fddeebbf3a7e7a6ac9c55dc21ba)]
|
|
246
282
|
- test: increase cypress timeout [ana-oprea - [`bdf4408`](https://github.com/eea/volto-tableau/commit/bdf44083cd84c96b4914d3f8a3bb17c5187f191c)]
|
|
247
283
|
- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`caff974`](https://github.com/eea/volto-tableau/commit/caff9742a703b224133a8dd2a969629e70c9fd33)]
|
|
284
|
+
- test: Fix eslint and yarn i18n [Alin Voinea - [`b8be7fb`](https://github.com/eea/volto-tableau/commit/b8be7fb9ab10faed0a1be8ce7e3d4e7c78ebe020)]
|
|
248
285
|
- i18n: Add en [Alin Voinea - [`c5e20dd`](https://github.com/eea/volto-tableau/commit/c5e20ddea25c830ac80665ee9a71e557e8cd117d)]
|
|
249
286
|
- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`2116ff9`](https://github.com/eea/volto-tableau/commit/2116ff95c6454e813bdca44e6c3aa81fa0a916b8)]
|
|
250
287
|
## [5.0.0](https://github.com/eea/volto-tableau/compare/4.1.1...5.0.0) - 25 July 2023
|
|
@@ -256,17 +293,21 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
256
293
|
#### :hammer_and_wrench: Others
|
|
257
294
|
|
|
258
295
|
- Release 5.0.0 [Alin Voinea - [`97c98e9`](https://github.com/eea/volto-tableau/commit/97c98e98b1295a4ad45756326dc20cd59517515f)]
|
|
296
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`2acb3a5`](https://github.com/eea/volto-tableau/commit/2acb3a5490f62ce0a95ebbd03c32874ac3a42603)]
|
|
259
297
|
### [4.1.1](https://github.com/eea/volto-tableau/compare/4.1.0...4.1.1) - 21 July 2023
|
|
260
298
|
|
|
261
299
|
#### :hammer_and_wrench: Others
|
|
262
300
|
|
|
263
301
|
- Add VisualizationViewWidget [Tiberiu Ichim - [`fa881cb`](https://github.com/eea/volto-tableau/commit/fa881cbc3643a46697fb16d1c86ada1d4121a46a)]
|
|
302
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`cbcbad2`](https://github.com/eea/volto-tableau/commit/cbcbad26f7aa3683122199c8d5cbd142903df93b)]
|
|
303
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`51abe6d`](https://github.com/eea/volto-tableau/commit/51abe6d4db80825fe2e396e04c7003c6ad79b480)]
|
|
264
304
|
### [4.1.0](https://github.com/eea/volto-tableau/compare/4.0.0...4.1.0) - 15 June 2023
|
|
265
305
|
|
|
266
306
|
## [4.0.0](https://github.com/eea/volto-tableau/compare/3.0.8...4.0.0) - 13 June 2023
|
|
267
307
|
|
|
268
308
|
#### :house: Internal changes
|
|
269
309
|
|
|
310
|
+
- chore: [JENKINS] Remove alpha testing version [valentinab25 - [`e33bb21`](https://github.com/eea/volto-tableau/commit/e33bb21eb429c33e3a15d771487a1c9af8ccb0d5)]
|
|
270
311
|
|
|
271
312
|
#### :hammer_and_wrench: Others
|
|
272
313
|
|
|
@@ -298,6 +339,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
298
339
|
|
|
299
340
|
#### :hammer_and_wrench: Others
|
|
300
341
|
|
|
342
|
+
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`f5deccd`](https://github.com/eea/volto-tableau/commit/f5deccd84372752908b300c5cfd78134818e5ce4)]
|
|
301
343
|
### [3.0.6](https://github.com/eea/volto-tableau/compare/3.0.5...3.0.6) - 30 January 2023
|
|
302
344
|
|
|
303
345
|
### [3.0.5](https://github.com/eea/volto-tableau/compare/3.0.4...3.0.5) - 26 January 2023
|
|
@@ -369,6 +411,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
369
411
|
- Update commands.js [Nilesh - [`7c48437`](https://github.com/eea/volto-tableau/commit/7c4843780efb9b85a4728de73c00d831c1d8fdcf)]
|
|
370
412
|
- Update e2e.js [Nilesh - [`f67b45c`](https://github.com/eea/volto-tableau/commit/f67b45c170f58f8d0301192994226f173e4cb00a)]
|
|
371
413
|
- latest volto compatibility refs #154757 [nileshgulia1 - [`881ba48`](https://github.com/eea/volto-tableau/commit/881ba482dc9b82e7fdac16549d41e80a6d26b3de)]
|
|
414
|
+
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`58e25df`](https://github.com/eea/volto-tableau/commit/58e25df2291add09670143bee54cde103ee835b9)]
|
|
372
415
|
### [1.3.0](https://github.com/eea/volto-tableau/compare/1.2.5...1.3.0) - 28 September 2022
|
|
373
416
|
|
|
374
417
|
#### :hammer_and_wrench: Others
|
|
@@ -382,11 +425,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
382
425
|
- Use volto 16 alpha 14 [Miu Razvan - [`93641be`](https://github.com/eea/volto-tableau/commit/93641be4c2393f49008aff789400cf7c947949fd)]
|
|
383
426
|
- Revert volto-tableau group to common [Andrei Grigore - [`9d24c6d`](https://github.com/eea/volto-tableau/commit/9d24c6d2767fed6a840cddaee55dbd5cecb544b5)]
|
|
384
427
|
- Tableaugroup typo fix [Andrei Grigore - [`b0b5378`](https://github.com/eea/volto-tableau/commit/b0b5378a437043120a96c9e5e8802584145daa22)]
|
|
428
|
+
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3234347`](https://github.com/eea/volto-tableau/commit/3234347e524cc0ed4918242f503fe9e7dba266b2)]
|
|
385
429
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`d237e1c`](https://github.com/eea/volto-tableau/commit/d237e1c72817d7e68a3eb698563674d1514db24f)]
|
|
386
430
|
### [1.2.4](https://github.com/eea/volto-tableau/compare/1.2.3...1.2.4) - 25 October 2021
|
|
387
431
|
|
|
388
432
|
#### :hammer_and_wrench: Others
|
|
389
433
|
|
|
434
|
+
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`2b19679`](https://github.com/eea/volto-tableau/commit/2b19679e2c7bcdc83082d1c73a595eea8b86d14f)]
|
|
435
|
+
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`384ccae`](https://github.com/eea/volto-tableau/commit/384ccaebed8c414a5c90eb96c6ce0a2b091f249c)]
|
|
436
|
+
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`589258e`](https://github.com/eea/volto-tableau/commit/589258e9b3cbba9cee37c57bb85ca5b707bc65d7)]
|
|
390
437
|
### [1.2.3](https://github.com/eea/volto-tableau/compare/1.2.2...1.2.3) - 14 June 2021
|
|
391
438
|
|
|
392
439
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { Provider } from 'react-redux';
|
|
4
|
+
import configureStore from 'redux-mock-store';
|
|
5
|
+
import View from './View';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
|
|
8
|
+
|
|
9
|
+
jest.mock('@eeacms/volto-tableau/Tableau/Tableau', () =>
|
|
10
|
+
jest.fn(() => <div>Mocked Tableau</div>),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
jest.mock('@plone/volto/registry', () => ({
|
|
14
|
+
blocks: {
|
|
15
|
+
blocksConfig: {
|
|
16
|
+
tableau_block: {
|
|
17
|
+
breakpoints: {},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const mockStore = configureStore([]);
|
|
24
|
+
|
|
25
|
+
describe('View component', () => {
|
|
26
|
+
let store;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
store = mockStore({
|
|
30
|
+
router: {
|
|
31
|
+
location: {
|
|
32
|
+
search: '?param1=value1',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
discodata_query: {
|
|
36
|
+
search: {},
|
|
37
|
+
},
|
|
38
|
+
screen: {},
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders correctly with title and description when loaded', () => {
|
|
43
|
+
const mockProps = {
|
|
44
|
+
block: '1234',
|
|
45
|
+
data: {
|
|
46
|
+
title: 'Test Title',
|
|
47
|
+
description: 'Test Description',
|
|
48
|
+
staticParameters: [],
|
|
49
|
+
urlParameters: [],
|
|
50
|
+
},
|
|
51
|
+
mode: 'view',
|
|
52
|
+
query: {},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
render(
|
|
56
|
+
<Provider store={store}>
|
|
57
|
+
<View {...mockProps} />
|
|
58
|
+
</Provider>,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// Simulăm vizualizarea încărcată
|
|
62
|
+
const tableauBlock = screen.getByText('Mocked Tableau');
|
|
63
|
+
expect(tableauBlock).toBeInTheDocument();
|
|
64
|
+
|
|
65
|
+
// Verificăm titlul și descrierea
|
|
66
|
+
expect(screen.queryByText('Test Title')).not.toBeInTheDocument();
|
|
67
|
+
expect(screen.queryByText('Test Description')).not.toBeInTheDocument();
|
|
68
|
+
|
|
69
|
+
// Aici simulăm setVizState pentru a actualiza starea vizualizării ca fiind "loaded"
|
|
70
|
+
mockProps.setVizState = jest.fn((state) => {
|
|
71
|
+
state.loaded = true;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Re-render după schimbarea stării
|
|
75
|
+
render(
|
|
76
|
+
<Provider store={store}>
|
|
77
|
+
<View {...mockProps} />
|
|
78
|
+
</Provider>,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect(screen.getByText('Test Title')).toBeInTheDocument();
|
|
82
|
+
expect(screen.getByText('Test Description')).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('sets extraFilters correctly based on query parameters', () => {
|
|
86
|
+
const mockProps = {
|
|
87
|
+
block: '1234',
|
|
88
|
+
data: {
|
|
89
|
+
staticParameters: [],
|
|
90
|
+
urlParameters: [{ field: 'filter1', urlParam: 'param1' }],
|
|
91
|
+
},
|
|
92
|
+
mode: 'view',
|
|
93
|
+
query: { param1: 'value1' },
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
render(
|
|
97
|
+
<Provider store={store}>
|
|
98
|
+
<View {...mockProps} />
|
|
99
|
+
</Provider>,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect(Tableau).toHaveBeenCalledWith(
|
|
103
|
+
expect.objectContaining({
|
|
104
|
+
extraFilters: { filter1: 'value1' },
|
|
105
|
+
}),
|
|
106
|
+
{},
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('renders Tableau with correct props', () => {
|
|
111
|
+
const mockProps = {
|
|
112
|
+
block: '1234',
|
|
113
|
+
data: {
|
|
114
|
+
title: 'Test Title',
|
|
115
|
+
description: 'Test Description',
|
|
116
|
+
staticParameters: [{ field: 'static1', value: 'staticValue' }],
|
|
117
|
+
urlParameters: [],
|
|
118
|
+
},
|
|
119
|
+
mode: 'view',
|
|
120
|
+
query: {},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
render(
|
|
124
|
+
<Provider store={store}>
|
|
125
|
+
<View {...mockProps} />
|
|
126
|
+
</Provider>,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
expect(Tableau).toHaveBeenCalledWith(
|
|
130
|
+
expect.objectContaining({
|
|
131
|
+
data: expect.objectContaining({
|
|
132
|
+
title: 'Test Title',
|
|
133
|
+
description: 'Test Description',
|
|
134
|
+
with_sources: true,
|
|
135
|
+
with_download: true,
|
|
136
|
+
with_share: true,
|
|
137
|
+
with_enlarge: true,
|
|
138
|
+
}),
|
|
139
|
+
extraOptions: { static1: 'staticValue' },
|
|
140
|
+
}),
|
|
141
|
+
{},
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -16,9 +16,21 @@ import {
|
|
|
16
16
|
} from '@eeacms/volto-tableau/Tableau/helpers';
|
|
17
17
|
|
|
18
18
|
import '@eeacms/volto-tableau/less/tableau.less';
|
|
19
|
+
import { getBaseUrl } from '@plone/volto/helpers';
|
|
20
|
+
|
|
21
|
+
function blobToBase64(blob) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const reader = new FileReader();
|
|
24
|
+
reader.onloadend = () => {
|
|
25
|
+
resolve(reader.result);
|
|
26
|
+
};
|
|
27
|
+
reader.onerror = reject;
|
|
28
|
+
reader.readAsDataURL(blob);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
19
31
|
|
|
20
32
|
const VisualizationWidget = (props) => {
|
|
21
|
-
const { location, content } = props;
|
|
33
|
+
const { location, content, onChange, id } = props;
|
|
22
34
|
const ogValue = props.value || {};
|
|
23
35
|
const inAddForm = props.location.pathname.split('/').pop() === 'add';
|
|
24
36
|
const viz = React.useRef();
|
|
@@ -120,6 +132,29 @@ const VisualizationWidget = (props) => {
|
|
|
120
132
|
);
|
|
121
133
|
}, [vizState, value]);
|
|
122
134
|
|
|
135
|
+
React.useEffect(() => {
|
|
136
|
+
if (value && value.url && value.preview_url_loaded !== value.url) {
|
|
137
|
+
fetch(
|
|
138
|
+
`${getBaseUrl(
|
|
139
|
+
'',
|
|
140
|
+
)}/cors-proxy/https://screenshot.eea.europa.eu/api/v1/retrieve_image_for_url?url=${encodeURIComponent(
|
|
141
|
+
value.url,
|
|
142
|
+
)}&w=1920&h=1000&waitfor=4000`,
|
|
143
|
+
)
|
|
144
|
+
.then((e) => e.blob())
|
|
145
|
+
.then((myBlob) => {
|
|
146
|
+
blobToBase64(myBlob).then((base64String) => {
|
|
147
|
+
onChange(id, {
|
|
148
|
+
...value,
|
|
149
|
+
preview: base64String,
|
|
150
|
+
preview_url_loaded: value.url,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
})
|
|
154
|
+
.catch(() => {});
|
|
155
|
+
}
|
|
156
|
+
}, [value, onChange, id]);
|
|
157
|
+
|
|
123
158
|
return (
|
|
124
159
|
<FormFieldWrapper {...props}>
|
|
125
160
|
<Modal id="tableau-editor-modal" open={open}>
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
VisualizationViewWidget,
|
|
6
6
|
CreatableSelectWidget,
|
|
7
7
|
} from './Widgets';
|
|
8
|
+
import { preview_image } from './middlewares/preview_image';
|
|
8
9
|
|
|
9
10
|
const applyConfig = (config) => {
|
|
10
11
|
config.settings.allowed_cors_destinations = [
|
|
@@ -12,7 +13,10 @@ const applyConfig = (config) => {
|
|
|
12
13
|
'public.tableau.com',
|
|
13
14
|
];
|
|
14
15
|
|
|
15
|
-
config.settings.storeExtenders = [
|
|
16
|
+
config.settings.storeExtenders = [
|
|
17
|
+
...(config.settings.storeExtenders || []),
|
|
18
|
+
preview_image,
|
|
19
|
+
];
|
|
16
20
|
|
|
17
21
|
config.views.contentTypesViews.tableau_visualization = VisualizationView;
|
|
18
22
|
config.widgets.id.tableau_visualization = VisualizationWidget;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CREATE_CONTENT,
|
|
3
|
+
UPDATE_CONTENT,
|
|
4
|
+
} from '@plone/volto/constants/ActionTypes';
|
|
5
|
+
|
|
6
|
+
export const preview_image = (middlewares) => [
|
|
7
|
+
(store) => (next) => (action) => {
|
|
8
|
+
if (![CREATE_CONTENT, UPDATE_CONTENT].includes(action.type)) {
|
|
9
|
+
return next(action);
|
|
10
|
+
}
|
|
11
|
+
const state = store.getState();
|
|
12
|
+
const contentData = state.content.data;
|
|
13
|
+
const lastPreviewImage = Object.keys(action?.request?.data).includes(
|
|
14
|
+
'preview_image',
|
|
15
|
+
)
|
|
16
|
+
? action?.request?.data.preview_image
|
|
17
|
+
: contentData?.preview_image;
|
|
18
|
+
const type = action?.request?.data?.['@type'] || contentData['@type'];
|
|
19
|
+
if (
|
|
20
|
+
!contentData ||
|
|
21
|
+
type !== 'tableau_visualization' ||
|
|
22
|
+
contentData.preview_image_saved ||
|
|
23
|
+
!action?.request?.data?.tableau_visualization?.preview
|
|
24
|
+
) {
|
|
25
|
+
return next(action);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (
|
|
29
|
+
lastPreviewImage &&
|
|
30
|
+
lastPreviewImage !== 'preview_image_generated_tableau_visualization.png'
|
|
31
|
+
) {
|
|
32
|
+
if (action?.request?.data?.tableau_visualization) {
|
|
33
|
+
const tableauVisualizationData = {
|
|
34
|
+
...action.request.data.tableau_visualization,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
tableauVisualizationData.preview &&
|
|
39
|
+
tableauVisualizationData.preview_url_loaded
|
|
40
|
+
)
|
|
41
|
+
delete tableauVisualizationData.preview;
|
|
42
|
+
delete tableauVisualizationData.preview_url_loaded;
|
|
43
|
+
|
|
44
|
+
return next({
|
|
45
|
+
...action,
|
|
46
|
+
request: {
|
|
47
|
+
...action.request,
|
|
48
|
+
data: {
|
|
49
|
+
...action.request.data,
|
|
50
|
+
|
|
51
|
+
tableau_visualization: tableauVisualizationData,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
} else return next(action);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const previewImage = {
|
|
60
|
+
preview_image: {
|
|
61
|
+
data: action.request.data.tableau_visualization.preview.split(',')[1],
|
|
62
|
+
encoding: 'base64',
|
|
63
|
+
'content-type': 'image/png',
|
|
64
|
+
filename: 'preview_image_generated_tableau_visualization.png',
|
|
65
|
+
},
|
|
66
|
+
preview_image_saved: true,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const tableauVisualizationData = {
|
|
70
|
+
...action.request.data.tableau_visualization,
|
|
71
|
+
};
|
|
72
|
+
delete tableauVisualizationData.preview;
|
|
73
|
+
delete tableauVisualizationData.preview_url_loaded;
|
|
74
|
+
|
|
75
|
+
return next({
|
|
76
|
+
...action,
|
|
77
|
+
request: {
|
|
78
|
+
...action.request,
|
|
79
|
+
data: {
|
|
80
|
+
...action.request.data,
|
|
81
|
+
...previewImage,
|
|
82
|
+
tableau_visualization: tableauVisualizationData,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (action.request.data.tableau_visualization.preview) {
|
|
88
|
+
const tableauVisualizationData = {
|
|
89
|
+
...action.request.data.tableau_visualization,
|
|
90
|
+
};
|
|
91
|
+
delete tableauVisualizationData.preview;
|
|
92
|
+
delete tableauVisualizationData.preview_url_loaded;
|
|
93
|
+
|
|
94
|
+
return next({
|
|
95
|
+
...action,
|
|
96
|
+
request: {
|
|
97
|
+
...action.request,
|
|
98
|
+
data: {
|
|
99
|
+
...action.request.data,
|
|
100
|
+
tableau_visualization: tableauVisualizationData,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
} else return next(action);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
...middlewares,
|
|
108
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { preview_image } from './preview_image';
|
|
2
|
+
describe('preview_image middleware', () => {
|
|
3
|
+
let store;
|
|
4
|
+
let next;
|
|
5
|
+
let action;
|
|
6
|
+
let middlewares;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
store = {
|
|
10
|
+
getState: jest.fn(() => ({
|
|
11
|
+
content: {
|
|
12
|
+
data: {
|
|
13
|
+
'@type': 'tableau_visualization',
|
|
14
|
+
preview_image: 'existing_image.png',
|
|
15
|
+
preview_image_saved: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
})),
|
|
19
|
+
};
|
|
20
|
+
next = jest.fn();
|
|
21
|
+
middlewares = [];
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should pass through if action type is not CREATE_CONTENT or UPDATE_CONTENT', () => {
|
|
25
|
+
action = { type: 'UPDATE_CONTENT', request: { data: {} } };
|
|
26
|
+
const middleware = preview_image(middlewares)[0]; // Accesăm prima funcție din array
|
|
27
|
+
middleware(store)(next)(action); // Executăm funcția de middleware
|
|
28
|
+
expect(next).toHaveBeenCalledWith(action); // Verificăm că funcția next a fost apelată cu acțiunea originală
|
|
29
|
+
});
|
|
30
|
+
});
|