-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Conversation
131466e
to
319e011
Compare
This is awesome, I hope this be ported to Flask-AppBuilder lists |
6f00ff4
to
ebeebe3
Compare
globals: { | ||
'ts-jest': { | ||
diagnostics: { | ||
warnOnly: true, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
superset/views/dashboard/views.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 Report
@@ 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
Continue to review full report at Codecov.
|
@etr2460 @graceguo-supercat @michellethomas Would be great to get some 👀 on this from folks who spend more of their time in the frontend. |
There was a problem hiding this 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
@dpgaspar I've updated with the changes your requested as best I could.
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.
I've updated the code to use the
I've updated the code to use the
This is true. looks like that links to |
|
||
const PAGE_SIZE = 25; | ||
|
||
interface Props { |
There was a problem hiding this comment.
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 (?)
There was a problem hiding this comment.
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{' '} |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
CATEGORY
Choose one
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
new view
TEST PLAN
ADDITIONAL INFORMATION
REVIEWERS