-
Notifications
You must be signed in to change notification settings - Fork 16.6k
refactor(explore): convert ControlPanelsContainer to typescript #13221
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
Conversation
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.
Remove this exposed datasource prop from #12609 since it's already available in formData, plus The typing would not conform with datasource for DatasourceControl, which uses the assigns datasource prop with the whole metadata of a datasource in mapStateToProps.
|
yeah, you are getting ready to work on dynamic controls thanks! |
705b500 to
91cd91c
Compare
2679eae to
53964e5
Compare
|
Moved debounce delay updates to another PR: #13250 Will rebase once merged. |
53964e5 to
1f4b063
Compare
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.
Will update the shared control to pass in datasource object instead of datasource string from form_data.
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.
This is used for allowing selecting adhoc metrics in adhoc filters, but it has stopping working:
#13249
The new selectedMetrics will be added by a superset-ui PR.
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.
Did more refactoring based on: #13211 (comment)
09ebe62 to
b8725fb
Compare
superset-frontend/.eslintrc.js
Outdated
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.
Disabling as we have seen fairly often nested-ternary in TypeScript extends. It should not be that hard to understand the code with prettier's help.
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.
nested ternary was used in this code:
const controlName =
typeof item === 'string'
? item
: item && 'name' in item
? item.name
: null;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.
Yeah, I'm a fan of nested ternaries when used sparingly. however, couldn't this be simplified to:
const controlName =
typeof item === 'string'
? item
: (item || {})?.name ?? null;or something like that?
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.
Not sure if that's really cleaner, but it doesn't use a nested ternary
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.
2dd459a to
71a3b5d
Compare
Codecov Report
@@ Coverage Diff @@
## master #13221 +/- ##
==========================================
- Coverage 77.12% 72.73% -4.40%
==========================================
Files 894 595 -299
Lines 45672 21247 -24425
Branches 5492 5490 -2
==========================================
- Hits 35223 15453 -19770
+ Misses 10325 5668 -4657
- Partials 124 126 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
718ff04 to
a2630e1
Compare
ktmud
left a comment
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.
@villebro @pkdotson @zhaoyongjie @kgabryje could you take a look at this when you have time?
Thanks!
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.
Reduce row limit to speed up the test (a little bit)
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.
Instead of check control types, I check whether the control uses column select.
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.
Move to inline function to use inferred types.
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.
This one does not work anyway (i.e. change datasource will not reset Time-series Table columns, and the filters collection in FilterBox) since previously props.datasource is passed as a string.
I don't plan to implement this reset because these control values should not be reset when changing datasource.
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.
Always use guessedFrame to tooltip and actual time range display because when passing in a new value and the popover is not open, the current frame may be inconsistent with the actual value.
This makes sure Last week is always displayed in the pill instead of tooltip.
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.
Clean up the datasource prop from adhoc metric popovers as they don't seem to affect the ability of the controls to reset values when changing datasource.
@pkdotson do you remember what was these for when you added them?
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.
OPERATORS.in and OPERATORS['not in'] are undefined, as identified by converting to typescript, so cleaning them up. AchocFilter already always convert the operator into uppercase.
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.
Split functions in controlUtils to TypeScript one by one...
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.
Instead of checking control types, I now check whether a control depends on datasource columns.
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.
Moved the resetting logic to reducers as each of these setControlValue call here will cause another re-rendering.
9efcc03 to
cb1dd58
Compare
|
Close to re-trigger full CI to fix test coverage report. |
Good call. I did a sweep and managed to find one place that I could optimize: caf3b60 |
caf3b60 to
430874c
Compare
|
@ktmud I found this typescript error: It's happening because I was going to fix it, but I was afraid of not having all the necessary context since this touches Shouldn't CI catch this? |
|
@michael-s-molina Did you run I'm pretty sure this was updated here: https://github.com/apache-superset/superset-ui/pull/962/files#diff-efc1b32a915b3738e7689b97eab6576ac7b206bc95d46e1ecaac6c8646287a65R27 The |
|
@ktmud Strangely I ran |





SUMMARY
Convert ControlPanelsContainer and some other related components to TypeScript.
Big refactoring are coming to chart controls and the Explore page, in order to support reading query results in controls, which is needed for things like ad-hoc column formatting in table chart.
Also did some refactoring to redo #12782 and #12609 . See comments for details.
Upgraded
superset-uito v0.17.11 to bring in:apache-superset/superset-ui#962
apache-superset/superset-ui#969
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
There should be no visible change.
TEST PLAN
CI and manual testing the chart control area.
ADDITIONAL INFORMATION