Skip to content

Conversation

carlosthe19916
Copy link
Contributor

@carlosthe19916 carlosthe19916 commented Aug 14, 2025

Fixes: #393, #394, https://issues.redhat.com/browse/TC-2393, and https://issues.redhat.com/browse/TC-2402

  • This PR creates a new FilterType date.
  • All current filters using "dateRange" are being replaced by "date". This way we avoid all issues described in the JIRAs and Github issues linked above.

The image below is an example of how the date filter is visulized:
image

Summary by Sourcery

Add a new date filter type and migrate all dateRange filters to separate before/after date filters across multiple list contexts, updating the UI components and request parameter handling to fix related issues

New Features:

  • Introduce a new 'date' filter type with dedicated DateFilter components for toolbar and panel

Bug Fixes:

  • Replace all existing dateRange filters with before/after date filters to resolve related Github and JIRA issues

Enhancements:

  • Update advisory, SBOM, and vulnerability search contexts to use separate 'before' and 'after' date filters
  • Adjust filter request parameter logic to handle 'date' filters correctly

Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
Copy link

sourcery-ai bot commented Aug 14, 2025

Reviewer's Guide

Introduce a new "date" filter type and replace all existing dateRange filters with separate before/after date filters across list contexts, update request parameter handling to support the new filter type, and add dedicated DateFilter components and rendering logic.

Sequence diagram for applying a date filter in the filter toolbar

sequenceDiagram
    participant User as actor User
    participant FilterToolbar
    participant DateFilter
    participant getFilterHubRequestParams
    User->>FilterToolbar: Selects a date filter
    FilterToolbar->>DateFilter: Renders DatePicker
    User->>DateFilter: Picks a date
    DateFilter->>FilterToolbar: Updates filter value
    FilterToolbar->>getFilterHubRequestParams: Prepares request params with date filter
    getFilterHubRequestParams->>FilterToolbar: Returns updated params
Loading

Class diagram for new and updated filter components

classDiagram
    class FilterType {
        <<enum>>
        multiselect
        search
        numsearch
        date
        dateRange
        autocompleteLabel
    }
    class DateFilter {
        +category
        +filterValue
        +setFilterValue
        +showToolbarItem
        +isDisabled
        +onDateChange()
    }
    class DateRangeFilter {
        +category
        +filterValue
        +setFilterValue
        +showToolbarItem
        +isDisabled
        +onDateChange()
    }
    FilterType <|-- DateFilter
    FilterType <|-- DateRangeFilter
    class FilterControl {
        +category
        +props
        +render()
    }
    FilterControl --> DateFilter : uses
    FilterControl --> DateRangeFilter : uses
Loading

Class diagram for updated filter context interfaces

classDiagram
    class IAdvisorySearchContext {
        +modifiedBefore
        +modifiedAfter
    }
    class ISbomSearchContext {
        +publishedBefore
        +publishedAfter
    }
    class IVulnerabilitySearchContext {
        +publishedBefore
        +publishedAfter
    }
    IAdvisorySearchContext o-- FilterType
    ISbomSearchContext o-- FilterType
    IVulnerabilitySearchContext o-- FilterType
Loading

File-Level Changes

Change Details Files
Add a new FilterType "date" and wire up rendering for date filters
  • Extend the FilterType enum with "date"
  • Add conditional rendering of DateFilter for type date in both toolbar and panel FilterControl components
client/src/app/components/FilterToolbar/FilterToolbar.tsx
client/src/app/components/FilterControl.tsx
client/src/app/components/FilterPanel/FilterControl.tsx
Replace dateRange filters with separate before/after date filters in list contexts
  • Split each dateRange filter into two filters (before and after) with serverFilterField and operator
  • Update categoryKey and title for revised/created before and after filters in advisory, SBOM, and vulnerability contexts
client/src/app/pages/advisory-list/advisory-context.tsx
client/src/app/pages/sbom-list/sbom-context.tsx
client/src/app/pages/vulnerability-list/vulnerability-context.tsx
Update search tabs filter props to use the new date filters
  • Adjust generic filter key unions to include publishedBefore/publishedAfter and modifiedBefore/modifiedAfter
client/src/app/pages/search/components/SearchTabs.tsx
Enhance filter parameter builder to handle date filters
  • Modify existing merge logic to key off both field and operator
  • Insert logic to parse American dates and push ISO-formatted date filters for type date
client/src/app/hooks/table-controls/filtering/getFilterHubRequestParams.ts
Create DateFilter components for toolbar and panel views
  • Implement DateFilter with PatternFly DatePicker, formatting, validation, and state syncing
  • Add parsing and formatting utilities (americanDateFormat, parseAmericanDate, isValidAmericanShortDate)
client/src/app/components/FilterToolbar/DateFilter.tsx
client/src/app/components/FilterPanel/DateFilter.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The two DateFilter implementations in FilterToolbar and FilterPanel are nearly identical—consider consolidating them into a single reusable component to reduce duplication and ensure consistency.
  • The date parsing/formatting utilities are duplicated under both FilterToolbar and FilterPanel—extract them into a shared module to avoid code duplication and divergence.
  • In getFilterHubRequestParams, add a return or else branch after handling FilterType.date to prevent falling through and unintentionally processing the dateRange logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The two DateFilter implementations in FilterToolbar and FilterPanel are nearly identical—consider consolidating them into a single reusable component to reduce duplication and ensure consistency.
- The date parsing/formatting utilities are duplicated under both FilterToolbar and FilterPanel—extract them into a shared module to avoid code duplication and divergence.
- In getFilterHubRequestParams, add a return or else branch after handling FilterType.date to prevent falling through and unintentionally processing the dateRange logic.

## Individual Comments

### Comment 1
<location> `client/src/app/hooks/table-controls/filtering/getFilterHubRequestParams.ts:146` </location>
<code_context>
           },
         });
       }
+      if (filterCategory.type === "date") {
+        const date = parseAmericanDate(serverFilterValue[0]);
+        pushOrMergeFilter(filters, {
+          field: serverFilterField,
+          operator: filterCategory.operator ?? "=",
</code_context>

<issue_to_address>
Date filter assumes serverFilterValue[0] is always present and valid.

Add a check to ensure serverFilterValue[0] exists and is a valid date before calling parseAmericanDate to prevent downstream errors.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 39.13043% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.95%. Comparing base (888b0d3) to head (e84f150).

Files with missing lines Patch % Lines
...nt/src/app/components/FilterToolbar/DateFilter.tsx 35.00% 10 Missing and 3 partials ⚠️
...ient/src/app/components/FilterPanel/DateFilter.tsx 37.50% 8 Missing and 2 partials ⚠️
...le-controls/filtering/getFilterHubRequestParams.ts 0.00% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #655      +/-   ##
==========================================
- Coverage   57.28%   55.95%   -1.33%     
==========================================
  Files         146      148       +2     
  Lines        2430     2475      +45     
  Branches      552      565      +13     
==========================================
- Hits         1392     1385       -7     
- Misses        833      884      +51     
- Partials      205      206       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carlosthe19916 carlosthe19916 linked an issue Aug 14, 2025 that may be closed by this pull request
@carlosthe19916 carlosthe19916 changed the title 🌱 add date filter and replace dateRange ✨ : add date filter and replace dateRange Aug 14, 2025
@carlosthe19916 carlosthe19916 changed the title ✨ : add date filter and replace dateRange ✨ add date filter and replace dateRange Aug 14, 2025
@carlosthe19916 carlosthe19916 requested a review from gildub August 14, 2025 12:03
@carlosthe19916 carlosthe19916 added the needs-backport Indicates a PR needs to be backported label Aug 18, 2025
@carlosthe19916 carlosthe19916 changed the title ✨ add date filter and replace dateRange ✨ Add date filter and replace dateRange Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-backport Indicates a PR needs to be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search SBOM - Created on-from filter field behave erratically Search SBOMs - Created on filter needs both dates filled
1 participant