You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2019/06/08 01:00:06 UTC
[incubator-superset] 07/08: [dashboard] pass dashboard filters to
share chart url in dropdown (#7642)
This is an automated email from the ASF dual-hosted git repository.
michellet pushed a commit to branch release--0.33
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 123d5b53669380c1943d898b8973c989561e84b4
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Fri Jun 7 15:22:56 2019 -0700
[dashboard] pass dashboard filters to share chart url in dropdown (#7642)
(cherry picked from commit f3091c525e90526da4bb4e4310c9cf8646830247)
---
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 bc19d63..8239370 100644
--- a/superset/assets/src/chart/Chart.jsx
+++ b/superset/assets/src/chart/Chart.jsx
@@ -31,7 +31,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,
@@ -56,7 +61,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 e0a01f1..ccf1b75 100644
--- a/superset/assets/src/chart/ChartRenderer.jsx
+++ b/superset/assets/src/chart/ChartRenderer.jsx
@@ -30,7 +30,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,
@@ -51,7 +51,7 @@ const BLANK = {};
const defaultProps = {
addFilter: () => BLANK,
- filters: BLANK,
+ initialValues: BLANK,
setControlValue() {},
triggerRender: false,
};
@@ -104,7 +104,7 @@ class ChartRenderer extends React.Component {
height,
annotationData,
datasource,
- filters,
+ initialValues,
formData,
queryResponse,
setControlValue,
@@ -115,7 +115,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 ff11208..4ede139 100644
--- a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
+++ b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
@@ -273,7 +273,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 5b27b13..71c38e5 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 44a491c..a9eb68a 100644
--- a/superset/assets/src/dashboard/reducers/getInitialState.js
+++ b/superset/assets/src/dashboard/reducers/getInitialState.js
@@ -196,6 +196,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 || {},