summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-12 22:42:13 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-12 22:42:13 -0800
commit05b4a93126b9fb3b0846ff1cc44c65bc360aec26 (patch)
treea3d6a8bb42a40d32e361b61cfe98fe2ab9ee0505
parentf2ccfd9acf2af43c2ae4d700cc9ea0cf69df57fc (diff)
downloadgitlab-ci-05b4a93126b9fb3b0846ff1cc44c65bc360aec26.tar.gz
Set runner tags via admin area
-rw-r--r--app/assets/stylesheets/application.scss1
-rw-r--r--app/assets/stylesheets/sections/runners.scss12
-rw-r--r--app/controllers/admin/runners_controller.rb13
-rw-r--r--app/views/admin/runners/_runner.html.haml15
-rw-r--r--app/views/admin/runners/assign_all.js.haml2
-rw-r--r--app/views/admin/runners/index.html.haml3
-rw-r--r--app/views/admin/runners/show.html.haml43
-rw-r--r--app/views/runners/index.html.haml2
-rw-r--r--spec/features/admin/runners_spec.rb2
9 files changed, 66 insertions, 27 deletions
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index b0cf649..1dd5da5 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -43,6 +43,7 @@
@import "sections/projects.scss";
@import "sections/builds.scss";
@import "sections/login.scss";
+@import "sections/runners.scss";
/*
* NProgress
diff --git a/app/assets/stylesheets/sections/runners.scss b/app/assets/stylesheets/sections/runners.scss
new file mode 100644
index 0000000..abf450d
--- /dev/null
+++ b/app/assets/stylesheets/sections/runners.scss
@@ -0,0 +1,12 @@
+.runner-state {
+ padding: 6px 12px;
+ margin-right: 10px;
+ color: #FFF;
+
+ &.runner-state-shared {
+ background: #32b186;
+ }
+ &.runner-state-specific {
+ background: #3286b1;
+ }
+}
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 3ef4973..ad6c610 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -13,11 +13,11 @@ class Admin::RunnersController < Admin::ApplicationController
end
def update
- @runner.update_attributes(description: params[:runner][:description])
+ @runner.update_attributes(params[:runner])
respond_to do |format|
format.js
- format.html { redirect_to admin_runners_path }
+ format.html { redirect_to admin_runner_path(@runner) }
end
end
@@ -28,12 +28,11 @@ class Admin::RunnersController < Admin::ApplicationController
end
def assign_all
- Project.unassigned(@runner).all.each { |project| @runner.assign_to(project, current_user) }
-
- respond_to do |format|
- format.js
- format.html { redirect_to admin_runners_path, notice: "Runner was assigned to all projects" }
+ Project.unassigned(@runner).all.each do |project|
+ @runner.assign_to(project, current_user)
end
+
+ redirect_to admin_runner_path(@runner), notice: "Runner was assigned to all projects"
end
private
diff --git a/app/views/admin/runners/_runner.html.haml b/app/views/admin/runners/_runner.html.haml
index f8593ca..29c3dcd 100644
--- a/app/views/admin/runners/_runner.html.haml
+++ b/app/views/admin/runners/_runner.html.haml
@@ -9,7 +9,7 @@
%td
= link_to admin_runner_path(runner) do
- = runner.token
+ = runner.short_sha
%td
.runner-description
= runner.description
@@ -26,15 +26,16 @@
- else
= runner.projects.count
%td
- %span.label.label-success
- #{runner.builds.success.count}
- %span /
- %span.label.label-danger
- #{runner.builds.failed.count}
+ #{runner.builds.count}
+ %td
+ - runner.tag_list.each do |tag|
+ %span.label.label-primary
+ = tag
%td
#{time_ago_in_words(runner.created_at)} ago
%td
.pull-right
- = link_to 'Assign to all', assign_all_admin_runner_path(runner), class: 'btn btn-small assign-all-runner', title: 'Assign runner to all projects', method: :put, remote: true
+ = link_to 'Edit', admin_runner_path(runner), class: 'btn btn-small'
+ &nbsp;
= link_to 'Remove', [:admin, runner], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-small'
diff --git a/app/views/admin/runners/assign_all.js.haml b/app/views/admin/runners/assign_all.js.haml
deleted file mode 100644
index 2b7d306..0000000
--- a/app/views/admin/runners/assign_all.js.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-:plain
- $("#runner_#{@runner.id}").replaceWith("#{escape_javascript(render(@runner))}")
diff --git a/app/views/admin/runners/index.html.haml b/app/views/admin/runners/index.html.haml
index 574233a..fd9849e 100644
--- a/app/views/admin/runners/index.html.haml
+++ b/app/views/admin/runners/index.html.haml
@@ -38,7 +38,8 @@
%th Runner token
%th Description
%th Projects
- %th Builds Stats
+ %th Builds
+ %th Tags
%th Registered
%th
diff --git a/app/views/admin/runners/show.html.haml b/app/views/admin/runners/show.html.haml
index 8da6b5f..6ea987a 100644
--- a/app/views/admin/runners/show.html.haml
+++ b/app/views/admin/runners/show.html.haml
@@ -1,11 +1,11 @@
-%h4.page-title
- Runner: #{@runner.token}
-
-%p.light= @runner.description
-%p
- = link_to admin_runners_path do
- &larr; Back to runners list
-%hr
+%h4
+ - if @runner.shared?
+ %span.runner-state.runner-state-shared
+ Shared
+ - else
+ %span.runner-state.runner-state-specific
+ Specific
+ Runner ##{@runner.id}
- if @runner.shared?
.bs-callout.bs-callout-success
@@ -15,6 +15,27 @@
.bs-callout.bs-callout-info
%h4 This runner will process build only from ASSIGNED projects
%p If you want runner to build unassigned projects you just need to disable all assignee projects
+%hr
+= form_for @runner, url: admin_runner_path(@runner), html: { class: 'form-horizontal' } do |f|
+ .form-group
+ = label_tag :token, class: 'control-label' do
+ Token
+ .col-sm-10
+ = f.text_field :token, class: 'form-control', readonly: true
+ .form-group
+ = label_tag :description, class: 'control-label' do
+ Description
+ .col-sm-10
+ = f.text_field :description, class: 'form-control'
+ .form-group
+ = label_tag :tag_list, class: 'control-label' do
+ Tags
+ .col-sm-10
+ = f.text_field :tag_list, class: 'form-control'
+ .help-block You can setup jobs to only use runners with specific tags
+ .form-actions
+ = f.submit 'Save', class: 'btn btn-save'
+
.row
.col-md-6
%h4 Restrict projects for this runner
@@ -39,6 +60,12 @@
%tr
%th Project
%th
+ .pull-right
+ = link_to 'Assign to all', assign_all_admin_runner_path(@runner),
+ class: 'btn btn-small assign-all-runner',
+ title: 'Assign runner to all projects',
+ method: :put
+
- @projects.each do |project|
%tr
%td
diff --git a/app/views/runners/index.html.haml b/app/views/runners/index.html.haml
index af8c3fc..14227b1 100644
--- a/app/views/runners/index.html.haml
+++ b/app/views/runners/index.html.haml
@@ -5,7 +5,7 @@
Runners can be placed on separate users, servers, and even on your local machine.
.bs-callout
- %h4 How to setup new project runner
+ %h4 How to setup a new project specific runner
%br
%p
diff --git a/spec/features/admin/runners_spec.rb b/spec/features/admin/runners_spec.rb
index f58eda5..25aabb5 100644
--- a/spec/features/admin/runners_spec.rb
+++ b/spec/features/admin/runners_spec.rb
@@ -22,6 +22,6 @@ describe "Admin Runners" do
visit admin_runner_path(runner)
end
- it { page.should have_content runner.token }
+ it { find_field('runner_token').value.should eq runner.token }
end
end