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

[dashboard] New, list view (react) #8845

Merged
merged 36 commits into from
Jan 16, 2020
Merged

Conversation

nytai
Copy link
Member

@nytai nytai commented Dec 16, 2019

CATEGORY

Choose one

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

SUMMARY

Replaces the current dashboard list view generated by FAB with one that is client rendered in react using the FAB/dashboard api. Design has tried to stay as close to the current design as possible, with some minor improvements. There have been recent efforts to redesign most of the views in superset, so having pages that are rendered in react will greatly facilitate those changes. The work in this PR is intended to lay the foundation for all list views that are to come.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

old view

Screen Shot 2019-12-20 at 9 34 47 AM

new view

Screen Shot 2019-12-20 at 9 30 06 AM

Screen Shot 2019-12-20 at 9 30 54 AM

Screen Shot 2019-12-20 at 9 29 56 AM

TEST PLAN

  • The welcome page works as before.
  • The dashboards page renders, sorts, and filters

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 nytai force-pushed the tai/list-view branch 2 times, most recently from 131466e to 319e011 Compare December 16, 2019 21:20
@nytai nytai changed the title new, Dashboard list view (react) [WIP] new, Dashboard list view (react) Dec 18, 2019
@nytai nytai marked this pull request as ready for review December 18, 2019 00:20
@aboganas
Copy link
Contributor

This is awesome, I hope this be ported to Flask-AppBuilder lists

@nytai nytai force-pushed the tai/list-view branch 2 times, most recently from 6f00ff4 to ebeebe3 Compare December 18, 2019 22:57
globals: {
'ts-jest': {
diagnostics: {
warnOnly: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

so type errors don't cause jest tests to fail (they're still reported though)

@@ -0,0 +1,224 @@
// Type definitions for react-table 7
Copy link
Member Author

Choose a reason for hiding this comment

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

the newest version of react-table doesn't have types in https://github.com/DefinitelyTyped/DefinitelyTyped

found these online and adjusted to for the features we're using.

"quotemark": [true, "single"],
"jsx-no-multiline-js": false,
"jsx-no-lambda": false
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have these rules enabled in eslint and I found them to be very tedious. Opened #8865 for larger discussion

@@ -102,6 +105,21 @@ def new(self): # pylint: disable=no-self-use
db.session.commit()
return redirect(f"/superset/dashboard/{new_dashboard.id}/?edit=true")

@has_access
Copy link
Member Author

Choose a reason for hiding this comment

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

found I had to run superset init after adding this decorator. Not sure if there's a way around it. This is necessary to override FAB's default list view.

Copy link
Member

@dpgaspar dpgaspar Jan 3, 2020

Choose a reason for hiding this comment

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

One possible way could be to override with:

Class Dashboard(BaseSupersetView):
     class_permission_name = "DashboardModelView"
     method_permission_name = {
        "new": "add",
        "list_all": "list",
    }

Note: This would deprecate the Dashboard.new permission

@codecov-io
Copy link

codecov-io commented Dec 23, 2019

Codecov Report

Merging #8845 into master will increase coverage by 0.47%.
The diff coverage is 80.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8845      +/-   ##
==========================================
+ Coverage   58.69%   59.16%   +0.47%     
==========================================
  Files         363      367       +4     
  Lines       11417    11679     +262     
  Branches     2801     2861      +60     
==========================================
+ Hits         6701     6910     +209     
- Misses       4538     4590      +52     
- Partials      178      179       +1
Impacted Files Coverage Δ
superset/assets/src/welcome/App.jsx 0% <ø> (ø) ⬆️
...t/assets/src/views/dashboardList/DashboardList.tsx 58.94% <58.94%> (ø)
superset/assets/src/welcome/Welcome.jsx 78.57% <75%> (-1.43%) ⬇️
superset/assets/src/welcome/DashboardTable.jsx 75% <85.18%> (-2.78%) ⬇️
...perset/assets/src/components/ListView/ListView.tsx 91.17% <91.17%> (ø)
...assets/src/components/ListView/TableCollection.tsx 92.59% <92.59%> (ø)
superset/assets/src/components/ListView/utils.ts 98.14% <98.14%> (ø)
... and 1 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 ff9bc74...8262355. Read the comment docs.

@nytai nytai changed the title [WIP] new, Dashboard list view (react) new, Dashboard list view (react) Dec 23, 2019
@dpgaspar dpgaspar changed the title new, Dashboard list view (react) [dashboard] New, list view (react) Jan 3, 2020
@nytai
Copy link
Member Author

nytai commented Jan 9, 2020

@etr2460 @graceguo-supercat @michellethomas Would be great to get some 👀 on this from folks who spend more of their time in the frontend.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

Tested it locally and looks good, but noticed the following:

  • when switching languages the user is redirected to the old dashboard list (previous MVC page)
  • column labels are not translated
  • Button labels are not translated
  • Edit form back button does not work work properly (previous MVC), I would say that it's only usable when using modal forms form add and edit

superset/models/dashboard.py Outdated Show resolved Hide resolved
superset/views/dashboard/api.py Outdated Show resolved Hide resolved
@nytai
Copy link
Member Author

nytai commented Jan 13, 2020

@dpgaspar I've updated with the changes your requested as best I could.

when switching languages the user is redirected to the old dashboard list (previous MVC page)

looks like the user is redirected to the edit page of a specific dashboard, not sure how that's happening but doubt it's due to any change I made. Seems like that url is exposed in FAB and I don't really understand how that works right now.

column labels are not translated

I've updated the code to use the label_columns data provided by the backend. Looks like we're missing some translations there.

Button labels are not translated

I've updated the code to use the t('....') function from superset-ui/translation which seems to be the way of handling translations on the frontend. We're also likely missing most translations there.

Edit form back button does not work work properly (previous MVC), I would say that it's only usable when using modal forms form add and edit

This is true. looks like that links to /back which appears to be an endpoint in FAB? Somehow it's redirecting back to the charts list. Not sure how that works or how it's configured. -- There's work being done to move that functionality to a modal so that could be the workaround solution for that issue.

@nytai nytai requested a review from dpgaspar January 13, 2020 21:31

const PAGE_SIZE = 25;

interface Props {
Copy link
Member

Choose a reason for hiding this comment

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

I'm unclear about the pros/cons of using interface over propTypes, assuming this is more typescript-friendly (?). Tradeoff seems to be consistency vs being more ts friendly (?)

Copy link
Member Author

Choose a reason for hiding this comment

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

We could use both. PropTypes are checked at runtime by react in development and log to the console. Interface/types are checked by the typescript compiler/vscode and produce errors at build time and are highlighted in the editor. I'd say typescript is favorable once the entire repo converts to typescript as the types will be available in the editor (on hover, cmd click, etc). For now I'm happy to also add PropTypes until we transition more to typescript.

FWIW: The react dev team recommends flow/typescript over PropTypes for larger projects: https://reactjs.org/docs/static-type-checking.html

<Modal show={this.state.showDeleteModal} onHide={this.toggleModal}>
<Modal.Header closeButton={true} />
<Modal.Body>
Are you sure you want to delete{' '}
Copy link
Member

Choose a reason for hiding this comment

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

t()

search: PropTypes.string,
};

state = {
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 the same as setting state in the constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, they are essentially the same thing. The class properties is just sugar for setting variables in constructor. I personally prefer this over using the constructor as the constructor requires a call to super() which can sometimes be overlooked.

return this.hasPerm('can_delete');
}

public static propTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

Wondered why we haven't used this syntax before and found this:
Screen Shot 2020-01-14 at 11 52 03 AM

Copy link
Member Author

@nytai nytai Jan 15, 2020

Choose a reason for hiding this comment

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

I've added the babel plugin for transform-class-properties. The proposal for these is currently in stage 3, I believe, which is the step right before formal adoption into the standard. The proposal states that implementation is already under way in the latest chrome and in node 12.
proposal:
https://github.com/tc39/proposal-class-fields#class-field-declarations-for-javascript

Happy to switch back too. FWIW, every react project I've worked on has had this syntax enabled by babel.

@mistercrunch mistercrunch merged commit 7b97764 into apache:master Jan 16, 2020
@nytai nytai mentioned this pull request Mar 10, 2020
12 tasks
@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/XXL 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants