summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-01-04 02:07:56 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-01-04 02:07:56 +0200
commit2d3b6375f38ac6e3a14fad93f243c258d74b0331 (patch)
tree66e84096d18f0775970a6e27d93eb72bf9688c6d
parent495deea7eb5aa4c8b8e2365a351d1c2eedf1010a (diff)
downloadgitlab-ce-2d3b6375f38ac6e3a14fad93f243c258d74b0331.tar.gz
hooks scaffold
-rw-r--r--app/assets/stylesheets/projects.css.scss7
-rw-r--r--app/controllers/hooks_controller.rb5
-rw-r--r--app/helpers/projects_helper.rb3
-rw-r--r--app/views/hooks/index.html.haml8
-rw-r--r--app/views/hooks/new.html.haml13
-rw-r--r--app/views/hooks/show.html.haml7
-rw-r--r--app/views/repositories/_head.html.haml2
-rw-r--r--config/routes.rb2
8 files changed, 40 insertions, 7 deletions
diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss
index 316ef033e28..63b15bae40f 100644
--- a/app/assets/stylesheets/projects.css.scss
+++ b/app/assets/stylesheets/projects.css.scss
@@ -181,6 +181,13 @@ input.ssh_project_url {
}
}
+.text_field {
+ width:400px;
+ padding:8px;
+ font-size:14px;
+ @include round-borders-all(4px);
+}
+
.input_button {
padding:8px;
font-size:14px;
diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb
index 70516dacf72..9205a6a6f67 100644
--- a/app/controllers/hooks_controller.rb
+++ b/app/controllers/hooks_controller.rb
@@ -20,13 +20,12 @@ class HooksController < ApplicationController
def create
@hook = @project.web_hooks.new(params[:hook])
- @hook.author = current_user
@hook.save
if @hook.valid?
- redirect_to [@project, @hook]
+ redirect_to project_hook_path(@project, @hook)
else
- respond_with(@hook)
+ render :new
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 902d278019c..57786338ceb 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -35,7 +35,8 @@ module ProjectsHelper
end
def repository_tab_class
- if controller.controller_name == "repositories"
+ if controller.controller_name == "repositories" ||
+ controller.controller_name == "hooks"
"current"
end
end
diff --git a/app/views/hooks/index.html.haml b/app/views/hooks/index.html.haml
index 956367393cb..b0795ad4b2f 100644
--- a/app/views/hooks/index.html.haml
+++ b/app/views/hooks/index.html.haml
@@ -1,10 +1,16 @@
= render "repositories/head"
+.right= link_to "Add new", new_project_hook_path(@project), :class => "grey-button append-bottom-10"
- unless @hooks.empty?
%div.update-data.ui-box.ui-box-small
.data
- @hooks.each do |hook|
- %a.update-item{:href => project_hooks_path(@project, hook)}
+ %a.update-item{:href => project_hook_path(@project, hook)}
%span.update-title{:style => "margin-bottom:0px;"}
= hook.url
+ %span.update-author.right
+ Added
+ = time_ago_in_words(hook.created_at)
+ ago
- else
%h3 No hooks
+
diff --git a/app/views/hooks/new.html.haml b/app/views/hooks/new.html.haml
new file mode 100644
index 00000000000..8078aefa503
--- /dev/null
+++ b/app/views/hooks/new.html.haml
@@ -0,0 +1,13 @@
+= render "repositories/head"
+= form_for [@project, @hook], :as => :hook, :url => project_hooks_path(@project) do |f|
+ -if @hook.errors.any?
+ %ul
+ - @hook.errors.full_messages.each do |msg|
+ %li= msg
+ = f.label :url, "URL:"
+ = f.text_field :url, :class => "text_field"
+ .clear
+ %br
+ .merge-tabs
+ = f.submit "Save", :class => "grey-button"
+
diff --git a/app/views/hooks/show.html.haml b/app/views/hooks/show.html.haml
new file mode 100644
index 00000000000..56b5fa9d3a1
--- /dev/null
+++ b/app/views/hooks/show.html.haml
@@ -0,0 +1,7 @@
+= render "repositories/head"
+= debug @hook
+
+- if can? current_user, :admin_project, @project
+ .merge-tabs
+ .right
+ = link_to 'Remove', project_hook_path(@project, @hook), :confirm => 'Are you sure?', :method => :delete, :class => "red-button"
diff --git a/app/views/repositories/_head.html.haml b/app/views/repositories/_head.html.haml
index c22286ec094..7ada9ff7798 100644
--- a/app/views/repositories/_head.html.haml
+++ b/app/views/repositories/_head.html.haml
@@ -8,7 +8,7 @@
= link_to tags_project_repository_path(@project), :class => "tab #{'active' if current_page?(tags_project_repository_path(@project)) }" do
%span
Tags
- -#= link_to "#", :class => "tab" do
+ = link_to project_hooks_path, :class => "tab #{'active' if controller.controller_name == "hooks" }" do
%span
Hooks
-#= link_to "#", :class => "tab" do
diff --git a/config/routes.rb b/config/routes.rb
index 416ea6a9498..5f129c904d0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -84,8 +84,8 @@ Gitlab::Application.routes.draw do
end
end
- resources :hooks, :only => [:index, :new, :create, :destroy, :show]
resources :snippets
+ resources :hooks, :only => [:index, :new, :create, :destroy, :show]
resources :commits
resources :team_members
resources :issues do