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

show edit modal on dashboards list view #9211

Merged
merged 9 commits into from
Mar 19, 2020

Conversation

suddjian
Copy link
Member

@suddjian suddjian commented Feb 26, 2020

CATEGORY

Choose one

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

SUMMARY

This changes the dashboard react list view to use the react-based edit modal, instead of linking to the CRUD-based edit page.

A detail of this implementation is that after editing a dashboard, it will stay in the list even if it is no longer applicable based on the chosen filters. This is intended, as removing a just-edited dashboard from the list could be annoying.

I had to remove the "owners" accessor column as it doesn't actually work correctly when a dashboard has owners populated. React complains about trying to render an object. Owners will need a component rather than just an accessor. This bug was invisible before, since the list endpoint for dashboards doesn't actually return owners at all.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After clicking the edit button
Screen Shot 2020-02-26 at 11 51 47 AM

After saving the dashboard
Screen Shot 2020-02-26 at 11 51 56 AM

TEST PLAN

  • Added a simple unit test
  • Smoke tested

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@nytai

Copy link
Member

@nytai nytai left a comment

Choose a reason for hiding this comment

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

a couple questions, none are blocking

"slug",
"table_names",
]
order_columns = ["dashboard_title", "changed_on", "published", "changed_by_fk"]
list_columns = [
"json_metadata",
Copy link
Member

Choose a reason for hiding this comment

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

Is this property consumed in the listview? Seems like we're fetching the full dashboard show payload on edit.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, we could use the metadata from the modal's fetch call.

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up simplifying the contract for PropertiesModal, now it just takes a dashboard id and fetches everything it needs on its own. Not ideal, it'd be nicer to pass a dashboard object as a prop, but we don't have a super consistent data model for a dashboard in every place that it's used, so it's probably the best option for now.

handleDashboardEdit = (edits: any, original: Dashboard) => {
this.setState({ loading: true });
return SupersetClient.get({
endpoint: `/api/v1/dashboard/${original.id}`,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we're making this call instead of just updating from edits?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there was some field that wasn't returned from the PUT endpoint. I wasn't sure how to add that field and eventually just did this to make it work. If you think it's worth the effort I'll take another pass at it, otherwise I can add a comment documenting why it's there.

Copy link
Member

Choose a reason for hiding this comment

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

happy to merge this, this shouldn't affect perf much. However, we should figure out how to configure the PUT response

Copy link
Member

Choose a reason for hiding this comment

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

might be edit_columns

Copy link
Member Author

@suddjian suddjian Mar 9, 2020

Choose a reason for hiding this comment

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

I remember this now. The API endpoint uses the edit_model_schema Marshmallow schema when returning the edited object, which is the same as the one used to parse incoming edited fields from the client. IMO a better design would be to return the entire object as it would from the GET endpoint, but that's a larger scale API design decision.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this particular case, the impact is that slug can be changed, which changes the url, but only slug is returned from the endpoint.

@codecov-io
Copy link

Codecov Report

Merging #9211 into master will increase coverage by 0.21%.
The diff coverage is 52.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9211      +/-   ##
==========================================
+ Coverage   58.92%   59.14%   +0.21%     
==========================================
  Files         372      373       +1     
  Lines       11999    12057      +58     
  Branches     2940     2961      +21     
==========================================
+ Hits         7071     7131      +60     
+ Misses       4750     4747       -3     
- Partials      178      179       +1     
Impacted Files Coverage Δ
...erset-frontend/src/dashboard/components/Header.jsx 41.79% <ø> (ø)
...ntend/src/dashboard/components/PropertiesModal.jsx 45.83% <50.00%> (+39.27%) ⬆️
...frontend/src/views/dashboardList/DashboardList.tsx 63.63% <54.16%> (+4.28%) ⬆️
...erset-frontend/src/SqlLab/components/ResultSet.jsx 75.70% <0.00%> (-1.86%) ⬇️
...t-frontend/src/dashboard/actions/dashboardState.js 30.66% <0.00%> (-1.06%) ⬇️
...uperset-frontend/src/views/chartList/ChartList.tsx 62.72% <0.00%> (-0.67%) ⬇️
superset-frontend/src/chart/Chart.jsx 10.41% <0.00%> (ø)
superset-frontend/src/setup/setupClient.js 0.00% <0.00%> (ø)
...erset-frontend/src/datasource/DatasourceEditor.jsx 61.25% <0.00%> (ø)
... and 10 more

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 cd4605e...b3ff8fc. Read the comment docs.

@rusackas rusackas merged commit 4659883 into apache:master Mar 19, 2020
@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.

5 participants