2015-12-04 11:55:23 +00:00
|
|
|
class Admin::RunnerProjectsController < Admin::ApplicationController
|
|
|
|
before_action :project, only: [:create]
|
|
|
|
|
|
|
|
def create
|
|
|
|
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
|
|
|
|
|
2016-06-14 15:11:43 +00:00
|
|
|
runner_project = @runner.assign_to(@project, current_user)
|
|
|
|
|
|
|
|
if runner_project.persisted?
|
2015-12-04 11:55:23 +00:00
|
|
|
redirect_to admin_runner_path(@runner)
|
|
|
|
else
|
|
|
|
redirect_to admin_runner_path(@runner), alert: 'Failed adding runner to project'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
rp = Ci::RunnerProject.find(params[:id])
|
|
|
|
runner = rp.runner
|
|
|
|
rp.destroy
|
|
|
|
|
|
|
|
redirect_to admin_runner_path(runner)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project
|
2017-02-02 23:43:19 +00:00
|
|
|
@project = Project.find_by_full_path(
|
2015-12-04 11:55:23 +00:00
|
|
|
[params[:namespace_id], '/', params[:project_id]].join('')
|
|
|
|
)
|
|
|
|
@project || render_404
|
|
|
|
end
|
|
|
|
end
|