Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #910 - Insights tab displayed for non-RHEL hosts #911

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Thorben-D
Copy link
Contributor

Fixes #910

Changes made

  • Add helper-function isNotRhelHost
  • Hide insights tab based on host-OS by using "hideTab" fill-metadata field.
  • Hide TotalRisk card based on host-OS by wrapping it.

The isNotRhelHost check is not the nicest but this is similar to how it is done in:
provisioning_templates/snippet/insights.erb:<% if @host.operatingsystem.name == 'RedHat' -%>

- Add helper-function isNotRhelHost
- Hide insights tab based on host-OS
- Hide TotalRisk card based on host-OS

export const isNotRhelHost = ({ hostDetails }) =>
// eslint-disable-next-line camelcase
!new RegExp('red\\s?hat', 'i').test(hostDetails?.operatingsystem_name);
Copy link

@nadjaheitmann nadjaheitmann Oct 2, 2024

Choose a reason for hiding this comment

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

operatingsystem_name is not safe as this value can be changed by the user. As this plugin depends on Katello anyways, you can use hostDetails?.operatingsystem_family

Choose a reason for hiding this comment

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

Well, you will get the OS type Redhat for Alma, Rocky, etc. as well, so this is tricky... But maybe you can use it for a sanity check.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no better check for this right now. I would just go with this solution.

Choose a reason for hiding this comment

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

What about checking at least for RHEL ? I don't know how people are naming their OSes these days.

Copy link
Contributor

Choose a reason for hiding this comment

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

on Redhat, these OS are created automatically from the imported Manifest.
Other areas will not work if OS name was changed, like https://github.com/theforeman/foreman/blob/develop/app/views/unattended/provisioning_templates/snippet/insights.erb#L10

Copy link

@bastian-src bastian-src left a comment

Choose a reason for hiding this comment

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

LGTM, adding the metadata field looks like a good solution to me.

@chris1984
Copy link
Member

Will take a look

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.

The "Insights" tab is displayed for all operating systems
5 participants