Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
c3857842
Commit
c3857842
authored
Jul 12, 2012
by
Valeriy Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
System Hooks: CRUD has done
parent
65dc68b3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
141 additions
and
77 deletions
+141
-77
app/controllers/admin/hooks_controller.rb
app/controllers/admin/hooks_controller.rb
+39
-0
app/controllers/admin/mailer_controller.rb
app/controllers/admin/mailer_controller.rb
+0
-45
app/models/web_hook.rb
app/models/web_hook.rb
+0
-2
app/views/admin/hooks/_data_ex.html.erb
app/views/admin/hooks/_data_ex.html.erb
+45
-0
app/views/admin/hooks/index.html.haml
app/views/admin/hooks/index.html.haml
+39
-0
app/views/admin/mailer/preview.html.haml
app/views/admin/mailer/preview.html.haml
+0
-28
app/views/help/system_hooks.html.haml
app/views/help/system_hooks.html.haml
+13
-0
app/views/layouts/admin.html.haml
app/views/layouts/admin.html.haml
+1
-1
config/routes.rb
config/routes.rb
+4
-1
No files found.
app/controllers/admin/hooks_controller.rb
0 → 100644
View file @
c3857842
class
Admin::HooksController
<
ApplicationController
layout
"admin"
before_filter
:authenticate_user!
before_filter
:authenticate_admin!
def
index
@hooks
=
SystemHook
.
all
@hook
=
SystemHook
.
new
end
def
create
@hook
=
SystemHook
.
new
(
params
[
:hook
])
respond_to
do
|
format
|
if
@hook
.
save
format
.
html
{
redirect_to
admin_hooks_path
,
notice:
'Hook was successfully created.'
}
else
format
.
html
{
render
:index
}
end
end
end
def
destroy
@hook
=
SystemHook
.
find
(
params
[
:id
])
@hook
.
destroy
redirect_to
admin_hooks_path
end
def
test
@hook
=
@project
.
hooks
.
find
(
params
[
:id
])
commits
=
@project
.
commits
(
@project
.
default_branch
,
nil
,
3
)
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
end
app/controllers/admin/mailer_controller.rb
deleted
100644 → 0
View file @
65dc68b3
class
Admin::MailerController
<
ApplicationController
layout
"admin"
before_filter
:authenticate_user!
before_filter
:authenticate_admin!
def
preview
end
def
preview_note
@note
=
Note
.
first
@user
=
@note
.
author
@project
=
@note
.
project
case
params
[
:type
]
when
"Commit"
then
@commit
=
@project
.
commit
render
:file
=>
'notify/note_commit_email'
,
:layout
=>
'notify'
when
"Issue"
then
@issue
=
Issue
.
first
render
:file
=>
'notify/note_issue_email'
,
:layout
=>
'notify'
else
render
:file
=>
'notify/note_wall_email'
,
:layout
=>
'notify'
end
rescue
render
:text
=>
"Preview not available"
end
def
preview_user_new
@user
=
User
.
first
@password
=
"DHasJKDHAS!"
render
:file
=>
'notify/new_user_email'
,
:layout
=>
'notify'
rescue
render
:text
=>
"Preview not available"
end
def
preview_issue_new
@issue
=
Issue
.
first
@user
=
@issue
.
assignee
@project
=
@issue
.
project
render
:file
=>
'notify/new_issue_email'
,
:layout
=>
'notify'
rescue
render
:text
=>
"Preview not available"
end
end
app/models/web_hook.rb
View file @
c3857842
...
...
@@ -12,8 +12,6 @@ class WebHook < ActiveRecord::Base
def
execute
(
data
)
WebHook
.
post
(
url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
})
rescue
# There was a problem calling this web hook, let's forget about it.
end
end
# == Schema Information
...
...
app/views/admin/hooks/_data_ex.html.erb
0 → 100644
View file @
c3857842
<%
data_ex_str
=
<<
eos
{
:before => "95790bf891e76fee5e1747ab589903a6a1f80f22",
:after => "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
:ref => "refs/heads/master",
:user_id => 4,
:user_name => "John Smith",
:repository => {
:name => "Diaspora",
:url => "localhost/diaspora",
:description => "",
:homepage => "localhost/diaspora",
:private => true
},
:commits => [
[0] {
:id => "450d0de7532f8b663b9c5cce183b...",
:message => "Update Catalan translation to e38cb41.",
:timestamp => "2011-12-12T14:27:31+02:00",
:url => "http://localhost/diaspora/commits/450d0de7532f...",
:author => {
:name => "Jordi Mallach",
:email => "jordi@softcatala.org"
}
},
....
[3] {
:id => "da1560886d4f094c3e6c9ef40349...",
:message => "fixed readme",
:timestamp => "2012-01-03T23:36:29+02:00",
:url => "http://localhost/diaspora/commits/da1560886d...",
:author => {
:name => "gitlab dev user",
:email => "gitlabdev@dv6700.(none)"
}
}
],
total_commits_count => 3
}
eos
%>
<%
js_lexer
=
Pygments
::
Lexer
[
:js
]
%>
<%=
raw
js_lexer
.
highlight
(
data_ex_str
)
%>
app/views/admin/hooks/index.html.haml
0 → 100644
View file @
c3857842
.alert.alert-info
%span
Post receive hooks for binding events.
%br
Read more about system hooks
%strong
#{
link_to
"here"
,
help_system_hooks_path
,
:class
=>
"vlink"
}
=
form_for
@hook
,
:as
=>
:hook
,
:url
=>
admin_hooks_path
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 System Hook"
,
:class
=>
"btn primary"
%hr
-
if
@hooks
.
any?
%h3
Hooks
%small
(
#{
@hooks
.
count
}
)
%br
%table
.admin-table
%tr
%th
URL
%th
Method
%th
-
@hooks
.
each
do
|
hook
|
%tr
%td
=
link_to
admin_hook_path
(
hook
)
do
%strong
=
hook
.
url
=
link_to
'Test Hook'
,
admin_hook_test_path
(
hook
),
:class
=>
"btn small right"
%td
POST
%td
=
link_to
'Remove'
,
admin_hook_path
(
hook
),
:confirm
=>
'Are you sure?'
,
:method
=>
:delete
,
:class
=>
"danger btn small right"
app/views/admin/mailer/preview.html.haml
deleted
100644 → 0
View file @
65dc68b3
%p
This is page with preview for all system emails that are sent to user
%p
Email previews built based on existing Project/Commit/Issue base - so some preview maybe unavailable unless object appear in system
#accordion
%h3
%a
New user
%div
%iframe
{
:src
=>
admin_mailer_preview_user_new_path
,
:width
=>
"100%"
,
:height
=>
"350"
}
%h3
%a
New issue
%div
%iframe
{
:src
=>
admin_mailer_preview_issue_new_path
,
:width
=>
"100%"
,
:height
=>
"350"
}
%h3
%a
Commit note
%div
%iframe
{
:src
=>
admin_mailer_preview_note_path
(
:type
=>
"Commit"
),
:width
=>
"100%"
,
:height
=>
"350"
}
%h3
%a
Issue note
%div
%iframe
{
:src
=>
admin_mailer_preview_note_path
(
:type
=>
"Issue"
),
:width
=>
"100%"
,
:height
=>
"350"
}
%h3
%a
Wall note
%div
%iframe
{
:src
=>
admin_mailer_preview_note_path
(
:type
=>
"Wall"
),
:width
=>
"100%"
,
:height
=>
"350"
}
:javascript
$
(
function
()
{
$
(
"
#accordion
"
).
accordion
();
});
app/views/help/system_hooks.html.haml
0 → 100644
View file @
c3857842
%h3
System hooks
.back_link
=
link_to
:back
do
←
back
%hr
%p
.slead
Your Gitlab instance can perform HTTP POST request on next event: create_project, delete_project, create_user, delete_user, change_team_member.
%br
System Hooks can be used for logging or change information in LDAP server.
%br
%h5
Hooks request example:
=
render
"admin/hooks/data_ex"
app/views/layouts/admin.html.haml
View file @
c3857842
...
...
@@ -15,7 +15,7 @@
%li
{
:class
=>
tab_class
(
:admin_logs
)}
=
link_to
"Logs"
,
admin_logs_path
%li
{
:class
=>
tab_class
(
:admin_emails
)}
=
link_to
"
Emails"
,
admin_email
s_path
=
link_to
"
Hooks"
,
admin_hook
s_path
%li
{
:class
=>
tab_class
(
:admin_resque
)}
=
link_to
"Resque"
,
admin_resque_path
...
...
config/routes.rb
View file @
c3857842
...
...
@@ -28,6 +28,7 @@ Gitlab::Application.routes.draw do
get
'help/workflow'
=>
'help#workflow'
get
'help/api'
=>
'help#api'
get
'help/web_hooks'
=>
'help#web_hooks'
get
'help/system_hooks'
=>
'help#system_hooks'
#
# Admin Area
...
...
@@ -47,11 +48,13 @@ Gitlab::Application.routes.draw do
end
end
resources
:team_members
,
:only
=>
[
:edit
,
:update
,
:destroy
]
get
'emails'
,
:to
=>
'mailer#preview'
get
'mailer/preview_note'
get
'mailer/preview_user_new'
get
'mailer/preview_issue_new'
resources
:hooks
,
:only
=>
[
:index
,
:create
,
:destroy
]
do
get
:test
end
resource
:logs
resource
:resque
,
:controller
=>
'resque'
root
:to
=>
"dashboard#index"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment