2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-04 06:55:23 -05:00
|
|
|
class Admin::RunnerProjectsController < Admin::ApplicationController
|
|
|
|
before_action :project, only: [:create]
|
|
|
|
|
2021-08-18 14:10:08 -04:00
|
|
|
feature_category :runner
|
2020-10-05 17:08:47 -04:00
|
|
|
|
2015-12-04 06:55:23 -05:00
|
|
|
def create
|
|
|
|
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
|
|
|
|
|
2018-05-28 06:49:08 -04:00
|
|
|
if @runner.assign_to(@project, current_user)
|
2021-09-17 11:11:44 -04:00
|
|
|
redirect_to admin_runner_path(@runner), notice: s_('Runners|Runner assigned to project.')
|
2015-12-04 06:55:23 -05:00
|
|
|
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
|
|
|
|
|
2021-09-17 11:11:44 -04:00
|
|
|
redirect_to admin_runner_path(runner), status: :found, notice: s_('Runners|Runner unassigned from project.')
|
2015-12-04 06:55:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project
|
2017-02-02 18:43:19 -05:00
|
|
|
@project = Project.find_by_full_path(
|
2015-12-04 06:55:23 -05:00
|
|
|
[params[:namespace_id], '/', params[:project_id]].join('')
|
|
|
|
)
|
|
|
|
@project || render_404
|
|
|
|
end
|
|
|
|
end
|