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(explore): Update chart save to use API endpoints #20498

Conversation

codyml
Copy link
Member

@codyml codyml commented Jun 24, 2022

SUMMARY

When a user saves a chart in Explore, the client sends one POST /explore request, then the server creates/updates the chart and optionally adds it to a new/existing dashboard as indicated. This PR updates Explore's SaveModal to instead use v1 API endpoints to accomplish the same. Here's the updated sequence of API calls:

  • If user is creating a new dashboard: POST /api/v1/dashboard/
  • If user is adding to a new dashboard: PUT /api/v1/dashboard/{dashboard_id}
  • If user is saving as a new chart: POST /api/v1/chart/
    • If adding to new/existing dashboard: { dashboards: [..., dashboard_id] }
  • If user is overwriting an existing chart: PUT /api/v1/chart/{chart_id}
    • If adding to new/existing dashboard: { dashboards: [..., dashboardId] }

In addition, this PR makes the Save and Save and Go to Dashboard buttons no longer trigger a page refresh.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Try performing the following tasks with and without proposed update and ensure that interface and user experience are identical (with the exception of there no longer being page refreshes):

  • Create new chart from scratch, save as new chart, don't add to dashboard
  • Create new chart from scratch, save as new chart, add to existing dashboard
  • Create new chart from scratch, save as new chart, add to new dashboard
  • Edit existing chart, overwrite existing chart, don't add to dashboard
  • Edit existing chart, overwrite existing chart, add to existing dashboard
  • Edit existing chart, overwrite existing chart, add to new dashboard
  • Edit existing chart, save as new chart, don't add to dashboard
  • Edit existing chart, save as new chart, add to existing dashboard
  • Edit existing chart, save as new chart, add to new dashboard

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

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I left some first-pass comments.

@codyml
Copy link
Member Author

codyml commented Jun 27, 2022

Waiting on inclusion of Explore in SPA so redirection is no longer necessary and toasts appear.

@codyml codyml force-pushed the codyml/sc-49561/endpoints-refactor-save-and-save-and-go-to branch from 10ab7aa to 622e053 Compare June 29, 2022 21:48
@codyml codyml force-pushed the codyml/sc-49561/endpoints-refactor-save-and-save-and-go-to branch 2 times, most recently from 437f5b7 to faa7bf4 Compare June 30, 2022 20:06
@codyml codyml changed the title chore(explore): Update chart save to use API endpoints [WIP] chore(explore): Update chart save to use API endpoints Jul 1, 2022
@codyml codyml force-pushed the codyml/sc-49561/endpoints-refactor-save-and-save-and-go-to branch from faa7bf4 to d971b93 Compare July 1, 2022 02:04
@codyml codyml marked this pull request as ready for review July 1, 2022 02:04
@codecov
Copy link

codecov bot commented Jul 1, 2022

Codecov Report

Merging #20498 (932e3cf) into master (c795dc2) will decrease coverage by 0.01%.
The diff coverage is 50.00%.

❗ Current head 932e3cf differs from pull request most recent head fcb00d0. Consider uploading reports for the commit fcb00d0 to get more accurate results

@@            Coverage Diff             @@
##           master   #20498      +/-   ##
==========================================
- Coverage   66.85%   66.83%   -0.02%     
==========================================
  Files        1753     1753              
  Lines       65833    65896      +63     
  Branches     7007     7013       +6     
==========================================
+ Hits        44011    44044      +33     
- Misses      20036    20069      +33     
+ Partials     1786     1783       -3     
Flag Coverage Δ
javascript 51.95% <50.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/explore/ExplorePage.tsx 0.00% <0.00%> (ø)
...set-frontend/src/explore/actions/hydrateExplore.ts 60.00% <ø> (ø)
...rset-frontend/src/explore/components/SaveModal.tsx 36.47% <2.85%> (-29.73%) ⬇️
.../explore/components/ExploreViewContainer/index.jsx 52.19% <33.33%> (-0.65%) ⬇️
...t-frontend/src/explore/actions/saveModalActions.js 98.33% <97.77%> (+41.81%) ⬆️
.../explore/exploreUtils/getParsedExploreURLParams.ts 91.42% <100.00%> (+0.25%) ⬆️

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 c795dc2...fcb00d0. Read the comment docs.

@codyml codyml marked this pull request as draft July 1, 2022 02:12
@codyml codyml force-pushed the codyml/sc-49561/endpoints-refactor-save-and-save-and-go-to branch 4 times, most recently from 876b912 to b6aed8c Compare July 1, 2022 19:52
@codyml codyml marked this pull request as ready for review July 1, 2022 19:52
@kgabryje
Copy link
Member

kgabryje commented Jul 5, 2022

Can we get rid of page refresh when you overwrite the chart? I removed window.location.assign(/explore/?slice_id=${value.id}); from SaveModal.tsx and it seems to be working. The only problem is that "altered" pill doesn't disappear but I think that can be fixed easily by updating explore.slice and/or charts[chart_id].sliceFormData (since slice holds the metadata of saved chart)

Ideally we could also prevent redirecting when saving as a new chart, but that might be trickier...

@codyml codyml force-pushed the codyml/sc-49561/endpoints-refactor-save-and-save-and-go-to branch from 5a0e0f9 to 28406e7 Compare July 5, 2022 17:34
@codyml
Copy link
Member Author

codyml commented Jul 5, 2022

Bugs found in manual testing:

  • When editing a chart from a dashboard then overwriting it, native filters are saved to the chart for all dashboards
  • When overwriting a chart and selecting a different dashboard than the one it's currently on in the modal, the chart is removed from the dashboard it's currently on.

@codyml
Copy link
Member Author

codyml commented Jul 8, 2022

Hi @codyml. I can only repro 1 issue that found found earlier (When overwriting a chart and selecting a different dashboard than the one it's currently on in the modal, the chart is removed from the dashboard it's currently on.).
Have you fixed it or not and are you planning to fix it?

@andrey-zayats I thought I had fixed it but I guess not :( will check it out and let you know when it's resolved, thanks!

@jinghua-qa
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@jinghua-qa Ephemeral environment spinning up at http://35.89.223.157:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@jinghua-qa
Copy link
Member

jinghua-qa commented Jul 11, 2022

I have found an issue that when add a new chart from explore to the dashboard and apply native filter to the dashboard, the filter indicator is not appear

Screen.Recording.2022-07-10.at.10.47.40.PM.mov

@codyml
Copy link
Member Author

codyml commented Jul 11, 2022

I have found an issue that when add a new chart from explore to the dashboard and apply native filter to the dashboard, the filter indicator is not appea

Screen.Recording.2022-07-10.at.10.47.40.PM.mov

@jinghua-qa Thanks, will look into this ASAP!

@jinghua-qa
Copy link
Member

I have found an issue that when add a new chart from explore to the dashboard and apply native filter to the dashboard, the filter indicator is not appear

Verified this issue is also exist in master, not related to this PR. So LGTM!

@michael-s-molina
Copy link
Member

Hi @codyml. This fixes codecov CI error. You need to rebase your PR.

@codyml codyml force-pushed the codyml/sc-49561/endpoints-refactor-save-and-save-and-go-to branch from 2811945 to fcb00d0 Compare July 12, 2022 16:35
@kgabryje kgabryje merged commit b1020e3 into apache:master Jul 13, 2022
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.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 preset-io size/XXL 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants