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

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

@chris1984
Copy link
Member

ACK, works great. Thanks @Thorben-D I am not seeing the insights tab for my Ubuntu 24.04 box

Before PR:
Screenshot 2024-10-22 150531
Screenshot 2024-10-22 150555

After PR:
Screenshot 2024-10-22 150622

@chris1984 chris1984 merged commit 4b34441 into theforeman:develop Oct 22, 2024
21 checks passed
@chris1984
Copy link
Member

@Thorben-D I am not seeing the insights tab for a normal RHEL host now, is this something you are able to investigate?

@chris1984
Copy link
Member

Screenshot 2024-10-22 155635

@Thorben-D
Copy link
Contributor Author

@chris1984 Thanks for having a look! Does the OS name of your RHEL host not contain any permutation of "Red Hat"?
Right now, that is the check that is done to determine whether the tab should be displayed or not.
We can't use os_family as that also says "Red hat" for alma-/rockylinux.
Maybe I should use the same check that determines the OS icon. That seems to work with "RHEL"...

@nadjaheitmann
Copy link

#911 (comment) That is what is was talking about :)

@chris1984
Copy link
Member

@Thorben-D my host name is ip-10-0-168-58.rhos-01.prod.psi.rdu2.redhat.com with the OS RHEL 9.4

@chris1984
Copy link
Member

I wonder if you could use the distribution facts like here
Screenshot 2024-10-23 083946

@chris1984
Copy link
Member

The Icon way, would work as well I think

@chris1984
Copy link
Member

@Thorben-D Do you think you can revisit this next week? Otherwise, I will prob have to revert the commit, so it does not affect our tests downstream when we do our weekly nightly/stream builds.

@Thorben-D
Copy link
Contributor Author

@chris1984 Not before wednesday I'm afraid. If that is too late, you'll have to revert the commit.
In that case, feel free to CC me in the PR and I'll give it a review.

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