Skip to content

Commit

Permalink
Merge pull request #19 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dana-cfc4 authored Jan 17, 2023
2 parents 86e6dc1 + a4ff1ce commit a83077d
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 50 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [3.0.3](https://github.com/eea/volto-tableau/compare/3.0.2...3.0.3) - 17 January 2023

#### :hammer_and_wrench: Others

- Add volto-embed and volto-block-style addons [dana-cfc4 - [`e557a05`](https://github.com/eea/volto-tableau/commit/e557a0561a46fa7de139d733e72dc17affa8f5e1)]
- 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)]
### [3.0.2](https://github.com/eea/volto-tableau/compare/3.0.1...3.0.2) - 13 January 2023

#### :hammer_and_wrench: Others
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-tableau",
"version": "3.0.2",
"version": "3.0.3",
"description": "@eeacms/volto-tableau: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -17,10 +17,14 @@
"url": "git@github.com:eea/volto-tableau.git"
},
"addons": [
"@eeacms/volto-resize-helper"
"@eeacms/volto-resize-helper",
"@eeacms/volto-embed",
"@eeacms/volto-block-style"
],
"dependencies": {
"@eeacms/volto-resize-helper": "^0.2.4"
"@eeacms/volto-resize-helper": "^0.2.4",
"@eeacms/volto-embed": "5.0.0",
"@eeacms/volto-block-style": "4.1.0"
},
"devDependencies": {
"@cypress/code-coverage": "^3.9.5",
Expand Down
28 changes: 23 additions & 5 deletions src/Blocks/EmbedEEATableauBlock/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import { SidebarPortal } from '@plone/volto/components';
import { getContent } from '@plone/volto/actions';
import View from './View';
import Schema from './schema';

import { BlockStyleWrapperEdit } from '@eeacms/volto-block-style/BlockStyleWrapper';
import cx from 'classnames';

import { connect } from 'react-redux';
import { compose } from 'redux';

const Edit = (props) => {
const { data, block, onChangeBlock, id } = props;
const { block, onChangeBlock, id } = props;
const data = React.useMemo(() => props.data || {}, [props.data]);
const schema = React.useMemo(() => Schema(props), [props]);

React.useEffect(() => {
Expand All @@ -21,8 +26,21 @@ const Edit = (props) => {
}, [block, data, onChangeBlock]);

return (
<>
<View data={data} id={id} />
<BlockStyleWrapperEdit
{...props}
role="presentation"
data={{
...(props.data || {}),
styles: {
...(props.data?.styles || {}),
customClass: cx(
props.data?.styles?.customClass || '',
'custom-embed-class',
),
},
}}
>
<View {...props} data={data} id={id} mode="edit" />
<SidebarPortal selected={props.selected}>
<BlockDataForm
block={block}
Expand All @@ -37,7 +55,7 @@ const Edit = (props) => {
formData={data}
/>
</SidebarPortal>
</>
</BlockStyleWrapperEdit>
);
};

Expand All @@ -51,4 +69,4 @@ export default compose(
getContent,
},
),
)(Edit);
)(React.memo(Edit));
74 changes: 53 additions & 21 deletions src/Blocks/EmbedEEATableauBlock/View.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import React from 'react';
import ConnectedTableau from '../../ConnectedTableau/ConnectedTableau';
import { Sources } from '../../Sources';
import { PrivacyProtection } from '@eeacms/volto-embed';

import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
import cx from 'classnames';

import { getContent } from '@plone/volto/actions';

import { connect } from 'react-redux';
import { compose } from 'redux';

const View = (props) => {
const { data, data_provenance, tableau_visualization } = props || {};
const { data_provenance, tableau_visualization } = props || {};
const data = React.useMemo(() => props.data || {}, [props.data]);
const { vis_url = '' } = data;
const show_sources = data?.show_sources ?? false;

Expand All @@ -20,25 +25,52 @@ const View = (props) => {
}, [vis_url]);

return (
<>
{data?.vis_url ? (
<>
<ConnectedTableau {...props.tableau_visualization} id={props.id} />
{show_sources &&
data_provenance &&
data_provenance?.data?.data_provenance &&
tableau_visualization ? (
<Sources sources={data_provenance.data.data_provenance} />
) : show_sources ? (
<div>Data provenance is not set in the visualization</div>
) : (
''
)}
</>
) : (
<div>Please select a visualization from block editor.</div>
)}
</>
<StyleWrapperView
{...props}
data={data}
styleData={{
...data.styles,
customClass: cx(data.styles?.customClass || '', 'embed-container'),
}}
>
<PrivacyProtection data={data} {...props}>
{data?.vis_url ? (
<>
<div className="tableau-block">
{props.mode === 'edit' ? (
<div className="tableau-info">
<h3 className="tableau-version">
== Tableau{' '}
{tableau_visualization?.general?.version || '2.8.0'} loaded
==
</h3>
</div>
) : (
''
)}
<ConnectedTableau
{...props.tableau_visualization}
id={props.id}
{...props}
/>
</div>

{show_sources &&
data_provenance &&
data_provenance?.data?.data_provenance &&
tableau_visualization ? (
<Sources sources={data_provenance.data.data_provenance} />
) : show_sources ? (
<div>Data provenance is not set in the visualization</div>
) : (
''
)}
</>
) : (
<div>Please select a visualization from block editor.</div>
)}
</PrivacyProtection>
</StyleWrapperView>
);
};

Expand All @@ -53,4 +85,4 @@ export default compose(
getContent,
},
),
)(View);
)(React.memo(View));
1 change: 1 addition & 0 deletions src/ConnectedTableau/ConnectedTableau.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ConnectedTableau = (props) => {
data={{ ...props?.general, ...props?.options, ...props?.extraOptions }}
url={props?.general?.url}
version={props?.general?.version}
{...props}
/>
</div>
);
Expand Down
6 changes: 5 additions & 1 deletion src/Tableau/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ const Tableau = (props) => {
''
) : (
<div className="tableau-loader">
<span>Loading Tableau v{version}</span>
<span>
{mode === 'edit'
? 'Loading...'
: `Loading Tableau v${version}`}
</span>
</div>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/TableauBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const View = (props) => {
<div className="tableau-block">
{props.mode === 'edit' ? (
<div className="tableau-info">
<h3 className="tableau-version">== Tableau {version} ==</h3>
<h3 className="tableau-version">== Tableau {version} loaded ==</h3>
{!props.data.url ? <p className="tableau-error">URL required</p> : ''}
{error ? <p className="tableau-error">{error}</p> : ''}
</div>
Expand Down
45 changes: 27 additions & 18 deletions src/Widgets/VisualizationWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ const VisualizationWidget = (props) => {
let schema = Schema(config);

React.useEffect(() => {
if (!intValue?.general || !intValue?.general?.version) {
setIntValue({
...intValue,
general: {
version: '2.8.0',
},
});
}
if (!intValue?.options) {
setIntValue({
...intValue,
Expand Down Expand Up @@ -111,18 +119,17 @@ const VisualizationWidget = (props) => {
tableauError ? (
<TableauNotDisplayed />
) : (
''
<div className="tableau-container">
<TableauView
setTableauError={setTableauError}
data={{
...intValue?.general,
...intValue?.options,
...intValue?.extraOptions,
}}
/>
</div>
)}
<div className="tableau-container">
<TableauView
setTableauError={setTableauError}
data={{
...intValue?.general,
...intValue?.options,
...intValue?.extraOptions,
}}
/>
</div>
</Grid.Column>
</Grid>
</Modal.Content>
Expand All @@ -144,15 +151,17 @@ const VisualizationWidget = (props) => {
tableauError ? (
<TableauNotDisplayed />
) : (
''
<TableauView
setTableauError={setTableauError}
data={{
...value?.general,
...value?.options,
...value?.extraOptions,
}}
/>
)}

<TableauView
setTableauError={setTableauError}
data={{ ...value?.general, ...value?.options, ...value?.extraOptions }}
/>
</FormFieldWrapper>
);
};

export default VisualizationWidget;
export default React.memo(VisualizationWidget);
6 changes: 5 additions & 1 deletion src/less/tableau.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
.tableau-block {
.tableau-info {
h3.tableau-version {
margin-right: 0.5rem;
display: flex;
height: 75px;
align-items: center;
justify-content: center;
background-color: #f4f4f1;
color: @tableauTitleColor;
}

Expand Down

0 comments on commit a83077d

Please sign in to comment.