Commit 2d3b6375f38ac6e3a14fad93f243c258d74b0331
1 parent
495deea7
Exists in
master
and in
4 other branches
hooks scaffold
Showing
8 changed files
with
40 additions
and
7 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
| @@ -181,6 +181,13 @@ input.ssh_project_url { | @@ -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 | .input_button { | 191 | .input_button { |
| 185 | padding:8px; | 192 | padding:8px; |
| 186 | font-size:14px; | 193 | font-size:14px; |
app/controllers/hooks_controller.rb
| @@ -20,13 +20,12 @@ class HooksController < ApplicationController | @@ -20,13 +20,12 @@ class HooksController < ApplicationController | ||
| 20 | 20 | ||
| 21 | def create | 21 | def create |
| 22 | @hook = @project.web_hooks.new(params[:hook]) | 22 | @hook = @project.web_hooks.new(params[:hook]) |
| 23 | - @hook.author = current_user | ||
| 24 | @hook.save | 23 | @hook.save |
| 25 | 24 | ||
| 26 | if @hook.valid? | 25 | if @hook.valid? |
| 27 | - redirect_to [@project, @hook] | 26 | + redirect_to project_hook_path(@project, @hook) |
| 28 | else | 27 | else |
| 29 | - respond_with(@hook) | 28 | + render :new |
| 30 | end | 29 | end |
| 31 | end | 30 | end |
| 32 | 31 |
app/helpers/projects_helper.rb
| @@ -35,7 +35,8 @@ module ProjectsHelper | @@ -35,7 +35,8 @@ module ProjectsHelper | ||
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | def repository_tab_class | 37 | def repository_tab_class |
| 38 | - if controller.controller_name == "repositories" | 38 | + if controller.controller_name == "repositories" || |
| 39 | + controller.controller_name == "hooks" | ||
| 39 | "current" | 40 | "current" |
| 40 | end | 41 | end |
| 41 | end | 42 | end |
app/views/hooks/index.html.haml
| 1 | = render "repositories/head" | 1 | = render "repositories/head" |
| 2 | +.right= link_to "Add new", new_project_hook_path(@project), :class => "grey-button append-bottom-10" | ||
| 2 | - unless @hooks.empty? | 3 | - unless @hooks.empty? |
| 3 | %div.update-data.ui-box.ui-box-small | 4 | %div.update-data.ui-box.ui-box-small |
| 4 | .data | 5 | .data |
| 5 | - @hooks.each do |hook| | 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 | %span.update-title{:style => "margin-bottom:0px;"} | 8 | %span.update-title{:style => "margin-bottom:0px;"} |
| 8 | = hook.url | 9 | = hook.url |
| 10 | + %span.update-author.right | ||
| 11 | + Added | ||
| 12 | + = time_ago_in_words(hook.created_at) | ||
| 13 | + ago | ||
| 9 | - else | 14 | - else |
| 10 | %h3 No hooks | 15 | %h3 No hooks |
| 16 | + |
| @@ -0,0 +1,13 @@ | @@ -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/repositories/_head.html.haml
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | = link_to tags_project_repository_path(@project), :class => "tab #{'active' if current_page?(tags_project_repository_path(@project)) }" do | 8 | = link_to tags_project_repository_path(@project), :class => "tab #{'active' if current_page?(tags_project_repository_path(@project)) }" do |
| 9 | %span | 9 | %span |
| 10 | Tags | 10 | Tags |
| 11 | - -#= link_to "#", :class => "tab" do | 11 | + = link_to project_hooks_path, :class => "tab #{'active' if controller.controller_name == "hooks" }" do |
| 12 | %span | 12 | %span |
| 13 | Hooks | 13 | Hooks |
| 14 | -#= link_to "#", :class => "tab" do | 14 | -#= link_to "#", :class => "tab" do |
config/routes.rb
| @@ -84,8 +84,8 @@ Gitlab::Application.routes.draw do | @@ -84,8 +84,8 @@ Gitlab::Application.routes.draw do | ||
| 84 | end | 84 | end |
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | - resources :hooks, :only => [:index, :new, :create, :destroy, :show] | ||
| 88 | resources :snippets | 87 | resources :snippets |
| 88 | + resources :hooks, :only => [:index, :new, :create, :destroy, :show] | ||
| 89 | resources :commits | 89 | resources :commits |
| 90 | resources :team_members | 90 | resources :team_members |
| 91 | resources :issues do | 91 | resources :issues do |