2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-04 06:55:23 -05:00
|
|
|
class Projects::RunnerProjectsController < Projects::ApplicationController
|
2016-02-01 17:58:04 -05:00
|
|
|
before_action :authorize_admin_build!
|
2015-12-04 06:55:23 -05:00
|
|
|
|
|
|
|
layout 'project_settings'
|
|
|
|
|
|
|
|
def create
|
|
|
|
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
|
|
|
|
|
2016-06-29 07:04:06 -04:00
|
|
|
return head(403) unless can?(current_user, :assign_runner, @runner)
|
2015-12-04 06:55:23 -05:00
|
|
|
|
2018-04-09 21:28:21 -04:00
|
|
|
path = project_runners_path(project)
|
2015-12-04 06:55:23 -05:00
|
|
|
|
2018-05-28 06:49:08 -04:00
|
|
|
if @runner.assign_to(project, current_user)
|
2015-12-04 06:55:23 -05:00
|
|
|
redirect_to path
|
|
|
|
else
|
|
|
|
redirect_to path, alert: 'Failed adding runner to project'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-12-10 11:44:06 -05:00
|
|
|
runner_project = project.runner_projects.find(params[:id])
|
2015-12-04 06:55:23 -05:00
|
|
|
runner_project.destroy
|
|
|
|
|
2018-07-02 06:43:06 -04:00
|
|
|
redirect_to project_runners_path(project), status: :found
|
2015-12-04 06:55:23 -05:00
|
|
|
end
|
|
|
|
end
|