-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
fix(dashboard): FilterBox JS error when datasets API is slow #15993
fix(dashboard): FilterBox JS error when datasets API is slow #15993
Conversation
327fb60
to
7d2e478
Compare
@@ -93,7 +94,7 @@ class ChartRenderer extends React.Component { | |||
nextProps.queriesResponse !== this.props.queriesResponse; | |||
return ( | |||
this.hasQueryResponseChange || | |||
nextProps.datasource !== this.props.datasource || | |||
!isEqual(nextProps.datasource, this.props.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.
👍
7d2e478
to
9c3a169
Compare
@@ -373,7 +373,7 @@ max-locals=15 | |||
max-returns=10 | |||
|
|||
# Maximum number of branch for function / method body | |||
max-branches=12 | |||
max-branches=15 |
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.
Allow more if
branches instead of suppressing the too-many-branches
error inline.
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.
Yikes! This is an anti-pattern in my opinion. The check is there for a reason to prevent non-readable code. If one must override this, it should be done locally and not globally.
Codecov Report
@@ Coverage Diff @@
## master #15993 +/- ##
==========================================
- Coverage 77.04% 76.95% -0.09%
==========================================
Files 988 989 +1
Lines 52389 52400 +11
Branches 6626 6634 +8
==========================================
- Hits 40365 40327 -38
- Misses 11800 11850 +50
+ Partials 224 223 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
for filter_ in form_data.get("adhoc_filters") or []: | ||
if filter_["clause"] == "WHERE" and filter_.get("subject"): | ||
column_names.add(filter_.get("subject")) | ||
|
||
# columns used by Filter Box |
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 LINER CHALLENGE!
column_names.update(filter_config["column"] for filter_config in form_data.get("filter_configs", []) if filter_config and "column" in filter_config)
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.
🥳
SUMMARY
This fixes a bug introduced by #15699: when the
/dashboard/<dashboardId>/datasets
API is slow and the FilterBox is rendered before this API is returned, it will fail and show a JS error:filterbox-fix-before.mp4
This PR makes the async re-rendering process more robust by:
PLACEHOLDER_DATASOURCE
for all chart renderers so similar JS errors will not happen for other charts which forgot to handle the case whendatasource
is not loaded.datasource
isPLACEHOLDER_DATASOURCE
. After the API is successfully returned, chart reducer will trigger a re-render.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
See above
After
filterbox-name-fix-after.mp4
TESTING INSTRUCTIONS
here to mock a slow response for the
/datasets
API.2. Create a dashboard with Filterbox, select a couple of filter columns with verbose names (change column
Label
in datasource editor).ADDITIONAL INFORMATION