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] fix chart showing loading icon when slice's immune fields is changed #7895

Merged

Conversation

graceguo-supercat
Copy link

@graceguo-supercat graceguo-supercat commented Jul 18, 2019

CATEGORY

Choose one

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

SUMMARY

When filter is changed, chart shows a loading icon, but not fetching data.

In Dashboard component, the logic to trigger chart refresh has problem. It only checks if whole chart is immune, but not check if chart immune to curtain fields in a applied filter.
After chart is triggered to refresh, its state changed from success to loading, so we show loading icon for the chart. But the effective filter for the chart is not changed (because filter is not applicable). At the result, chart didn't send new query, but since the chart did not change state any more, the chart's loading status will not disappear.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

before:
Pk8afppq1w

after: should not show loading icon, and no fetching api call
ZChCuSsdWA

TEST PLAN

Added new unit test for this case.

REVIEWERS

@williaster @michellethomas @mistercrunch @etr2460

@codecov-io
Copy link

codecov-io commented Jul 18, 2019

Codecov Report

Merging #7895 into master will increase coverage by 0.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #7895      +/-   ##
=========================================
+ Coverage   65.79%   65.8%   +0.01%     
=========================================
  Files         461     461              
  Lines       22188   22199      +11     
  Branches     2425    2433       +8     
=========================================
+ Hits        14598   14608      +10     
- Misses       7469    7470       +1     
  Partials      121     121
Impacted Files Coverage Δ
superset/assets/src/chart/Chart.jsx 11.11% <0%> (+0.24%) ⬆️
...t/assets/src/dashboard/reducers/getInitialState.js 0% <0%> (ø) ⬆️
...rset/assets/src/dashboard/components/Dashboard.jsx 90.76% <100%> (+1.67%) ⬆️

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 2b3e7fe...5b57294. Read the comment docs.

@graceguo-supercat graceguo-supercat force-pushed the gg-FixFilterImmuneFields branch 3 times, most recently from 1530d0e to 89f7c02 Compare July 18, 2019 20:31
@graceguo-supercat graceguo-supercat force-pushed the gg-FixFilterImmuneFields branch from 89f7c02 to f4b94a8 Compare July 19, 2019 19:14
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

one nit

const { filters } = this.props.dashboardState || {};
const currentFilteredNames =
filterKey && filters[filterKey] ? Object.keys(filters[filterKey]) : [];
const filter_immune_slices = this.props.dashboardInfo.metadata
Copy link
Member

Choose a reason for hiding this comment

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

camelCase for the const

filterKey && filters[filterKey] ? Object.keys(filters[filterKey]) : [];
const filter_immune_slices = this.props.dashboardInfo.metadata
.filter_immune_slices;
const filter_immune_slice_fields = this.props.dashboardInfo.metadata
Copy link
Member

Choose a reason for hiding this comment

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

camelCase for the const

@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
/* eslint-disable camelcase */
Copy link
Member

Choose a reason for hiding this comment

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

then we can probably get rid of this comment

@graceguo-supercat
Copy link
Author

graceguo-supercat commented Jul 23, 2019

i am kind of hesitate to rename all filter_immune_slice_fields to camelCase filterImmuneSliceFields:

  • There are a few read-only config variables that are one-to-one mapped to fields in JSON Metadata, like filter_immune_slice_fields, filter_immune_slices, timed_refresh_immune_slices. It will be easier to map feature to its stored configuration, when we globally search the same key in the code base.
  • But this behavior is not consistent, some config variables are converted to camelCase, for example: expandedSlices, refresh_frequency... 😓
  • Changing filter_immune_slices and filter_immune_slice_fields variables will touch about 6 files 20 places, it's not very relevant to the purpose of this bug fix.

I would rather keep this PR simple, just for bug fixing.
But in another PR involved big code refactor (#7908), i can change these filter related variables (filter_immune_slice_fields and filter_immune_slices) in all front-end code.

@graceguo-supercat graceguo-supercat changed the title [dashboard] fix chart showing loading icon when immune fields updated [dashboard] fix chart showing loading icon when slice's immune fields is changed Jul 23, 2019
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

this looks good then; assuming triggerQuery handles all the logic necessary to determine if a chart needs to be refreshed

@graceguo-supercat graceguo-supercat merged commit df9efa8 into apache:master Jul 25, 2019
@graceguo-supercat graceguo-supercat deleted the gg-FixFilterImmuneFields branch August 8, 2019 20:38
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.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/M 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants