Skip to content

Commit

Permalink
Fixes #38188 - Added error display for "Synchronize Now" button
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanshekar committed Feb 5, 2025
1 parent b959a02 commit c0146a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
14 changes: 14 additions & 0 deletions app/assets/javascripts/katello/sync_management/sync_management.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ $("#sync_product_form")
if ($("input[name='repoids[]']:checked").length === 0) {
return false;
}
})
.on("ajax:error", function (event, response) {
let errorMessage = localize("error");
if (response && response.responseJSON && response.responseJSON.error) {
errorMessage = response.responseJSON.error;
}
if (window.tfm && window.tfm.toastNotifications) {
window.tfm.toastNotifications.notify({
message: errorMessage,
type: "danger",
});
} else {
alert(errorMessage);
}
});

$("#sync_toggle").on("change", function () {
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/katello/sync_management_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ def index
end

def sync
tasks = sync_repos(params[:repoids]) || []
render :json => tasks.as_json
begin
tasks = sync_repos(params[:repoids]) || []
render json: tasks.as_json
rescue StandardError => e
render json: { error: e.message }, status: :internal_server_error
end
end

def sync_status
Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def check_ready_to_act!
.uniq
.map { |task| "- #{Setting['foreman_url']}/foreman_tasks/tasks/#{task&.id}" }
.join("\n")
fail _("This repository has pending tasks in associated content views. Please wait for the tasks: " + errored_tasks +
fail _("Repository #{self.label} has pending tasks in associated content views. Please wait for the tasks: " + errored_tasks +
" to complete before proceeding.")
end
end
Expand Down

0 comments on commit c0146a5

Please sign in to comment.