console icon indicating copy to clipboard operation
console copied to clipboard

OCPBUGS-69387: update operator details when changing channels

Open rhamilto opened this issue 3 weeks ago • 13 comments

Summary

This PR refactors the operator details display to dynamically update when changing channels in the OperatorHub. Previously, operator details would remain static even when switching channels. Now, most operator metadata fields (see noted exclusions below) respond to channel selection changes.

Changes

New Hook Created

  • useCurrentChannel - Centralized hook that returns the currently selected channel based on URL query parameters, falling back to the default channel or first available channel. This hook eliminates code duplication across all operator detail components.

New Components Created

The following components were extracted to dynamically read from the selected channel (all use useCurrentChannel hook):

  • OperatorCapability - Displays capability level based on current channel
  • OperatorContainerImage - Shows container image from current channel
  • OperatorCreatedAt - Displays creation timestamp for current channel with improved date validation using Number.isNaN(Date.parse(...))
  • OperatorInfrastructureFeatures - Lists infrastructure features from current channel CSV
  • OperatorRepository - Shows repository link from current channel
  • OperatorSupport - Displays support information with marketplace workflow support
  • OperatorValidSubscriptions - Lists valid subscriptions from current channel

Hook Updates

  • useCurrentCSVDescription - Updated to use useSearchParams instead of deprecated getQueryArgument, and now accepts optional selectedChannel parameter

Refactoring in useOperatorCatalogItems

  • Replaced inline rendering of operator details with new dedicated components
  • Details now automatically update when the channel parameter changes
  • Removed unused imports (PlainList, Timestamp, ExternalLink, CapabilityLevel, getSupportWorkflowUrl)

Infrastructure Features Calculation

  • Infrastructure features are now computed dynamically using useMemo based on current channel's CSV annotations in both:
    • OperatorDescription component - for description section
    • OperatorHubItemDetails component - for details display
  • Removed infraFeatures prop from OperatorDescription component

Testing

  • Verify operator details update when changing channels in OperatorHub
  • Confirm all metadata fields (capability, container image, created date, etc.) reflect selected channel
  • Test with operators having multiple channels with different metadata
  • Verify date validation works correctly for invalid date strings

Note

  • source, provider, displayName, and keywords operator metadata fields were intentionally excluded from this fix since they are less likely to change when the channel changes.

🤖 Generated with Claude Code

rhamilto avatar Dec 16 '25 19:12 rhamilto

@rhamilto: This pull request references Jira Issue OCPBUGS-69387, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 16 '25 19:12 openshift-ci-robot

[!IMPORTANT]

Review skipped

Auto reviews are limited based on label configuration.

:no_entry_sign: Review skipped — only excluded labels are configured. (1)
  • do-not-merge/work-in-progress

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.

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

Walkthrough

Adds seven new operator-hub React components, a new useCurrentChannel hook, updates useCurrentCSVDescription to accept selectedChannel and use useSearchParams, and moves infrastructure-feature computation into OperatorDescription and OperatorHubItemDetails internals.

Changes

Cohort / File(s) Summary
New operator-hub components
frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-capability.tsx, frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-container-image.tsx, frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-created-at.tsx, frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-infrastructure-features.tsx, frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-repository.tsx, frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-support.tsx, frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-valid-subscriptions.tsx
Seven new exported React functional components. Each takes a packageManifest: PackageManifestKind, uses useCurrentChannel to read current CSV annotations, renders annotation-derived values (with fallbacks), and adds local prop types or exported prop types as noted. Some components call helpers (e.g., getInfrastructureFeatures, getValidSubscription, getSupportWorkflowUrl) and log onError.
New hook
frontend/packages/operator-lifecycle-manager/src/hooks/useCurrentChannel.tsx
New useCurrentChannel(packageManifest: PackageManifestKind) hook that reads channel from URL via useSearchParams, falls back to packageManifest defaults, and returns the matching channel object or undefined.
Hook signature update
frontend/packages/operator-lifecycle-manager/src/hooks/useCurrentCSVDescription.tsx
useCurrentCSVDescription signature changed to accept optional selectedChannel; URL query reading switched from getQueryArgument to useSearchParams; resolution order is selectedChannel → URL channel → package defaultChannel.
Operator item details refactor
frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-item-details.tsx
Removed infraFeatures from OperatorDescriptionProps and OperatorDescription props. Added getInfrastructureFeatures import and moved infra feature computation into OperatorDescription and OperatorHubItemDetails via useMemo, using cluster flags and onError logging.
Integration update
frontend/packages/operator-lifecycle-manager/src/hooks/useOperatorCatalogItems.tsx
Replaced inline UI usage with the seven new components (Capability, ContainerImage, CreatedAt, InfrastructureFeatures, Repository, Support, ValidSubscriptions). Removed passing infraFeatures downstream and updated item details/metadata wiring to use the new modular components.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay attention to URL resolution and precedence in useCurrentChannel and updated useCurrentCSVDescription.
  • Verify useMemo dependency arrays and onError logging in operator-hub-item-details.tsx.
  • Confirm new components consistently access annotations, handle undefined values, and export types/imports correctly.
  • Check useOperatorCatalogItems.tsx integration for remaining references to removed props and correct imports/exports.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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

coderabbitai[bot] avatar Dec 16 '25 19:12 coderabbitai[bot]

@coderabbitai review

rhamilto avatar Dec 16 '25 21:12 rhamilto

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Dec 16 '25 21:12 coderabbitai[bot]

/retest

rhamilto avatar Dec 16 '25 21:12 rhamilto

/cherrypick release-4.21

rhamilto avatar Dec 16 '25 21:12 rhamilto

@rhamilto: once the present PR merges, I will cherry-pick it on top of release-4.21 in a new PR and assign it to you.

In response to this:

/cherrypick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@rhamilto Other than de-duping some of the channel selection logic that we talked about, looks good! Let me know when you update and I can give it the final lgtm tag.

Done. And I think Claude, CodeRabbit, and I are all in agreement now. ;-)

rhamilto avatar Dec 16 '25 21:12 rhamilto

/label acknowledge-critical-fixes-only

rhamilto avatar Dec 17 '25 13:12 rhamilto

/jira refresh

rhamilto avatar Dec 17 '25 13:12 rhamilto

@rhamilto: This pull request references Jira Issue OCPBUGS-69387, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact: /cc @XiyunZhao

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 17 '25 13:12 openshift-ci-robot

@XiyunZhao, can you please verify? /test okd-scos-images

rhamilto avatar Dec 18 '25 13:12 rhamilto

/retest

rhamilto avatar Dec 19 '25 15:12 rhamilto

/lgtm

sg00dwin avatar Dec 22 '25 18:12 sg00dwin

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto, sg00dwin, TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openshift-ci[bot] avatar Dec 22 '25 18:12 openshift-ci[bot]

/retest

rhamilto avatar Dec 23 '25 01:12 rhamilto

/test okd-scos-images

rhamilto avatar Dec 23 '25 13:12 rhamilto

/test okd-scos-images

rhamilto avatar Dec 23 '25 13:12 rhamilto

/test okd-scos-images

rhamilto avatar Dec 23 '25 19:12 rhamilto

@rhamilto: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-images 120b7fb0fa41e865393df9f522c84bc99b901949 link true /test okd-scos-images

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

openshift-ci[bot] avatar Dec 23 '25 20:12 openshift-ci[bot]