gitlab-org--gitlab-foss/app/controllers/projects/runner_projects_controller.rb

34 lines
854 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2015-12-04 06:55:23 -05:00
class Projects::RunnerProjectsController < Projects::ApplicationController
before_action :authorize_admin_build!
2015-12-04 06:55:23 -05:00
layout 'project_settings'
feature_category :runner
2015-12-04 06:55:23 -05:00
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
return head(403) unless can?(current_user, :assign_runner, @runner)
2015-12-04 06:55:23 -05:00
path = project_runners_path(project)
2015-12-04 06:55:23 -05:00
if @runner.assign_to(project, current_user)
2015-12-04 06:55:23 -05:00
redirect_to path
else
assign_to_messages = @runner.errors.messages[:assign_to]
alert = assign_to_messages&.join(',') || 'Failed adding runner to project'
redirect_to path, alert: alert
2015-12-04 06:55:23 -05:00
end
end
def destroy
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