Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

graceguo-supercat
Copy link

@graceguo-supercat graceguo-supercat commented Jun 4, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Screen Shot 2019-06-03 at 5 17 17 PM

In dashboard, we allow user to share chart, which is a shorten url which carried current dashboard filters state, and chart's parent tab information (if it has one). But currently, dashboard's selected filters values are not included in the shorten url.

I found in dashboard's component, we used filters props for dashboard's selected filters state. But for Chart component, we used filters props to carry the values for the current filter_box, so that current filter_box will pre-populate selected values.

Solution:
filter prop should be assigned at the right place.

TEST PLAN

CI and manual test

REVIEWERS

@michellethomas @etr2460 @kristw @williaster

@codecov-io
Copy link

codecov-io commented Jun 4, 2019

Codecov Report

Merging #7642 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7642   +/-   ##
=======================================
  Coverage   65.57%   65.57%           
=======================================
  Files         435      435           
  Lines       21754    21754           
  Branches     2394     2394           
=======================================
  Hits        14266    14266           
  Misses       7367     7367           
  Partials      121      121
Impacted Files Coverage Δ
superset/assets/src/chart/Chart.jsx 10.86% <ø> (ø) ⬆️
superset/assets/src/chart/ChartRenderer.jsx 7.57% <ø> (ø) ⬆️
...t/assets/src/dashboard/reducers/getInitialState.js 0% <ø> (ø) ⬆️
.../src/dashboard/components/gridComponents/Chart.jsx 70.88% <ø> (ø) ⬆️
superset/assets/src/dashboard/containers/Chart.jsx 90.9% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d62c37b...2f79a85. Read the comment docs.

@mistercrunch
Copy link
Member

So is the filters prop really more of a extraFilters prop, to add filter on top of the chart's self-defined filters? Should we rename it to reflect that more clearly?

@graceguo-supercat
Copy link
Author

graceguo-supercat commented Jun 4, 2019

So is the filters prop really more of a extraFilters prop, to add filter on top of the chart's self-defined filters?

Not exactly. For Dashboard components, filters prop is the current filters state in redux. extraFilters has merged extra dashboard filter's value with chart's own formData params. It is not stored in redux state, but will be passed to backend as query parameter.

For FilterBox viz, filters prop is just original selected values:
https://github.com/apache/incubator-superset/blob/1dc17f357cf5c94f663f7a338a7814d5f79452e9/superset/assets/src/visualizations/FilterBox/transformProps.js#L51
So I prefer to re-name Chart component's filters props to be origSelectedValues. But origSelectedValues is not in the standard chart props list:
https://github.com/apache-superset/superset-ui/blob/7b3ab5f71398c7180b5a24f69e67016802025183/packages/superset-ui-chart/src/models/ChartProps.ts#L19

Besides origSelectedValues for FilterBox, is there any other viz_type using filters prop? @kristw

@graceguo-supercat graceguo-supercat requested a review from kristw June 4, 2019 19:00
@graceguo-supercat graceguo-supercat force-pushed the gg-FixDashboardFilterParam branch from 158fa7c to fc33529 Compare June 4, 2019 19:02
@mistercrunch
Copy link
Member

All this is somewhat confusing (not because of your PR! was confusing before). Ideally we clarify the prop names / split them into many, or at least adding some comments to the code with the things you just mentioned.

@graceguo-supercat graceguo-supercat force-pushed the gg-FixDashboardFilterParam branch from fc33529 to 2f79a85 Compare June 6, 2019 20:46
// 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 interactive with dashboard, it will be user picked values from any filter_box
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo interactive => interacting

// original selected values for FilterBox viz
// so that FilterBox can pre-populate selected values
// only affect UI control
origSelectedValues: PropTypes.object,
Copy link
Contributor

@kristw kristw Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about initialFilters so we know at least it is related to filters?
On a side note, is this field only used by filter_box?

Copy link
Contributor

@kristw kristw Jun 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified and only table and filter_box use this filters field from ChartProps.

In a follow up thought, initialValues might be a better name (use values from your initial idea to make it sounds more open to other vis andinitialto shorten theorigSelected` part)

Hmm. or initialState.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vote for initialValues

@kristw
Copy link
Contributor

kristw commented Jun 6, 2019

LGTM. Have a few small comments.

@kristw
Copy link
Contributor

kristw commented Jun 7, 2019

Once this PR is in I can work on updating the ChartProps to change the filters name to match the name in this PR and less confusing. (It will be a breaking change on the @superset-ui, which can go along with a few breaking changes I am planning.)

@graceguo-supercat graceguo-supercat force-pushed the gg-FixDashboardFilterParam branch from 2f79a85 to ab87f36 Compare June 7, 2019 21:24
@graceguo-supercat graceguo-supercat merged commit f3091c5 into apache:master Jun 7, 2019
michellethomas pushed a commit that referenced this pull request Jun 8, 2019
@graceguo-supercat graceguo-supercat deleted the gg-FixDashboardFilterParam branch August 8, 2019 20:39
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants