Skip to content

Conversation

@hexcafe
Copy link

@hexcafe hexcafe commented Jul 1, 2024

SUMMARY

The show_filters URL param is no longer working (logic to handle it was removed with #23228).

This PR re-introduces the logic pertinent to this flow from that PR + updates DashboardBuilder so that it works with current master.

This fix should also reflect to embedded when setting filters.visible to false through the SDK configuration.

Fixes #26758.
Fixes #30538.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Tested both with horizontal and vertical filter bar:
image

Embedded:
image

TESTING INSTRUCTIONS

Tests added. For manual testing:

  1. Create a dashboard and configure at least one filter to it.
  2. Copy the dashboard URL, add show_filters=false as a URL parameter and access it.

ADDITIONAL INFORMATION

@dosubot dosubot bot added dashboard Namespace | Anything related to the Dashboard dashboard:native-filters Related to the native filters of the Dashboard labels Jul 1, 2024
@rusackas rusackas requested review from Vitor-Avila and kgabryje July 1, 2024 16:49
@Vitor-Avila
Copy link
Contributor

Thanks for the PR, @hexcafe. Hey @michael-s-molina @john-bodley,
I believe this is a continuation of #25804 which was aiming to fix #24195 (used to work until #23228).

I checked out this PR locally and tested and it works ✅ but since I'm just getting familiar with frontend I wanted to get your thoughts.

I didn't think so, but this also works with the horizontal filter bar 🙌

Thanks!

@michael-s-molina
Copy link
Member

@hexcafe @Vitor-Avila Shouldn't we just revert this part that was deleted in #23228?

@RoBYCoNTe
Copy link

Any news about this PR?

@grzaks
Copy link

grzaks commented Oct 5, 2024

Would be great to see this one merged into next release.

@nawar
Copy link

nawar commented Oct 28, 2024

Can we please get this reviewed?

@Vitor-Avila
Copy link
Contributor

@michael-s-molina would you prefer to have that code block restored as opposed to using the approach in this PR?

@michael-s-molina
Copy link
Member

@michael-s-molina would you prefer to have that code block restored as opposed to using the approach in this PR?

@Vitor-Avila It seems we should restore that code given that nativeFiltersEnabled, which is used for many things when calculating the dashboard state, used to depend on that parameter.

@zslegl
Copy link

zslegl commented Apr 1, 2025

Any progress on reviewing this fix?

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Just rebased this, and it looks fine to me. Let's see if CI (still) passes.

@rusackas
Copy link
Member

rusackas commented Apr 2, 2025

I'm not sure if @Vitor-Avila or @michael-s-molina want to revisit restoring the old code block (which GitHub won't let me view at the moment for some reason 😢) but this PR looks pretty harmless to me in the meantime.

@Vitor-Avila
Copy link
Contributor

@rusackas not sure if @hexcafe is around to assess potentially re-introducing that code. Let me check real quick if that would still work.

@sfirke
Copy link
Member

sfirke commented Apr 2, 2025

I would like to prioritize getting this fix into the next release. If @hexcafe or someone else is up for restoring the old code block, great, but let's not let that hold this up further if no one can deliver that soon. (I just took an attempt but didn't get it working)

@Vitor-Avila
Copy link
Contributor

@rusackas @michael-s-molina I restored the code from that PR locally (on top of master) to superset-frontend/src/dashboard/components/DashboardBuilder/state.ts:

  • declared this const:
const showNativeFilters = useSelector<RootState, boolean>(
    state => (getUrlParam(URL_PARAMS.showFilters) ?? true),
  );
  • Updated the definition for nativeFiltersEnabled to:
const nativeFiltersEnabled =
  showNativeFilters &&
  (canEdit || (!canEdit && filterValues.length !== 0));

Still, when loading a dashboard with show_filters=false, the filter bar is visible and expanded. It seems we also need a change in superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx similar to this PR:

const showFilterBar = !editMode && nativeFiltersEnabled;

Would it be better to build on top of this open PR or create a new one?

@Vitor-Avila
Copy link
Contributor

@sfirke happy to help here :) just want to confirm if I should open a new/separate PR or if I should build on top of this one. I'd say the latter since we also need a similar change to @hexcafe and that should preserve his contribution to the work

@sfirke
Copy link
Member

sfirke commented Apr 2, 2025

I think just build on this PR to preserve hexcafe's contribution while also moving it forward while you're looking at the code

@pull-request-size pull-request-size bot added size/M and removed size/XS labels Apr 2, 2025
@Vitor-Avila Vitor-Avila requested a review from rusackas April 2, 2025 20:27
@Vitor-Avila
Copy link
Contributor

Vitor-Avila commented Apr 2, 2025

@rusackas @sfirke @michael-s-molina I believe this should be all good now. Could I get a new review? Tried adding some tests, but manual tests are always encouraged haha 🙏

@github-actions
Copy link
Contributor

github-actions bot commented Apr 2, 2025

@sfirke Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

@github-actions
Copy link
Contributor

github-actions bot commented Apr 2, 2025

@sfirke Ephemeral environment spinning up at http://18.236.110.2:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

export const useNativeFilters = () => {
const [isInitialized, setIsInitialized] = useState(false);
const showNativeFilters = useSelector<RootState, boolean>(
state => getUrlParam(URL_PARAMS.showFilters) ?? true,
Copy link
Member

Choose a reason for hiding this comment

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

@Vitor-Avila The original code had && state.dashboardInfo.metadata?.show_native_filters. Isn't that needed anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

@michael-s-molina my understanding is that the original PR fully removed metadata.show_native_filters (from all places). I suspect the reason for it is that this metadata config was intended to permanently hide the native filters on dashboards that had filter box, until it was fully migrated. So I don't think we need that back. If we want to bring that logic, we would need to re-update the schemas, and logic in other places too.

Not sure if you had a chance to test in that ephemeral but I believe things are working properly with these changes.

@Vitor-Avila
Copy link
Contributor

@sfirke I noticed you created an ephemeral here -- let me know when you're good with testing and I'll merge this one. 🙌

@sfirke
Copy link
Member

sfirke commented Apr 3, 2025

Hi @Vitor-Avila - I just tested in the ephemeral and it looks ready to merge 🚀 Thanks for this fix!

@sfirke
Copy link
Member

sfirke commented Apr 3, 2025

This actually closes two issues, I just linked the other in the top post.

@Vitor-Avila Vitor-Avila merged commit bcb4332 into apache:master Apr 3, 2025
62 of 63 checks passed
@Vitor-Avila
Copy link
Contributor

awesome! thanks for taking the time to test it. Just merged it

@michael-s-molina michael-s-molina added the v5.0 Label added by the release manager to track PRs to be included in the 5.0 branch label Apr 3, 2025
michael-s-molina pushed a commit that referenced this pull request Apr 3, 2025
Co-authored-by: Evan Rusackas <[email protected]>
Co-authored-by: Vitor Avila <[email protected]>
(cherry picked from commit bcb4332)
@sfirke sfirke moved this to Done in Apache Superset 5.0.0 Apr 9, 2025
michael-s-molina pushed a commit that referenced this pull request Apr 14, 2025
Co-authored-by: Evan Rusackas <[email protected]>
Co-authored-by: Vitor Avila <[email protected]>
(cherry picked from commit bcb4332)
@michael-s-molina michael-s-molina moved this from Done to Cherried in Apache Superset 5.0.0 May 12, 2025
alexandrusoare pushed a commit to alexandrusoare/superset that referenced this pull request Jun 19, 2025
Co-authored-by: Evan Rusackas <[email protected]>
Co-authored-by: Vitor Avila <[email protected]>
(cherry picked from commit bcb4332)
@mistercrunch mistercrunch added 🍒 5.0.0 Cherry-picked to 5.0.0 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Jul 29, 2025
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 dashboard Namespace | Anything related to the Dashboard size/M v5.0 Label added by the release manager to track PRs to be included in the 5.0 branch 🍒 5.0.0 Cherry-picked to 5.0.0

Projects

No open projects
Status: Cherried

Development

Successfully merging this pull request may close these issues.

Adding show_filters= to a dashboard URL doesn't do anything Filters.visible= false Still shows the filters on embedded iFrame