-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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(dashboard/native-filters): Hide filters out of scope of current tab #14933
Conversation
@kgabryje Thank you Kamil for implementing this(more ideal) solution. |
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 minor thought on deferring loading to first display of out-of-scope filters, other than that (and failed tests) this is looks and works super well (= I wasn't able to break it)!
...-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
Show resolved
Hide resolved
Shouldn’t the initial state be the filters applicable to the standalone charts and the filters applicable to the selected tab since we always select a tab by default? When we have a tab group the first tab always starts selected, so the filters should be the same as when the user manually selects it. |
I think that our intention was to hide the filters as a reaction to user manually setting focus on some tab by clicking it. I see your point however and that makes sense to me. Let's wait for product input (CC @junlincc) and come back to that matter in the second iteration of the feature. |
b621f60
to
28e8c40
Compare
Codecov Report
@@ Coverage Diff @@
## master #14933 +/- ##
==========================================
- Coverage 77.62% 77.62% -0.01%
==========================================
Files 963 965 +2
Lines 49316 49497 +181
Branches 6228 6261 +33
==========================================
+ Hits 38284 38423 +139
- Misses 10833 10873 +40
- Partials 199 201 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
when user add value to filters in out of scope section, does apply button get enabled? |
Yes, we only change how the filters are displayed |
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! I propose merging this as-is as I feel this UX is superior to the current one in every way. We can then continue the discussions about refining this functionality later.
xit('should filter by published correctly', () => { | ||
it('should filter by published correctly', () => { |
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.
wow, this was unexpected, bycatch fixing and re-enabling a flaky test 😄
* upstream/master: (68 commits) fix typos (apache#14950) docs: fix custom oauth config (apache#14997) fix: apply template_params on external_metadata (apache#14996) fix: toggle fullscreen on the dashboard (apache#14979) feat(native-filters): add markers and number formatter + simple tests (apache#14981) fix(native-filters): Fix "undefined" error after editing a filter (apache#14984) fix(native-filters): remove implied fetch predicate (apache#14982) fix(native-filters): update cascaded filter state on change (apache#14980) fix(filter box): replace freeform where clause with ilike (apache#14900) refactor: Convert TableElement.jsx component from class to functional with hooks (apache#14830) fix: renamed sqllab filters to _filters (apache#14971) feat(native-filters): apply cascading without instant filtering (apache#14966) chore: bump superset-ui to 0.17.53 (apache#14968) fix(native-filters): cascading filters not rendering in tab (apache#14964) feat: add type_generic and is_dttm to table metadata (apache#14863) additional safeguard (apache#14953) feat: Adding FORCE_SSL as feature flag in config.py (apache#14934) feat(dashboard/native-filters): Hide filters out of scope of current tab (apache#14933) fix: time parser truncate to first day of year/month (apache#14945) fix: is_temporal should overwrite is_dttm (apache#14894) ...
tabsInScope: Array.from(tabsInScope), | ||
}); | ||
}); | ||
dispatch(setFilterConfiguration(nativeFiltersValues)); |
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.
@kgabryje This update function is called every time a user opens a dashboard, even without any change. This is not a correct behavior.
And, update dashboard should check user permission and get user confirm. This call is secretly changed dashboard json_metadata without user confirm. This will cause serious issue. Please fix asap. Otherwise this PR should be reverted.
cc @junlincc
In airbnb we didn't enable dashboard native filters feature flag, but because of this PR, all the recent visited dashboard were set
This will cause dashboard in a wrong state.
I think it is necessary to create a DB migration to fix the side-effects caused by this PR. In the migration script, scan every dashboard's metadata, when dashboard native filters feature is not enabled, should remove above 2 properties from dashboard json_metadata. |
@graceguo-supercat Thank you for raising those issues and providing context. PR #15146 solves part of the problem, another part will be fixed in a separate PR by @villebro |
…tab (apache#14933) * Optimize finding charts and tabs in scope * Put filters out of scope in Collapse * Use lastFocusedTabId instead of directPathToChild * Fix tests * Fix cypress test * Uncomment e2e test
…tab (apache#14933) * Optimize finding charts and tabs in scope * Put filters out of scope in Collapse * Use lastFocusedTabId instead of directPathToChild * Fix tests * Fix cypress test * Uncomment e2e test
…tab (apache#14933) * Optimize finding charts and tabs in scope * Put filters out of scope in Collapse * Use lastFocusedTabId instead of directPathToChild * Fix tests * Fix cypress test * Uncomment e2e test
SUMMARY
On dashboards with tabs, native filters that are out of scope of currently focused tab should be hidden.
When user opens a dashboard with top level tabs, the active top level tab is used as an initially focused tab. For dashboards without top level tabs, initially every filter is considered to be in scope, until the user clicks on a tab.
Hidden filters are moved to a new collapsible section in the native filters panel. In order to prevent expensive rerendering of native filters when they are moved in and out of collapsible, I used
react-reverse-portal
library, which utilizes React portals to perform reparenting without unmounting and remounting the child. In our case, it was essential, as each native filter sends a request to backend on mount - if a user had many native filters with narrow scopes, we'd risk having lots of redundant API calls on each tab change.Moreover, I optimized finding charts and tabs in scope for each native filter. Before, functions that traverse the whole component tree in search for charts and tabs were called every time a native filter was focused. Now, they are called once for each filter when the filters are initialized (and then again when filter's scope or dashboard layout changes).
In case of dashboards without any tabs, there are no visible changes.
Potential improvements:
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2021-06-01.at.17.50.05.mov
TESTING INSTRUCTIONS
DASHBOARD_NATIVE_FILTERS
feature flag to True.ADDITIONAL INFORMATION
CC: @junlincc @villebro