Skip to content

Commit

Permalink
Merge pull request #19 from eea/develop
Browse files Browse the repository at this point in the history
get Visualisations data in block View, render download_button correctly
  • Loading branch information
razvanMiu authored Jun 17, 2021
2 parents ec2299c + 1957684 commit daaaca0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ 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).

#### [2.0.2](https://github.com/eea/volto-plotlycharts/compare/2.0.1...2.0.2)

- get Visualisations data in block View, render download_button correctly [`1658198`](https://github.com/eea/volto-plotlycharts/commit/1658198afb633af3b30fe4e15e9554061d86e988)

#### [2.0.1](https://github.com/eea/volto-plotlycharts/compare/2.0.0...2.0.1)

> 10 June 2021
- Cypress code coverage [`#18`](https://github.com/eea/volto-plotlycharts/pull/18)
- Rebase develop on master [`#17`](https://github.com/eea/volto-plotlycharts/pull/17)
- do not break on non mosaic addons [`09a662f`](https://github.com/eea/volto-plotlycharts/commit/09a662f70d3fb02a6a0b4a70e2faeed6d0608d48)
- Updated dependencies [`dd27154`](https://github.com/eea/volto-plotlycharts/commit/dd27154be2870ee389bfa453a179e4af84cc797d)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-plotlycharts",
"version": "2.0.1",
"version": "2.0.2",
"description": "Plotly Charts and Editor integration for Volto",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
44 changes: 22 additions & 22 deletions src/ConnectedChart/ConnectedChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@eeacms/volto-datablocks/helpers';
import { connect } from 'react-redux';
import config from '@plone/volto/registry';
import React from 'react'; // , useState
import React, { useEffect } from 'react'; // , useState
import ResponsiveContainer from '../ResponsiveContainer';
import { getDataFromProvider } from '@eeacms/volto-datablocks/actions';
import { getChartDataFromVisualization } from '../actions';
Expand Down Expand Up @@ -61,31 +61,31 @@ function mixProviderData(chartData, providerData, parameters) {
*/
function ConnectedChart(props) {
// need to bind them in this closure, useEffect depends on them;
// const provider_url =
// props.data.provider_url || props.chartDataFromVis?.provider_url;
// const url = props.data.url;
// const getDataFromProvider = props.getDataFromProvider;
// const getChartDataFromVisualization = props.getChartDataFromVisualization;
const provider_url =
props.data.provider_url || props.chartDataFromVis?.provider_url;
const url = props.data.url;
const getDataFromProvider = props.getDataFromProvider;
const getChartDataFromVisualization = props.getChartDataFromVisualization;

// const source_url = props.source;
const source_url = props.source;

const visData = props.chartDataFromVis;

// NOTE: this is a candidate for a HOC, withProviderData
// useEffect(() => {
// if (source_url && !visData) {
// getChartDataFromVisualization(source_url);
// }
// if (provider_url) getDataFromProvider(provider_url || url);
// }, [
// provider_url,
// visData,
// url,
// source_url,
// props.data,
// getDataFromProvider,
// getChartDataFromVisualization,
// ]);
//NOTE: this is a candidate for a HOC, withProviderData
useEffect(() => {
if (source_url && !visData) {
getChartDataFromVisualization(source_url);
}
if (provider_url) getDataFromProvider(provider_url || url);
}, [
provider_url,
visData,
url,
source_url,
props.data,
getDataFromProvider,
getChartDataFromVisualization,
]);

// const [visible, setVisible] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion src/EmbedChartBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const EmbedChartView = ({
initialSource={data.chart_source}
initialSourceLink={data.chart_source_link}
multipleSources={data.chartSources}
providerUrl={providerUrl}
providerUrl={providerUrl || data.chartData?.provider_url}
download_button={data.download_button}
/>
</div>
Expand Down

0 comments on commit daaaca0

Please sign in to comment.