-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #35713 - Host details tab for Debian packages
- Loading branch information
1 parent
c045d9b
commit 6fa8d38
Showing
26 changed files
with
1,551 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Katello | ||
class HostDebPresenter < SimpleDelegator | ||
attr_accessor :installed_package, :upgradable_versions, :deb_id | ||
|
||
def initialize(installed_package, upgradable_versions, deb_id) | ||
@installed_package = installed_package | ||
@upgradable_versions = upgradable_versions | ||
@deb_id = deb_id | ||
super(@installed_package) | ||
end | ||
|
||
def self.with_latest(packages, host) | ||
upgradable_packages_map = ::Katello::Deb.installable_for_hosts([host]).select(:id, :name, :architecture, :version).order(version: :desc).group_by { |i| [i.name, i.architecture] } | ||
installed_packages_map = ::Katello::Deb.where(version: packages.map(&:version)).select(:id, :architecture, :name).group_by { |i| [i.name, i.architecture] } | ||
|
||
packages.map do |p| | ||
upgrades = upgradable_packages_map[[p.name, p.architecture]]&.pluck(:version) | ||
installed = installed_packages_map[[p.name, p.architecture]]&.first&.id | ||
HostDebPresenter.new(p, upgrades, installed) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'katello_test_helper' | ||
require 'byebug' | ||
|
||
module Katello | ||
class HostDebPresenterTest < ActiveSupport::TestCase | ||
def setup | ||
@repo = katello_repositories(:debian_10_amd64_dev) | ||
@deb = katello_debs(:one_new) | ||
end | ||
|
||
let(:installed_deb) { Katello::InstalledDeb.create(name: 'uno', version: @deb.version, architecture: @deb.architecture) } | ||
let(:new_version) { '1.2' } | ||
|
||
test "deb with set upgradable_version" do | ||
presenter = HostDebPresenter.new(installed_deb, [new_version], @deb.id) | ||
|
||
assert_equal presenter.upgradable_versions, [new_version] | ||
assert_equal presenter.name, installed_deb.name | ||
assert_equal presenter.deb_id, @deb.id | ||
end | ||
|
||
test "with nil upgradable_version" do | ||
presenter = HostDebPresenter.new(installed_deb, nil, @deb.id) | ||
|
||
assert_nil presenter.upgradable_versions | ||
assert_equal presenter.name, installed_deb.name | ||
assert_equal presenter.deb_id, @deb.id | ||
end | ||
|
||
test "with_latest" do | ||
host = katello_content_facets(:content_facet_one).host | ||
host.content_facet.bound_repositories << @repo | ||
update = Katello::Deb.create(name: 'uno', pulp_id: 'uno-new-uuid', version: '1.2', architecture: 'amd64') | ||
::Katello::Deb.stubs(:installable_for_hosts).returns(Katello::Deb.where(id: update.id)) | ||
presenter = HostDebPresenter.with_latest([installed_deb], host).first | ||
|
||
assert_equal presenter.upgradable_versions, [new_version] | ||
assert_equal presenter.name, installed_deb.name | ||
assert_equal presenter.deb_id, @deb.id | ||
end | ||
|
||
test "with arch" do | ||
host = katello_content_facets(:content_facet_one).host | ||
host.content_facet.bound_repositories << @repo | ||
update = Katello::Deb.create(name: 'one', pulp_id: 'one-new-uuid', version: '1.2', architecture: 'noarch') | ||
::Katello::Deb.stubs(:installable_for_hosts).returns(Katello::Deb.where(id: update.id)) | ||
presenter = HostDebPresenter.with_latest([installed_deb], host).first | ||
|
||
assert_nil presenter.upgradable_versions | ||
assert_equal presenter.name, installed_deb.name | ||
assert_equal presenter.deb_id, @deb.id | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
webpack/components/extensions/HostDetails/Tabs/ContentTab/constants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.