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

Support toggling different filter states independently #6056

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

robertknight
Copy link
Member

@robertknight robertknight commented Jan 5, 2024

In order to support a UI like the one shown in #6006 (comment) it needs to be possible to toggle different filter modes independently. For example, if a teacher is grading an assignment with a page range specified, there will be filters for both the student being graded and the page range, and it should be possible to toggle them independently. This PR refactors the focusActive state in the filters store module to support this.

  • The first commit changes the focusActive state from a boolean to a set of enabled states and extends the toggleFocusMode store action API
  • The second commit revises the documentation for the filter states

There should be no functional changes , as the new capabilities are not used by the UI yet.

*/
export type FilterKey = 'cfi' | 'page' | 'user';
export type FilterKey = 'cfi' | 'pages' | 'user';

This comment was marked as outdated.

@robertknight robertknight force-pushed the multiple-filter-active-states branch 2 times, most recently from 22140e4 to 3414a52 Compare January 5, 2024 15:28
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (568a440) 99.44% compared to head (64624f1) 99.45%.
Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6056   +/-   ##
=======================================
  Coverage   99.44%   99.45%           
=======================================
  Files         265      265           
  Lines       10149    10195   +46     
  Branches     2459     2474   +15     
=======================================
+ Hits        10093    10139   +46     
  Misses         56       56           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robertknight robertknight marked this pull request as draft January 5, 2024 15:47
@robertknight
Copy link
Member Author

robertknight commented Jan 5, 2024

I need to check that the page => pages transition is handled correctly when the filters are actually applied.

Edit: Reverted this change and updated code comments to save the next guy from making the same mistake.

Store the focus filter activation state as a set of active filters (eg.
`{"user", "page"}`) instead of a boolean. This will allow the filters to be
toggled independently in future.

To support the existing UI where there is only a single toggle control,
`toggleFocusMode` retains the ability to toggle all configured filters.  Once
the new search UI is rolled out for everyone, we can probably remove this.
 - Try to better explain the context in which each of the filters is
   used

 - Re-organize the state fields so that user-applied filters are at the
   top, followed by the focus filter state
This unfortunately doesn't catch mistakes where incorrect property names are
used because TS allows excess properties, but it does at least document what the
expected keys are.
@robertknight robertknight force-pushed the multiple-filter-active-states branch from 6b749dc to 64624f1 Compare January 8, 2024 14:27
@robertknight robertknight marked this pull request as ready for review January 8, 2024 14:29
@robertknight robertknight requested a review from acelaya January 8, 2024 14:30
Copy link
Contributor

@acelaya acelaya left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

@robertknight robertknight merged commit 4da8b92 into main Jan 8, 2024
@robertknight robertknight deleted the multiple-filter-active-states branch January 8, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants