From 3340d0941f8628ae0d51bbb7fa8b2cad2886671b Mon Sep 17 00:00:00 2001 From: Pavan Soma Shekar Date: Wed, 18 Dec 2024 16:09:18 +0000 Subject: [PATCH] Fixes #38112 - Order LCEs by LCE path in Content View GUI and Hammer --- app/models/katello/content_view.rb | 4 +++- app/models/katello/content_view_version.rb | 6 ++++++ .../katello/api/v2/content_view_versions/base.json.rabl | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/katello/content_view.rb b/app/models/katello/content_view.rb index e13cb2f9735..b69c1437cfa 100644 --- a/app/models/katello/content_view.rb +++ b/app/models/katello/content_view.rb @@ -342,7 +342,9 @@ def latest_version_id end def latest_version_env - latest_version_object.try(:environments) || [] + environments = organization.readable_promotion_paths.flatten + environments.insert(0, organization.library) + environments.intersection(latest_version_object.try(:environments) || []) end def last_task diff --git a/app/models/katello/content_view_version.rb b/app/models/katello/content_view_version.rb index 530912a23bc..a7910ab748a 100644 --- a/app/models/katello/content_view_version.rb +++ b/app/models/katello/content_view_version.rb @@ -108,6 +108,12 @@ def to_s name end + def sorted_organization_readable_environments + organization_readable_environments = organization.readable_promotion_paths.flatten + organization_readable_environments.insert(0, organization.library) + organization_readable_environments.intersection(environments) + end + def self.contains_file(file_unit_id) where(id: Katello::Repository.where(id: Katello::RepositoryFileUnit.where(file_unit_id: file_unit_id).select(:repository_id)).select(:content_view_version_id)) end diff --git a/app/views/katello/api/v2/content_view_versions/base.json.rabl b/app/views/katello/api/v2/content_view_versions/base.json.rabl index 6d57054a5eb..41924a50e12 100644 --- a/app/views/katello/api/v2/content_view_versions/base.json.rabl +++ b/app/views/katello/api/v2/content_view_versions/base.json.rabl @@ -49,7 +49,7 @@ end extends 'katello/api/v2/common/timestamps' version = @object || @resource -child :environments => :environments do +child :sorted_organization_readable_environments => :environments do attributes :id, :name, :label node :publish_date do |env|