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

543 Refactor of Saved Search Accordion #561

Merged
merged 30 commits into from
Sep 5, 2024

Conversation

hawkishpolicy
Copy link
Collaborator

Refactored the Saved Searches Accordion to better match the recently improved Side Drawer.

🗣 Description

  • Removed the old MUI Data Grid based table.
  • Saved Searches are now displayed via a series of Radio button controlled list items.
  • The user can now toggle the active status of the Saved Search.
  • Updated the Save Search button to a MUI button.
  • Provided a name check to prevent the User from saving duplicate named searches.
  • Provided a filter check to prevent User from saving a search with no advanced filters.
  • Removed fetchSearch call, savedSearch state, and savedSearchCount state from Dashboard.
  • These items are now in their own context.
  • Extended context to Drawer Interior and Dashboard.

💭 Motivation and context

🧪 Testing

📷 Screenshots (if appropriate)

Screenshot 2024-08-15 at 10 38 25 AM
Screenshot 2024-08-23 at 5 14 15 PM
Screenshot 2024-08-23 at 4 55 29 PM
Screenshot 2024-08-23 at 5 15 16 PM

Screenshot 2024-08-23 at 5 14 34 PM

Screenshot 2024-08-23 at 4 55 29 PM
Screenshot 2024-08-23 at 4 55 35 PM

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced
    in code comments.
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release.

hawkishpolicy and others added 16 commits August 15, 2024 11:57
…r-crasm-545' into 543-refactor-of-saved-search-accordion
- Started working on functions to handle Saved Searches via the checkbox controlled list in the DrawerInterior component.
- Removed useHistory hook from DrawerInterior.tsx
- Removed unnecessary imports from DrawerInterior.tsx
- Removed history.push to '/Inventory' as search is only inside of Inventory now.
- Toggling of saved search Checkbox now handled by toggleSavedSearch function in DrawerInterior.tsx.
- filtering by  Saved Search handled by displaySavedSearch function in DrawerInterior.tsx.
- Restroing search to default handled by revertSearch function in DrawerInterior.tsx.
…r-crasm-545' into 543-refactor-of-saved-search-accordion
- Created a state based prop for initial filters in Layout.tsx
- Passed this prop to FilterDrawerV2.tsx and DrawerInterior.tsx
- Created new function restoreInitialFilters that iterates over the initial filters and adds them to the filter context.
- revertSearch clears filters and searchTerm then applies restoreInitialFilters.
- displaySavedSearch nows clear filters then applies filter from the saved search object.
- cleaned up code.
- Remove 'savedSearch' from localStorage on revertSearch.
- Built isSavedSearchActive function to check if a saved search is active.
- Edited toggleSavedSearch to use isSavedSearchActive.
- Checked prop is now based on isSavedSearchActive.
- switched prototype method from .find to .filter in toggleSavedSearch
- refactored isSavedSearchActive to parse 'savedSearch' id from localStorage and compare to id passed in from checkbox.
- Switched the 'Save Search' button from standard button to MUI button.
- Removed button styling from sortBarStyle.ts in favor of default MUI styling.
- Created new SavedSearchContext.
- Created new SavedSearchContextProvider.
- Moved fetchSearches to SavedSearchContextProvider.
- savedSearches and setSavedSearches are now in SavedSearchContext.
- savedSearchCount and setSavedSearchCount are now in SavedSearchContext.
- removed old fetchSearches from DrawerInterior.
- removed old savedSearches and savedSearchCount state from DrawerInterior.
- Imported savedSearches from SavedSearchContext.
- Added check in onChange that triggers alert and return if target value is equal to any savedSearch.name
- Deleted original code and imports.
- Refactored Saved Search Layout.
- Added ternary operator to check if there are saved searches.
@hawkishpolicy hawkishpolicy self-assigned this Aug 24, 2024
@hawkishpolicy hawkishpolicy linked an issue Aug 24, 2024 that may be closed by this pull request
5 tasks
Janson Bunce and others added 3 commits August 25, 2024 22:29
- Removed Alert for duplicate saved search name.
- Added a to-do to reference a need for btter validation inside a new MUI dialog.
- Commented out savedSearchContext as it may be needed for validation.
ameliav

This comment was marked as resolved.

Copy link
Contributor

@ameliav ameliav left a comment

Choose a reason for hiding this comment

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

LGTM

@ameliav ameliav requested a review from chrtorres August 30, 2024 18:15
@schmelz21 schmelz21 merged commit 0f5be32 into develop Sep 5, 2024
11 of 15 checks passed
@schmelz21 schmelz21 deleted the 543-refactor-of-saved-search-accordion branch September 5, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor of Saved Search Accordion
4 participants