2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-04 11:55:23 +00:00
|
|
|
class Admin::RunnerProjectsController < Admin::ApplicationController
|
|
|
|
before_action :project, only: [:create]
|
|
|
|
|
2021-08-18 18:10:08 +00:00
|
|
|
feature_category :runner
|
2022-04-25 15:08:44 +00:00
|
|
|
urgency :low
|
2020-10-05 21:08:47 +00:00
|
|
|
|
2015-12-04 11:55:23 +00:00
|
|
|
def create
|
|
|
|
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
|
|
|
|
|
2022-08-05 09:12:06 +00:00
|
|
|
if ::Ci::Runners::AssignRunnerService.new(@runner, @project, current_user).execute.success?
|
2022-01-06 18:13:45 +00:00
|
|
|
redirect_to edit_admin_runner_url(@runner), notice: s_('Runners|Runner assigned to project.')
|
2015-12-04 11:55:23 +00:00
|
|
|
else
|
2022-01-06 18:13:45 +00:00
|
|
|
redirect_to edit_admin_runner_url(@runner), alert: 'Failed adding runner to project'
|
2015-12-04 11:55:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
rp = Ci::RunnerProject.find(params[:id])
|
|
|
|
runner = rp.runner
|
2022-03-09 09:08:34 +00:00
|
|
|
|
|
|
|
::Ci::Runners::UnassignRunnerService.new(rp, current_user).execute
|
2015-12-04 11:55:23 +00:00
|
|
|
|
2022-01-06 18:13:45 +00:00
|
|
|
redirect_to edit_admin_runner_url(runner), status: :found, notice: s_('Runners|Runner unassigned from project.')
|
2015-12-04 11:55:23 +00:00
|
|
|
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
|