@eeacms/volto-tableau 3.0.2 → 3.0.3

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,6 +4,12 @@ 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
+ ### [3.0.3](https://github.com/eea/volto-tableau/compare/3.0.2...3.0.3) - 17 January 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Add volto-embed and volto-block-style addons [dana-cfc4 - [`e557a05`](https://github.com/eea/volto-tableau/commit/e557a0561a46fa7de139d733e72dc17affa8f5e1)]
12
+ - Fix default tableau version, add privacy protection, add style wrapper, add title for tableau edit [dana-cfc4 - [`9859224`](https://github.com/eea/volto-tableau/commit/98592247bd58895bd253411cfce981e639093e85)]
7
13
  ### [3.0.2](https://github.com/eea/volto-tableau/compare/3.0.1...3.0.2) - 13 January 2023
8
14
 
9
15
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tableau",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "@eeacms/volto-tableau: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -17,10 +17,14 @@
17
17
  "url": "git@github.com:eea/volto-tableau.git"
18
18
  },
19
19
  "addons": [
20
- "@eeacms/volto-resize-helper"
20
+ "@eeacms/volto-resize-helper",
21
+ "@eeacms/volto-embed",
22
+ "@eeacms/volto-block-style"
21
23
  ],
22
24
  "dependencies": {
23
- "@eeacms/volto-resize-helper": "^0.2.4"
25
+ "@eeacms/volto-resize-helper": "^0.2.4",
26
+ "@eeacms/volto-embed": "5.0.0",
27
+ "@eeacms/volto-block-style": "4.1.0"
24
28
  },
25
29
  "devDependencies": {
26
30
  "@cypress/code-coverage": "^3.9.5",
@@ -4,11 +4,16 @@ import { SidebarPortal } from '@plone/volto/components';
4
4
  import { getContent } from '@plone/volto/actions';
5
5
  import View from './View';
6
6
  import Schema from './schema';
7
+
8
+ import { BlockStyleWrapperEdit } from '@eeacms/volto-block-style/BlockStyleWrapper';
9
+ import cx from 'classnames';
10
+
7
11
  import { connect } from 'react-redux';
8
12
  import { compose } from 'redux';
9
13
 
10
14
  const Edit = (props) => {
11
- const { data, block, onChangeBlock, id } = props;
15
+ const { block, onChangeBlock, id } = props;
16
+ const data = React.useMemo(() => props.data || {}, [props.data]);
12
17
  const schema = React.useMemo(() => Schema(props), [props]);
13
18
 
14
19
  React.useEffect(() => {
@@ -21,8 +26,21 @@ const Edit = (props) => {
21
26
  }, [block, data, onChangeBlock]);
22
27
 
23
28
  return (
24
- <>
25
- <View data={data} id={id} />
29
+ <BlockStyleWrapperEdit
30
+ {...props}
31
+ role="presentation"
32
+ data={{
33
+ ...(props.data || {}),
34
+ styles: {
35
+ ...(props.data?.styles || {}),
36
+ customClass: cx(
37
+ props.data?.styles?.customClass || '',
38
+ 'custom-embed-class',
39
+ ),
40
+ },
41
+ }}
42
+ >
43
+ <View {...props} data={data} id={id} mode="edit" />
26
44
  <SidebarPortal selected={props.selected}>
27
45
  <BlockDataForm
28
46
  block={block}
@@ -37,7 +55,7 @@ const Edit = (props) => {
37
55
  formData={data}
38
56
  />
39
57
  </SidebarPortal>
40
- </>
58
+ </BlockStyleWrapperEdit>
41
59
  );
42
60
  };
43
61
 
@@ -51,4 +69,4 @@ export default compose(
51
69
  getContent,
52
70
  },
53
71
  ),
54
- )(Edit);
72
+ )(React.memo(Edit));
@@ -1,6 +1,10 @@
1
1
  import React from 'react';
2
2
  import ConnectedTableau from '../../ConnectedTableau/ConnectedTableau';
3
3
  import { Sources } from '../../Sources';
4
+ import { PrivacyProtection } from '@eeacms/volto-embed';
5
+
6
+ import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
7
+ import cx from 'classnames';
4
8
 
5
9
  import { getContent } from '@plone/volto/actions';
6
10
 
@@ -8,7 +12,8 @@ import { connect } from 'react-redux';
8
12
  import { compose } from 'redux';
9
13
 
10
14
  const View = (props) => {
11
- const { data, data_provenance, tableau_visualization } = props || {};
15
+ const { data_provenance, tableau_visualization } = props || {};
16
+ const data = React.useMemo(() => props.data || {}, [props.data]);
12
17
  const { vis_url = '' } = data;
13
18
  const show_sources = data?.show_sources ?? false;
14
19
 
@@ -20,25 +25,52 @@ const View = (props) => {
20
25
  }, [vis_url]);
21
26
 
22
27
  return (
23
- <>
24
- {data?.vis_url ? (
25
- <>
26
- <ConnectedTableau {...props.tableau_visualization} id={props.id} />
27
- {show_sources &&
28
- data_provenance &&
29
- data_provenance?.data?.data_provenance &&
30
- tableau_visualization ? (
31
- <Sources sources={data_provenance.data.data_provenance} />
32
- ) : show_sources ? (
33
- <div>Data provenance is not set in the visualization</div>
34
- ) : (
35
- ''
36
- )}
37
- </>
38
- ) : (
39
- <div>Please select a visualization from block editor.</div>
40
- )}
41
- </>
28
+ <StyleWrapperView
29
+ {...props}
30
+ data={data}
31
+ styleData={{
32
+ ...data.styles,
33
+ customClass: cx(data.styles?.customClass || '', 'embed-container'),
34
+ }}
35
+ >
36
+ <PrivacyProtection data={data} {...props}>
37
+ {data?.vis_url ? (
38
+ <>
39
+ <div className="tableau-block">
40
+ {props.mode === 'edit' ? (
41
+ <div className="tableau-info">
42
+ <h3 className="tableau-version">
43
+ == Tableau{' '}
44
+ {tableau_visualization?.general?.version || '2.8.0'} loaded
45
+ ==
46
+ </h3>
47
+ </div>
48
+ ) : (
49
+ ''
50
+ )}
51
+ <ConnectedTableau
52
+ {...props.tableau_visualization}
53
+ id={props.id}
54
+ {...props}
55
+ />
56
+ </div>
57
+
58
+ {show_sources &&
59
+ data_provenance &&
60
+ data_provenance?.data?.data_provenance &&
61
+ tableau_visualization ? (
62
+ <Sources sources={data_provenance.data.data_provenance} />
63
+ ) : show_sources ? (
64
+ <div>Data provenance is not set in the visualization</div>
65
+ ) : (
66
+ ''
67
+ )}
68
+ </>
69
+ ) : (
70
+ <div>Please select a visualization from block editor.</div>
71
+ )}
72
+ </PrivacyProtection>
73
+ </StyleWrapperView>
42
74
  );
43
75
  };
44
76
 
@@ -53,4 +85,4 @@ export default compose(
53
85
  getContent,
54
86
  },
55
87
  ),
56
- )(View);
88
+ )(React.memo(View));
@@ -14,6 +14,7 @@ const ConnectedTableau = (props) => {
14
14
  data={{ ...props?.general, ...props?.options, ...props?.extraOptions }}
15
15
  url={props?.general?.url}
16
16
  version={props?.general?.version}
17
+ {...props}
17
18
  />
18
19
  </div>
19
20
  );
@@ -212,7 +212,11 @@ const Tableau = (props) => {
212
212
  ''
213
213
  ) : (
214
214
  <div className="tableau-loader">
215
- <span>Loading Tableau v{version}</span>
215
+ <span>
216
+ {mode === 'edit'
217
+ ? 'Loading...'
218
+ : `Loading Tableau v${version}`}
219
+ </span>
216
220
  </div>
217
221
  )}
218
222
  </>
@@ -69,7 +69,7 @@ const View = (props) => {
69
69
  <div className="tableau-block">
70
70
  {props.mode === 'edit' ? (
71
71
  <div className="tableau-info">
72
- <h3 className="tableau-version">== Tableau {version} ==</h3>
72
+ <h3 className="tableau-version">== Tableau {version} loaded ==</h3>
73
73
  {!props.data.url ? <p className="tableau-error">URL required</p> : ''}
74
74
  {error ? <p className="tableau-error">{error}</p> : ''}
75
75
  </div>
@@ -53,6 +53,14 @@ const VisualizationWidget = (props) => {
53
53
  let schema = Schema(config);
54
54
 
55
55
  React.useEffect(() => {
56
+ if (!intValue?.general || !intValue?.general?.version) {
57
+ setIntValue({
58
+ ...intValue,
59
+ general: {
60
+ version: '2.8.0',
61
+ },
62
+ });
63
+ }
56
64
  if (!intValue?.options) {
57
65
  setIntValue({
58
66
  ...intValue,
@@ -111,18 +119,17 @@ const VisualizationWidget = (props) => {
111
119
  tableauError ? (
112
120
  <TableauNotDisplayed />
113
121
  ) : (
114
- ''
122
+ <div className="tableau-container">
123
+ <TableauView
124
+ setTableauError={setTableauError}
125
+ data={{
126
+ ...intValue?.general,
127
+ ...intValue?.options,
128
+ ...intValue?.extraOptions,
129
+ }}
130
+ />
131
+ </div>
115
132
  )}
116
- <div className="tableau-container">
117
- <TableauView
118
- setTableauError={setTableauError}
119
- data={{
120
- ...intValue?.general,
121
- ...intValue?.options,
122
- ...intValue?.extraOptions,
123
- }}
124
- />
125
- </div>
126
133
  </Grid.Column>
127
134
  </Grid>
128
135
  </Modal.Content>
@@ -144,15 +151,17 @@ const VisualizationWidget = (props) => {
144
151
  tableauError ? (
145
152
  <TableauNotDisplayed />
146
153
  ) : (
147
- ''
154
+ <TableauView
155
+ setTableauError={setTableauError}
156
+ data={{
157
+ ...value?.general,
158
+ ...value?.options,
159
+ ...value?.extraOptions,
160
+ }}
161
+ />
148
162
  )}
149
-
150
- <TableauView
151
- setTableauError={setTableauError}
152
- data={{ ...value?.general, ...value?.options, ...value?.extraOptions }}
153
- />
154
163
  </FormFieldWrapper>
155
164
  );
156
165
  };
157
166
 
158
- export default VisualizationWidget;
167
+ export default React.memo(VisualizationWidget);
@@ -9,7 +9,11 @@
9
9
  .tableau-block {
10
10
  .tableau-info {
11
11
  h3.tableau-version {
12
- margin-right: 0.5rem;
12
+ display: flex;
13
+ height: 75px;
14
+ align-items: center;
15
+ justify-content: center;
16
+ background-color: #f4f4f1;
13
17
  color: @tableauTitleColor;
14
18
  }
15
19