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

Feature/update special filter UI and create any/none/fuzzy query params #238

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

aswallace
Copy link
Contributor

@aswallace aswallace commented Sep 13, 2024

Description

A Big Ticket! This PR includes:

  • UX updates to the special filter types (date, numerical range, search box with fuzzy search)
  • Logic for fuzzy searching (transferred over from Feature/enable optional fuzzy search #154 )
  • Logic for any/none filters (include/exclude query params)
    • Corresponding UI for this in annotation filter form

closes #53 , closes #74

TODO: fix font (#235 )

Testing

  • New & updated unit tests
  • Tested manually with an EC2 instance of FES (the local version has the fuzzy search changes, but hasn't been deployed) and staging version of Mongo.

Screenshots

EDIT: Updated screenshots 9/30/2024

Any/none option

The radio buttons are a little off center with Helvetica, but I think it will be fixed when we're using the correct Open Sans link
any value

no value

Search box with new fuzzy search toggle (exact/non-fuzzy by default)

fuzzy search

Date range with filter type choice group

date range modal

Numerical range with filter type choice group

numerical range modal

Copy link
Contributor

@BrianWhitneyAI BrianWhitneyAI left a comment

Choose a reason for hiding this comment

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

Nice! My biggest comments are on the similarity between the include/exclude/fuzzy filter logic that shows up in duplicate or triplicate frequently. Not sure if there is a way around it

packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
packages/core/components/QueryPart/QueryFilter.tsx Outdated Show resolved Hide resolved
packages/core/state/selection/actions.ts Outdated Show resolved Hide resolved
packages/core/state/selection/actions.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@SeanLeRoy SeanLeRoy left a comment

Choose a reason for hiding this comment

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

Pausing the merge of this PR to get feedback about the filter type division.

packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
packages/core/components/ChoiceGroup/index.tsx Outdated Show resolved Hide resolved
setSearchMaxValue("");
setSearchMinValue(overallMin);
setSearchMaxValue(overallMax);
onSearch(`RANGE(${overallMin},${overallMax})`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Debatable if this is in the scope of this PR but I think its odd we pass a string version of a range filter to the parent component rather than something like onSearch(min, max)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, although onSearch is a pre-existing function also used for searchboxes so would need some additional changes to accept other args. RANGE as a filter value in general could use refactoring, we have to do some additional processing in number-formatter and date-formatter as well

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the decision to make the ANY, EXCLUDE EVERYTHING, and FUZZY filters totally separate has made the state logic of other components much more complicated. I like the idea of each having their own class, but could they each have a "type" property that we could then use in the components to separate out the filters we need? I'm unsure what we gain by having them separated since we can create composed selectors to separate them out of the state branch if need by like:

const getAnnotationsFilteredOut = createSelector(getFileFilters, filters) => (
    filters
        .filter(filter => filter.type === FilterType.EXCLUDE)
        .map(filter => filter.annotationName)
))

const getAnnotationsRequired = createSelector(getFileFilters, filters) => (
    filters
        .filter(filter => filter.type === FilterType.ANY)
        .map(filter => filter.annotationName)
))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but would need to think about how we'd incorporate fuzzy filters into this, since a filter can be both a regular FileFilter with a value AND a fuzzy filter

Copy link
Contributor

Choose a reason for hiding this comment

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

That could be another type I think

@aswallace aswallace marked this pull request as draft September 24, 2024 22:54
@aswallace aswallace marked this pull request as ready for review September 30, 2024 17:27
@aswallace
Copy link
Contributor Author

aswallace commented Sep 30, 2024

CHANGES FROM PREVIOUS VERSION

Added a new optional type arg to filters in 181067e, so now filters can be exclude (null), any value, fuzzy, or default (regular filter) (open to changing the names of these). This allows us to get rid of a lot of the duplicate logic I had before, especially for redux and the AnnotationFilterForm component.

This means the FileExplorerUrl (our local BFF url parsing class) will NOT have the fuzzy/include/exclude params that I'd added in before, since now all filters are part of the filter param but with an extra type arg. However, the queries we send to FES do still need the new query params.

  • Because of this, I kept (but simplified) the FuzzyFilter, ExcludeFilter, and IncludeFilter subtypes, bc even though they don't add new logic, they're a helpful shorthand for creating those filters. Could be convinced that they are unnecessary

Also no longer includes the unrelated UX changes to the modals since was merged in #250

@aswallace aswallace removed the request for review from lynwilhelm September 30, 2024 17:43
Copy link

@kmitcham kmitcham left a comment

Choose a reason for hiding this comment

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

Seems to still be reasonable.

Copy link
Contributor

@SeanLeRoy SeanLeRoy left a comment

Choose a reason for hiding this comment

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

Looks great!! I'm psyched we were able to reduce some of the complexity from this. Make sure the backwards compatible comment I mentioned is true, but besides that LGTM

packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
dispatch(selection.actions.addFileFilter(createFileFilter(item)));
};

// TODO: Should this select ALL or just the visible items in list?
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 just visible items

packages/core/components/AnnotationFilterForm/index.tsx Outdated Show resolved Hide resolved
.map((parsedFilter) => new FileFilter(parsedFilter.name, parsedFilter.value)),
.map(
(parsedFilter) =>
new FileFilter(parsedFilter.name, parsedFilter.value, parsedFilter.type)
Copy link
Contributor

Choose a reason for hiding this comment

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

This works with type being undefined? Just triple checking that we aren't making links created before this PR unusable - our links have to always be backwards compatible now that we are tied to the EMT paper publication

Copy link
Contributor Author

@aswallace aswallace Oct 2, 2024

Choose a reason for hiding this comment

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

yep! I gave the parent class a default value. Many of our unit tests still use FileFilter(name, value) without a type, so the constructor provides it with FilterType.DEFAULT if no arg is given.

Added tests for this in d685394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants