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

feat(native-filters): Show/Hide filter bar by metdata ff #14261

Merged
merged 14 commits into from Apr 28, 2021

Conversation

simcha90
Copy link
Contributor

@simcha90 simcha90 commented Apr 21, 2021

SUMMARY

As we are slowly releasing native filters we would like to have the ability per dashboard to choose if to hide/show the filter.
some of dashboard owners still not ready to just convert their filter boxes into native filters and although they could both live together having an empty filter bar might be confusing for end clients.
therefore we are adding the ability to
Show/Hide filter bar by using show_native_filters as another property within the dashboard metadata in addition to the Global feature flag

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #14261 (b03b909) into master (22f9e12) will increase coverage by 0.07%.
The diff coverage is 53.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14261      +/-   ##
==========================================
+ Coverage   77.05%   77.13%   +0.07%     
==========================================
  Files         954      954              
  Lines       48140    48149       +9     
  Branches     5986     5991       +5     
==========================================
+ Hits        37096    37140      +44     
+ Misses      10847    10812      -35     
  Partials      197      197              
Flag Coverage Δ
hive 80.77% <100.00%> (+<0.01%) ⬆️
javascript 72.02% <50.00%> (-0.01%) ⬇️
mysql 81.03% <100.00%> (+<0.01%) ⬆️
postgres 81.07% <100.00%> (+<0.01%) ⬆️
presto 80.76% <100.00%> (?)
python 81.59% <100.00%> (+0.15%) ⬆️
sqlite 80.67% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/dashboard/actions/hydrate.js 3.30% <0.00%> (-0.06%) ⬇️
...d/components/DashboardBuilder/DashboardBuilder.tsx 86.95% <71.42%> (-1.42%) ⬇️
...omponents/nativeFilters/FilterBar/Header/index.tsx 90.90% <100.00%> (ø)
superset/dashboards/schemas.py 99.37% <100.00%> (+<0.01%) ⬆️
superset/models/core.py 89.13% <0.00%> (+0.27%) ⬆️
superset/connectors/sqla/models.py 90.07% <0.00%> (+1.45%) ⬆️
superset/db_engine_specs/presto.py 89.89% <0.00%> (+5.47%) ⬆️

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 22f9e12...b03b909. Read the comment docs.

@amitmiran137 amitmiran137 changed the title feat(native-filters): Hide filter bar by matdata feat(native-filters): Show/Hide filter bar by metdata ff Apr 21, 2021
@amitmiran137 amitmiran137 added v1.2 and removed v1.2 labels Apr 22, 2021
@simcha90 simcha90 requested a review from a team as a code owner April 25, 2021 10:27
@pull-request-size pull-request-size bot added size/L and removed size/S labels Apr 25, 2021
Copy link

@vonsamnang01041994 vonsamnang01041994 left a comment

Choose a reason for hiding this comment

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

ok

Copy link
Member

@amitmiran137 amitmiran137 left a comment

Choose a reason for hiding this comment

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

LGTM!

  1. tested that migration works
  2. when key doesn't exist it default to true as if only the DASHBOARD_NATIVE_FILTERS FF is calling the shots
  3. when key is false no filter bar
  4. when key is true , filter bar is shown

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

I think this is a good feature and would probably be helpful in the migration effort leaving old dashboards as-is until a conscious decision to migrate has been made. However, for now I think we should only disable native filters for dashboards that have filter boxes added to them. In addition, I'd add a comment to UPDATING.md to let users know that this option now exists and has been set to false for all charts that have filter boxes, otherwise end users might not know why certain dashboards are missing the feature. Also calling on @graceguo-supercat and @junlincc for feeback.

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

I would like to avoid adding a database migration for this.

If some dashboard owners would like to remove the filter bar from their dashboards, it makes sense to add a metadata json option that they can set, but setting it as the default seems like overkill. Especially so when the native filters are already behind a feature flag in the first place.

Side note: There are also efforts underway to build an option for dashboard owners to auto-migrate from filter box to native filters, so the issue of having filter boxes hanging around will hopefully be short lived.

Side note 2: In the case where a non-editor is viewing a dashboard that has no native filters, it might be better to not show the filter bar since it will just be empty.

.all()
)

changed_filters = 0
Copy link
Member

Choose a reason for hiding this comment

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

Is this variable used for something?

@graceguo-supercat
Copy link

graceguo-supercat commented Apr 27, 2021

Currently dashboard has no automatic logic to convert filter_box into filter bar.

  • if dashboard already had filter component and no filter_box, Dashboard should show filter bar.
  • if dashboard already had filter component and some old filter_box, we should show both filter bar and filter_box. This means user started manually convert filter_box to new filter components.
  • if dashboard had no filter component but had many old had filter_box, I guess this type of users are not ready to manually convert their filter_box to filter component yet, then we should hide filter bar when user open dashboard.

In short, we should show filter bar if dashboard has any native filter metadata, otherwise, hide filter bar by default.
What is new feature flag supposed to do?

@amitmiran137
Copy link
Member

Currently dashboard has no automatic logic to convert filter_box into filter bar.

  • if dashboard already had filter component and no filter_box, Dashboard should show filter bar.
  • if dashboard already had filter component and some old filter_box, we should show both filter bar and filter_box. This means user started manually convert filter_box to new filter components.
  • if dashboard had no filter component but had many old had filter_box, I guess this type of users are not ready to manually convert their filter_box to filter component yet, then we should hide filter bar when user open dashboard.

In short, we should show filter bar if dashboard has any native filter metadata, otherwise, hide filter bar by default.
What is new feature flag supposed to do?

It enables you to hide the filter component in a specific Dashboard

@amitmiran137
Copy link
Member

I would like to avoid adding a database migration for this.

If some dashboard owners would like to remove the filter bar from their dashboards, it makes sense to add a metadata json option that they can set, but setting it as the default seems like overkill. Especially so when the native filters are already behind a feature flag in the first place.

Side note: There are also efforts underway to build an option for dashboard owners to auto-migrate from filter box to native filters, so the issue of having filter boxes hanging around will hopefully be short lived.

Side note 2: In the case where a non-editor is viewing a dashboard that has no native filters, it might be better to not show the filter bar since it will just be empty.

I think I'm going to replace the migration with side note 2
That would accomplish exactly the use of showing the filter bar when it is not relevant
Thanks for that !

Copy link
Member

@amitmiran137 amitmiran137 left a comment

Choose a reason for hiding this comment

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

We should also hide filter bar if no native filters exists
@simcha90

@simcha90
Copy link
Contributor Author

simcha90 commented Apr 27, 2021

@suddjian added proposal:

Side note 2: In the case where a non-editor is viewing a dashboard that has no native filters, it might be better to not show the filter bar since it will just be empty.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Apr 27, 2021
Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

Thanks for making that change, this LGTM

@amitmiran137 amitmiran137 merged commit 2486fd4 into apache:master Apr 28, 2021
@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Apr 28, 2021
amitmiran137 pushed a commit that referenced this pull request Apr 28, 2021
* fix:fix get permission function

* feat: hide native filters by metadata

* fix: fix show_native_filters name

* fix: metadata

* chore: add migration to hide native_filters in all existing dashboards

* chore: fix pre-commit

* fix: make migration migration dashboard with filter_box only

* fix: pre-commit

* feat: hide filter bar if no permission edit and no filters

* fix: remove migration

Co-authored-by: amitmiran137 <amit.miran@nielsen.com>
(cherry picked from commit 2486fd4)
metadata = {};
}

metadata.show_native_filters =
Copy link
Member

Choose a reason for hiding this comment

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

@simcha90 @amitmiran137 @villebro should this use the DASHBOARD_NATIVE_FILTERS feature flag for defining the fallback rather than defaulting to true? We've seen instances at Airbnb where dashboard native filters are showing up in the dashboard metadata even though the feature is disabled.

QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* fix:fix get permission function

* feat: hide native filters by metadata

* fix: fix show_native_filters name

* fix: metadata

* chore: add migration to hide native_filters in all existing dashboards

* chore: fix pre-commit

* fix: make migration migration dashboard with filter_box only

* fix: pre-commit

* feat: hide filter bar if no permission edit and no filters

* fix: remove migration

Co-authored-by: amitmiran137 <amit.miran@nielsen.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 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 dashboard:native-filters Related to the native filters of the Dashboard size/M v1.2 🚢 1.2.0
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

9 participants