@eeacms/volto-tableau 5.0.0 → 5.0.2
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/.husky/pre-commit +2 -0
- package/CHANGELOG.md +64 -1
- package/DEVELOP.md +61 -6
- package/Dockerfile +14 -0
- package/Jenkinsfile +67 -18
- package/Makefile +131 -0
- package/README.md +12 -113
- package/RELEASE.md +74 -0
- package/cypress.config.js +1 -1
- package/docker-compose.yml +32 -0
- package/locales/de/LC_MESSAGES/volto.po +14 -0
- package/locales/en/LC_MESSAGES/volto.po +14 -0
- package/locales/it/LC_MESSAGES/volto.po +14 -0
- package/locales/ro/LC_MESSAGES/volto.po +14 -0
- package/locales/volto.pot +16 -0
- package/package.json +38 -10
- package/src/Blocks/EmbedTableauVisualization/View.jsx +15 -2
- package/src/Blocks/EmbedTableauVisualization/View.test.jsx +44 -0
- package/src/Blocks/EmbedTableauVisualization/schema.js +22 -4
- package/src/Tableau/Tableau.jsx +21 -6
- package/src/Tableau/Tableau.test.jsx +30 -0
- package/src/Utils/Download/Download.jsx +69 -41
- package/src/Utils/Download/Download.test.jsx +22 -0
- package/src/Utils/FigureNote/FigureNote.jsx +43 -0
- package/src/Utils/FigureNote/FigureNote.test.jsx +25 -0
- package/src/Utils/MoreInfoLink/MoreInfoLink.jsx +22 -0
- package/src/Utils/MoreInfoLink/MoreInfoLink.test.jsx +24 -0
- package/src/Utils/Share/Share.jsx +62 -14
- package/src/Utils/Sources/Sources.jsx +5 -4
- package/src/Views/VisualizationView.jsx +1 -4
- package/src/Widgets/VisualizationViewWidget.jsx +0 -3
- package/src/helpers.js +24 -0
- package/src/less/tableau.less +143 -35
- package/src/less/tableau.variables +3 -1
- package/.i18n.babel.config.js +0 -1
package/RELEASE.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## Release
|
|
2
|
+
|
|
3
|
+
### Automatic release using Jenkins
|
|
4
|
+
|
|
5
|
+
* The automatic release is started by creating a [Pull Request](../../compare/master...develop) from `develop` to `master`. The pull request status checks correlated to the branch and PR Jenkins jobs need to be processed successfully. 1 review from a github user with rights is mandatory.
|
|
6
|
+
* It runs on every commit on `master` branch, which is protected from direct commits, only allowing pull request merge commits.
|
|
7
|
+
* The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the Readme.md badges and the green check/red cross/yellow circle near the last commit information. If you click on the icon, you will have the list of checks that were run. The `continuous-integration/jenkins/branch` link goes to the Jenkins job execution webpage.
|
|
8
|
+
* Automated release scripts are located in the `eeacms/gitflow` docker image, specifically [js-release.sh](https://github.com/eea/eea.docker.gitflow/blob/master/src/js-release.sh) script. It uses the `release-it` tool.
|
|
9
|
+
* As long as a PR request is open from develop to master, the PR Jenkins job will automatically re-create the CHANGELOG.md and package.json files to be production-ready.
|
|
10
|
+
* The version format must be MAJOR.MINOR.PATCH. By default, next release is set to next minor version (with patch 0).
|
|
11
|
+
* You can manually change the version in `package.json`. The new version must not be already present in the tags/releases of the repository, otherwise it will be automatically increased by the script. Any changes to the version will trigger a `CHANGELOG.md` re-generation.
|
|
12
|
+
* Automated commits and commits with [JENKINS] or [YARN] in the commit log are excluded from `CHANGELOG.md` file.
|
|
13
|
+
|
|
14
|
+
### Manual release from the develop branch ( beta release )
|
|
15
|
+
|
|
16
|
+
#### Installation and configuration of release-it
|
|
17
|
+
|
|
18
|
+
You need to first install the [release-it](https://github.com/release-it/release-it) client.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install -g release-it
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
|
|
25
|
+
|
|
26
|
+
Release-it is a tool that automates 4 important steps in the release process:
|
|
27
|
+
|
|
28
|
+
1. Version increase in `package.json` ( increased from the current version in `package.json`)
|
|
29
|
+
2. `CHANGELOG.md` automatic generation from commit messages ( grouped by releases )
|
|
30
|
+
3. GitHub release on the commit with the changelog and package.json modification on the develop branch
|
|
31
|
+
4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
|
|
32
|
+
|
|
33
|
+
To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Using release-it tool
|
|
46
|
+
|
|
47
|
+
There are 3 yarn scripts that can be run to do the release
|
|
48
|
+
|
|
49
|
+
##### yarn release-beta
|
|
50
|
+
|
|
51
|
+
Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
? Select increment (next version):
|
|
55
|
+
❯ prepatch (0.1.1-beta.0)
|
|
56
|
+
preminor (0.2.0-beta.0)
|
|
57
|
+
premajor (1.0.0-beta.0)
|
|
58
|
+
Other, please specify...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
##### yarn release-major-beta
|
|
62
|
+
|
|
63
|
+
Same as `yarn release-beta`, but with premajor version pre-selected.
|
|
64
|
+
|
|
65
|
+
##### yarn release
|
|
66
|
+
|
|
67
|
+
Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
|
|
68
|
+
|
|
69
|
+
#### Important notes
|
|
70
|
+
|
|
71
|
+
> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
|
|
72
|
+
|
|
73
|
+
> Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
|
|
74
|
+
|
package/cypress.config.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
version: "3"
|
|
2
|
+
services:
|
|
3
|
+
backend:
|
|
4
|
+
image: eeacms/plone-backend
|
|
5
|
+
ports:
|
|
6
|
+
- "8080:8080"
|
|
7
|
+
environment:
|
|
8
|
+
SITE: "Plone"
|
|
9
|
+
PROFILES: "eea.kitkat:testing"
|
|
10
|
+
|
|
11
|
+
frontend:
|
|
12
|
+
build:
|
|
13
|
+
context: ./
|
|
14
|
+
dockerfile: ./Dockerfile
|
|
15
|
+
args:
|
|
16
|
+
ADDON_NAME: "${ADDON_NAME}"
|
|
17
|
+
ADDON_PATH: "${ADDON_PATH}"
|
|
18
|
+
VOLTO_VERSION: ${VOLTO_VERSION:-16}
|
|
19
|
+
ports:
|
|
20
|
+
- "3000:3000"
|
|
21
|
+
- "3001:3001"
|
|
22
|
+
depends_on:
|
|
23
|
+
- backend
|
|
24
|
+
volumes:
|
|
25
|
+
- ./:/app/src/addons/${ADDON_PATH}
|
|
26
|
+
environment:
|
|
27
|
+
CI: "true"
|
|
28
|
+
NODE_ENV: "development"
|
|
29
|
+
RAZZLE_JEST_CONFIG: "src/addons/${ADDON_PATH}/jest-addon.config.js"
|
|
30
|
+
RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone"
|
|
31
|
+
RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone"
|
|
32
|
+
HOST: "0.0.0.0"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: \n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: \n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: \n"
|
|
8
|
+
"Language: \n"
|
|
9
|
+
"Language-Team: \n"
|
|
10
|
+
"Content-Type: \n"
|
|
11
|
+
"Content-Transfer-Encoding: \n"
|
|
12
|
+
"Plural-Forms: \n"
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: \n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: \n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: \n"
|
|
8
|
+
"Language: \n"
|
|
9
|
+
"Language-Team: \n"
|
|
10
|
+
"Content-Type: \n"
|
|
11
|
+
"Content-Transfer-Encoding: \n"
|
|
12
|
+
"Plural-Forms: \n"
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: \n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: \n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: \n"
|
|
8
|
+
"Language: \n"
|
|
9
|
+
"Language-Team: \n"
|
|
10
|
+
"Content-Type: \n"
|
|
11
|
+
"Content-Transfer-Encoding: \n"
|
|
12
|
+
"Plural-Forms: \n"
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: \n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: \n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: \n"
|
|
8
|
+
"Language: \n"
|
|
9
|
+
"Language-Team: \n"
|
|
10
|
+
"Content-Type: \n"
|
|
11
|
+
"Content-Transfer-Encoding: \n"
|
|
12
|
+
"Plural-Forms: \n"
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: Plone\n"
|
|
4
|
+
"POT-Creation-Date: 2023-06-28T10:48:22.678Z\n"
|
|
5
|
+
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
6
|
+
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
7
|
+
"MIME-Version: 1.0\n"
|
|
8
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
9
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
10
|
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
11
|
+
"Language-Code: en\n"
|
|
12
|
+
"Language-Name: English\n"
|
|
13
|
+
"Preferred-Encodings: utf-8\n"
|
|
14
|
+
"Domain: volto\n"
|
|
15
|
+
|
|
16
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-tableau",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "@eeacms/volto-tableau: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -30,21 +30,49 @@
|
|
|
30
30
|
"@cypress/code-coverage": "^3.9.5",
|
|
31
31
|
"@plone/scripts": "*",
|
|
32
32
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
33
|
+
"husky": "^8.0.3",
|
|
34
|
+
"lint-staged": "^14.0.1",
|
|
33
35
|
"md5": "^2.3.0"
|
|
34
36
|
},
|
|
37
|
+
"lint-staged": {
|
|
38
|
+
"src/**/*.{js,jsx,ts,tsx,json}": [
|
|
39
|
+
"make lint-fix",
|
|
40
|
+
"make prettier-fix"
|
|
41
|
+
],
|
|
42
|
+
"src/**/*.{jsx}": [
|
|
43
|
+
"make i18n"
|
|
44
|
+
],
|
|
45
|
+
"theme/**/*.{css,less}": [
|
|
46
|
+
"make stylelint-fix"
|
|
47
|
+
],
|
|
48
|
+
"src/**/*.{css,less}": [
|
|
49
|
+
"make stylelint-fix"
|
|
50
|
+
],
|
|
51
|
+
"theme/**/*.overrides": [
|
|
52
|
+
"make stylelint-fix"
|
|
53
|
+
],
|
|
54
|
+
"src/**/*.overrides": [
|
|
55
|
+
"make stylelint-fix"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
35
58
|
"scripts": {
|
|
36
59
|
"release": "release-it",
|
|
37
60
|
"release-major-beta": "release-it major --preRelease=beta",
|
|
38
61
|
"release-beta": "release-it --preRelease=beta",
|
|
39
62
|
"bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
63
|
+
"test": "make test",
|
|
64
|
+
"test:fix": "make test-update",
|
|
65
|
+
"pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix",
|
|
66
|
+
"stylelint": "make stylelint",
|
|
67
|
+
"stylelint:overrides": "make stylelint-overrides",
|
|
68
|
+
"stylelint:fix": "make stylelint-fix",
|
|
69
|
+
"prettier": "make prettier",
|
|
70
|
+
"prettier:fix": "make prettier-fix",
|
|
71
|
+
"lint": "make lint",
|
|
72
|
+
"lint:fix": "make lint-fix",
|
|
73
|
+
"i18n": "make i18n",
|
|
74
|
+
"cypress:run": "make cypress-run",
|
|
75
|
+
"cypress:open": "make cypress-open",
|
|
76
|
+
"prepare": "husky install"
|
|
49
77
|
}
|
|
50
78
|
}
|
|
@@ -10,9 +10,17 @@ import { compose } from 'redux';
|
|
|
10
10
|
|
|
11
11
|
const View = (props) => {
|
|
12
12
|
const data = props.data;
|
|
13
|
-
const {
|
|
14
|
-
|
|
13
|
+
const {
|
|
14
|
+
with_note = true,
|
|
15
|
+
with_sources = true,
|
|
16
|
+
with_more_info = true,
|
|
17
|
+
with_download = true,
|
|
18
|
+
with_share = true,
|
|
19
|
+
tableau_height = '700',
|
|
20
|
+
} = data;
|
|
21
|
+
const { figure_note = [], data_provenance = {}, tableau_visualization } =
|
|
15
22
|
props.tableau_visualization_data || {};
|
|
23
|
+
|
|
16
24
|
const tableau_vis_url = flattenToAppURL(data.tableau_vis_url || '');
|
|
17
25
|
|
|
18
26
|
React.useEffect(() => {
|
|
@@ -40,10 +48,15 @@ const View = (props) => {
|
|
|
40
48
|
<Tableau
|
|
41
49
|
data={{
|
|
42
50
|
...tableau_visualization,
|
|
51
|
+
with_note,
|
|
43
52
|
with_sources,
|
|
53
|
+
with_more_info,
|
|
44
54
|
with_download,
|
|
45
55
|
with_share,
|
|
56
|
+
tableau_height,
|
|
57
|
+
tableau_vis_url,
|
|
46
58
|
}}
|
|
59
|
+
figure_note={figure_note}
|
|
47
60
|
sources={data_provenance.data || []}
|
|
48
61
|
/>
|
|
49
62
|
)}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import { Provider } from 'react-redux';
|
|
5
|
+
import configureStore from 'redux-mock-store';
|
|
6
|
+
import View from './View';
|
|
7
|
+
|
|
8
|
+
const mockStore = configureStore([]);
|
|
9
|
+
const store = mockStore({ content: { subrequests: [] } });
|
|
10
|
+
|
|
11
|
+
window.URL.createObjectURL = jest.fn(() => 'test');
|
|
12
|
+
|
|
13
|
+
jest.mock('@eeacms/volto-embed', () => ({
|
|
14
|
+
PrivacyProtection: ({ children }) => <div>{children}</div>,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('@plone/volto/components', () => ({
|
|
18
|
+
Icon: ({ children }) => <img alt="incon">{children}</img>,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('@plone/volto/components', () => ({
|
|
22
|
+
Toast: ({ children }) => <p>{children}</p>,
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
describe('View', () => {
|
|
26
|
+
const data = {
|
|
27
|
+
'@type': 'embed_tableau_visualization',
|
|
28
|
+
dataprotection: {},
|
|
29
|
+
tableau_vis_url: 'http://localhost:3000/tableau-ct',
|
|
30
|
+
with_download: true,
|
|
31
|
+
with_more_info: true,
|
|
32
|
+
with_note: true,
|
|
33
|
+
with_share: true,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
it('should render the component', () => {
|
|
37
|
+
const { container } = render(
|
|
38
|
+
<Provider store={store}>
|
|
39
|
+
<View data={data} />
|
|
40
|
+
</Provider>,
|
|
41
|
+
);
|
|
42
|
+
expect(container.querySelector('.embed-container')).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -49,9 +49,12 @@ export default () => {
|
|
|
49
49
|
title: 'Default',
|
|
50
50
|
fields: [
|
|
51
51
|
'tableau_vis_url',
|
|
52
|
+
'with_note',
|
|
52
53
|
'with_sources',
|
|
54
|
+
'with_more_info',
|
|
53
55
|
'with_download',
|
|
54
56
|
'with_share',
|
|
57
|
+
'tableau_height',
|
|
55
58
|
],
|
|
56
59
|
},
|
|
57
60
|
{
|
|
@@ -65,6 +68,21 @@ export default () => {
|
|
|
65
68
|
title: 'Tableau visualization',
|
|
66
69
|
widget: 'url',
|
|
67
70
|
},
|
|
71
|
+
with_note: {
|
|
72
|
+
title: 'Show note',
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
defaultValue: true,
|
|
75
|
+
},
|
|
76
|
+
with_sources: {
|
|
77
|
+
title: 'Show sources',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
defaultValue: true,
|
|
80
|
+
},
|
|
81
|
+
with_more_info: {
|
|
82
|
+
title: 'Show more info',
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
defaultValue: true,
|
|
85
|
+
},
|
|
68
86
|
with_download: {
|
|
69
87
|
title: 'Show download button',
|
|
70
88
|
type: 'boolean',
|
|
@@ -75,10 +93,10 @@ export default () => {
|
|
|
75
93
|
type: 'boolean',
|
|
76
94
|
defaultValue: true,
|
|
77
95
|
},
|
|
78
|
-
|
|
79
|
-
title: '
|
|
80
|
-
type: '
|
|
81
|
-
defaultValue:
|
|
96
|
+
tableau_height: {
|
|
97
|
+
title: 'Height',
|
|
98
|
+
type: 'text',
|
|
99
|
+
defaultValue: '700',
|
|
82
100
|
},
|
|
83
101
|
dataprotection: {
|
|
84
102
|
widget: 'object',
|
package/src/Tableau/Tableau.jsx
CHANGED
|
@@ -16,7 +16,9 @@ import { Button } from 'semantic-ui-react';
|
|
|
16
16
|
import { Toast, Icon } from '@plone/volto/components';
|
|
17
17
|
import { useTableau } from '@eeacms/volto-tableau/hooks';
|
|
18
18
|
import JsonCodeSnippet from '@eeacms/volto-tableau/Utils/JsonCodeSnippet/JsonCodeSnippet';
|
|
19
|
+
import FigureNote from '@eeacms/volto-tableau/Utils/FigureNote/FigureNote';
|
|
19
20
|
import Sources from '@eeacms/volto-tableau/Utils/Sources/Sources';
|
|
21
|
+
import MoreInfoLink from '@eeacms/volto-tableau/Utils/MoreInfoLink/MoreInfoLink';
|
|
20
22
|
import Download from '@eeacms/volto-tableau/Utils/Download/Download';
|
|
21
23
|
import Share from '@eeacms/volto-tableau/Utils/Share/Share';
|
|
22
24
|
import { getSheetnames, getActiveSheetname, getDevice } from './helpers';
|
|
@@ -80,8 +82,9 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
80
82
|
extraOptions = {},
|
|
81
83
|
mode = 'view',
|
|
82
84
|
screen = {},
|
|
83
|
-
|
|
85
|
+
figure_note = [],
|
|
84
86
|
sources,
|
|
87
|
+
version = '2.8.0',
|
|
85
88
|
setVizState,
|
|
86
89
|
onChangeBlock,
|
|
87
90
|
} = props;
|
|
@@ -92,11 +95,14 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
92
95
|
sheetname = '',
|
|
93
96
|
toolbarPosition = 'Top',
|
|
94
97
|
breakpointUrls = [],
|
|
98
|
+
tableau_vis_url,
|
|
99
|
+
with_note,
|
|
95
100
|
with_sources,
|
|
101
|
+
with_more_info,
|
|
96
102
|
with_download,
|
|
97
103
|
with_share,
|
|
104
|
+
tableau_height = '700',
|
|
98
105
|
} = data;
|
|
99
|
-
|
|
100
106
|
const device = useMemo(
|
|
101
107
|
() => getDevice(breakpoints, screen.page?.width || Infinity),
|
|
102
108
|
[breakpoints, screen],
|
|
@@ -406,15 +412,24 @@ const Tableau = forwardRef((props, ref) => {
|
|
|
406
412
|
clearData={clearData}
|
|
407
413
|
/>
|
|
408
414
|
<div
|
|
415
|
+
style={{ height: tableau_height + 'px' }}
|
|
409
416
|
className={cx('tableau', `tableau-${version}`, {
|
|
410
417
|
'tableau-autoscale': autoScale,
|
|
411
418
|
})}
|
|
412
419
|
ref={vizEl}
|
|
413
420
|
/>
|
|
414
|
-
<div className="
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
421
|
+
<div className="visualization-info-container">
|
|
422
|
+
<div className="visualization-info">
|
|
423
|
+
{with_note && loaded && <FigureNote note={figure_note || []} />}
|
|
424
|
+
{with_sources && loaded && <Sources sources={sources} />}
|
|
425
|
+
{with_more_info && loaded && (
|
|
426
|
+
<MoreInfoLink contentTypeLink={tableau_vis_url} />
|
|
427
|
+
)}
|
|
428
|
+
</div>
|
|
429
|
+
<div className="visualization-info">
|
|
430
|
+
{with_download && loaded && <Download viz={viz.current} />}
|
|
431
|
+
{with_share && loaded && <Share contentTypeLink={tableau_vis_url} />}
|
|
432
|
+
</div>
|
|
418
433
|
</div>
|
|
419
434
|
</div>
|
|
420
435
|
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import { Provider } from 'react-redux';
|
|
5
|
+
import configureStore from 'redux-mock-store';
|
|
6
|
+
import Tableau from './Tableau';
|
|
7
|
+
|
|
8
|
+
const mockStore = configureStore([]);
|
|
9
|
+
const store = mockStore({});
|
|
10
|
+
|
|
11
|
+
window.URL.createObjectURL = jest.fn(() => 'test');
|
|
12
|
+
|
|
13
|
+
jest.mock('@plone/volto/components', () => ({
|
|
14
|
+
Icon: ({ children }) => <img alt="incon">{children}</img>,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('@plone/volto/components', () => ({
|
|
18
|
+
Toast: ({ children }) => <p>{children}</p>,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
describe('Tableau', () => {
|
|
22
|
+
it('should render the component', () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<Provider store={store}>
|
|
25
|
+
<Tableau />
|
|
26
|
+
</Provider>,
|
|
27
|
+
);
|
|
28
|
+
expect(container.querySelector('.tableau-wrapper')).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Popup } from 'semantic-ui-react';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
-
import { Icon } from '@plone/volto/components';
|
|
5
|
-
import downloadSVG from '@eeacms/volto-tableau/icons/download.svg';
|
|
6
4
|
|
|
7
5
|
const Download = ({ viz }) => {
|
|
8
6
|
const [expanded, setExpanded] = React.useState(false);
|
|
@@ -14,8 +12,7 @@ const Download = ({ viz }) => {
|
|
|
14
12
|
trigger={
|
|
15
13
|
<div className="tableau-download-container">
|
|
16
14
|
<button className={cx('tableau-download-button', { expanded })}>
|
|
17
|
-
|
|
18
|
-
<Icon name={downloadSVG} size="24px" />
|
|
15
|
+
Download <i class="ri-download-fill"></i>
|
|
19
16
|
</button>
|
|
20
17
|
</div>
|
|
21
18
|
}
|
|
@@ -29,42 +26,73 @@ const Download = ({ viz }) => {
|
|
|
29
26
|
}}
|
|
30
27
|
ref={popupRef}
|
|
31
28
|
>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
29
|
+
<ul className="no-bullets">
|
|
30
|
+
<li>
|
|
31
|
+
Data formats
|
|
32
|
+
<div className="visualization-wrapper">
|
|
33
|
+
<div className="visualization-info">
|
|
34
|
+
<div>
|
|
35
|
+
<button
|
|
36
|
+
className="tableau-download-button tableau-format-download"
|
|
37
|
+
onClick={() => {
|
|
38
|
+
viz.showExportCrossTabDialog();
|
|
39
|
+
popupRef.current.triggerRef.current.click();
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<span>CSV</span>
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
<div>
|
|
46
|
+
<button
|
|
47
|
+
className="tableau-download-button tableau-format-download"
|
|
48
|
+
onClick={() => {
|
|
49
|
+
viz.exportCrossTabToExcel();
|
|
50
|
+
popupRef.current.triggerRef.current.click();
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<span>Excel</span>
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</li>
|
|
59
|
+
<li>
|
|
60
|
+
Image formats
|
|
61
|
+
<div className="visualization-wrapper">
|
|
62
|
+
<div className="visualization-info">
|
|
63
|
+
<div>
|
|
64
|
+
<button
|
|
65
|
+
className="tableau-download-button tableau-format-download"
|
|
66
|
+
onClick={() => {
|
|
67
|
+
viz.showExportImageDialog();
|
|
68
|
+
popupRef.current.triggerRef.current.click();
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<span>PNG</span>
|
|
72
|
+
</button>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</li>
|
|
77
|
+
<li>
|
|
78
|
+
Other formats
|
|
79
|
+
<div className="visualization-wrapper">
|
|
80
|
+
<div className="visualization-info">
|
|
81
|
+
<div>
|
|
82
|
+
<button
|
|
83
|
+
className="tableau-download-button tableau-format-download"
|
|
84
|
+
onClick={() => {
|
|
85
|
+
viz.showExportPDFDialog();
|
|
86
|
+
popupRef.current.triggerRef.current.click();
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<span>PDF</span>
|
|
90
|
+
</button>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</li>
|
|
95
|
+
</ul>
|
|
68
96
|
</Popup>
|
|
69
97
|
);
|
|
70
98
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
|
|
5
|
+
import Download from './Download';
|
|
6
|
+
|
|
7
|
+
window.URL.createObjectURL = jest.fn(() => 'test');
|
|
8
|
+
|
|
9
|
+
jest.mock('@plone/volto/components', () => ({
|
|
10
|
+
Icon: ({ children }) => <img alt="incon">{children}</img>,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('Download', () => {
|
|
14
|
+
const viz = {};
|
|
15
|
+
|
|
16
|
+
it('should render the component', () => {
|
|
17
|
+
const { container } = render(<Download viz={viz} />);
|
|
18
|
+
expect(
|
|
19
|
+
container.querySelector('.tableau-download-container'),
|
|
20
|
+
).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|