Skip to content

Commit

Permalink
Fixes #38097 - Add packages count to new All Hosts page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadjaheitmann authored and sbernhard committed Dec 19, 2024
1 parent cf57e55 commit 26d9ea9
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
8 changes: 0 additions & 8 deletions app/views/katello/api/v2/hosts/base.json.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ object @resource

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
Expand Down
13 changes: 13 additions & 0 deletions app/views/katello/api/v2/hosts/os_attributes.json.rabl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object @resource

@resource ||= @object

attributes :id, :name, :description

node :operatingsystem_family do |resource|
resource.operatingsystem&.family
end

node :operatingsystem_major do |resource|
resource.operatingsystem&.major
end
2 changes: 2 additions & 0 deletions lib/katello/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@
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'
extend_rabl_template 'api/v2/hosts/show', 'katello/api/v2/hosts/os_attributes'
extend_rabl_template 'api/v2/hosts/index', 'katello/api/v2/hosts/os_attributes'

# Katello variables for Host Registration
extend_allowed_registration_vars :activation_keys
Expand Down
18 changes: 18 additions & 0 deletions test/views/api/v2/hosts_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'katello_test_helper'

module Katello
class HostsViewTest < ActiveSupport::TestCase
def setup
@host = FactoryBot.build(:host, :with_operatingsystem,
:compute_resource_id => compute_resources(:one).id)
end

def test_base
render_rabl('katello/api/v2/hosts/base.json', @host)
end

def test_show
render_rabl('katello/api/v2/hosts/show.json', @host)
end
end
end
9 changes: 7 additions & 2 deletions webpack/ForemanColumnExtensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const hostsIndexColumnExtensions = [
const registered = !!hostDetails?.subscription_facet_attributes?.uuid;
const { security, bugfix, enhancement } = errataCounts ?? {};
const upgradableRpmCount = hostDetails?.content_facet_attributes?.upgradable_package_count;
const upgradableDebCount = hostDetails?.content_facet_attributes?.upgradable_deb_count;
if (!registered) return '—';
const hostErrataUrl = type => `hosts/${hostDetails?.name}#/Content/errata?type=${type}&show=installable`;
return (
Expand All @@ -119,10 +120,14 @@ const hostsIndexColumnExtensions = [
<Link to={hostErrataUrl('enhancement')}>{enhancement}</Link>
</FlexItem>
}
{upgradableRpmCount !== undefined &&
{(upgradableRpmCount !== undefined || upgradableDebCount !== undefined) &&
<FlexItem>
<PackageIcon />
<Link to={`hosts/${hostDetails?.name}#/Content/Packages?status=Upgradable`}>{upgradableRpmCount}</Link>
{ hostDetails?.operatingsystem_family === 'Debian' ?
<Link to={`hosts/${hostDetails?.name}#/Content/Debs?status=Upgradable`}>{upgradableDebCount}</Link>
:
<Link to={`hosts/${hostDetails?.name}#/Content/Packages?status=Upgradable`}>{upgradableRpmCount}</Link>
}
</FlexItem>
}
</Flex>
Expand Down

0 comments on commit 26d9ea9

Please sign in to comment.