OCPBUGS-69387: update operator details when changing channels
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
useSearchParamsinstead of deprecatedgetQueryArgument, and now accepts optionalselectedChannelparameter
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
useMemobased on current channel's CSV annotations in both:OperatorDescriptioncomponent - for description sectionOperatorHubItemDetailscomponent - for details display
- Removed
infraFeaturesprop fromOperatorDescriptioncomponent
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, andkeywordsoperator metadata fields were intentionally excluded from this fix since they are less likely to change when the channel changes.
🤖 Generated with Claude Code
@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.
[!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.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein 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
useCurrentChanneland updateduseCurrentCSVDescription. - Verify
useMemodependency arrays and onError logging inoperator-hub-item-details.tsx. - Confirm new components consistently access annotations, handle undefined values, and export types/imports correctly.
- Check
useOperatorCatalogItems.tsxintegration 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 review
✅ 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.
/retest
/cherrypick release-4.21
@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. ;-)
/label acknowledge-critical-fixes-only
/jira refresh
@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.
@XiyunZhao, can you please verify? /test okd-scos-images
/retest
/lgtm
[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
- ~~frontend/OWNERS~~ [TheRealJon,rhamilto]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/retest
/test okd-scos-images
/test okd-scos-images
/test okd-scos-images
@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.