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

fix: Copy dashboard filters when copying dashboard #24303

Conversation

jfrag1
Copy link
Member

@jfrag1 jfrag1 commented Jun 6, 2023

SUMMARY

This PR will make it so that dashboard native filters are properly copied when copying a dashboard using the "Save as" option in the UI. This functionality broke as a result of an api v1 migration.

set_dash_metadata just takes the current dash's params and adds certain keys from the data dict passed in. Before calling set_dash_metadata, the newly copied dashboard should share the same metadata as the original dash so that no keys are lost, in this case native_filter_configuration was being lost.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
copy_dash_filters_before

After:
copy_dash_filters_after

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@jfrag1 jfrag1 closed this Jun 6, 2023
@jfrag1 jfrag1 reopened this Jun 6, 2023
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #24303 (cd90d0a) into master (ede6acd) will increase coverage by 1.78%.
The diff coverage is 100.00%.

❗ Current head cd90d0a differs from pull request most recent head 6c060b9. Consider uploading reports for the commit 6c060b9 to get more accurate results

@@            Coverage Diff             @@
##           master   #24303      +/-   ##
==========================================
+ Coverage   66.53%   68.31%   +1.78%     
==========================================
  Files        1957     1957              
  Lines       75623    75624       +1     
  Branches     8224     8224              
==========================================
+ Hits        50312    51663    +1351     
+ Misses      23202    21852    -1350     
  Partials     2109     2109              
Flag Coverage Δ
hive 53.39% <0.00%> (?)
mysql 78.92% <100.00%> (+<0.01%) ⬆️
postgres 79.00% <100.00%> (+<0.01%) ⬆️
presto 53.31% <0.00%> (?)
python 82.82% <100.00%> (+3.69%) ⬆️
sqlite 77.53% <100.00%> (+<0.01%) ⬆️
unit 53.44% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/dashboards/dao.py 97.20% <100.00%> (+0.01%) ⬆️

... and 95 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -154,6 +154,34 @@ def test_copy_dashboard(self, mock_g):
db.session.delete(dash)
db.session.commit()

@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
@patch("superset.dashboards.dao.g")
def test_copy_dashboard_copies_native_filters(self, mock_g):
Copy link
Member Author

Choose a reason for hiding this comment

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

test fails without this fix

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

Looks great. Especially when the test is more code than the fix! :)

@jfrag1 jfrag1 closed this Jun 6, 2023
@jfrag1 jfrag1 reopened this Jun 6, 2023
@eschutho eschutho merged commit e791ba5 into apache:master Jun 8, 2023
@eschutho eschutho deleted the jack/copy-dash-filters-when-copying-dashboard branch June 8, 2023 22:49
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Jun 9, 2023
@sadpandajoe
Copy link
Member

🏷️ preset:2023.23

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

Successfully merging this pull request may close these issues.

None yet

4 participants