This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new f3091c5 [dashboard] pass dashboard filters to share chart url in
dropdown (#7642)
f3091c5 is described below
commit f3091c525e90526da4bb4e4310c9cf8646830247
Author: Grace Guo <[email protected]>
AuthorDate: Fri Jun 7 15:22:56 2019 -0700
[dashboard] pass dashboard filters to share chart url in dropdown (#7642)
---
superset/assets/src/chart/Chart.jsx | 9 +++++++--
superset/assets/src/chart/ChartRenderer.jsx | 8 ++++----
.../assets/src/dashboard/components/gridComponents/Chart.jsx | 2 +-
superset/assets/src/dashboard/containers/Chart.jsx | 2 +-
superset/assets/src/dashboard/reducers/getInitialState.js | 4 ++++
5 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/superset/assets/src/chart/Chart.jsx
b/superset/assets/src/chart/Chart.jsx
index 0218a17..08d0663 100644
--- a/superset/assets/src/chart/Chart.jsx
+++ b/superset/assets/src/chart/Chart.jsx
@@ -35,7 +35,12 @@ const propTypes = {
actions: PropTypes.object,
chartId: PropTypes.number.isRequired,
datasource: PropTypes.object.isRequired,
- filters: PropTypes.object,
+ // original selected values for FilterBox viz
+ // so that FilterBox can pre-populate selected values
+ // only affect UI control
+ initialValues: PropTypes.object,
+ // formData contains chart's own filter parameter
+ // and merged with extra filter that current dashboard applying
formData: PropTypes.object.isRequired,
height: PropTypes.number,
width: PropTypes.number,
@@ -60,7 +65,7 @@ const BLANK = {};
const defaultProps = {
addFilter: () => BLANK,
- filters: BLANK,
+ initialValues: BLANK,
setControlValue() {},
triggerRender: false,
};
diff --git a/superset/assets/src/chart/ChartRenderer.jsx
b/superset/assets/src/chart/ChartRenderer.jsx
index c83d1c8..2f64957 100644
--- a/superset/assets/src/chart/ChartRenderer.jsx
+++ b/superset/assets/src/chart/ChartRenderer.jsx
@@ -29,7 +29,7 @@ const propTypes = {
actions: PropTypes.object,
chartId: PropTypes.number.isRequired,
datasource: PropTypes.object.isRequired,
- filters: PropTypes.object,
+ initialValues: PropTypes.object,
formData: PropTypes.object.isRequired,
height: PropTypes.number,
width: PropTypes.number,
@@ -50,7 +50,7 @@ const BLANK = {};
const defaultProps = {
addFilter: () => BLANK,
- filters: BLANK,
+ initialValues: BLANK,
setControlValue() {},
triggerRender: false,
};
@@ -103,7 +103,7 @@ class ChartRenderer extends React.Component {
height,
annotationData,
datasource,
- filters,
+ initialValues,
formData,
queryResponse,
setControlValue,
@@ -114,7 +114,7 @@ class ChartRenderer extends React.Component {
height,
annotationData,
datasource,
- filters,
+ filters: initialValues,
formData,
onAddFilter: this.handleAddFilter,
onError: this.handleRenderFailure,
diff --git a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
index 9b1b5f1..7490faa 100644
--- a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
+++ b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
@@ -283,7 +283,7 @@ class Chart extends React.Component {
chartId={id}
chartStatus={chart.chartStatus}
datasource={datasource}
- filters={filters}
+ initialValues={filters[id]}
formData={formData}
queryResponse={chart.queryResponse}
timeout={timeout}
diff --git a/superset/assets/src/dashboard/containers/Chart.jsx
b/superset/assets/src/dashboard/containers/Chart.jsx
index d47c7c9..ae0d15f 100644
--- a/superset/assets/src/dashboard/containers/Chart.jsx
+++ b/superset/assets/src/dashboard/containers/Chart.jsx
@@ -53,7 +53,7 @@ function mapStateToProps(
{},
slice: sliceEntities.slices[id],
timeout: dashboardInfo.common.conf.SUPERSET_WEBSERVER_TIMEOUT,
- filters: filters[id] || EMPTY_FILTERS,
+ filters: filters || EMPTY_FILTERS,
// note: this method caches filters if possible to prevent render cascades
formData: getFormDataWithExtraFilters({
chart,
diff --git a/superset/assets/src/dashboard/reducers/getInitialState.js
b/superset/assets/src/dashboard/reducers/getInitialState.js
index fb5ff75..8113356 100644
--- a/superset/assets/src/dashboard/reducers/getInitialState.js
+++ b/superset/assets/src/dashboard/reducers/getInitialState.js
@@ -205,6 +205,10 @@ export default function(bootstrapData) {
dashboardState: {
sliceIds: Array.from(sliceIds),
refresh: false,
+ // All the filter_box's state in this dashboard
+ // When dashboard is first loaded into browser,
+ // its value is from preselect_filters that dashboard owner saved in
dashboard's meta data
+ // When user start interacting with dashboard, it will be user picked
values from all filter_box
filters,
directPathToChild,
expandedSlices: dashboard.metadata.expanded_slices || {},