@eeacms/volto-tableau 6.0.6 → 7.0.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.
- package/CHANGELOG.md +30 -3
- package/Jenkinsfile +29 -26
- package/README.md +19 -15
- package/package.json +1 -1
- package/src/Blocks/EmbedTableauVisualization/Edit.jsx +3 -2
- package/src/Blocks/EmbedTableauVisualization/Edit.test.jsx +87 -0
- package/src/Blocks/EmbedTableauVisualization/View.jsx +36 -28
- package/src/Blocks/EmbedTableauVisualization/View.test.jsx +34 -14
- package/src/Blocks/EmbedTableauVisualization/__snapshots__/Edit.test.jsx.snap +20 -0
- package/src/Blocks/EmbedTableauVisualization/__snapshots__/View.test.jsx.snap +18 -1
- package/src/Blocks/EmbedTableauVisualization/index.js +1 -1
- package/src/Tableau/Tableau.jsx +9 -12
- package/src/Utils/Download.test.jsx +44 -0
- package/src/Utils/__snapshots__/Download.test.jsx.snap +111 -0
- package/src/Views/VisualizationView.jsx +2 -0
- package/src/Widgets/VisualizationViewWidget.jsx +10 -5
- package/src/Widgets/VisualizationViewWidget.test.jsx +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,38 @@ 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
|
-
### [
|
|
7
|
+
### [7.0.1](https://github.com/eea/volto-tableau/compare/7.0.0...7.0.1) - 24 November 2023
|
|
8
8
|
|
|
9
|
-
#### :
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- fix [Miu Razvan - [`4036e40`](https://github.com/eea/volto-tableau/commit/4036e4018bc0faf86aba7a330b52f0a975343be0)]
|
|
12
|
+
- update [Miu Razvan - [`e274b41`](https://github.com/eea/volto-tableau/commit/e274b416f65b446f0e2453e9f0ed6f4cdd27a3f6)]
|
|
13
|
+
- fix [Miu Razvan - [`da14168`](https://github.com/eea/volto-tableau/commit/da14168f40d161264488810e7b08facb265a2c00)]
|
|
14
|
+
- fix [Miu Razvan - [`faba267`](https://github.com/eea/volto-tableau/commit/faba267e7fde6a5b906fdcff010ed9d46ecea741)]
|
|
15
|
+
- fix [Miu Razvan - [`a772a85`](https://github.com/eea/volto-tableau/commit/a772a85e19b80a7202f23ad45e3aff6fa3ae9c3c)]
|
|
16
|
+
## [7.0.0](https://github.com/eea/volto-tableau/compare/6.0.6...7.0.0) - 23 November 2023
|
|
17
|
+
|
|
18
|
+
#### :bug: Bug Fixes
|
|
19
|
+
|
|
20
|
+
- fix: unittests [Miu Razvan - [`ce983d2`](https://github.com/eea/volto-tableau/commit/ce983d26d18fc2ed6d24f3fa64999e85c3b90051)]
|
|
10
21
|
|
|
11
|
-
|
|
22
|
+
#### :hammer_and_wrench: Others
|
|
23
|
+
|
|
24
|
+
- update [Miu Razvan - [`a7a6f1f`](https://github.com/eea/volto-tableau/commit/a7a6f1f8f0f2ed727a13d386fd30396f80418130)]
|
|
25
|
+
- bump version [Miu Razvan - [`192c7ae`](https://github.com/eea/volto-tableau/commit/192c7ae64e6c659a1f676a3506aa87563cb715e7)]
|
|
26
|
+
- tests [Miu Razvan - [`94aeb23`](https://github.com/eea/volto-tableau/commit/94aeb2332fa98088b0da456df692368163d01221)]
|
|
27
|
+
- update [Miu Razvan - [`daaeeb5`](https://github.com/eea/volto-tableau/commit/daaeeb51876276909d506c9f1851b83089ff9124)]
|
|
28
|
+
- update [Miu Razvan - [`48e976f`](https://github.com/eea/volto-tableau/commit/48e976f0e9ff6d11dd18a61f6d17bd6c0de11e5a)]
|
|
29
|
+
- update [Miu Razvan - [`fcc702a`](https://github.com/eea/volto-tableau/commit/fcc702a38cc3942d84282443d5de543f0e361389)]
|
|
30
|
+
- update [Miu Razvan - [`ef9abd3`](https://github.com/eea/volto-tableau/commit/ef9abd3617bde7148fe2ac6d33079f3d5f82a302)]
|
|
31
|
+
- update snapshot [Dobricean Ioan Dorian - [`baaeccf`](https://github.com/eea/volto-tableau/commit/baaeccf8c589c7a6bac6a5522a0a23b90b9fda1d)]
|
|
32
|
+
- unify view and edit [Dobricean Ioan Dorian - [`1159da9`](https://github.com/eea/volto-tableau/commit/1159da96057dc78a1ac46371c57f55e7786aab34)]
|
|
33
|
+
- fix tests [Dobricean Ioan Dorian - [`33bff4b`](https://github.com/eea/volto-tableau/commit/33bff4b8e9060548610990c6817b49cb06be79ae)]
|
|
34
|
+
- test [Dobricean Ioan Dorian - [`48505ca`](https://github.com/eea/volto-tableau/commit/48505caef84d12091035fdd79cf64067e7f819e2)]
|
|
35
|
+
- split the view and edit [Dobricean Ioan Dorian - [`7227bb1`](https://github.com/eea/volto-tableau/commit/7227bb1fb70e5d895f15872ed6533e089be99836)]
|
|
36
|
+
- update embed tableau so it can work with serialized data [Dobricean Ioan Dorian - [`59d958c`](https://github.com/eea/volto-tableau/commit/59d958c7a1a5055ea62e04abcbf34ee93f52e23a)]
|
|
37
|
+
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`c452d70`](https://github.com/eea/volto-tableau/commit/c452d704819fb485e3cd3b39c2501361d20e8559)]
|
|
38
|
+
### [6.0.6](https://github.com/eea/volto-tableau/compare/6.0.5...6.0.6) - 17 November 2023
|
|
12
39
|
|
|
13
40
|
#### :hammer_and_wrench: Others
|
|
14
41
|
|
package/Jenkinsfile
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
pipeline {
|
|
2
|
+
tools {
|
|
3
|
+
jdk 'Java17'
|
|
4
|
+
}
|
|
2
5
|
agent {
|
|
3
6
|
node { label 'docker-host' }
|
|
4
7
|
}
|
|
@@ -245,33 +248,33 @@ pipeline {
|
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
250
|
|
|
248
|
-
stage('SonarQube compare to master') {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
251
|
+
// stage('SonarQube compare to master') {
|
|
252
|
+
// when {
|
|
253
|
+
// anyOf {
|
|
254
|
+
// allOf {
|
|
255
|
+
// not { environment name: 'CHANGE_ID', value: '' }
|
|
256
|
+
// environment name: 'CHANGE_TARGET', value: 'develop'
|
|
257
|
+
// }
|
|
258
|
+
// allOf {
|
|
259
|
+
// environment name: 'CHANGE_ID', value: ''
|
|
260
|
+
// branch 'develop'
|
|
261
|
+
// not { changelog '.*^Automated release [0-9\\.]+$' }
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
264
|
+
// }
|
|
265
|
+
// steps {
|
|
266
|
+
// script {
|
|
267
|
+
// sh '''echo "Error" > checkresult.txt'''
|
|
268
|
+
// catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
|
269
|
+
// sh '''set -o pipefail; docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt'''
|
|
270
|
+
// }
|
|
268
271
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
272
|
+
// publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: 'Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed',
|
|
273
|
+
// text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
|
|
274
|
+
// detailsURL: "${env.BUILD_URL}display/redirect"
|
|
275
|
+
// }
|
|
276
|
+
// }
|
|
277
|
+
// }
|
|
275
278
|
|
|
276
279
|
stage('Pull Request') {
|
|
277
280
|
when {
|
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@ Registers a VisualizationView component for a content type named 'tableau_visual
|
|
|
24
24
|
|
|
25
25
|
## Getting started
|
|
26
26
|
|
|
27
|
+
### Upgrade
|
|
28
|
+
|
|
29
|
+
#### 7.x.x -> requires >= eea.api.dataconnector@7.0
|
|
30
|
+
|
|
27
31
|
### Try volto-tableau with Docker
|
|
28
32
|
|
|
29
33
|
git clone https://github.com/eea/volto-tableau.git
|
|
@@ -43,25 +47,25 @@ Go to http://localhost:3000
|
|
|
43
47
|
|
|
44
48
|
1. Start Volto frontend
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
- If you already have a volto project, just update `package.json`:
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
```JSON
|
|
53
|
+
"addons": [
|
|
54
|
+
"@eeacms/volto-tableau"
|
|
55
|
+
],
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@eeacms/volto-tableau": "*"
|
|
59
|
+
}
|
|
60
|
+
```
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
- If not, create one:
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
```
|
|
65
|
+
npm install -g yo @plone/generator-volto
|
|
66
|
+
yo @plone/volto my-volto-project --canary --addon @eeacms/volto-tableau
|
|
67
|
+
cd my-volto-project
|
|
68
|
+
```
|
|
65
69
|
|
|
66
70
|
1. Install new add-ons and restart Volto:
|
|
67
71
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
3
3
|
import { SidebarPortal } from '@plone/volto/components';
|
|
4
|
-
import View from './View';
|
|
5
4
|
import getSchema from './schema';
|
|
6
5
|
|
|
6
|
+
import View from './View';
|
|
7
|
+
|
|
7
8
|
const Edit = (props) => {
|
|
8
9
|
const schema = React.useMemo(() => getSchema(props), [props]);
|
|
9
10
|
|
|
10
11
|
return (
|
|
11
12
|
<React.Fragment>
|
|
12
|
-
<View
|
|
13
|
+
<View mode="edit" {...props} />
|
|
13
14
|
<SidebarPortal selected={props.selected}>
|
|
14
15
|
<BlockDataForm
|
|
15
16
|
block={props.block}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
|
|
7
|
+
import Edit from './Edit';
|
|
8
|
+
import installEmbedTableau from '.';
|
|
9
|
+
|
|
10
|
+
installEmbedTableau(config);
|
|
11
|
+
|
|
12
|
+
const mockStore = configureStore([]);
|
|
13
|
+
|
|
14
|
+
window.URL.createObjectURL = jest.fn(() => 'test');
|
|
15
|
+
|
|
16
|
+
jest.mock('@plone/volto/components', () => ({
|
|
17
|
+
Icon: ({ children }) => <img alt="incon">{children}</img>,
|
|
18
|
+
Toast: ({ children }) => <p>{children}</p>,
|
|
19
|
+
SidebarPortal: jest.requireActual(
|
|
20
|
+
'@plone/volto/components/manage/Sidebar/SidebarPortal',
|
|
21
|
+
).default,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
jest.mock('@eeacms/volto-matomo/utils', () => ({
|
|
25
|
+
trackLink: jest.fn(),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
jest.mock(
|
|
29
|
+
'@eeacms/volto-embed/PrivacyProtection/PrivacyProtection',
|
|
30
|
+
() => ({ children }) => {
|
|
31
|
+
return children;
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
jest.mock('@eeacms/volto-embed/helpers', () => ({
|
|
36
|
+
pickMetadata: (data) => data,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const store = mockStore({
|
|
40
|
+
intl: {
|
|
41
|
+
locale: 'en',
|
|
42
|
+
messages: {},
|
|
43
|
+
},
|
|
44
|
+
content: {
|
|
45
|
+
create: {},
|
|
46
|
+
subrequests: [],
|
|
47
|
+
},
|
|
48
|
+
connected_data_parameters: {},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('Edit', () => {
|
|
52
|
+
const data = {
|
|
53
|
+
'@type': 'embed_tableau_visualization',
|
|
54
|
+
dataprotection: {
|
|
55
|
+
enabled: false,
|
|
56
|
+
},
|
|
57
|
+
tableau_vis_url: 'http://localhost:3000/tableau-ct',
|
|
58
|
+
with_download: true,
|
|
59
|
+
with_more_info: true,
|
|
60
|
+
with_notes: true,
|
|
61
|
+
with_share: true,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
it('should render the component', () => {
|
|
65
|
+
const component = renderer.create(
|
|
66
|
+
<Provider store={store}>
|
|
67
|
+
<Edit
|
|
68
|
+
id="my-tableau"
|
|
69
|
+
data={data}
|
|
70
|
+
pathname="/news"
|
|
71
|
+
selected={false}
|
|
72
|
+
block="1234"
|
|
73
|
+
index={1}
|
|
74
|
+
onChangeBlock={() => {}}
|
|
75
|
+
onSelectBlock={() => {}}
|
|
76
|
+
onDeleteBlock={() => {}}
|
|
77
|
+
onFocusPreviousBlock={() => {}}
|
|
78
|
+
onFocusNextBlock={() => {}}
|
|
79
|
+
handleKeyDown={() => {}}
|
|
80
|
+
content={{}}
|
|
81
|
+
/>
|
|
82
|
+
</Provider>,
|
|
83
|
+
);
|
|
84
|
+
const json = component.toJSON();
|
|
85
|
+
expect(json).toMatchSnapshot();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { connect } from 'react-redux';
|
|
3
|
-
import { compose } from 'redux';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
4
2
|
import { Message } from 'semantic-ui-react';
|
|
5
3
|
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
4
|
+
import { connect } from 'react-redux';
|
|
5
|
+
import { compose } from 'redux';
|
|
6
6
|
import { getContent } from '@plone/volto/actions';
|
|
7
|
-
import
|
|
7
|
+
import PrivacyProtection from '@eeacms/volto-embed/PrivacyProtection/PrivacyProtection';
|
|
8
|
+
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
8
9
|
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
|
|
9
10
|
|
|
11
|
+
function getTableauVisualization(props) {
|
|
12
|
+
const { isBlock } = props;
|
|
13
|
+
const content = (isBlock ? props.tableauContent : props.content) || {};
|
|
14
|
+
const tableau_visualization =
|
|
15
|
+
(isBlock
|
|
16
|
+
? props.tableauContent?.tableau_visualization
|
|
17
|
+
: props.content?.tableau_visualization) ||
|
|
18
|
+
props.data.tableau_visualization ||
|
|
19
|
+
{};
|
|
20
|
+
return {
|
|
21
|
+
...pickMetadata(content),
|
|
22
|
+
...tableau_visualization,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
const View = (props) => {
|
|
11
|
-
const data = props
|
|
27
|
+
const { isBlock, id, mode, data, getContent } = props;
|
|
12
28
|
const {
|
|
13
29
|
with_notes = true,
|
|
14
30
|
with_sources = true,
|
|
@@ -18,32 +34,25 @@ const View = (props) => {
|
|
|
18
34
|
with_enlarge = true,
|
|
19
35
|
tableau_height = 700,
|
|
20
36
|
} = data;
|
|
21
|
-
const { figure_note = [], data_provenance = {}, tableau_visualization } =
|
|
22
|
-
props.tableau_visualization_data || {};
|
|
23
37
|
|
|
24
38
|
const tableau_vis_url = flattenToAppURL(data.tableau_vis_url || '');
|
|
25
39
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
const tableau_visualization = getTableauVisualization(props);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const tableauVisId = flattenToAppURL(tableau_visualization['@id'] || '');
|
|
44
|
+
if (
|
|
45
|
+
isBlock &&
|
|
46
|
+
mode === 'edit' &&
|
|
47
|
+
tableau_vis_url &&
|
|
48
|
+
tableau_vis_url !== tableauVisId
|
|
49
|
+
) {
|
|
50
|
+
getContent(tableau_vis_url, null, id);
|
|
29
51
|
}
|
|
30
|
-
|
|
31
|
-
}, [tableau_vis_url]);
|
|
52
|
+
}, [id, isBlock, getContent, mode, tableau_vis_url, tableau_visualization]);
|
|
32
53
|
|
|
33
54
|
if (props.mode === 'edit' && !tableau_vis_url) {
|
|
34
|
-
return
|
|
35
|
-
<Message>
|
|
36
|
-
Please select a tableau visualization from block editor.
|
|
37
|
-
</Message>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (props.mode === 'edit' && !tableau_visualization?.url) {
|
|
42
|
-
return <Message>Url is not set in the visualization</Message>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!tableau_visualization?.url) {
|
|
46
|
-
return null;
|
|
55
|
+
return <Message>Please select a tableau from block editor.</Message>;
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
return (
|
|
@@ -64,8 +73,6 @@ const View = (props) => {
|
|
|
64
73
|
tableau_height,
|
|
65
74
|
tableau_vis_url,
|
|
66
75
|
}}
|
|
67
|
-
figure_note={figure_note}
|
|
68
|
-
sources={data_provenance.data || []}
|
|
69
76
|
/>
|
|
70
77
|
</PrivacyProtection>
|
|
71
78
|
</div>
|
|
@@ -75,7 +82,8 @@ const View = (props) => {
|
|
|
75
82
|
export default compose(
|
|
76
83
|
connect(
|
|
77
84
|
(state, props) => ({
|
|
78
|
-
|
|
85
|
+
tableauContent: state.content.subrequests?.[props.id]?.data,
|
|
86
|
+
isBlock: !!props.data?.['@type'],
|
|
79
87
|
}),
|
|
80
88
|
{
|
|
81
89
|
getContent,
|
|
@@ -1,31 +1,51 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import { Provider } from 'react-redux';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
5
3
|
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
6
5
|
import View from './View';
|
|
7
6
|
|
|
8
7
|
const mockStore = configureStore([]);
|
|
9
|
-
const store = mockStore({ content: { subrequests: [] } });
|
|
10
8
|
|
|
11
9
|
window.URL.createObjectURL = jest.fn(() => 'test');
|
|
12
10
|
|
|
13
|
-
jest.mock('@eeacms/volto-embed', () => ({
|
|
14
|
-
PrivacyProtection: ({ children }) => <div>{children}</div>,
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
11
|
jest.mock('@plone/volto/components', () => ({
|
|
18
12
|
Icon: ({ children }) => <img alt="incon">{children}</img>,
|
|
13
|
+
Toast: ({ children }) => <p>{children}</p>,
|
|
19
14
|
}));
|
|
20
15
|
|
|
21
|
-
jest.mock('@
|
|
22
|
-
|
|
16
|
+
jest.mock('@eeacms/volto-matomo/utils', () => ({
|
|
17
|
+
trackLink: jest.fn(),
|
|
23
18
|
}));
|
|
24
19
|
|
|
20
|
+
jest.mock(
|
|
21
|
+
'@eeacms/volto-embed/PrivacyProtection/PrivacyProtection',
|
|
22
|
+
() => ({ children }) => {
|
|
23
|
+
return children;
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
jest.mock('@eeacms/volto-embed/helpers', () => ({
|
|
28
|
+
pickMetadata: (data) => data,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const store = mockStore({
|
|
32
|
+
intl: {
|
|
33
|
+
locale: 'en',
|
|
34
|
+
messages: {},
|
|
35
|
+
},
|
|
36
|
+
content: {
|
|
37
|
+
create: {},
|
|
38
|
+
subrequests: [],
|
|
39
|
+
},
|
|
40
|
+
connected_data_parameters: {},
|
|
41
|
+
});
|
|
42
|
+
|
|
25
43
|
describe('View', () => {
|
|
26
44
|
const data = {
|
|
27
45
|
'@type': 'embed_tableau_visualization',
|
|
28
|
-
dataprotection: {
|
|
46
|
+
dataprotection: {
|
|
47
|
+
enabled: false,
|
|
48
|
+
},
|
|
29
49
|
tableau_vis_url: 'http://localhost:3000/tableau-ct',
|
|
30
50
|
with_download: true,
|
|
31
51
|
with_more_info: true,
|
|
@@ -34,12 +54,12 @@ describe('View', () => {
|
|
|
34
54
|
};
|
|
35
55
|
|
|
36
56
|
it('should render the component', () => {
|
|
37
|
-
const
|
|
57
|
+
const component = renderer.create(
|
|
38
58
|
<Provider store={store}>
|
|
39
59
|
<View data={data} />
|
|
40
60
|
</Provider>,
|
|
41
61
|
);
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
const json = component.toJSON();
|
|
63
|
+
expect(json).toMatchSnapshot();
|
|
44
64
|
});
|
|
45
65
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Edit should render the component 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="embed-tableau"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
className="tableau-wrapper"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
className="tableau tableau-2.8.0"
|
|
12
|
+
style={
|
|
13
|
+
Object {
|
|
14
|
+
"height": "700px",
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
`;
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`View should render the component 1`] =
|
|
3
|
+
exports[`View should render the component 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="embed-tableau"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
className="tableau-wrapper"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
className="tableau tableau-2.8.0"
|
|
12
|
+
style={
|
|
13
|
+
Object {
|
|
14
|
+
"height": "700px",
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
`;
|
|
@@ -6,7 +6,7 @@ import sliderSVG from '@plone/volto/icons/slider.svg';
|
|
|
6
6
|
export default (config) => {
|
|
7
7
|
config.blocks.blocksConfig.embed_tableau_visualization = {
|
|
8
8
|
id: 'embed_tableau_visualization',
|
|
9
|
-
title: 'Embed
|
|
9
|
+
title: 'Embed Dashboard (Tableau)',
|
|
10
10
|
icon: sliderSVG,
|
|
11
11
|
group: 'common',
|
|
12
12
|
edit: EmbedTableauVisualizatonEdit,
|
package/src/Tableau/Tableau.jsx
CHANGED
|
@@ -89,20 +89,19 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
89
89
|
extraOptions = {},
|
|
90
90
|
mode = 'view',
|
|
91
91
|
screen = {},
|
|
92
|
-
figure_note = [],
|
|
93
|
-
sources,
|
|
94
92
|
version = '2.8.0',
|
|
95
93
|
setVizState,
|
|
96
94
|
onChangeBlock,
|
|
97
95
|
} = props;
|
|
98
96
|
const {
|
|
97
|
+
data_provenance = {},
|
|
98
|
+
figure_note = [],
|
|
99
99
|
autoScale = false,
|
|
100
100
|
hideTabs = false,
|
|
101
101
|
hideToolbar = false,
|
|
102
102
|
sheetname = '',
|
|
103
103
|
toolbarPosition = 'Top',
|
|
104
104
|
breakpointUrls = [],
|
|
105
|
-
tableau_vis_url,
|
|
106
105
|
with_notes = true,
|
|
107
106
|
with_sources = true,
|
|
108
107
|
with_more_info = true,
|
|
@@ -317,14 +316,14 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
317
316
|
};
|
|
318
317
|
|
|
319
318
|
const updateScale = () => {
|
|
320
|
-
const
|
|
319
|
+
const iframe = vizEl.current.querySelector('iframe');
|
|
321
320
|
const { sheetSize = {} } = viz.current.getVizSize() || {};
|
|
322
321
|
const vizWidth = sheetSize?.minSize?.width || 1;
|
|
323
322
|
const scale = Math.min(vizEl.current.clientWidth / vizWidth, 1);
|
|
324
|
-
|
|
323
|
+
iframe.style.transform = `scale(${scale})`;
|
|
325
324
|
window.requestAnimationFrame(() => {
|
|
326
325
|
if (vizEl.current) {
|
|
327
|
-
vizEl.current.style.height = `${scale *
|
|
326
|
+
vizEl.current.style.height = `${scale * iframe.clientHeight}px`;
|
|
328
327
|
}
|
|
329
328
|
});
|
|
330
329
|
};
|
|
@@ -441,9 +440,9 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
441
440
|
{loaded && (
|
|
442
441
|
<div className={cx('visualization-toolbar', { mobile })}>
|
|
443
442
|
<div className="left-col">
|
|
444
|
-
{with_notes && <FigureNote
|
|
445
|
-
{with_sources && <Sources sources={
|
|
446
|
-
{with_more_info && <MoreInfo href={
|
|
443
|
+
{with_notes && <FigureNote notes={figure_note || []} />}
|
|
444
|
+
{with_sources && <Sources sources={data_provenance?.data || []} />}
|
|
445
|
+
{with_more_info && <MoreInfo href={data['@id']} />}
|
|
447
446
|
</div>
|
|
448
447
|
<div className="right-col">
|
|
449
448
|
{with_enlarge && loaded && (
|
|
@@ -463,9 +462,7 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
463
462
|
</Enlarge>
|
|
464
463
|
)}
|
|
465
464
|
{with_download && loaded && <Download viz={viz.current} />}
|
|
466
|
-
{with_share && loaded &&
|
|
467
|
-
<Share href={tableau_vis_url || data.url} />
|
|
468
|
-
)}
|
|
465
|
+
{with_share && loaded && <Share href={data['@id']} />}
|
|
469
466
|
</div>
|
|
470
467
|
</div>
|
|
471
468
|
)}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
|
|
6
|
+
import Download from './Download';
|
|
7
|
+
|
|
8
|
+
const mockStore = configureStore([]);
|
|
9
|
+
|
|
10
|
+
window.URL.createObjectURL = jest.fn(() => 'test');
|
|
11
|
+
|
|
12
|
+
jest.mock('semantic-ui-react', () => ({
|
|
13
|
+
Popup: ({ content, trigger }) => {
|
|
14
|
+
return (
|
|
15
|
+
<div className="popup">
|
|
16
|
+
<div className="trigger">{trigger}</div>
|
|
17
|
+
<div className="content">{content}</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const store = mockStore({
|
|
24
|
+
intl: {
|
|
25
|
+
locale: 'en',
|
|
26
|
+
messages: {},
|
|
27
|
+
},
|
|
28
|
+
content: {
|
|
29
|
+
create: {},
|
|
30
|
+
subrequests: [],
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Edit', () => {
|
|
35
|
+
it('should render the component', () => {
|
|
36
|
+
const component = renderer.create(
|
|
37
|
+
<Provider store={store}>
|
|
38
|
+
<Download />
|
|
39
|
+
</Provider>,
|
|
40
|
+
);
|
|
41
|
+
const json = component.toJSON();
|
|
42
|
+
expect(json).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Edit should render the component 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="popup"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
className="trigger"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
className="tableau-download-container"
|
|
12
|
+
>
|
|
13
|
+
<button
|
|
14
|
+
className="trigger-button"
|
|
15
|
+
>
|
|
16
|
+
<i
|
|
17
|
+
className="ri-download-fill"
|
|
18
|
+
/>
|
|
19
|
+
Download
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div
|
|
24
|
+
className="content"
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
className="item"
|
|
28
|
+
>
|
|
29
|
+
<span
|
|
30
|
+
className="label"
|
|
31
|
+
>
|
|
32
|
+
Data formats
|
|
33
|
+
</span>
|
|
34
|
+
<div
|
|
35
|
+
className="types"
|
|
36
|
+
>
|
|
37
|
+
<div
|
|
38
|
+
className="type"
|
|
39
|
+
>
|
|
40
|
+
<button
|
|
41
|
+
onClick={[Function]}
|
|
42
|
+
>
|
|
43
|
+
<span>
|
|
44
|
+
CSV
|
|
45
|
+
</span>
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
<div
|
|
49
|
+
className="type"
|
|
50
|
+
>
|
|
51
|
+
<button
|
|
52
|
+
onClick={[Function]}
|
|
53
|
+
>
|
|
54
|
+
<span>
|
|
55
|
+
Excel
|
|
56
|
+
</span>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<div
|
|
62
|
+
className="item"
|
|
63
|
+
>
|
|
64
|
+
<span
|
|
65
|
+
className="label"
|
|
66
|
+
>
|
|
67
|
+
Image formats
|
|
68
|
+
</span>
|
|
69
|
+
<div
|
|
70
|
+
className="types"
|
|
71
|
+
>
|
|
72
|
+
<div
|
|
73
|
+
className="type"
|
|
74
|
+
>
|
|
75
|
+
<button
|
|
76
|
+
onClick={[Function]}
|
|
77
|
+
>
|
|
78
|
+
<span>
|
|
79
|
+
PNG
|
|
80
|
+
</span>
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div
|
|
86
|
+
className="item"
|
|
87
|
+
>
|
|
88
|
+
<span
|
|
89
|
+
className="label"
|
|
90
|
+
>
|
|
91
|
+
Other formats
|
|
92
|
+
</span>
|
|
93
|
+
<div
|
|
94
|
+
className="types"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
className="type"
|
|
98
|
+
>
|
|
99
|
+
<button
|
|
100
|
+
onClick={[Function]}
|
|
101
|
+
>
|
|
102
|
+
<span>
|
|
103
|
+
PDF
|
|
104
|
+
</span>
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
`;
|
|
@@ -3,6 +3,7 @@ import { hasBlocksData } from '@plone/volto/helpers';
|
|
|
3
3
|
import { Container } from 'semantic-ui-react';
|
|
4
4
|
import config from '@plone/volto/registry';
|
|
5
5
|
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
6
|
+
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
6
7
|
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
|
|
7
8
|
|
|
8
9
|
const VisualizationView = (props) => {
|
|
@@ -17,6 +18,7 @@ const VisualizationView = (props) => {
|
|
|
17
18
|
<Tableau
|
|
18
19
|
data={{
|
|
19
20
|
...tableau_visualization,
|
|
21
|
+
...pickMetadata(content),
|
|
20
22
|
with_notes: false,
|
|
21
23
|
with_sources: false,
|
|
22
24
|
with_more_info: false,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { connect } from 'react-redux';
|
|
2
2
|
import config from '@plone/volto/registry';
|
|
3
|
+
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
4
|
+
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
const { value = {} } = props;
|
|
6
|
-
|
|
6
|
+
function VisualizationViewWidget(props) {
|
|
7
7
|
return (
|
|
8
8
|
<Tableau
|
|
9
9
|
data={{
|
|
10
|
-
...value,
|
|
10
|
+
...(props.value || {}),
|
|
11
|
+
...pickMetadata(props.content),
|
|
11
12
|
with_notes: false,
|
|
12
13
|
with_sources: false,
|
|
13
14
|
with_more_info: false,
|
|
@@ -21,3 +22,7 @@ export default function VisualizationViewWidget(props) {
|
|
|
21
22
|
/>
|
|
22
23
|
);
|
|
23
24
|
}
|
|
25
|
+
|
|
26
|
+
export default connect((state) => ({ content: state.content.data }))(
|
|
27
|
+
VisualizationViewWidget,
|
|
28
|
+
);
|
|
@@ -6,13 +6,19 @@ import configureStore from 'redux-mock-store';
|
|
|
6
6
|
import VisualizationViewWidget from './VisualizationViewWidget';
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore([]);
|
|
9
|
-
const store = mockStore({
|
|
9
|
+
const store = mockStore({
|
|
10
|
+
content: { data: {} },
|
|
11
|
+
});
|
|
10
12
|
|
|
11
13
|
jest.mock('@plone/volto/components', () => ({
|
|
12
14
|
Icon: ({ children }) => <img alt="incon">{children}</img>,
|
|
13
15
|
Toast: ({ children }) => <p>{children}</p>,
|
|
14
16
|
}));
|
|
15
17
|
|
|
18
|
+
jest.mock('@eeacms/volto-embed/helpers', () => ({
|
|
19
|
+
pickMetadata: (data) => data,
|
|
20
|
+
}));
|
|
21
|
+
|
|
16
22
|
describe('VisualizationViewWidget', () => {
|
|
17
23
|
it('should render the component', () => {
|
|
18
24
|
const data = {
|