[dashboard] pass dashboard filters to share chart url in dropdown (#7642)

This commit is contained in:
Grace Guo 2019-06-07 15:22:56 -07:00 committed by GitHub
parent 39d67cbc59
commit f3091c525e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 8 deletions

View File

@ -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,
};

View File

@ -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,

View File

@ -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}

View File

@ -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,

View File

@ -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 || {},