Skip to content

Conversation

hawkishpolicy
Copy link
Collaborator

Per Design Team request, this PR replaces the current Domain and IP filters used in the Findings Library with an Autocomplete based component that provides a list of Domain names and IP addresses based on user input.

🗣 Description

  • Added new /domains/search endpoint that accepts a search_term, search_field, region filters, and organization filters.
  • This returns the following:
    • an array of objects containing id and name if flagged with "name" search_field.
    • or an array of objects containing id and ip if flagged with "ip" search_field.
    • results are limited based on region and/or organization filters.
  • The results of this call are then broken into respective Domain Results and IP Results via filtering and mapping.
  • They are then filtered against existing filters to prevent redundant results.
  • A natural language sort is then applied.
  • From there they are rendered in the Autocomplete based component.
  • A checkbox controlled list is rendered below to allow the user to monitor applied filters and remove them if desired.

💭 Motivation and context

  • Closes CRASM-2704

🧪 Testing

  • tested locally.

✅ 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 relevant repo and/or project documentation has been updated to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.
  • Bump major, minor, patch, pre-release, and/or build versions as appropriate via the bump_version script if this repository is versioned and the changes in this PR warrant a version bump.
  • Create a pre-release (necessary if and only if the pre-release version was bumped).

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release (necessary if and only if the version was bumped).

Janson Bunce and others added 18 commits September 22, 2025 11:34
- Brought in filters, addFilter, and removeFilter from props.
- Updated useEffect to include regionFilterValues and orgFilterValues as dependencies.
- Updated searchDomainsAndIPs call to include regionFilterValues and orgFilterValues.
- Updated handleDomainChange to remove existing 'domain' filters before adding a new one.
- Needs testing but refactored endpoint appears to be working.
- Allows user to select/deselect domains to filter by.
- Extends current facet filter functionaility of filtering by multiple domains.
- a search_field prop to toggle between domain and IP search
- conditional rendering of Autocomplete options based on search_field
- conditional adding of filters based on search_field
- conditional rendering of checkbox controlled lists based on search_field
- need to separate state for domain and IP search terms, results, and selected values
  - this should eliminate duplicate calls related to the useEffect.
- Improved code readability and maintainability.
- Removed unused state variables and handlers.
- Ensured consistent state management for domain and IP filters.
- Prevent potential bugs related to state handling and duplicate api calls.
- began trouble shooting an issue where autocomplete was not closing properly.
  - this issue affects autocompletes throughout the app.
- Restored original Open logic for RegionAndOrganizationFilters and VSDashRegionAndOrgFilters components.
- This change is out of scope for the current task but is necessary to maintain existing functionality.
- Need to determine if the open logic should be custom or handled internally by MUI Autocomplete component.
  - I'm leaning towards the latter, as I'm not sure why we need custom state and logic for this.
- Cleaned up code.
- Cleaned up ResultsShallow type by making fields optional.
- Applied ResultsShallow type to domain search API calls.
  - This kept the codebase consistent and reduced potential errors.
  - Made applying domain name and IP data to rendered components cleaner and more reliable.
- Ensured Domain Results are based off of domain names via filter and mapping.
- Ensured IP Results are based off of IP addresses via filter and mapping.
- Added utility function to identify IP addresses in Domain results.
- Filtered out results that are already selected in filters.
- Implemented custom sorting logic for domain names and IP addresses.
  - Domain names are sorted alphabetically.
  - IP addresses are sorted numerically to ensure correct order (e.g., 192.168.1.1).
- Improved sorting logic for IP addresses to ensure numerical order.
- Increased Elasticsearch query size to 15 to ensure sufficient results.
- Removed unnecessary return statements in async functions.
- Removed console.log statements used for debugging.
- frontend/src/components/FilterDrawer/DrawerInterior.tsx
- removes the old commented-out TaggedArrayInput components for domain and IP filters.
- removes unused imports.
@hawkishpolicy hawkishpolicy marked this pull request as ready for review September 29, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants