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: use rison for list view filters stateful urls #11675

Merged
merged 15 commits into from
Nov 24, 2020

Conversation

riahk
Copy link
Contributor

@riahk riahk commented Nov 12, 2020

SUMMARY

  • For ListView logic filter logic, update URL filters param to use a rison format
  • Clean up filters to only include filters set to non-default values and rm irrelevant data
  • Update Filters UI component to properly populate selected dropdown filter (for non-async filter options)
  • Add viewMode URL param

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2020-11-13 at 12 41 00 PM

Screen Shot 2020-11-13 at 12 41 39 PM

TEST PLAN

  • Fix tests broken by update of use-query-params lib
  • Update the styledMount/styledShallow helper functions to include Router and QueryParamProvider

ADDITIONAL INFORMATION

@nytai
Copy link
Member

nytai commented Nov 12, 2020

I'm confused, what in this change is actually making these filters "sticky"?

@codecov-io
Copy link

codecov-io commented Nov 12, 2020

Codecov Report

Merging #11675 (f6a653e) into master (86651cd) will increase coverage by 0.50%.
The diff coverage is 94.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11675      +/-   ##
==========================================
+ Coverage   62.86%   63.36%   +0.50%     
==========================================
  Files         889      905      +16     
  Lines       43055    43891     +836     
  Branches     4015     4216     +201     
==========================================
+ Hits        27066    27811     +745     
- Misses      15811    15901      +90     
- Partials      178      179       +1     
Flag Coverage Δ
javascript 62.90% <94.33%> (+0.07%) ⬆️
python 63.63% <ø> (+0.75%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/views/App.tsx 0.00% <ø> (ø)
superset-frontend/src/components/ListView/utils.ts 80.86% <92.68%> (+4.32%) ⬆️
...erset-frontend/src/components/ListView/Filters.tsx 90.00% <100.00%> (+0.76%) ⬆️
...rset-frontend/src/components/ListView/ListView.tsx 95.91% <100.00%> (-0.09%) ⬇️
...t-frontend/src/views/CRUD/data/query/QueryList.tsx 72.38% <0.00%> (-3.18%) ⬇️
superset/dashboards/commands/export.py 91.17% <0.00%> (-2.77%) ⬇️
...d/src/dashboard/components/FiltersBadge/Styles.tsx 28.94% <0.00%> (-1.61%) ⬇️
superset/datasets/api.py 91.66% <0.00%> (-1.20%) ⬇️
...ntend/src/views/CRUD/annotation/AnnotationList.tsx 76.92% <0.00%> (-1.10%) ⬇️
...end/src/components/Select/SupersetStyledSelect.tsx 87.91% <0.00%> (-0.98%) ⬇️
... and 54 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 86651cd...f6a653e. Read the comment docs.

@riahk
Copy link
Contributor Author

riahk commented Nov 13, 2020

@nytai might need to use a different name, I think the original understanding of this feature is different from the actual implementation! I'm going based on the associated issue title. It's more a re-working of the formatting and fixing some UI bugs.

@nytai
Copy link
Member

nytai commented Nov 13, 2020

@riahk I figured as much. Do you think we could rename that ticket, or at the very least this PR, to something like refactor(list views): clean up query params state or something similar. I'm worried if we ever do decide to implement "sticky" filters, stumbling on this commit/PR could cause some confusion.

@mistercrunch mistercrunch changed the title feat: list view sticky filters feat: use rison for list view filters stateful urls Nov 13, 2020
@@ -78,6 +82,23 @@ export function convertFilters(fts: InternalFilter[]): FilterValue[] {
.map(({ value, operator, id }) => ({ value, operator, id }));
}

// convertFilters but to handle new decoded rison format
export function convertFiltersRison(filterObj: any): FilterValue[] {
Copy link
Member

@mistercrunch mistercrunch Nov 13, 2020

Choose a reason for hiding this comment

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

I noticed before that all unselected filters muddy the urls, can we filter out where value === undefined?

Also did we consider going with a better/simpler data structure? maybe

{
   user: ['==', 'mistercrunch'],
   dataset: ['==', 'some_dataset'],
}

(dataset:!(==,some_dataset),user:!(==,mistercrunch))

OR

[
   ["user", "==", "mistercrunch"],
   ["dataset", "!=", "some_dataset"]
]

!(!(user,==,mistercrunch),!(dataset,'!!=',some_dataset))

You can play with structures and see resulting URLs here https://rison.io/

Copy link
Member

@mistercrunch mistercrunch Nov 13, 2020

Choose a reason for hiding this comment

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

I think the operators names were long too, and using things like == != IN would make for nicer/shorter URLs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this update should only put non-default filters in the URL for a much cleaner experience. I'll add some screenshots that show the URL params next to the selected filters. Also want to remove the operators but I'm working through a weird bug around that atm.

Copy link
Member

@nytai nytai left a comment

Choose a reason for hiding this comment

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

Looking good, just a couple suggestions

superset-frontend/src/components/ListView/ListView.tsx Outdated Show resolved Hide resolved
@@ -63,11 +68,11 @@ function updateInList(list: any[], index: number, update: any): any[] {
];
}

function mergeCreateFilterValues(list: Filter[], updateList: FilterValue[]) {
function mergeCreateFilterValues(list: Filter[], updateObj: any) {
Copy link
Member

Choose a reason for hiding this comment

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

can we type the query filters object? something like

type QueryFilterState = {
  [id: string]: [value: FilterValue["value"], operator: FilterValue["value"]]
}

Copy link
Member

Choose a reason for hiding this comment

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

I'm also going to be modifying this file in #11702 so I'll make this change when I rebase after this is merged.

@riahk riahk requested a review from nytai November 20, 2020 17:56
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';

// Wrapper component for mounting TODO: move to util file
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to address this TODO before merge?

Copy link
Member

Choose a reason for hiding this comment

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

This appears to be a util file, I think this comment just needs to be removed

@nytai nytai merged commit 6019113 into apache:master Nov 24, 2020
@nytai nytai deleted the moriah/sticky-filters branch November 24, 2020 19:19
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.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 size/L 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants