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
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
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 | + | ... | ... |
... | ... | @@ -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 | 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 | ... | ... |