Commit 0687ecb66d52868db27ef89a18e4109abc70b935

Authored by Dmitriy Zaporozhets
1 parent 169b4ce0

UI with event types for Project WebHooks

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/stylesheets/gitlab_bootstrap/forms.scss
@@ -13,6 +13,13 @@ form { @@ -13,6 +13,13 @@ form {
13 margin-top: 1px !important; 13 margin-top: 1px !important;
14 } 14 }
15 } 15 }
  16 +
  17 + &.list-label {
  18 + float: none;
  19 + padding: 0 !important;
  20 + margin: 0;
  21 + text-align: left;
  22 + }
16 } 23 }
17 } 24 }
18 25
app/models/project_hook.rb
@@ -13,4 +13,6 @@ @@ -13,4 +13,6 @@
13 13
14 class ProjectHook < WebHook 14 class ProjectHook < WebHook
15 belongs_to :project 15 belongs_to :project
  16 +
  17 + attr_accessible :push_events, :issues_events, :merge_requests_events
16 end 18 end
app/views/projects/hooks/index.html.haml
1 %h3.page-title 1 %h3.page-title
2 - Post-receive hooks 2 + Web hooks
3 3
4 %p.light 4 %p.light
5 - #{link_to "Post-receive hooks ", help_web_hooks_path, class: "vlink"} can be  
6 - used for binding events when someone pushes to the repository. 5 + #{link_to "Web hooks ", help_web_hooks_path, class: "vlink"} can be
  6 + used for binding events when something happends to the the project.
7 7
8 %hr.clearfix 8 %hr.clearfix
9 9
@@ -13,23 +13,50 @@ @@ -13,23 +13,50 @@
13 - @hook.errors.full_messages.each do |msg| 13 - @hook.errors.full_messages.each do |msg|
14 %p= msg 14 %p= msg
15 .control-group 15 .control-group
16 - = f.label :url, "URL:" 16 + = f.label :url, "URL"
17 .controls 17 .controls
18 = f.text_field :url, class: "text_field input-xxlarge input-xpadding", placeholder: 'http://example.com/trigger-ci.json' 18 = f.text_field :url, class: "text_field input-xxlarge input-xpadding", placeholder: 'http://example.com/trigger-ci.json'
19 &nbsp; 19 &nbsp;
20 = f.submit "Add Web Hook", class: "btn btn-create" 20 = f.submit "Add Web Hook", class: "btn btn-create"
  21 + .control-group
  22 + = f.label :url, "Trigger"
  23 + .controls
  24 + %div
  25 + = f.check_box :push_events, class: 'pull-left'
  26 + .prepend-left-20
  27 + = f.label :push_events, class: 'list-label' do
  28 + %strong Push events
  29 + %p.light
  30 + This url will be triggered in case of push to repository
  31 + %div
  32 + = f.check_box :issues_events, class: 'pull-left'
  33 + .prepend-left-20
  34 + = f.label :issues_events, class: 'list-label' do
  35 + %strong Issues events
  36 + %p.light
  37 + This url will be triggered for created issues
  38 + %div
  39 + = f.check_box :merge_requests_events, class: 'pull-left'
  40 + .prepend-left-20
  41 + = f.label :merge_requests_events, class: 'list-label' do
  42 + %strong Merge Request events
  43 + %p.light
  44 + This url will be triggered for created merge requests
21 %hr 45 %hr
22 46
23 -if @hooks.any? 47 -if @hooks.any?
24 .ui-box 48 .ui-box
25 .title 49 .title
26 - Hooks (#{@hooks.count}) 50 + Web Hooks (#{@hooks.count})
27 %ul.well-list 51 %ul.well-list
28 - @hooks.each do |hook| 52 - @hooks.each do |hook|
29 %li 53 %li
30 - %span.badge.badge-info POST  
31 - &rarr;  
32 - %span.monospace= hook.url  
33 .pull-right 54 .pull-right
34 = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small grouped" 55 = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small grouped"
35 = link_to 'Remove', project_hook_path(@project, hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small grouped" 56 = link_to 'Remove', project_hook_path(@project, hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small grouped"
  57 + .clearfix
  58 + %span.monospace= hook.url
  59 + %p
  60 + - %w(push_events issues_events merge_requests_events).each do |trigger|
  61 + - if hook.send(trigger)
  62 + %span.label.label-gray= trigger.titleize