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

Pass url parameters from dashboard to charts #8536

Merged
merged 7 commits into from
Nov 21, 2019
Merged

Pass url parameters from dashboard to charts #8536

merged 7 commits into from
Nov 21, 2019

Conversation

villebro
Copy link
Member

@villebro villebro commented Nov 9, 2019

CATEGORY

Choose one

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

SUMMARY

Currently URL parameters are correctly handled in explore mode. However, current functionality is limited/broken in the following ways:

  • Any default values for url_params specified in charts are erased if the chart is opened via the Charts page.
  • query parameters passed to dashboards are not forwarded to chart requests, making them unusable in dashboards.

This PR does the following:

  • Default values for query parameters are left unchanged when opening a chart via the Charts page.
  • URL parameters passed to a dashboard are updated to the chart defaults prior to rendering.
  • Add note about setting default values for url_params.
  • Add cypress test to ensure params are passed through from the dashboard to chart requests.
  • Add python test to ensure that url params are appended to pre-defined params.

SCREENSHOTS

Datasource query:
image

Chart metadata with default values for url_params:
image

Dashboard with url parameter (note name2 falling back to default value):
image

TEST PLAN

  • Tested locally
  • CI
  • Ensured that new tests fail when run on master branch

ADDITIONAL INFORMATION

REVIEWERS

@senturkayhan @rsdpyenugula @mistercrunch @graceguo-supercat @etr2460

@codecov-io
Copy link

codecov-io commented Nov 10, 2019

Codecov Report

Merging #8536 into master will increase coverage by <.01%.
The diff coverage is 68.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8536      +/-   ##
==========================================
+ Coverage   65.77%   65.78%   +<.01%     
==========================================
  Files         482      482              
  Lines       23794    23801       +7     
  Branches     2587     2587              
==========================================
+ Hits        15651    15657       +6     
- Misses       7974     7975       +1     
  Partials      169      169
Impacted Files Coverage Δ
superset/jinja_context.py 76.69% <ø> (ø) ⬆️
...t/assets/src/dashboard/reducers/getInitialState.js 0% <0%> (ø) ⬆️
superset/utils/core.py 88.08% <100%> (+0.06%) ⬆️
superset/views/core.py 71.85% <88.88%> (+0.05%) ⬆️

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 fc14eff...d0cd45e. Read the comment docs.

@pull-request-size pull-request-size bot added size/L and removed size/S labels Nov 17, 2019
@villebro villebro changed the title [WIP] Pass url parameters from dashboard to charts Pass url parameters from dashboard to charts Nov 17, 2019
@villebro
Copy link
Member Author

This is ready for review

cy.server();
cy.login();

cy.visit(WORLD_HEALTH_DASHBOARD + '?param1=123&param2=abc');
Copy link
Member Author

Choose a reason for hiding this comment

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

Here I would have used qs introduced in cypress 3.5.0 (https://docs.cypress.io/guides/references/changelog.html#3-5-0), but since we're still on 3.4.1, I had to put it in the URL by hand. If there are no objections, I can bump to 3.6.1 which would make this test slightly cleaner (being able to assert against the same object that's being passed to visit).

Choose a reason for hiding this comment

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

👍

@villebro
Copy link
Member Author

Nudging testers/reviewers, would be great to get 👀 on this to kill this long standing bug.

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

Minor note, otherwise LGTM

url_params = {
key: value
for key, value in request.args.items()
if key not in ("edit", "standalone")
Copy link
Member

Choose a reason for hiding this comment

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

The blacklisting here seems brittle. Wondering if it's necessary.

@villebro villebro merged commit 7104b04 into apache:master Nov 21, 2019
@villebro villebro deleted the url_params branch November 21, 2019 21:15
@villebro villebro added the v0.35 label Dec 23, 2019
@ForzaDesignStudio
Copy link

Hi, i am trying this and have followed the solution but it will not filter for me. i have done they query in sql lab, made the chart and changed the metadata that makes a table with name_1, name_2, but changing the URL does not seem to filter my dashboard. Any idea why this is not working? Did you test this on a server rather than locally just? thanks!
Version 0.35.1

image

@villebro
Copy link
Member Author

@ForzaDesignStudio unfortunately this had to be dropped from 0.35.2 as it didn't apply cleanly to the 0.35 branch. As it stands this fix will be available in the 0.36.0 release, probably due out this month.

@villebro villebro removed the v0.35 label Feb 12, 2020
@ForzaDesignStudio
Copy link

thank you for the quick reply. i will try it in the next release.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 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/L 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jinja macro url_params is not working from the dashboard
5 participants