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

chore: Migrate copy_dash endpoint to api v1 #23112

Merged
merged 7 commits into from
Apr 6, 2023

Conversation

jfrag1
Copy link
Member

@jfrag1 jfrag1 commented Feb 17, 2023

SUMMARY

This PR deprecates superset/copy_dash/<dash_id>/ and introduces api/v1/dashboard/<dash_id>/copy/ to replace it.

The new endpoint behaves nearly identically to the old one; the only functional differences are that the endpoint accepts a json body instead of a form, and it only responds with the data used by the frontend.

This PR also marks the superset/save_dash/<dash_id>/ endpoint as deprecated as it is not called from client code anywhere.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

[x] Add tests
[x] Test copying a dashboard from the frontend with "Save as"

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

@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

Merging #23112 (c9649b0) into master (9d2f43d) will increase coverage by 0.02%.
The diff coverage is 78.94%.

❗ Current head c9649b0 differs from pull request most recent head 48f0782. Consider uploading reports for the commit 48f0782 to get more accurate results

@@            Coverage Diff             @@
##           master   #23112      +/-   ##
==========================================
+ Coverage   67.71%   67.74%   +0.02%     
==========================================
  Files        1916     1916              
  Lines       74014    74100      +86     
  Branches     8039     8039              
==========================================
+ Hits        50122    50202      +80     
- Misses      21843    21850       +7     
+ Partials     2049     2048       -1     
Flag Coverage Δ
hive 52.73% <30.63%> (-0.02%) ⬇️
javascript 53.96% <75.60%> (+0.01%) ⬆️
mysql 78.51% <74.77%> (+0.02%) ⬆️
postgres 78.59% <74.77%> (+0.02%) ⬆️
presto 52.65% <30.63%> (-0.02%) ⬇️
python 82.43% <80.18%> (+0.02%) ⬆️
sqlite 77.10% <74.77%> (+0.02%) ⬆️
unit 52.62% <36.03%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
...ackages/superset-ui-core/src/query/types/Filter.ts 100.00% <ø> (ø)
...tend/src/components/Chart/DrillBy/DrillByChart.tsx 100.00% <ø> (+7.14%) ⬆️
...et-frontend/src/dashboard/components/SaveModal.tsx 39.28% <0.00%> (+1.35%) ⬆️
...t-frontend/src/dashboard/reducers/nativeFilters.ts 39.28% <0.00%> (-1.46%) ⬇️
superset/constants.py 100.00% <ø> (ø)
...et-frontend/src/dashboard/actions/nativeFilters.ts 42.55% <33.33%> (+0.16%) ⬆️
...eFilters/FiltersConfigModal/FiltersConfigModal.tsx 63.81% <33.33%> (+0.18%) ⬆️
superset/db_engine_specs/bigquery.py 69.54% <45.45%> (-0.18%) ⬇️
superset/utils/csv.py 96.66% <50.00%> (-1.61%) ⬇️
...tend/src/components/Chart/DrillBy/DrillByModal.tsx 86.66% <85.71%> (-5.00%) ⬇️
... and 9 more

... and 2 files with indirect coverage changes

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

@jfrag1 jfrag1 closed this Feb 17, 2023
@jfrag1 jfrag1 reopened this Feb 17, 2023
@dpgaspar dpgaspar requested review from dpgaspar and geido March 10, 2023 09:04
@@ -1225,3 +1228,68 @@ def delete_embedded(self, dashboard: Dashboard) -> Response:
for embedded in dashboard.embedded:
DashboardDAO.delete(embedded)
return self.response(200, message="OK")

@expose("/<id_or_slug>/copy/", methods=["POST"])
@protect()
Copy link
Member

Choose a reason for hiding this comment

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

let's make this endpoint permission be can write on Dashboard add copy_dash to https://github.com/apache/superset/blob/master/superset/constants.py#L151

@@ -299,3 +293,38 @@ def favorited_ids(dashboards: List[Dashboard]) -> List[FavStar]:
)
.all()
]

@classmethod
def copy_dashboard(
Copy link
Member

Choose a reason for hiding this comment

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

nit: how about just def copy( we know it's a dashboard from the class

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to be explicit here

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

This looks good, but let's do what @dpgaspar recommended and add the method to constants.py so we don't add a new unneeded permission.

@jfrag1
Copy link
Member Author

jfrag1 commented Apr 6, 2023

This looks good, but let's do what @dpgaspar recommended and add the method to constants.py so we don't add a new unneeded permission.

I added it just now, but I'm curious if the permission_name decorator does the same thing? Is the difference that with only the decorator, a DB record will still be created for the copy_dash permission but it won't do anything?

Edit: The test that failed after I made the change seems to confirm that is the case

@jfrag1 jfrag1 closed this Apr 6, 2023
@jfrag1 jfrag1 reopened this Apr 6, 2023
@hughhhh hughhhh merged commit 326c058 into apache:master Apr 6, 2023
@hughhhh hughhhh deleted the jack/migrate-copy-dash-to-api-v1 branch April 6, 2023 15:32
@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 13, 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 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants