-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
feat(native-filters): Hide filters which don't affect any visible charts #15063
Conversation
/testenv up DASHBOARD_NATIVE_FILTERS = True |
@junlincc Ephemeral environment spinning up at http://34.213.155.134:8080. Credentials are |
// Filter is in scope if any of it's charts is visible. | ||
// Chart is visible if it's placed in an active tab tree or if it's not attached to any tab. | ||
// Chart is in an active tab tree if all of it's ancestors of type TAB are active | ||
const isFilterInScope = cascadeFilters[index].chartsInScope?.some( |
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.
const isFilterInScope = cascadeFilters[index].chartsInScope?.some( | |
const isFilterInScope = filter.chartsInScope?.some( |
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.
Riiiight 🤦 Done
const tabParents = chartLayoutItem?.parents.filter( | ||
(parent: string) => dashboardLayout[parent].type === TAB_TYPE, | ||
); | ||
return ( |
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'd love to see this logic moved out of components into a library of redux selectors, such as selectActiveTabbedCharts()
, selectFiltersInScope()
, selectChartsInScopeByFilter()
etc. That way the state logic will be in a central location and easier to manage.
It will also allow calculations to be memoized between different components. This is a triple-nested loop, which could become nasty on a dashboard with a lot of charts, tabs, and filters with significant numbers of charts in scope. And I know similar loops are running elsewhere in the app.
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 split some of that logic and moved it to superset/superset-frontend/src/dashboard/components/nativeFilters/state.ts
, but I'm not sure if that's exactly what you expected. Can you take another look?
/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=True |
@kgabryje Ephemeral environment spinning up at http://54.203.224.120:8080. Credentials are |
c3fe54c
to
85ebda2
Compare
Codecov Report
@@ Coverage Diff @@
## master #15063 +/- ##
==========================================
- Coverage 77.54% 77.53% -0.01%
==========================================
Files 967 967
Lines 49759 49787 +28
Branches 6352 6358 +6
==========================================
+ Hits 38585 38602 +17
- Misses 10972 10983 +11
Partials 202 202
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
LGTM
Ephemeral environment shutdown and build artifacts deleted. |
…rts (apache#15063) * feat(native-filters): Hide filters which don't affect any visible charts * Fix lint errors * Add comments * Code review fix * Fix tests * Refactor logic in FilterControls
…rts (apache#15063) * feat(native-filters): Hide filters which don't affect any visible charts * Fix lint errors * Add comments * Code review fix * Fix tests * Refactor logic in FilterControls
…rts (apache#15063) * feat(native-filters): Hide filters which don't affect any visible charts * Fix lint errors * Add comments * Code review fix * Fix tests * Refactor logic in FilterControls
SUMMARY
This PR changes the behaviour of hiding native filters out of scope, which was originally implemented in #14933.
Before, we considered filters to be "in scope" if they were placed in the last clicked tab. This approach presented several issues. The most significant issue was that in case of dashboards without top level tabs, there was no way to have charts unattached to any tab to be considered in scope once some row level tab had been clicked (as the scope was set only by clicking tabs).
The new proposal, implemented in this PR, is that we consider all visible charts to be "in scope". That means that in order to determine if a filter is in scope, we no longer check only the last clicked tab, but the whole tabs tree of the dashboard. For details, see attached recordings of the new native filters behaviour presented on dashboards with (the first video) and without (second video) top level tabs
Potential improvement: rename "Filters out of scope" section or add a label for filters in scope to make it clear for the user why specific filters are out of scope. If you have any ideas, I'm open for suggestions 🙂
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: see #14933
After:
https://user-images.githubusercontent.com/15073128/121371437-d6de1a00-c93d-11eb-9776-5ba53f35ab33.mov
https://user-images.githubusercontent.com/15073128/121371703-0ab93f80-c93e-11eb-8b92-3d216a049450.mov
TESTING INSTRUCTIONS
DASHBOARD_NATIVE_FILTERS
feature flag toTrue
ADDITIONAL INFORMATION
CC: @junlincc @villebro @michael-s-molina