summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-12 16:17:15 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-12 16:17:15 -0800
commitc8ada3322b211d13fb26adb2ceac054aced5ee6f (patch)
tree4c7b376baf62d7dae6373ca623011e742f3cce5c
parent8aaab1477240a2b4158e5145b881509e2a99d021 (diff)
downloadgitlab-ci-c8ada3322b211d13fb26adb2ceac054aced5ee6f.tar.gz
Runner edit via project settings. Small cleanup for runner index page
-rw-r--r--app/assets/stylesheets/generic/common.scss7
-rw-r--r--app/controllers/admin/builds_controller.rb2
-rw-r--r--app/controllers/admin/runner_projects_controller.rb1
-rw-r--r--app/controllers/admin/runners_controller.rb1
-rw-r--r--app/controllers/runners_controller.rb23
-rw-r--r--app/models/runner.rb4
-rw-r--r--app/views/jobs/index.html.haml4
-rw-r--r--app/views/runners/_runner.html.haml17
-rw-r--r--app/views/runners/edit.html.haml20
-rw-r--r--app/views/runners/index.html.haml32
-rw-r--r--config/routes.rb2
11 files changed, 77 insertions, 36 deletions
diff --git a/app/assets/stylesheets/generic/common.scss b/app/assets/stylesheets/generic/common.scss
index eda5cf6..16ad7b6 100644
--- a/app/assets/stylesheets/generic/common.scss
+++ b/app/assets/stylesheets/generic/common.scss
@@ -71,3 +71,10 @@
margin-top: 0px;
margin-bottom: 15px;
}
+
+.slead {
+ margin-bottom: 18px;
+ font-size: 16px;
+ font-weight: normal;
+ line-height: 1.4;
+}
diff --git a/app/controllers/admin/builds_controller.rb b/app/controllers/admin/builds_controller.rb
index 5b83efc..bc6bd8f 100644
--- a/app/controllers/admin/builds_controller.rb
+++ b/app/controllers/admin/builds_controller.rb
@@ -1,6 +1,4 @@
class Admin::BuildsController < Admin::ApplicationController
- before_filter :authenticate_user!
-
def index
@builds = Build.order('created_at DESC').page(params[:page]).per(30)
end
diff --git a/app/controllers/admin/runner_projects_controller.rb b/app/controllers/admin/runner_projects_controller.rb
index 73f35a0..f06ce09 100644
--- a/app/controllers/admin/runner_projects_controller.rb
+++ b/app/controllers/admin/runner_projects_controller.rb
@@ -1,5 +1,4 @@
class Admin::RunnerProjectsController < Admin::ApplicationController
- before_filter :authenticate_user!
layout 'project'
def index
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 4df7145..3ef4973 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -1,5 +1,4 @@
class Admin::RunnersController < Admin::ApplicationController
- before_filter :authenticate_user!
before_filter :runner, except: :index
def index
diff --git a/app/controllers/runners_controller.rb b/app/controllers/runners_controller.rb
index c1a732d..f061282 100644
--- a/app/controllers/runners_controller.rb
+++ b/app/controllers/runners_controller.rb
@@ -1,17 +1,30 @@
class RunnersController < ApplicationController
before_filter :authenticate_user!
before_filter :project
+ before_filter :set_runner, only: [:edit, :update, :destroy]
before_filter :authorize_access_project!
layout 'project'
def index
- @runners = @project.runners.page(params[:page]).per(20)
+ @runners = @project.runners.order('id DESC').page(params[:page]).per(20)
end
- def destroy
- @runner = @project.runners.find(params[:id])
+ def edit
+ end
+
+ def update
+ runner_params = params[:runner]
+ runner_params.delete(:token)
+ if @runner.update_attributes(runner_params)
+ redirect_to edit_project_runner_path(@project, @runner), notice: 'Runner was successfully updated.'
+ else
+ redirect_to edit_project_runner_path(@project, @runner), alert: 'Runner was not updated.'
+ end
+ end
+
+ def destroy
if @runner.only_for?(@project)
@runner.destroy
end
@@ -24,4 +37,8 @@ class RunnersController < ApplicationController
def project
@project = Project.find(params[:project_id])
end
+
+ def set_runner
+ @runner ||= @project.runners.find(params[:id])
+ end
end
diff --git a/app/models/runner.rb b/app/models/runner.rb
index add411b..d252a39 100644
--- a/app/models/runner.rb
+++ b/app/models/runner.rb
@@ -44,4 +44,8 @@ class Runner < ActiveRecord::Base
def only_for?(project)
projects == [project]
end
+
+ def short_sha
+ token[0...10]
+ end
end
diff --git a/app/views/jobs/index.html.haml b/app/views/jobs/index.html.haml
index 75fbad6..7622c96 100644
--- a/app/views/jobs/index.html.haml
+++ b/app/views/jobs/index.html.haml
@@ -1,5 +1,5 @@
-%h3.project-title Jobs
-%p.light Jobs are basically tasks you want CI to run on push
+%p.slead
+ Jobs are scripts you want CI to run on each push to repository
%hr
= nested_form_for @project, html: { class: 'form-horizontal' } do |f|
diff --git a/app/views/runners/_runner.html.haml b/app/views/runners/_runner.html.haml
index a32c36d..8be67b6 100644
--- a/app/views/runners/_runner.html.haml
+++ b/app/views/runners/_runner.html.haml
@@ -1,25 +1,20 @@
%tr{id: dom_id(runner)}
%td
- = runner.id
+ %strong ##{runner.id}
%td
- = runner.token.to_s
+ = runner.short_sha
%td
.runner-description
= runner.description
- %span (#{link_to 'edit', '#', class: 'edit-runner-link'})
- .runner-description-form.hide
- = form_for [:admin, runner], remote: true, html: { class: 'form-inline' } do |f|
- .form-group
- = f.text_field :description, class: 'form-control'
- = f.submit 'Save', class: 'btn'
- %span (#{link_to 'cancel', '#', class: 'cancel'})
%td
- if build = runner.builds.last
= link_to "##{build.id}", [build.project, build]
%td
#{time_ago_in_words(runner.created_at)} ago
%td
- - if runner.only_for?(@project)
- .pull-right
+ .pull-right
+ = link_to 'Edit', edit_project_runner_path(@project, runner), class: 'btn btn-small'
+ &nbsp;
+ - if runner.only_for?(@project)
= link_to 'Remove', [@project, runner], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-small'
diff --git a/app/views/runners/edit.html.haml b/app/views/runners/edit.html.haml
new file mode 100644
index 0000000..a7b4d2f
--- /dev/null
+++ b/app/views/runners/edit.html.haml
@@ -0,0 +1,20 @@
+%h4 Runner ##{@runner.id}
+%hr
+= form_for [@project, @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 :labels, class: 'control-label' do
+ Description
+ .col-sm-10
+ = f.text_field :labels, class: 'form-control'
+ .form-actions
+ = f.submit 'Save', class: 'btn btn-save'
diff --git a/app/views/runners/index.html.haml b/app/views/runners/index.html.haml
index e298905..692416a 100644
--- a/app/views/runners/index.html.haml
+++ b/app/views/runners/index.html.haml
@@ -1,21 +1,23 @@
-%h3.project-title
- Project specific runners
-
- .pull-right
- %small
- = pluralize(@runners.total_count, 'runner')
-%hr
-%p.lead
- %span To register new runner you should enter the following registration token. With this token the runner will request a unique runner token and use that for future communication.
- %code #{@project.token}
+%p.slead
+ A 'runner' is a process which runs a build.
+ You can setup as many runners as you need.
+ %br
+ Runners can be placed on separate users, servers, and even on your local machine.
.bs-callout
+ %h4 How to setup new project runner
+
+ %br
+ %p
+ 1. Install GitLab Runner software.
+ Checkout #{link_to 'runner repository', 'https://gitlab.com/gitlab-org/gitlab-ci-runner/blob/master/README.md', target: '_blank'} to find out how install one
+
+ %p
+ 2. Use the following registration token during setup:
+ %code #{@project.token}
%p
- A 'runner' is a process which runs a build.
- You can setup as many runners as you need.
- %br
- Runners can be placed on separate users, servers, and even on your local machine.
- %br
+ 3. Start runner!
+
%table.table
%thead
diff --git a/config/routes.rb b/config/routes.rb
index 234dd0a..9233892 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -40,7 +40,7 @@ GitlabCi::Application.routes.draw do
end
end
- resources :runners, only: [:index, :destroy]
+ resources :runners, only: [:index, :edit, :update, :destroy]
resources :jobs, only: [:index]
end