From 7a9c083b93cce26ac33980c55d15e441a39cae34 Mon Sep 17 00:00:00 2001 From: Nadja Heitmann Date: Wed, 31 Jan 2024 08:50:31 +0000 Subject: [PATCH] Fixes #37144 - Use OS family for host details page packages tab --- app/views/katello/api/v2/hosts/base.json.rabl | 9 +++++++++ lib/katello/plugin.rb | 1 + .../extensions/HostDetails/Tabs/DebsTab/DebsTab.js | 7 +------ .../Tabs/ModuleStreamsTab/ModuleStreamsTab.js | 9 +-------- .../HostDetails/Tabs/PackagesTab/PackagesTab.js | 7 +------ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/views/katello/api/v2/hosts/base.json.rabl b/app/views/katello/api/v2/hosts/base.json.rabl index b7f80309087..f337ab2a016 100644 --- a/app/views/katello/api/v2/hosts/base.json.rabl +++ b/app/views/katello/api/v2/hosts/base.json.rabl @@ -4,6 +4,15 @@ object @resource @facet = @resource.content_facet attributes :id, :name, :description + +node :operatingsystem_family do |resource| + resource.operatingsystem.family +end + +node :operatingsystem_major do |resource| + resource.operatingsystem.major +end + if @facet node :content_view do content_view = @facet&.single_content_view diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb index bda664feb42..2370486f791 100644 --- a/lib/katello/plugin.rb +++ b/lib/katello/plugin.rb @@ -303,6 +303,7 @@ extend_rabl_template 'api/v2/smart_proxies/main', 'katello/api/v2/smart_proxies/pulp_info' extend_rabl_template 'api/v2/hosts/show', 'katello/api/v2/hosts/host_collections' + extend_rabl_template 'api/v2/hosts/show', 'katello/api/v2/hosts/show' # Katello variables for Host Registration extend_allowed_registration_vars :activation_keys diff --git a/webpack/components/extensions/HostDetails/Tabs/DebsTab/DebsTab.js b/webpack/components/extensions/HostDetails/Tabs/DebsTab/DebsTab.js index 3fa5572f856..cc0a89bc5d8 100644 --- a/webpack/components/extensions/HostDetails/Tabs/DebsTab/DebsTab.js +++ b/webpack/components/extensions/HostDetails/Tabs/DebsTab/DebsTab.js @@ -45,12 +45,7 @@ import { hasRequiredPermissions as can, import SortableColumnHeaders from '../../../../Table/components/SortableColumnHeaders'; import { useRexJobPolling } from '../RemoteExecutionHooks'; -export const hideDebsTab = ({ hostDetails }) => { - const osMatch = hostDetails?.operatingsystem_name?.match(/(\D+) (\d+|\D+)/); - if (!osMatch) return false; - const [, os] = osMatch; - return !(osMatch && os.match(/Debian|Ubuntu/i)); -}; +export const hideDebsTab = ({ hostDetails }) => !(hostDetails?.operatingsystem_family === 'Debian'); const invokeRexJobs = ['create_job_invocations']; const createBookmarks = ['create_bookmarks']; diff --git a/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js b/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js index d3ff74425f2..bf2842a0837 100644 --- a/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js +++ b/webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js @@ -47,14 +47,7 @@ import { userPermissionsFromHostDetails, } from '../../hostDetailsHelpers'; -const moduleStreamSupported = ({ os, version }) => - os.match(/RedHat|RHEL|CentOS|Rocky|AlmaLinux|Oracle Linux/i) && Number(version) > 7; -export const hideModuleStreamsTab = ({ hostDetails }) => { - const osMatch = hostDetails?.operatingsystem_name?.match(/(\D+) (\d+)/); - if (!osMatch) return false; - const [, os, version] = osMatch; - return !(osMatch && moduleStreamSupported({ os, version })); -}; +export const hideModuleStreamsTab = ({ hostDetails }) => !(hostDetails?.operatingsystem_family === 'Redhat' && Number(hostDetails?.operatingsystem_major > 7)); const EnabledIcon = ({ streamText, streamInstallStatus, upgradable }) => { switch (true) { diff --git a/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js b/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js index 789a9e8b52b..aacd9035d0d 100644 --- a/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js +++ b/webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js @@ -50,12 +50,7 @@ import { runSubmanRepos } from '../../Cards/ContentViewDetailsCard/HostContentVi const invokeRexJobs = ['create_job_invocations']; const createBookmarks = ['create_bookmarks']; -export const hidePackagesTab = ({ hostDetails }) => { - const osMatch = hostDetails?.operatingsystem_name?.match(/(\D+) (\d+|\D+)/); - if (!osMatch) return false; - const [, os] = osMatch; - return !(osMatch && os.match(/RedHat|RHEL|CentOS|Rocky|AlmaLinux|Alma|Oracle Linux|Oracle|Suse Linux Enterprise Server|SLES/i)); -}; +export const hidePackagesTab = ({ hostDetails }) => !(hostDetails?.operatingsystem_family?.match(/RedHat|SUSE/i)); const UpdateVersionsSelect = ({ packageName,