@eeacms/volto-tableau 3.0.8 → 4.1.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 +20 -7
- package/Jenkinsfile +2 -0
- package/jest-addon.config.js +2 -2
- package/package.json +1 -1
- package/src/{TableauBlock → Blocks/EmbedTableauVisualization}/Edit.jsx +7 -7
- package/src/Blocks/EmbedTableauVisualization/View.jsx +66 -0
- package/src/Blocks/EmbedTableauVisualization/index.js +30 -0
- package/src/Blocks/{EmbedEEATableauBlock → EmbedTableauVisualization}/schema.js +32 -13
- package/src/Blocks/TableauBlock/Edit.jsx +41 -0
- package/src/Blocks/TableauBlock/View.jsx +101 -0
- package/src/Blocks/TableauBlock/index.js +30 -0
- package/src/Blocks/TableauBlock/schema.js +224 -0
- package/src/Blocks/index.js +9 -0
- package/src/Tableau/Tableau.jsx +430 -0
- package/src/Tableau/helpers.js +41 -0
- package/src/Utils/Download/Download.jsx +72 -0
- package/src/Utils/JsonCodeSnippet/JsonCodeSnippet.jsx +48 -0
- package/src/Utils/Share/Share.jsx +21 -0
- package/src/Utils/Sources/Sources.jsx +66 -0
- package/src/Views/VisualizationView.jsx +18 -32
- package/src/Widgets/VisualizationWidget.jsx +92 -122
- package/src/Widgets/schema.js +88 -115
- package/src/helpers.js +15 -34
- package/src/hooks.js +18 -0
- package/src/icons/download.svg +5 -0
- package/src/index.js +4 -66
- package/src/less/tableau.less +172 -70
- package/src/less/tableau.variables +7 -13
- package/src/Blocks/EmbedEEATableauBlock/Edit.jsx +0 -56
- package/src/Blocks/EmbedEEATableauBlock/View.jsx +0 -74
- package/src/ConnectedTableau/ConnectedTableau.jsx +0 -29
- package/src/CustomWidgets/UrlParamsWidget.jsx +0 -29
- package/src/DownloadExtras/TableauDownload.jsx +0 -124
- package/src/DownloadExtras/TableauFullscreen.jsx +0 -78
- package/src/DownloadExtras/TableauShare.jsx +0 -81
- package/src/DownloadExtras/style.less +0 -152
- package/src/Sources/Sources.jsx +0 -50
- package/src/Sources/index.js +0 -3
- package/src/Sources/style.css +0 -7
- package/src/Tableau/View.jsx +0 -254
- package/src/TableauBlock/View.jsx +0 -109
- package/src/TableauBlock/schema.js +0 -124
- package/src/Widgets/style.less +0 -8
- package/src/actions.js +0 -9
- package/src/constants.js +0 -1
- package/src/downloadHelpers/downloadHelpers.js +0 -25
- package/src/middleware.js +0 -39
- package/src/store.js +0 -72
package/CHANGELOG.md
CHANGED
|
@@ -4,12 +4,31 @@ 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
|
+
### [4.1.0](https://github.com/eea/volto-tableau/compare/4.0.0...4.1.0) - 15 June 2023
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: improved tableau [Miu Razvan - [`4189653`](https://github.com/eea/volto-tableau/commit/41896533c23857cc4ffc9517b042b1066dfe590b)]
|
|
12
|
+
|
|
13
|
+
## [4.0.0](https://github.com/eea/volto-tableau/compare/3.0.8...4.0.0) - 13 June 2023
|
|
14
|
+
|
|
15
|
+
#### :house: Internal changes
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#### :hammer_and_wrench: Others
|
|
19
|
+
|
|
20
|
+
- update [Miu Razvan - [`02db357`](https://github.com/eea/volto-tableau/commit/02db357750d3c8d2db29b61af9e09c6880599089)]
|
|
21
|
+
- update [Miu Razvan - [`543312b`](https://github.com/eea/volto-tableau/commit/543312bcf7a7a8c385087f6c38717ba4effa938e)]
|
|
22
|
+
- prettier [Miu Razvan - [`f318c80`](https://github.com/eea/volto-tableau/commit/f318c800e6051b06053490a99c4f4923aa04c72d)]
|
|
23
|
+
- Prepeare 4.0.0 release -> require eea.api.dataconnector@4.7 [Miu Razvan - [`0a26f69`](https://github.com/eea/volto-tableau/commit/0a26f6980d3c35b7d2ac2c404a94abb0e9b89619)]
|
|
24
|
+
- refact: improve tableau + cleanup [Miu Razvan - [`6729fa0`](https://github.com/eea/volto-tableau/commit/6729fa0ebded7419d588bc87dc64bc2b47a9f572)]
|
|
25
|
+
- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`0c63253`](https://github.com/eea/volto-tableau/commit/0c632532d6d1bd79fbc553af003f949788ca6303)]
|
|
26
|
+
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`04f79a3`](https://github.com/eea/volto-tableau/commit/04f79a32af3463818768e6ce614245583faf2731)]
|
|
7
27
|
### [3.0.8](https://github.com/eea/volto-tableau/compare/3.0.7...3.0.8) - 18 May 2023
|
|
8
28
|
|
|
9
29
|
#### :bug: Bug Fixes
|
|
10
30
|
|
|
11
31
|
- fix: resolution for countup #252559 [Andrei Grigore - [`9851b63`](https://github.com/eea/volto-tableau/commit/9851b6335e710022d9402f659b2e3ec333130e2c)]
|
|
12
|
-
- fix: load screenshot of tableau in privacy protection #252559 [Andrei Grigore - [`fdc2f1b`](https://github.com/eea/volto-tableau/commit/fdc2f1b0cf0c212e5e14eefa721585686dff338d)]
|
|
13
32
|
|
|
14
33
|
#### :hammer_and_wrench: Others
|
|
15
34
|
|
|
@@ -26,7 +45,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
26
45
|
|
|
27
46
|
#### :hammer_and_wrench: Others
|
|
28
47
|
|
|
29
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`f5deccd`](https://github.com/eea/volto-tableau/commit/f5deccd84372752908b300c5cfd78134818e5ce4)]
|
|
30
48
|
### [3.0.6](https://github.com/eea/volto-tableau/compare/3.0.5...3.0.6) - 30 January 2023
|
|
31
49
|
|
|
32
50
|
### [3.0.5](https://github.com/eea/volto-tableau/compare/3.0.4...3.0.5) - 26 January 2023
|
|
@@ -98,7 +116,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
98
116
|
- Update commands.js [Nilesh - [`7c48437`](https://github.com/eea/volto-tableau/commit/7c4843780efb9b85a4728de73c00d831c1d8fdcf)]
|
|
99
117
|
- Update e2e.js [Nilesh - [`f67b45c`](https://github.com/eea/volto-tableau/commit/f67b45c170f58f8d0301192994226f173e4cb00a)]
|
|
100
118
|
- latest volto compatibility refs #154757 [nileshgulia1 - [`881ba48`](https://github.com/eea/volto-tableau/commit/881ba482dc9b82e7fdac16549d41e80a6d26b3de)]
|
|
101
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`58e25df`](https://github.com/eea/volto-tableau/commit/58e25df2291add09670143bee54cde103ee835b9)]
|
|
102
119
|
### [1.3.0](https://github.com/eea/volto-tableau/compare/1.2.5...1.3.0) - 28 September 2022
|
|
103
120
|
|
|
104
121
|
#### :hammer_and_wrench: Others
|
|
@@ -112,15 +129,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
112
129
|
- Use volto 16 alpha 14 [Miu Razvan - [`93641be`](https://github.com/eea/volto-tableau/commit/93641be4c2393f49008aff789400cf7c947949fd)]
|
|
113
130
|
- Revert volto-tableau group to common [Andrei Grigore - [`9d24c6d`](https://github.com/eea/volto-tableau/commit/9d24c6d2767fed6a840cddaee55dbd5cecb544b5)]
|
|
114
131
|
- Tableaugroup typo fix [Andrei Grigore - [`b0b5378`](https://github.com/eea/volto-tableau/commit/b0b5378a437043120a96c9e5e8802584145daa22)]
|
|
115
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3234347`](https://github.com/eea/volto-tableau/commit/3234347e524cc0ed4918242f503fe9e7dba266b2)]
|
|
116
132
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`d237e1c`](https://github.com/eea/volto-tableau/commit/d237e1c72817d7e68a3eb698563674d1514db24f)]
|
|
117
133
|
### [1.2.4](https://github.com/eea/volto-tableau/compare/1.2.3...1.2.4) - 25 October 2021
|
|
118
134
|
|
|
119
135
|
#### :hammer_and_wrench: Others
|
|
120
136
|
|
|
121
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`2b19679`](https://github.com/eea/volto-tableau/commit/2b19679e2c7bcdc83082d1c73a595eea8b86d14f)]
|
|
122
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`384ccae`](https://github.com/eea/volto-tableau/commit/384ccaebed8c414a5c90eb96c6ce0a2b091f249c)]
|
|
123
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`589258e`](https://github.com/eea/volto-tableau/commit/589258e9b3cbba9cee37c57bb85ca5b707bc65d7)]
|
|
124
137
|
### [1.2.3](https://github.com/eea/volto-tableau/compare/1.2.2...1.2.3) - 14 June 2021
|
|
125
138
|
|
|
126
139
|
#### :hammer_and_wrench: Others
|
package/Jenkinsfile
CHANGED
|
@@ -6,6 +6,7 @@ pipeline {
|
|
|
6
6
|
NAMESPACE = "@eeacms"
|
|
7
7
|
SONARQUBE_TAGS = "volto.eea.europa.eu,climate-energy.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,water.europa.eu-freshwater,water.europa.eu-marine,industry.eea.europa.eu"
|
|
8
8
|
DEPENDENCIES = ""
|
|
9
|
+
VOLTO = ""
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
stages {
|
|
@@ -187,6 +188,7 @@ pipeline {
|
|
|
187
188
|
def nodeJS = tool 'NodeJS';
|
|
188
189
|
withSonarQubeEnv('Sonarqube') {
|
|
189
190
|
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
|
|
191
|
+
sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
|
|
190
192
|
sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
|
|
191
193
|
sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
|
|
192
194
|
}
|
package/jest-addon.config.js
CHANGED
|
@@ -5,18 +5,18 @@ module.exports = {
|
|
|
5
5
|
'!src/**/*.d.ts',
|
|
6
6
|
],
|
|
7
7
|
moduleNameMapper: {
|
|
8
|
+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
8
9
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
9
10
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
10
11
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
11
12
|
'@package/(.*)$': '<rootDir>/src/$1',
|
|
12
13
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
13
|
-
'@eeacms/(.*?)/(.*)$': '<rootDir>/
|
|
14
|
+
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
14
15
|
'@plone/volto-slate':
|
|
15
16
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
16
17
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
17
18
|
'load-volto-addons':
|
|
18
19
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
19
|
-
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
20
20
|
},
|
|
21
21
|
transform: {
|
|
22
22
|
'^.+\\.js(x)?$': 'babel-jest',
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
2
3
|
import { SidebarPortal } from '@plone/volto/components';
|
|
3
|
-
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
4
|
-
import config from '@plone/volto/registry';
|
|
5
|
-
import getSchema from './schema';
|
|
6
4
|
import View from './View';
|
|
5
|
+
import getSchema from './schema';
|
|
7
6
|
|
|
8
7
|
const Edit = (props) => {
|
|
9
|
-
const
|
|
8
|
+
const schema = React.useMemo(() => getSchema(props), [props]);
|
|
10
9
|
|
|
11
10
|
return (
|
|
12
|
-
|
|
11
|
+
<React.Fragment>
|
|
13
12
|
<View {...props} mode="edit" />
|
|
14
13
|
<SidebarPortal selected={props.selected}>
|
|
15
|
-
<
|
|
14
|
+
<BlockDataForm
|
|
15
|
+
block={props.block}
|
|
16
16
|
schema={schema}
|
|
17
17
|
title={schema.title}
|
|
18
18
|
onChangeField={(id, value) => {
|
|
@@ -24,7 +24,7 @@ const Edit = (props) => {
|
|
|
24
24
|
formData={props.data}
|
|
25
25
|
/>
|
|
26
26
|
</SidebarPortal>
|
|
27
|
-
|
|
27
|
+
</React.Fragment>
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PrivacyProtection } from '@eeacms/volto-embed';
|
|
3
|
+
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
|
|
4
|
+
|
|
5
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
6
|
+
import { getContent } from '@plone/volto/actions';
|
|
7
|
+
|
|
8
|
+
import { connect } from 'react-redux';
|
|
9
|
+
import { compose } from 'redux';
|
|
10
|
+
|
|
11
|
+
const View = (props) => {
|
|
12
|
+
const data = props.data;
|
|
13
|
+
const { with_sources = true, with_download = true, with_share = true } = data;
|
|
14
|
+
const { data_provenance, tableau_visualization } =
|
|
15
|
+
props.tableau_visualization_data || {};
|
|
16
|
+
const tableau_vis_url = flattenToAppURL(data.tableau_vis_url || '');
|
|
17
|
+
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
if (tableau_vis_url) {
|
|
20
|
+
props.getContent(tableau_vis_url, null, props.id);
|
|
21
|
+
}
|
|
22
|
+
// eslint-disable-next-line
|
|
23
|
+
}, [tableau_vis_url]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="embed-container">
|
|
27
|
+
<PrivacyProtection
|
|
28
|
+
{...props}
|
|
29
|
+
data={{ ...data, url: tableau_visualization?.url }}
|
|
30
|
+
>
|
|
31
|
+
{!tableau_vis_url && (
|
|
32
|
+
<div>Please select a tableau visualization from block editor.</div>
|
|
33
|
+
)}
|
|
34
|
+
{!!tableau_vis_url && (
|
|
35
|
+
<>
|
|
36
|
+
{!tableau_visualization?.url && props.mode === 'edit' && (
|
|
37
|
+
<div>Url is not set in the visualization</div>
|
|
38
|
+
)}
|
|
39
|
+
{!!tableau_visualization?.url && (
|
|
40
|
+
<Tableau
|
|
41
|
+
data={{
|
|
42
|
+
...tableau_visualization,
|
|
43
|
+
with_sources,
|
|
44
|
+
with_download,
|
|
45
|
+
with_share,
|
|
46
|
+
}}
|
|
47
|
+
sources={data_provenance.data || []}
|
|
48
|
+
/>
|
|
49
|
+
)}
|
|
50
|
+
</>
|
|
51
|
+
)}
|
|
52
|
+
</PrivacyProtection>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default compose(
|
|
58
|
+
connect(
|
|
59
|
+
(state, props) => ({
|
|
60
|
+
tableau_visualization_data: state.content.subrequests?.[props.id]?.data,
|
|
61
|
+
}),
|
|
62
|
+
{
|
|
63
|
+
getContent,
|
|
64
|
+
},
|
|
65
|
+
),
|
|
66
|
+
)(React.memo(View));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import EmbedTableauVisualizatonEdit from './Edit';
|
|
2
|
+
import EmbedTableauVisualizatonView from './View';
|
|
3
|
+
|
|
4
|
+
import sliderSVG from '@plone/volto/icons/slider.svg';
|
|
5
|
+
|
|
6
|
+
export default (config) => {
|
|
7
|
+
config.blocks.blocksConfig.embed_tableau_visualization = {
|
|
8
|
+
id: 'embed_tableau_visualization',
|
|
9
|
+
title: 'Embed EEA Tableau visualization',
|
|
10
|
+
icon: sliderSVG,
|
|
11
|
+
group: 'common',
|
|
12
|
+
edit: EmbedTableauVisualizatonEdit,
|
|
13
|
+
view: EmbedTableauVisualizatonView,
|
|
14
|
+
restricted: false,
|
|
15
|
+
mostUsed: false,
|
|
16
|
+
sidebarTab: 1,
|
|
17
|
+
blocks: {},
|
|
18
|
+
security: {
|
|
19
|
+
addPermission: [],
|
|
20
|
+
view: [],
|
|
21
|
+
},
|
|
22
|
+
breakpoints: {
|
|
23
|
+
desktop: [Infinity, 992],
|
|
24
|
+
tablet: [991, 768],
|
|
25
|
+
phone: [767, 0],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return config;
|
|
30
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getProtectionSchema = () => ({
|
|
2
2
|
title: 'Data Protection',
|
|
3
3
|
|
|
4
4
|
fieldsets: [
|
|
@@ -40,33 +40,52 @@ const ProtectionSchema = () => ({
|
|
|
40
40
|
required: [],
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
export default () => {
|
|
44
44
|
return {
|
|
45
|
-
title: 'Embed EEA Tableau',
|
|
45
|
+
title: 'Embed EEA Tableau visualization',
|
|
46
46
|
fieldsets: [
|
|
47
47
|
{
|
|
48
48
|
id: 'default',
|
|
49
49
|
title: 'Default',
|
|
50
|
-
fields: [
|
|
50
|
+
fields: [
|
|
51
|
+
'tableau_vis_url',
|
|
52
|
+
'with_sources',
|
|
53
|
+
'with_download',
|
|
54
|
+
'with_share',
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'privacy',
|
|
59
|
+
title: 'Privacy',
|
|
60
|
+
fields: ['dataprotection'],
|
|
51
61
|
},
|
|
52
62
|
],
|
|
53
63
|
properties: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
tableau_vis_url: {
|
|
65
|
+
title: 'Tableau visualization',
|
|
66
|
+
widget: 'url',
|
|
67
|
+
},
|
|
68
|
+
with_download: {
|
|
69
|
+
title: 'Show download button',
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
defaultValue: true,
|
|
57
72
|
},
|
|
58
|
-
|
|
59
|
-
title: '
|
|
73
|
+
with_share: {
|
|
74
|
+
title: 'Show share button',
|
|
60
75
|
type: 'boolean',
|
|
76
|
+
defaultValue: true,
|
|
77
|
+
},
|
|
78
|
+
with_sources: {
|
|
79
|
+
title: 'Show sources',
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
defaultValue: true,
|
|
61
82
|
},
|
|
62
83
|
dataprotection: {
|
|
63
84
|
widget: 'object',
|
|
64
|
-
schema:
|
|
85
|
+
schema: getProtectionSchema(),
|
|
65
86
|
},
|
|
66
87
|
},
|
|
67
88
|
|
|
68
|
-
required: ['
|
|
89
|
+
required: ['tableau_vis_url'],
|
|
69
90
|
};
|
|
70
91
|
};
|
|
71
|
-
|
|
72
|
-
export default Schema;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
3
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
4
|
+
import config from '@plone/volto/registry';
|
|
5
|
+
import getSchema from './schema';
|
|
6
|
+
import View from './View';
|
|
7
|
+
|
|
8
|
+
const Edit = (props) => {
|
|
9
|
+
const viz = React.useRef();
|
|
10
|
+
const [vizState, setVizState] = React.useState({
|
|
11
|
+
loaded: false,
|
|
12
|
+
loading: false,
|
|
13
|
+
error: null,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const schema = React.useMemo(() => getSchema(config, viz.current, vizState), [
|
|
17
|
+
vizState,
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<View {...props} mode="edit" setVizState={setVizState} ref={viz} />
|
|
23
|
+
<SidebarPortal selected={props.selected}>
|
|
24
|
+
<BlockDataForm
|
|
25
|
+
block={props.block}
|
|
26
|
+
schema={schema}
|
|
27
|
+
title={schema.title}
|
|
28
|
+
onChangeField={(id, value) => {
|
|
29
|
+
props.onChangeBlock(props.block, {
|
|
30
|
+
...props.data,
|
|
31
|
+
[id]: value,
|
|
32
|
+
});
|
|
33
|
+
}}
|
|
34
|
+
formData={props.data}
|
|
35
|
+
/>
|
|
36
|
+
</SidebarPortal>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default Edit;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau';
|
|
4
|
+
import qs from 'querystring';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
import '@eeacms/volto-tableau/less/tableau.less';
|
|
7
|
+
|
|
8
|
+
const View = React.forwardRef((props, ref) => {
|
|
9
|
+
const viz = React.useRef();
|
|
10
|
+
const [vizState, setVizState] = React.useState({
|
|
11
|
+
loaded: false,
|
|
12
|
+
loading: false,
|
|
13
|
+
error: null,
|
|
14
|
+
});
|
|
15
|
+
const [extraFilters, setExtraFilters] = React.useState({});
|
|
16
|
+
const { block, data = {}, query = {}, onChangeBlock, mode } = props;
|
|
17
|
+
const {
|
|
18
|
+
urlParameters = [],
|
|
19
|
+
staticParameters = [],
|
|
20
|
+
title = null,
|
|
21
|
+
description = null,
|
|
22
|
+
with_sources = true,
|
|
23
|
+
with_download = true,
|
|
24
|
+
with_share = true,
|
|
25
|
+
sources,
|
|
26
|
+
} = data;
|
|
27
|
+
|
|
28
|
+
const extraOptions = React.useMemo(() => {
|
|
29
|
+
const options = {};
|
|
30
|
+
staticParameters.forEach((parameter) => {
|
|
31
|
+
if (parameter.field) {
|
|
32
|
+
options[parameter.field] = parameter.value;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return options;
|
|
36
|
+
}, [staticParameters]);
|
|
37
|
+
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
const newFilters = { ...extraFilters };
|
|
40
|
+
urlParameters.forEach((element) => {
|
|
41
|
+
if (element.field && typeof query[element.urlParam] !== 'undefined') {
|
|
42
|
+
newFilters[element.field] = query[element.urlParam];
|
|
43
|
+
} else if (newFilters[element.field]) {
|
|
44
|
+
delete newFilters[element.field];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
setExtraFilters(newFilters);
|
|
48
|
+
/* eslint-disable-next-line */
|
|
49
|
+
}, [JSON.stringify(query), JSON.stringify(urlParameters)]);
|
|
50
|
+
|
|
51
|
+
React.useImperativeHandle(ref, () => {
|
|
52
|
+
return viz.current;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (props.setVizState) {
|
|
57
|
+
props.setVizState(vizState);
|
|
58
|
+
}
|
|
59
|
+
/* eslint-disable-next-line */
|
|
60
|
+
}, [vizState]);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div className="tableau-block">
|
|
64
|
+
{vizState.loaded && title ? (
|
|
65
|
+
<h3 className="tableau-title">{title}</h3>
|
|
66
|
+
) : (
|
|
67
|
+
''
|
|
68
|
+
)}
|
|
69
|
+
{vizState.loaded && description ? (
|
|
70
|
+
<p className="tableau-description">{description}</p>
|
|
71
|
+
) : (
|
|
72
|
+
''
|
|
73
|
+
)}
|
|
74
|
+
<Tableau
|
|
75
|
+
ref={viz}
|
|
76
|
+
mode={mode}
|
|
77
|
+
block={block}
|
|
78
|
+
data={{ ...data, with_sources, with_download, with_share }}
|
|
79
|
+
sources={sources}
|
|
80
|
+
extraFilters={extraFilters}
|
|
81
|
+
extraOptions={extraOptions}
|
|
82
|
+
breakpoints={config.blocks.blocksConfig.tableau_block.breakpoints}
|
|
83
|
+
setVizState={setVizState}
|
|
84
|
+
onChangeBlock={onChangeBlock}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export default connect(
|
|
91
|
+
(state) => ({
|
|
92
|
+
query: {
|
|
93
|
+
...(qs.parse(state.router.location?.search?.replace('?', '')) || {}),
|
|
94
|
+
...(state.discodata_query?.search || {}),
|
|
95
|
+
},
|
|
96
|
+
screen: state.screen,
|
|
97
|
+
}),
|
|
98
|
+
null,
|
|
99
|
+
null,
|
|
100
|
+
{ forwardRef: true },
|
|
101
|
+
)(View);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import TableauEdit from './Edit';
|
|
2
|
+
import TableauView from './View';
|
|
3
|
+
|
|
4
|
+
import sliderSVG from '@plone/volto/icons/slider.svg';
|
|
5
|
+
|
|
6
|
+
export default (config) => {
|
|
7
|
+
config.blocks.blocksConfig.tableau_block = {
|
|
8
|
+
id: 'tableau_block',
|
|
9
|
+
title: 'Tableau',
|
|
10
|
+
icon: sliderSVG,
|
|
11
|
+
group: 'common',
|
|
12
|
+
edit: TableauEdit,
|
|
13
|
+
view: TableauView,
|
|
14
|
+
restricted: false,
|
|
15
|
+
mostUsed: false,
|
|
16
|
+
sidebarTab: 1,
|
|
17
|
+
blocks: {},
|
|
18
|
+
security: {
|
|
19
|
+
addPermission: [],
|
|
20
|
+
view: [],
|
|
21
|
+
},
|
|
22
|
+
breakpoints: {
|
|
23
|
+
desktop: [Infinity, 992],
|
|
24
|
+
tablet: [991, 768],
|
|
25
|
+
phone: [767, 0],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return config;
|
|
30
|
+
};
|