Skip to content

Conversation

@chris1984
Copy link
Member

@chris1984 chris1984 commented Sep 19, 2025

What are the changes introduced in this pull request?

  • Remove the dependency on host-specific response data

  • This approach is consistent with how other components in the codebase handle this configuration and ensures that all hosts (with or without insights_facet) properly determine which advisor engine to display based on the global system settings.

  • Now the Insights/Recommendations tab will be hidden if either:

    • The host is not a RHEL host (existing logic), OR
    • The host doesn't have an insights_facet (new logic)
  • This means that for a host to show the Recommendations tab, it must be:

    • A RHEL host (Red Hat Enterprise Linux), AND
    • Have an insights_facet (indicated by the presence of insights_attributes in the response)

Considerations taken when implementing this change?

  • Made sure it still works on non-iop systems

What are the testing steps for this pull request?

  • Setup a devel box with IOP
  • Click on the devel box hostname since that should not have a subscription/insights_facet and see that it pulls up the non-iop recommendations page
Screenshot 2025-09-19 at 14-53-42 ip-10-0-168-128 rhos-01 prod psi rdu2 redhat com
  • Check out PR
  • Clear your browser cache
  • Visit the same host and see we have don't have a recommendations page

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR refactors the InsightsTab component to derive advisor engine selection from a global hook instead of host-specific response data, adds a strict Boolean check for clarity, and removes unused PropTypes and defaultProps for cleaner code.

File-Level Changes

Change Details Files
Refactor advisor engine detection to use global hook
  • Replace response.insights_attributes.use_iop_mode lookup with useAdvisorEngineConfig()
  • Remove inline eslint-disable comment for camelcase
webpack/InsightsHostDetailsTab/NewHostDetailsTab.js
Enforce strict Boolean evaluation
  • Update rendering condition to isLocalAdvisorEngine === true
webpack/InsightsHostDetailsTab/NewHostDetailsTab.js
Clean up PropTypes and defaultProps
  • Remove response PropTypes definition
  • Clear defaultProps object
webpack/InsightsHostDetailsTab/NewHostDetailsTab.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

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:

  • You can remove the empty propTypes and defaultProps declarations entirely since this component no longer accepts any props.
  • Consider renaming isLocalAdvisorEngine to something like isIopModeEnabled to better reflect that it’s driven by your useAdvisorEngineConfig hook.
  • Double-check that useAdvisorEngineConfig always returns a strict boolean so you don’t need the === true check (or provide a default value of false inside the hook).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You can remove the empty propTypes and defaultProps declarations entirely since this component no longer accepts any props.
- Consider renaming `isLocalAdvisorEngine` to something like `isIopModeEnabled` to better reflect that it’s driven by your `useAdvisorEngineConfig` hook.
- Double-check that `useAdvisorEngineConfig` always returns a strict boolean so you don’t need the `=== true` check (or provide a default value of false inside the hook).

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.

@jeremylenz
Copy link
Collaborator

  • Consider renaming isLocalAdvisorEngine to something like isIopModeEnabled to better reflect that it’s driven by your useAdvisorEngineConfig hook.

Not in the scope of this PR, but I've been wanting to do this. It's no longer just "advisor," so we should call it useIopConfig and isIop or some such.

@chris1984
Copy link
Member Author

chris1984 commented Sep 23, 2025

  • Consider renaming isLocalAdvisorEngine to something like isIopModeEnabled to better reflect that it’s driven by your useAdvisorEngineConfig hook.

Not in the scope of this PR, but I've been wanting to do this. It's no longer just "advisor," so we should call it useIopConfig and isIop or some such.

Changed the names, let me know what you think? Also updated the changes you and AI wanted.

Copy link
Collaborator

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

This works, but thinking about it more ..

  • I don't think an unregistered host will ever have recommendations.
  • For Vulnerabilities, we just don't show the tab at all.

I think we should just not show the tab at all for unregistered hosts. Thoughts?

@chris1984 chris1984 force-pushed the iop-recommendation branch 2 times, most recently from f89919a to 51992db Compare September 24, 2025 01:10
@chris1984
Copy link
Member Author

chris1984 commented Sep 24, 2025

This works, but thinking about it more ..

  • I don't think an unregistered host will ever have recommendations.
  • For Vulnerabilities, we just don't show the tab at all.

I think we should just not show the tab at all for unregistered hosts. Thoughts?

Makes sense, updated the pr to:
Now the Insights/Recommendations tab will be hidden if either:

The host is not a RHEL host (existing logic), OR
The host doesn't have an insights_facet (new logic)

This means that for a host to show the Recommendations tab, it must be:

A RHEL host (Red Hat Enterprise Linux), AND
Have an insights_facet (indicated by the presence of insights_attributes in the response)

@chris1984 chris1984 changed the title SAT-37817 - Show correct Recommendations for iop non registered hosts SAT-37817 - Hide Recommendations page for non registered hosts Sep 24, 2025
@chris1984 chris1984 changed the title SAT-37817 - Hide Recommendations page for non registered hosts SAT-37817 - Hide Recommendations page for non-registered hosts Sep 24, 2025
Copy link
Collaborator

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

I checked out the PR
My host has insights_attributes in the response, but I don't see a Recommendations tab:

Image

@chris1984 chris1984 force-pushed the iop-recommendation branch 3 times, most recently from df4799c to 2d85255 Compare September 26, 2025 00:49
@chris1984
Copy link
Member Author

I checked out the PR My host has insights_attributes in the response, but I don't see a Recommendations tab:

Image

@jeremylenz updated, let me know what you think. I tested it on a host that didn't have an insights_facet and one that did, and it worked as intended now.

Copy link
Collaborator

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Works well

thanks @chris1984 !

ACK 👍

@chris1984 chris1984 merged commit 8d8faa7 into theforeman:develop Sep 28, 2025
24 checks passed
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.

2 participants