summaryrefslogtreecommitdiff
path: root/app/controllers/admin/runner_projects_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin/runner_projects_controller.rb')
-rw-r--r--app/controllers/admin/runner_projects_controller.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/controllers/admin/runner_projects_controller.rb b/app/controllers/admin/runner_projects_controller.rb
new file mode 100644
index 00000000000..20d621742f9
--- /dev/null
+++ b/app/controllers/admin/runner_projects_controller.rb
@@ -0,0 +1,35 @@
+class Admin::RunnerProjectsController < Admin::ApplicationController
+ before_action :project, only: [:create]
+
+ def index
+ @runner_projects = project.ci_runner_projects.all
+ @runner_project = project.ci_runner_projects.new
+ end
+
+ def create
+ @runner = Ci::Runner.find(params[:runner_project][:runner_id])
+
+ if @runner.assign_to(@project, current_user)
+ 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
+ @project = Project.find_with_namespace(
+ [params[:namespace_id], '/', params[:project_id]].join('')
+ )
+ @project || render_404
+ end
+end