Skip to content

ROX-34990: Add Between date range condition to date filter input#21051

Open
sachaudh wants to merge 9 commits into
ROX-34989-date-range-filter-utilsfrom
ROX-34990-date-range-between-condition
Open

ROX-34990: Add Between date range condition to date filter input#21051
sachaudh wants to merge 9 commits into
ROX-34989-date-range-filter-utilsfrom
ROX-34990-date-range-between-condition

Conversation

@sachaudh

@sachaudh sachaudh commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

Jira: ROX-34990

This is the next slice of the VM 2.0 date range filtering work (ROX-28073), stacked on top of #21050 which added the range serialization utils. Right now the date filter input only supports single-date conditions ("Before", "On", "After"), so there's no way to scope results to a window of time. This PR adds a "Between" condition that lets users pick a start and end date.

  • Added a "Between" option to the date condition selector, rendered after the existing "Before"/"On"/"After" options
  • Selecting "Between" swaps the single date picker for start and end date pickers, following the PatternFly date range pattern: the end picker stays disabled until the start date is valid, then defaults to the day after the start date
  • Added inline validation so the end date can't be before the start date, with an error message and no search emitted on apply
  • Applying a valid range serializes it as tr/<startMs>-<endMs> (start of day to end of day) using serializeAbsoluteDateRange from ROX-34989: Add date range serialization and chip formatting utils #21050
  • The single-date and range inputs are split into SearchFilterDateSingle and SearchFilterDateRange body components, each owning its own state and validation, with shared date parsing helpers in utils/dateInput.ts
  • The Between condition is opted in per attribute via typed inputProps (DatePickerSearchFilterAttribute with enableBetweenCondition, following the existing condition-text precedent), so the generic CompoundSearchFilter library stays feature-flag-free
  • The ROX_VULN_MGMT_DATE_RANGE_FILTER flag is applied in the vulnerability layer: AdvancedFiltersToolbar maps its config through enableDateRangeConditions when the flag is on. This scopes Between to vulnerability list views only; other surfaces that reuse the same date-picker attributes (Violations, Clusters, Policies) and the Image Vulnerability Report wizard keep Before/On/After. With the flag off, the condition selector is unchanged everywhere
  • Added a new component test spec for SearchFilterConditionDate and extended the CompoundSearchFilter spec with config-driven tests covering attributes with and without the Between opt-in

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added component tests
  • added unit tests
  • modified existing tests

How I validated my change

  • Ran the two affected Cypress component specs: all 23 tests pass (9 in the new SearchFilterConditionDate.cy.jsx, 14 in CompoundSearchFilter.cy.jsx, including the 2 config-driven Between opt-in tests)
  • Added a unit test for the enableDateRangeConditions mapper (3 tests: enables Between on date-picker attributes only, returns copies, never mutates the shared attribute constants)
  • Lint and type checks pass on the changed files
  • To see it in the UI: enable ROX_VULN_MGMT_DATE_RANGE_FILTER, go to a vulnerability page with a date filter attribute (for example Vulnerability Management CVEs with "Discovered time"), open the condition selector, and pick "Between". Pick a start date, confirm the end date defaults to the next day, apply, and check that the filter chip shows the range. With the flag off, the selector should only show "Before"/"On"/"After". Non-vulnerability pages with date filters (for example Violations) should never show "Between", flag on or off

Screenshots / Screen recordings

Click on "Between" to show two date pickers. The second is disabled until the first is selected.

Screenshot 2026-06-09 at 9 58 36 PM

When the first is selected, you can choose any date from that date forward. Days before the start date are disabled.

Screenshot 2026-06-09 at 9 58 46 PM

When you click on the "Submit" button, the chip/label will show up with human-readable text.

Screenshot 2026-06-09 at 9 58 57 PM

Screen Recording of the flow

Screen.Recording.2026-06-09.at.9.57.11.PM.mov

sachaudh added 2 commits June 9, 2026 21:32
Users could only filter VM 2.0 results by a single date (Before/On/After).
Add an opt-in Between condition to SearchFilterConditionDate that reveals
two date pickers wired per the PatternFly date-range pattern: the end
picker stays disabled until the start date is valid, defaults to the day
after the start date, highlights the range via rangeStart, and rejects an
end date before the start date with an inline validator. Applying emits
the backend time-range format tr/<startMs>-<endMs> via
serializeAbsoluteDateRange instead of the single-date prefix format.

The condition is hidden behind the isBetweenEnabled prop (default false)
so behavior is unchanged until the feature flag wiring passes it in, and
the Before/On/After branches are untouched. Component test covers the
prop gating, range apply, same-day range, validator, and single-date
regression.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
Read ROX_VULN_MGMT_DATE_RANGE_FILTER once in the date-picker dispatcher
and pass isBetweenEnabled down, so the Between condition appears on every
date-picker attribute when the flag is on and behavior is byte-identical
to today when it is off. The flag is read in
CompoundSearchFilterInputField rather than the leaf input so the leaf
stays a pure presentational component that is testable without context.

Wrap the CompoundSearchFilter component test in a mock
FeatureFlagsContext provider (pattern from
ImageComponentVulnerabilitiesTable.cy.jsx) because the dispatcher now
requires the context, and cover both flag states.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
@openshift-ci

openshift-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 1b27d588-0c2e-4b8f-8ef8-9501069166ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ROX-34990-date-range-between-condition

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🚀 Build Images Ready

Images are ready for commit c971372. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.12.x-139-gc971372587

sachaudh added 3 commits June 10, 2026 08:51
The dispatcher-level feature-flag check coupled the generic
CompoundSearchFilter library to a VM-specific flag and enabled the new
Between condition on non-VM surfaces (Violations, Clusters, Policies)
that the spec marks out of scope. Replace it with a typed
DatePickerSearchFilterAttribute carrying optional
inputProps.enableBetweenCondition, following the condition-text
precedent, so each surface opts in per attribute and the library
carries no feature-flag knowledge. Component tests no longer need a
mock FeatureFlagsContext.

Between is temporarily unreachable in the product UI until the VM
layer applies the opt-in behind the flag (follow-up commit).

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
SearchFilterConditionDate had grown to four state variables, a
branching apply handler, and duplicated DatePicker blocks to serve
two distinct input shapes. Splitting the bodies into
SearchFilterDateSingle and SearchFilterDateRange gives each input
shape its own state, validation, and apply handler, so the parent
only owns the condition selection. This keeps the upcoming
relative-age work (ROX-28073 stretch) from growing the same
component further.

Shared date parsing and formatting helpers move to utils/dateInput
so both bodies use identical strict MM/DD/YYYY handling. Behavior
and aria-labels are unchanged; both Cypress component specs pass
without selector changes.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
Apply the Between opt-in in AdvancedFiltersToolbar behind
ROX_VULN_MGMT_DATE_RANGE_FILTER instead of inside the generic
CompoundSearchFilter library. The previous dispatcher-level flag
check leaked the new condition onto every surface with a
date-picker attribute (Violations, Clusters, Policies), which the
spec scopes out and whose time-range query handling is untested.

The enableDateRangeConditions mapper spread-copies entities and
date-picker attributes because the attribute objects are shared
module constants that other surfaces render directly. The Image
Vulnerability Report wizard intentionally keeps Before/On/After
only; its toolbar does not pass through this mapper.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
sachaudh added 4 commits June 10, 2026 17:04
Editing the start date previously clobbered an end date the user had
already picked, resetting it to the day after the new start (or clearing
it while the start was mid-edit). Only default the end date when it is
empty or would fall before the new start, so corrections to the start
date no longer discard the user's selection.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
enableDateRangeConditions deliberately spreads existing inputProps so
date-picker attributes can gain other props later; the strict toEqual
assertion would start failing as soon as one does.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
The memo keyed on a prop that callers recreate on every render, so it
never avoided recomputation; the config mapping is cheap enough to run
inline.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
The length guard in dateParse already requires exactly 2/2/4 digit
segments, so the padStart calls were dead code that suggested padding
could happen. Use the literal 'On' for the default date condition so
it is type-checked against DateCondition instead of depending on key
order in dateConditionMap.

Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
@sachaudh sachaudh marked this pull request as ready for review June 11, 2026 00:28
@sachaudh sachaudh requested a review from a team as a code owner June 11, 2026 00:28
@sachaudh sachaudh requested a review from dvail June 11, 2026 00:28
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.

1 participant