diff --git a/app/controllers/katello/api/v2/activation_keys_controller.rb b/app/controllers/katello/api/v2/activation_keys_controller.rb index d11529818d8..f65f13fef54 100644 --- a/app/controllers/katello/api/v2/activation_keys_controller.rb +++ b/app/controllers/katello/api/v2/activation_keys_controller.rb @@ -323,7 +323,7 @@ def find_content_view_environments ids: params[:content_view_environment_ids], organization: @organization || @activation_key&.organization) if @content_view_environments.blank? - handle_errors(candlepin_names: params[:content_view_environments], + handle_errors(labels: params[:content_view_environments], ids: params[:content_view_environment_ids]) end end diff --git a/app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb b/app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb index 2268b1b18e9..a8fd16aa42d 100644 --- a/app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb +++ b/app/controllers/katello/concerns/api/v2/hosts_controller_extensions.rb @@ -53,7 +53,7 @@ def set_content_view_environments if cves.present? @host.content_facet.content_view_environments = cves else - handle_errors(candlepin_names: cve_params[:content_view_environments], + handle_errors(labels: cve_params[:content_view_environments], ids: cve_params[:content_view_environment_ids]) end end diff --git a/app/controllers/katello/concerns/api/v2/multi_cv_params_handling.rb b/app/controllers/katello/concerns/api/v2/multi_cv_params_handling.rb index 94a635bfa47..0ea16d2bcf5 100644 --- a/app/controllers/katello/concerns/api/v2/multi_cv_params_handling.rb +++ b/app/controllers/katello/concerns/api/v2/multi_cv_params_handling.rb @@ -4,9 +4,9 @@ module Api::V2::MultiCVParamsHandling extend ActiveSupport::Concern include ::Katello::Api::V2::ErrorHandling - def handle_errors(candlepin_names: [], ids: []) - if candlepin_names.present? - fail HttpErrors::UnprocessableEntity, "No content view environments found with names: #{candlepin_names.join(',')}" + def handle_errors(labels: [], ids: []) + if labels.present? + fail HttpErrors::UnprocessableEntity, "No content view environments found with names: #{labels.join(',')}" elsif ids.present? fail HttpErrors::UnprocessableEntity, "No content view environments found with ids: #{ids}" end diff --git a/app/models/katello/content_view_environment.rb b/app/models/katello/content_view_environment.rb index ad53db0e7e6..12ab68b148d 100644 --- a/app/models/katello/content_view_environment.rb +++ b/app/models/katello/content_view_environment.rb @@ -35,8 +35,8 @@ def self.for_content_facets(content_facets) joins(:content_view_environment_content_facets, :content_facets).where("#{Katello::ContentViewEnvironmentContentFacet.table_name}.content_facet_id" => content_facets).uniq end - def self.with_candlepin_name(cp_name, organization: Organization.current) - joins(:environment, :content_view).where("#{Katello::KTEnvironment.table_name}.organization_id" => organization, label: cp_name).first + def self.with_label_and_org(label, organization: Organization.current) + joins(:environment, :content_view).where("#{Katello::KTEnvironment.table_name}.organization_id" => organization, label: label).first end # retrieve the owning environment for this content view environment. @@ -56,10 +56,6 @@ def default_environment? content_view.default? && environment.library? end - def candlepin_name - label - end - def priority(content_object) if content_object.is_a? Katello::ActivationKey content_view_environment_activation_keys.find_by(:activation_key_id => content_object.id).try(:priority) @@ -86,7 +82,7 @@ def self.fetch_content_view_environments(labels: [], ids: [], organization:) elsif labels.present? environment_names = labels.map(&:strip) environment_names.each do |name| - cve = with_candlepin_name(name, organization: organization) + cve = with_label_and_org(name, organization: organization) if cve.blank? label_errors << name else diff --git a/app/models/katello/host/content_facet.rb b/app/models/katello/host/content_facet.rb index f9b66d305a5..551a238c728 100644 --- a/app/models/katello/host/content_facet.rb +++ b/app/models/katello/host/content_facet.rb @@ -359,11 +359,6 @@ def update_errata_status host.refresh_global_status! end - # TODO: uncomment when we need to display multiple CVE names in the UI - # def content_view_environment_names - # content_view_environments.map(&:candlepin_name).join(', ') - # end - def self.joins_installable_relation(content_model, facet_join_model) facet_repository = Katello::ContentFacetRepository.table_name content_table = content_model.table_name diff --git a/app/views/katello/api/v2/activation_keys/base.json.rabl b/app/views/katello/api/v2/activation_keys/base.json.rabl index 601513414a2..76d837f2e1d 100644 --- a/app/views/katello/api/v2/activation_keys/base.json.rabl +++ b/app/views/katello/api/v2/activation_keys/base.json.rabl @@ -28,7 +28,7 @@ child :content_view_environments => :content_view_environments do } end node :label do |cve| - cve.candlepin_name + cve.label end end diff --git a/app/views/katello/api/v2/content_facet/base.json.rabl b/app/views/katello/api/v2/content_facet/base.json.rabl index bf61454a609..77fc616b4df 100644 --- a/app/views/katello/api/v2/content_facet/base.json.rabl +++ b/app/views/katello/api/v2/content_facet/base.json.rabl @@ -27,8 +27,8 @@ child :content_view_environments => :content_view_environments do lifecycle_environment_library: cve.lifecycle_environment&.library? } end - node :candlepin_name do |cve| - cve.candlepin_name + node :label do |cve| + cve.label end end diff --git a/test/controllers/api/v2/activation_keys_controller_test.rb b/test/controllers/api/v2/activation_keys_controller_test.rb index 4091c21da9d..4ce4b992861 100644 --- a/test/controllers/api/v2/activation_keys_controller_test.rb +++ b/test/controllers/api/v2/activation_keys_controller_test.rb @@ -213,7 +213,7 @@ def test_create_with_content_view_environments_param content_view_environments = ['published_dev_view_library'] ActivationKey.any_instance.expects(:reload) assert_sync_task(::Actions::Katello::ActivationKey::Create) do |activation_key| - assert_equal content_view_environments, activation_key.content_view_environments.map(&:candlepin_name), [cve.candlepin_name] + assert_equal content_view_environments, activation_key.content_view_environments.map(&:label), [cve.label] assert_valid activation_key end diff --git a/test/models/content_view_environment_test.rb b/test/models/content_view_environment_test.rb index 91bd0d4f5e8..90b64d120a2 100644 --- a/test/models/content_view_environment_test.rb +++ b/test/models/content_view_environment_test.rb @@ -30,14 +30,14 @@ def test_hosts assert_includes cve.hosts, host end - def test_with_candlepin_name + def test_with_label_and_org dev = katello_environments(:dev) view = katello_content_views(:library_dev_view) cve = Katello::ContentViewEnvironment.where(:environment_id => dev, :content_view_id => view).first - assert_equal cve, ContentViewEnvironment.with_candlepin_name('published_dev_view_dev', organization: dev.organization) + assert_equal cve, ContentViewEnvironment.with_label_and_org('published_dev_view_dev', organization: dev.organization) end - def test_fetch_content_view_environments_candlepin_names + def test_fetch_content_view_environments_labels dev = katello_environments(:dev) view = katello_content_views(:library_dev_view) cve = Katello::ContentViewEnvironment.where(:environment_id => dev, :content_view_id => view).first @@ -60,7 +60,7 @@ def test_fetch_content_view_environments_invalid_ids_does_not_mutate_array assert_equal [0, 999], input_ids # should not have a map! which mutates the input array end - def test_fetch_content_view_environments_mixed_validity_candlepin_names + def test_fetch_content_view_environments_mixed_validity_labels dev = katello_environments(:dev) assert_raises(HttpErrors::UnprocessableEntity) do ContentViewEnvironment.fetch_content_view_environments(labels: ['published_dev_view_dev, bogus'], organization: dev.organization) diff --git a/webpack/ForemanColumnExtensions/index.js b/webpack/ForemanColumnExtensions/index.js index c2444e83bfa..e2514dd9e6e 100644 --- a/webpack/ForemanColumnExtensions/index.js +++ b/webpack/ForemanColumnExtensions/index.js @@ -131,7 +131,7 @@ const hostsIndexColumnExtensions = [ } > - {truncate(contentViewEnvironments.map(cve => cve.candlepin_name).join(', '), 35)} + {truncate(contentViewEnvironments.map(cve => cve.label).join(', '), 35)} diff --git a/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js b/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js index 937c6acb950..2ca26dcfa98 100644 --- a/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js +++ b/webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js @@ -194,7 +194,7 @@ const RepositorySetsTab = () => { const { name: lifecycleEnvironmentName } = lifecycleEnvironment ?? {}; const multiEnvHost = contentViewEnvironments.length > 1; const contentViewEnvironmentNames = - contentViewEnvironments.map(({ candlepin_name: candlepinName }) => candlepinName).join(', '); + contentViewEnvironments.map(({ label }) => label).join(', '); const nonLibraryHost = contentViewDefault === false || lifecycleEnvironmentLibrary === false; const [isBulkActionOpen, setIsBulkActionOpen] = useState(false);