Commit 2d3b6375f38ac6e3a14fad93f243c258d74b0331

Authored by Dmitriy Zaporozhets
1 parent 495deea7

hooks scaffold

app/assets/stylesheets/projects.css.scss
... ... @@ -181,6 +181,13 @@ input.ssh_project_url {
181 181 }
182 182 }
183 183  
  184 +.text_field {
  185 + width:400px;
  186 + padding:8px;
  187 + font-size:14px;
  188 + @include round-borders-all(4px);
  189 +}
  190 +
184 191 .input_button {
185 192 padding:8px;
186 193 font-size:14px;
... ...
app/controllers/hooks_controller.rb
... ... @@ -20,13 +20,12 @@ class HooksController < ApplicationController
20 20  
21 21 def create
22 22 @hook = @project.web_hooks.new(params[:hook])
23   - @hook.author = current_user
24 23 @hook.save
25 24  
26 25 if @hook.valid?
27   - redirect_to [@project, @hook]
  26 + redirect_to project_hook_path(@project, @hook)
28 27 else
29   - respond_with(@hook)
  28 + render :new
30 29 end
31 30 end
32 31  
... ...
app/helpers/projects_helper.rb
... ... @@ -35,7 +35,8 @@ module ProjectsHelper
35 35 end
36 36  
37 37 def repository_tab_class
38   - if controller.controller_name == "repositories"
  38 + if controller.controller_name == "repositories" ||
  39 + controller.controller_name == "hooks"
39 40 "current"
40 41 end
41 42 end
... ...
app/views/hooks/index.html.haml
1 1 = render "repositories/head"
  2 +.right= link_to "Add new", new_project_hook_path(@project), :class => "grey-button append-bottom-10"
2 3 - unless @hooks.empty?
3 4 %div.update-data.ui-box.ui-box-small
4 5 .data
5 6 - @hooks.each do |hook|
6   - %a.update-item{:href => project_hooks_path(@project, hook)}
  7 + %a.update-item{:href => project_hook_path(@project, hook)}
7 8 %span.update-title{:style => "margin-bottom:0px;"}
8 9 = hook.url
  10 + %span.update-author.right
  11 + Added
  12 + = time_ago_in_words(hook.created_at)
  13 + ago
9 14 - else
10 15 %h3 No hooks
  16 +
... ...
app/views/hooks/new.html.haml 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 += render "repositories/head"
  2 += form_for [@project, @hook], :as => :hook, :url => project_hooks_path(@project) do |f|
  3 + -if @hook.errors.any?
  4 + %ul
  5 + - @hook.errors.full_messages.each do |msg|
  6 + %li= msg
  7 + = f.label :url, "URL:"
  8 + = f.text_field :url, :class => "text_field"
  9 + .clear
  10 + %br
  11 + .merge-tabs
  12 + = f.submit "Save", :class => "grey-button"
  13 +
... ...
app/views/hooks/show.html.haml 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 += render "repositories/head"
  2 += debug @hook
  3 +
  4 +- if can? current_user, :admin_project, @project
  5 + .merge-tabs
  6 + .right
  7 + = link_to 'Remove', project_hook_path(@project, @hook), :confirm => 'Are you sure?', :method => :delete, :class => "red-button"
... ...
app/views/repositories/_head.html.haml
... ... @@ -8,7 +8,7 @@
8 8 = link_to tags_project_repository_path(@project), :class => "tab #{'active' if current_page?(tags_project_repository_path(@project)) }" do
9 9 %span
10 10 Tags
11   - -#= link_to "#", :class => "tab" do
  11 + = link_to project_hooks_path, :class => "tab #{'active' if controller.controller_name == "hooks" }" do
12 12 %span
13 13 Hooks
14 14 -#= link_to "#", :class => "tab" do
... ...
config/routes.rb
... ... @@ -84,8 +84,8 @@ Gitlab::Application.routes.draw do
84 84 end
85 85 end
86 86  
87   - resources :hooks, :only => [:index, :new, :create, :destroy, :show]
88 87 resources :snippets
  88 + resources :hooks, :only => [:index, :new, :create, :destroy, :show]
89 89 resources :commits
90 90 resources :team_members
91 91 resources :issues do
... ...