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 12, 2023
1 parent cfc586c commit 8362fbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions 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 @@ -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?
if repositories.empty?
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 8362fbb

Please sign in to comment.