Hooks UI improved, Request tests added
This commit is contained in:
parent
7b7547aa00
commit
28cb43135c
10 changed files with 125 additions and 85 deletions
|
@ -465,3 +465,8 @@ table.admin-table {
|
|||
background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf);
|
||||
}
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,3 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.new_project {
|
||||
.field_with_errors {
|
||||
display:inline;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,8 @@ class HooksController < ApplicationController
|
|||
respond_to :html
|
||||
|
||||
def index
|
||||
@hooks = @project.web_hooks
|
||||
end
|
||||
|
||||
def new
|
||||
@hook = @project.web_hooks.new
|
||||
@hooks = @project.web_hooks.all
|
||||
@hook = WebHook.new
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -23,25 +20,22 @@ class HooksController < ApplicationController
|
|||
@hook.save
|
||||
|
||||
if @hook.valid?
|
||||
redirect_to project_hook_path(@project, @hook)
|
||||
redirect_to project_hooks_path(@project)
|
||||
else
|
||||
render :new
|
||||
@hooks = @project.web_hooks.all
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
def test
|
||||
@hook = @project.web_hooks.find(params[:id])
|
||||
commits = @project.commits(@project.default_branch, nil, 3)
|
||||
data = @project.web_hook_data(commits.last.id, commits.first.id, "refs/heads/#{@project.default_branch}", current_user.keys.first.identifier)
|
||||
data = @project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{@project.default_branch}", current_user)
|
||||
@hook.execute(data)
|
||||
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
def show
|
||||
@hook = @project.web_hooks.find(params[:id])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@hook = @project.web_hooks.find(params[:id])
|
||||
@hook.destroy
|
||||
|
|
|
@ -1,19 +1,43 @@
|
|||
= render "projects/project_head"
|
||||
|
||||
- if can? current_user, :admin_project, @project
|
||||
.alert-message.block-message
|
||||
Post receive hooks for binding events when someone push to repository.
|
||||
= link_to new_project_hook_path(@project), :class => "btn small", :title => "New Web Hook" do
|
||||
Add Post Receive Hook
|
||||
.alert.alert-info
|
||||
%span
|
||||
Post receive hooks for binding events when someone push to repository.
|
||||
%br
|
||||
Read more about web hooks
|
||||
%strong #{link_to "here", help_web_hooks_path, :class => "vlink"}
|
||||
|
||||
%p Read more about web hooks #{link_to "here", help_web_hooks_path, :class => "vlink"}
|
||||
= form_for [@project, @hook], :as => :hook, :url => project_hooks_path(@project) do |f|
|
||||
-if @hook.errors.any?
|
||||
.alert-message.block-message.error
|
||||
- @hook.errors.full_messages.each do |msg|
|
||||
%p= msg
|
||||
.clearfix
|
||||
= f.label :url, "URL:"
|
||||
.input
|
||||
= f.text_field :url, :class => "text_field xxlarge"
|
||||
|
||||
= f.submit "Add Web Hook", :class => "btn primary"
|
||||
%hr
|
||||
|
||||
-if @hooks.any?
|
||||
%table
|
||||
%h3
|
||||
Hooks
|
||||
%small (#{@hooks.count})
|
||||
%br
|
||||
%table.admin-table
|
||||
%tr
|
||||
%th URL
|
||||
%th Method
|
||||
%th
|
||||
- @hooks.each do |hook|
|
||||
%tr
|
||||
%td
|
||||
= link_to project_hook_path(@project, hook) do
|
||||
= hook.url
|
||||
%strong= hook.url
|
||||
= link_to 'Test Hook', test_project_hook_path(@project, hook), :class => "btn small right"
|
||||
%td POST
|
||||
%td
|
||||
= link_to 'Remove', project_hook_path(@project, hook), :confirm => 'Are you sure?', :method => :delete, :class => "danger btn small right"
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
= 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
|
||||
.clearfix
|
||||
= f.label :url, "URL:"
|
||||
.input= f.text_field :url, :class => "text_field"
|
||||
.actions
|
||||
= f.submit "Save", :class => "btn"
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
= render "repositories/head"
|
||||
%pre= @hook.url
|
||||
|
||||
- if can? current_user, :admin_project, @project
|
||||
.actions
|
||||
= link_to 'Test Hook', test_project_hook_path(@project, @hook), :class => "btn"
|
||||
= link_to 'Remove', project_hook_path(@project, @hook), :confirm => 'Are you sure?', :method => :delete, :class => "danger btn"
|
Loading…
Add table
Add a link
Reference in a new issue