summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-23 10:02:42 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-23 10:02:42 +0000
commit08a484e2b179a0f4a75df3cda4d713dee6f82725 (patch)
tree27349365b76336fe6c78083e5545198866127343 /app/controllers
parent5be8be7d1965476ced2841dd4c3592ba8db84423 (diff)
parentedf9620bfb1ceca4d90303028012b7fa6672fe9f (diff)
downloadgitlab-ci-08a484e2b179a0f4a75df3cda4d713dee6f82725.tar.gz
Merge branch 'project-runners-page' into 'master'
Improved runner page for project Tasks: - [x] Ability to add runner to several projects - [x] Render runner status (online, offline, disabled) - [x] Two column style of page: specific and shared runners - [x] Toggle shared runners for project - [x] Fix tests - [x] Write tests for new functionality - [x] Remove runner instead disabling if it is last project for this runner - [x] Cleanup and refactor code - [x] Improve query for authorised runners (reject duplicates) - [x] Improve UI based on https://dev.gitlab.org/gitlab/gitlab-ci/issues/185#note_41582 See merge request !61
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects_controller.rb10
-rw-r--r--app/controllers/runner_projects_controller.rb32
-rw-r--r--app/controllers/runners_controller.rb6
3 files changed, 44 insertions, 4 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index dfeb091..f10d42b 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -2,9 +2,9 @@ class ProjectsController < ApplicationController
PROJECTS_PER_PAGE = 100
before_filter :authenticate_user!, except: [:build, :badge, :index, :show]
- before_filter :project, only: [:build, :integration, :show, :badge, :edit, :update, :destroy]
+ before_filter :project, only: [:build, :integration, :show, :badge, :edit, :update, :destroy, :toggle_shared_runners]
before_filter :authorize_access_project!, except: [:build, :gitlab, :badge, :index, :show, :new, :create]
- before_filter :authorize_manage_project!, only: [:edit, :integration, :update, :destroy]
+ before_filter :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners]
before_filter :authenticate_token!, only: [:build]
before_filter :no_cache, only: [:badge]
protect_from_forgery except: :build
@@ -65,7 +65,6 @@ class ProjectsController < ApplicationController
def update
if project.update_attributes(project_params)
-
EventService.new.change_project_settings(current_user, project)
redirect_to :back, notice: 'Project was successfully updated.'
@@ -101,6 +100,11 @@ class ProjectsController < ApplicationController
send_file image.path, filename: image.name, disposition: 'inline'
end
+ def toggle_shared_runners
+ project.toggle!(:shared_runners_enabled)
+ redirect_to :back
+ end
+
protected
def project
diff --git a/app/controllers/runner_projects_controller.rb b/app/controllers/runner_projects_controller.rb
new file mode 100644
index 0000000..b27f888
--- /dev/null
+++ b/app/controllers/runner_projects_controller.rb
@@ -0,0 +1,32 @@
+class RunnerProjectsController < ApplicationController
+ before_filter :authenticate_user!
+ before_filter :project
+ before_filter :authorize_manage_project!
+
+ layout 'project'
+
+ def create
+ @runner = Runner.find(params[:runner_project][:runner_id])
+
+ return head(403) unless current_user.authorized_runners.include?(@runner)
+
+ if @runner.assign_to(project, current_user)
+ redirect_to project_runners_path(project)
+ else
+ redirect_to project_runners_path(project), alert: 'Failed adding runner to project'
+ end
+ end
+
+ def destroy
+ runner_project = project.runner_projects.find(params[:id])
+ runner_project.destroy
+
+ redirect_to project_runners_path(project)
+ end
+
+ private
+
+ def project
+ @project ||= Project.find(params[:project_id])
+ end
+end
diff --git a/app/controllers/runners_controller.rb b/app/controllers/runners_controller.rb
index 02465d6..12578b3 100644
--- a/app/controllers/runners_controller.rb
+++ b/app/controllers/runners_controller.rb
@@ -8,7 +8,11 @@ class RunnersController < ApplicationController
layout 'project'
def index
- @runners = @project.runners.order('id DESC').page(params[:page]).per(20)
+ @runners = @project.runners.order('id DESC')
+ @specific_runners = current_user.authorized_runners.
+ where.not(id: @runners).order('runners.id DESC').page(params[:page]).per(20)
+ @shared_runners = Runner.shared.active
+ @shared_runners_count = @shared_runners.count(:all)
end
def edit