Skip to content

Commit

Permalink
Fixes #36739 - Product without any repo is added to a Sync Plan regar…
Browse files Browse the repository at this point in the history
…dless the error message
  • Loading branch information
sjha4 committed Sep 13, 2023
1 parent cfc586c commit 03e01fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/models/katello/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Product < Katello::Model
validates_lengths_from_database :except => [:label]
validates :provider_id, :presence => true
validate :ensure_provider_type_matches_id
validate :ensure_no_sync_plans_on_empty_product
validates_with Validators::KatelloNameFormatValidator, :attributes => :name
validates_with Validators::KatelloLabelFormatValidator, :attributes => :label
validates_with Validators::ProductUniqueAttributeValidator, :attributes => :name
Expand Down Expand Up @@ -107,7 +108,7 @@ def repos(env, content_view = nil, include_feedless = true)
end

def enabled?
self.repositories.present?
self.redhat? && self.repositories.present?
end

delegate :cdn_configuration, :library, to: :organization
Expand Down Expand Up @@ -263,5 +264,12 @@ def ensure_provider_type_matches_id
errors.add(:base, _("Cannot associate a Red Hat provider with a custom product"))
end
end

def ensure_no_sync_plans_on_empty_product
return if sync_plan_id.nil?
unless enabled?
fail _("Cannot add empty product %s to sync plan!") % name
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ angular.module('Bastion.sync-plans').controller('SyncPlanAddProductsController',

error = function (response) {
deferred.reject(response.data.errors);
Notification.setErrorMessage(response.data.errors.base);
Notification.setErrorMessage(response.data.displayMessage);
$scope.table.working = false;
};

Expand Down

0 comments on commit 03e01fe

Please sign in to comment.