Skip to content

Commit

Permalink
[webui] Refactoring package abort build
Browse files Browse the repository at this point in the history
The abort_build action posts now directly to the backend instead to the API.
  • Loading branch information
ChrisBr committed Nov 4, 2015
1 parent d470c05 commit e1b0840
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Webui::PackageController < Webui::WebuiController
:update_build_log, :devel_project, :buildresult, :rpmlint_result,
:rpmlint_log, :meta, :attributes, :repositories, :files]

before_filter :do_backend_login, only: [:save_meta, :abort_build, :remove]
before_filter :do_backend_login, only: [:save_meta, :remove]

prepend_before_filter :lockout_spiders, :only => [:revisions, :dependency, :rdiff, :binary, :binaries, :requests]

Expand Down Expand Up @@ -846,8 +846,16 @@ def update_build_log
end

def abort_build
params[:redirect] = 'live_build_log'
api_cmd('abortbuild', params)
authorize @package, :update?

if @package.abort_build(params)
flash[:notice] = "Triggered abort build for #{@project.name}/#{@package.name} successfully."
redirect_to controller: :package, action: :show, project: @project, package: @package
else
flash[:error] = "Error while triggering abort build for #{@project.name}/#{@package.name}: #{@package.errors.full_messages.to_sentence}."
redirect_to controller: :package, action: :live_build_log, project: @project, package: @package, repository: params[:repository]
end

end

def trigger_rebuild
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,10 @@ def wipe_binaries(params)
backend_build_command(:wipe, params.slice!(:package, :arch, :repository))
end

def abort_build(params)
backend_build_command(:abortbuild, params.slice!(:package, :arch, :repository))
end

def backend_build_command(command, params)
begin
Suse::Backend.post("/build/#{URI.escape(project.name)}?cmd=#{command}&#{params.to_query}", '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<%= link_to sprited_text('rebuild', 'Trigger Rebuild'), {action: 'trigger_rebuild', project: @project, package: @package, arch: @arch, repo: @repo}, method: :delete %>
</span>
<span class="link_abort_build hidden">
<%= link_to "[Abort build]", action: 'abort_build', project: @project, package: @package, arch: @arch, repo: @repo %>
<%= link_to "[Abort build]", action: 'abort_build', project: @project, package: @package, arch: @arch, repository: @repo %>
</span></p>
<% end %>

0 comments on commit e1b0840

Please sign in to comment.