Skip to content

Conversation

@bastilian
Copy link
Member

@bastilian bastilian commented Nov 26, 2025

This updates the "Exposure report" modal to only allow selecting a minor version of the same major version already selected.

How to test:

  1. Open the "Report by operating system versions" "Create report" modal
  2. Select a RHEL version
  3. Verify only the selection of a minor version in the same major version is allowe
  4. Verify the report is still properly created

Summary by Sourcery

New Features:

  • Enforce a major-version constraint on OS version checkbox selections in the exposure report modal.

Summary by Sourcery

New Features:

  • Add validation to only allow selecting OS minor versions that share the major version of the currently selected OS version in the exposure report modal.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 26, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Limits OS minor-version selection in the Exposure Report modal to the same major version as any already-selected version, by adding a helper to validate allowed majors and wiring it into the checkbox disabling logic.

Flow diagram for checkbox disabling logic with major-version constraint

flowchart TD
  A[Render_minor_version_checkbox] --> B[Read_isSelected]
  B --> C[Compute_selectedTotal]
  C --> D[Check_isFetchLoading]
  D --> E{Is_checkbox_currently_selected?}
  E -->|Yes| F{Is_fetch_loading?}
  F -->|Yes| G[Disable_checkbox]
  F -->|No| H[Keep_checkbox_enabled]

  E -->|No| I{Has_user_selected_any_version?}
  I -->|No| J{Is_fetch_loading_or_selectedTotal_eq_5?}
  J -->|Yes| G
  J -->|No| H

  I -->|Yes| K[Determine_osMajorVersion_for_this_checkbox]
  K --> L[Call_isAllowedMajorVersion_with_osMajorVersion]
  L --> M{Is_major_version_allowed?}
  M -->|No| G
  M -->|Yes| N{Is_fetch_loading_or_selectedTotal_eq_5?}
  N -->|Yes| G
  N -->|No| H

  G:::disabled
  H:::enabled

  classDef disabled fill:#fdd,stroke:#d33,stroke-width:1px;
  classDef enabled fill:#dfd,stroke:#3a3,stroke-width:1px;
Loading

File-Level Changes

Change Details Files
Enforce that all selected OS minor versions share the same major version in the exposure report modal UI.
  • Add isAllowedMajorVersion helper that inspects the first selected OS version’s osMajorVersion and allows only matching majors, defaulting to allow when nothing is selected.
  • Extend the minor-version mapping to destructure osMajorVersion from each item so it can be used in selection logic.
  • Update checkbox disabling logic to disable options when a different major version is selected, while preserving existing limits based on max selection count and loading state.
src/Components/SmartComponents/Modals/OsExposureReportModal/OsExposureReportModal.js

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

@bastilian bastilian changed the title feat(ExposureReport): RHINENG-20238 - Only allow selecting of the sam… feat(ExposureReport): RHINENG-20238 - Only allow selecting of the same major version Nov 26, 2025
@bastilian bastilian marked this pull request as ready for review November 27, 2025 15:03
@bastilian bastilian requested a review from a team as a code owner November 27, 2025 15:03
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 isAllowedMajorVersion helper is quite hard to follow due to the Object.values(selectedOsVersions[0])[0][0]?.osMajorVersion access pattern; consider restructuring selectedOsVersions access (or precomputing a selectedMajorVersion with useMemo) so the function reads as a straightforward comparison against a clearly named value.
  • Instead of recomputing the allowed major version check inline for each checkbox, you could compute the currently selected major version once per render and pass a simple boolean comparison into the isDisabled expression to reduce repeated work and improve readability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `isAllowedMajorVersion` helper is quite hard to follow due to the `Object.values(selectedOsVersions[0])[0][0]?.osMajorVersion` access pattern; consider restructuring `selectedOsVersions` access (or precomputing a `selectedMajorVersion` with `useMemo`) so the function reads as a straightforward comparison against a clearly named value.
- Instead of recomputing the allowed major version check inline for each checkbox, you could compute the currently selected major version once per render and pass a simple boolean comparison into the `isDisabled` expression to reduce repeated work and improve readability.

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
Contributor

@LightOfHeaven1994 LightOfHeaven1994 left a comment

Choose a reason for hiding this comment

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

LGTM, pretty simple fix that works great!

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.64%. Comparing base (729d781) to head (d92e43f).
⚠️ Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
...als/OsExposureReportModal/OsExposureReportModal.js 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2435      +/-   ##
==========================================
- Coverage   52.72%   52.64%   -0.09%     
==========================================
  Files         166      167       +1     
  Lines        4681     4696      +15     
  Branches     1515     1463      -52     
==========================================
+ Hits         2468     2472       +4     
- Misses       1997     2224     +227     
+ Partials      216        0     -216     
Flag Coverage Δ
combined 52.64% <0.00%> (?)
cypress 35.90% <ø> (?)
jest 51.61% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@bastilian bastilian merged commit d55c012 into RedHatInsights:master Dec 3, 2025
8 checks passed
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.

3 participants