From 2ee377e610175e04e89f1b80087723e33528c2fe 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..877f34df187 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_content_view_environments + content_view_environments = organization.readable_promotion_paths.flatten + content_view_environments.insert(0, organization.library) + content_view_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..6388c2800a0 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_content_view_environments => :environments do attributes :id, :name, :label node :publish_date do |env|