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): add support for preselect filters #15427

Merged
merged 3 commits into from
Jun 29, 2021

Conversation

villebro
Copy link
Member

SUMMARY

This PR adds support for opening a dashboard with predefined filters passed via URL params. When clicking on "Copy dashboard URL" or "Share dashboard by email" in the Dashboard menu, a shortcut to an URL with RISON encoded filter state is created, which can be used to share the currently selected filters.

SCREENSHOTS

When opening up the link, the dashboard opens up with the predefined filter selection. Notice native_filters in the URL params:
image

TESTING INSTRUCTIONS

  1. Open a dashboard with native filters
  2. Select a few filters
  3. Click "Copy dashboard URL" or "Share dashboard by email"
  4. Open the link and notice the dashboard opening with the previously selected filters. (please note: the prepopulated URL will reference port 8088 when in dev-server mode. So remember to manually update this to 9000 when testing locally)

ADDITIONAL INFORMATION

  • Has associated issue: closes add support for preselect_filters to the dashboard native filters  #14918
  • 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 Jun 28, 2021

Codecov Report

Merging #15427 (06c664d) into master (f53b2c6) will decrease coverage by 0.01%.
The diff coverage is 69.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15427      +/-   ##
==========================================
- Coverage   77.22%   77.21%   -0.02%     
==========================================
  Files         975      975              
  Lines       50634    50681      +47     
  Branches     6222     6239      +17     
==========================================
+ Hits        39104    39133      +29     
- Misses      11319    11337      +18     
  Partials      211      211              
Flag Coverage Δ
javascript 71.73% <69.81%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
...erset-frontend/src/components/AnchorLink/index.jsx 95.83% <ø> (ø)
superset-frontend/src/constants.ts 100.00% <ø> (ø)
superset-frontend/src/dashboard/actions/hydrate.js 1.72% <ø> (ø)
...frontend/src/dashboard/components/Header/index.jsx 67.15% <ø> (ø)
...dashboard/components/SliceHeaderControls/index.tsx 76.98% <ø> (ø)
...ntend/src/dashboard/containers/DashboardHeader.jsx 100.00% <ø> (ø)
superset-frontend/src/utils/urlUtils.ts 45.94% <14.28%> (-7.39%) ⬇️
...board/components/nativeFilters/FilterBar/index.tsx 84.25% <42.85%> (-6.17%) ⬇️
.../components/Header/HeaderActionsDropdown/index.jsx 67.08% <50.00%> (ø)
...veFilters/FilterBar/FilterControls/FilterValue.tsx 65.68% <83.33%> (+0.38%) ⬆️
... and 6 more

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 f53b2c6...06c664d. Read the comment docs.

@villebro villebro changed the title Villebro/share native filters feat(native-filters): add support for preselect filters Jun 28, 2021
@@ -195,6 +197,10 @@ const FilterValue: React.FC<FilterProps> = ({
/>
);
}
const filterState = { ...filter.dataMask?.filterState };
if (filterState.value === undefined && preselection) {
filterState.value = preselection;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think in previous PR someone added regression for validation, but because your changes affect this place also, can you add here like:

const isMissingRequiredValue = checkIsMissingRequiredValue(
    filter,
    filter.dataMask?.filterState,
  );
...
filterState={{
            ...filter.dataMask?.filterState,
            validateMessage: isMissingRequiredValue && t('Value is required'),
          }}

or may be we can create separate PR for it

Copy link
Contributor

@simcha90 simcha90 left a comment

Choose a reason for hiding this comment

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

Checked locally, works ok

@villebro villebro merged commit 4630abb into apache:master Jun 29, 2021
@villebro villebro deleted the villebro/share-native-filters branch June 29, 2021 16:16
@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Jun 29, 2021
amitmiran137 pushed a commit that referenced this pull request Jul 4, 2021
* feat(native-filters): add support for sharing preselected filters

* abc

* add serialization

(cherry picked from commit 4630abb)
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* feat(native-filters): add support for sharing preselected filters

* abc

* add serialization
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* feat(native-filters): add support for sharing preselected filters

* abc

* add serialization
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* feat(native-filters): add support for sharing preselected filters

* abc

* add serialization
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.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 preset-io size/L v1.3 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for preselect_filters to the dashboard native filters
5 participants