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

chore(dashboard): Disable 'Set filter mapping' when appropriate #23261

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Mar 1, 2023

SUMMARY

This PR addresses recommendation #⁠5 in #14383.

The "set filter mapping" dashboard menu option (see screenshot) is used to configure the filter scopes for legacy (filter-box) filters. By defaults filter scopes are implicitly defined, i.e., charts have no immunity to filter-boxes, however users can explicitly specify them (by defining their scope and inclusion/exclusion logic).

Though both legacy and native filters can coexist the behavior is not ideal from a UX perspective, i.e., when the DASHBOARD_NATIVE_FILTERS feature is enabled users should strive to solely use the native filters functionality/modal to define filtering whilst simultaneously removing legacy filter-box charts.

This PR ensures that if the DASHBOARD_NATIVE_FILTERS feature is enabled and no legacy filter mapping is explicitly defined (filter-box charts can be present*) then the menu option to set the mapping should not be present, i.e., we should prevent users from having the ability to define legacy filter scopes. The TL;DR is we want to prevent users from creating new legacy filter scopes when the feature is enabled.

* If filter-box charts are present then (per my previous comment) implicit filter scope logic is still adhered to even if there's no explicitly defined legacy filter scopes. The TL;DR with this change users wont be able to configure the filter-box charts' scopes/immunity, however users should be encouraged to simply remove the filter-box charts from the dashboard and replace them with native filters.

Screenshot 2023-03-08 at 10 11 39 PM

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Added unit tests.

ADDITIONAL INFORMATION

  • Has associated issue: [SIP-64] Migrate filter_box to Dashboard Native Filter Component #14383
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@john-bodley john-bodley force-pushed the john-bodley--disable-check-filter-mapping branch from 6fa443c to 1faa5b4 Compare March 1, 2023 23:48
@john-bodley john-bodley marked this pull request as ready for review March 2, 2023 01:08
@john-bodley john-bodley force-pushed the john-bodley--disable-check-filter-mapping branch from 1faa5b4 to 0382922 Compare March 2, 2023 05:18
@john-bodley john-bodley changed the title fix(dashboard): Disable 'Set filter mapping' when appropriate feature(dashboard): Disable 'Set filter mapping' when appropriate Mar 2, 2023
@john-bodley john-bodley changed the title feature(dashboard): Disable 'Set filter mapping' when appropriate chore(dashboard): Disable 'Set filter mapping' when appropriate Mar 2, 2023
@john-bodley john-bodley force-pushed the john-bodley--disable-check-filter-mapping branch from 0382922 to be702f3 Compare March 2, 2023 17:34
expect(screen.getByText('Edit properties')).toBeInTheDocument();
expect(screen.getByText('Edit CSS')).toBeInTheDocument();
});

test('should render filter mapping in edit mode if DASHBOARD_NATIVE_FILTERS disabled and mapping undefined', async () => {

Choose a reason for hiding this comment

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

Seems like this test is failing

@john-bodley john-bodley force-pushed the john-bodley--disable-check-filter-mapping branch 6 times, most recently from 137d984 to 37fd75c Compare March 7, 2023 18:44
@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 7, 2023
@john-bodley john-bodley force-pushed the john-bodley--disable-check-filter-mapping branch 5 times, most recently from 2ec74b4 to 8f547b2 Compare March 7, 2023 23:06
@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #23261 (3594e89) into master (7d8383c) will increase coverage by 0.07%.
The diff coverage is 77.34%.

❗ Current head 3594e89 differs from pull request most recent head 04a56ef. Consider uploading reports for the commit 04a56ef to get more accurate results

@@            Coverage Diff             @@
##           master   #23261      +/-   ##
==========================================
+ Coverage   67.51%   67.58%   +0.07%     
==========================================
  Files        1907     1907              
  Lines       73436    73531      +95     
  Branches     7977     7981       +4     
==========================================
+ Hits        49581    49698     +117     
+ Misses      21803    21785      -18     
+ Partials     2052     2048       -4     
Flag Coverage Δ
javascript 53.82% <62.50%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...et-ui-chart-controls/src/operators/sortOperator.ts 100.00% <ø> (ø)
...rt-controls/src/shared-controls/customControls.tsx 17.39% <0.00%> (-7.61%) ⬇️
...-core/src/hooks/useChangeEffect/useChangeEffect.ts 100.00% <ø> (ø)
...hooks/useComponentDidMount/useComponentDidMount.ts 100.00% <ø> (ø)
...oks/useComponentDidUpdate/useComponentDidUpdate.ts 100.00% <ø> (ø)
...src/hooks/useElementOnScreen/useElementOnScreen.ts 100.00% <ø> (ø)
...erset-ui-core/src/hooks/usePrevious/usePrevious.ts 100.00% <ø> (ø)
...re/src/hooks/useTruncation/useCSSTextTruncation.ts 100.00% <ø> (ø)
...c/hooks/useTruncation/useChildElementTruncation.ts 100.00% <ø> (ø)
...chart-echarts/src/Timeseries/Area/controlPanel.tsx 40.00% <ø> (ø)
... and 152 more

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

{editMode &&
!(
isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) &&
isEmpty(dashboardInfo?.metadata?.filter_scopes)
Copy link
Member Author

Choose a reason for hiding this comment

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

See my comment in the PR description. I think it's fine to look at the filter_scopes field (since this is what setting the filter mapping configures) rather than checking for the non-presence of filter-box charts.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM

});

it('should render filter mapping in edit mode if explicit filter scopes defined', async () => {
const mockedProps = {
Copy link
Member

@michael-s-molina michael-s-molina Mar 16, 2023

Choose a reason for hiding this comment

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

Nit: Can you extract mockedProps to a sharable constant similar to editModeOnProps and reuse it in the tests? It could be something like propsWithFilterScopes

@john-bodley john-bodley force-pushed the john-bodley--disable-check-filter-mapping branch from 8f547b2 to 07709a9 Compare March 16, 2023 20:44
@pull-request-size pull-request-size bot added size/M and removed size/L labels Mar 16, 2023
@john-bodley john-bodley merged commit ad72cd3 into apache:master Mar 17, 2023
@john-bodley john-bodley deleted the john-bodley--disable-check-filter-mapping branch March 17, 2023 01:09
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Mar 21, 2023
john-bodley added a commit to airbnb/superset-fork that referenced this pull request Mar 21, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 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 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants