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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
faadd9e0
Commit
faadd9e0
authored
Dec 08, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use class reader instead of dynamic constant
parent
f99b0cc5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
10 deletions
+12
-10
app/models/concerns/triggerable_hooks.rb
app/models/concerns/triggerable_hooks.rb
+5
-3
app/services/test_hooks/base_service.rb
app/services/test_hooks/base_service.rb
+1
-1
app/views/admin/hooks/edit.html.haml
app/views/admin/hooks/edit.html.haml
+1
-1
app/views/admin/hooks/index.html.haml
app/views/admin/hooks/index.html.haml
+2
-2
app/views/projects/hooks/edit.html.haml
app/views/projects/hooks/edit.html.haml
+1
-1
app/views/projects/settings/integrations/_project_hook.html.haml
...ws/projects/settings/integrations/_project_hook.html.haml
+2
-2
No files found.
app/models/concerns/triggerable_hooks.rb
View file @
faadd9e0
...
...
@@ -17,8 +17,10 @@ module TriggerableHooks
class_methods
do
attr_reader
:triggerable_hooks
attr_reader
:triggers
def
hooks_for
(
trigger
)
callable_scopes
=
self
::
TRIGGERS
.
keys
+
[
:all
]
callable_scopes
=
triggers
.
keys
+
[
:all
]
return
none
unless
callable_scopes
.
include?
(
trigger
)
public_send
(
trigger
)
# rubocop:disable GitlabSecurity/PublicSend
...
...
@@ -28,9 +30,9 @@ module TriggerableHooks
def
triggerable_hooks
(
hooks
)
triggers
=
AVAILABLE_TRIGGERS
.
slice
(
*
hooks
)
const_set
(
'TRIGGERS'
,
triggers
)
@triggers
=
triggers
self
::
TRIGGERS
.
each
do
|
trigger
,
event
|
triggers
.
each
do
|
trigger
,
event
|
scope
trigger
,
->
{
where
(
event
=>
true
)
}
end
end
...
...
app/services/test_hooks/base_service.rb
View file @
faadd9e0
...
...
@@ -9,7 +9,7 @@ module TestHooks
end
def
execute
trigger_key
=
hook
.
class
::
TRIGGERS
.
key
(
trigger
.
to_sym
)
trigger_key
=
hook
.
class
.
triggers
.
key
(
trigger
.
to_sym
)
trigger_data_method
=
"
#{
trigger
}
_data"
if
trigger_key
.
nil?
||
!
self
.
respond_to?
(
trigger_data_method
,
true
)
...
...
app/views/admin/hooks/edit.html.haml
View file @
faadd9e0
...
...
@@ -13,7 +13,7 @@
=
render
partial:
'form'
,
locals:
{
form:
f
,
hook:
@hook
}
.form-actions
=
f
.
submit
'Save changes'
,
class:
'btn btn-create'
=
render
'shared/web_hooks/test_button'
,
triggers:
SystemHook
::
TRIGGERS
,
hook:
@hook
=
render
'shared/web_hooks/test_button'
,
triggers:
SystemHook
.
triggers
,
hook:
@hook
=
link_to
'Remove'
,
admin_hook_path
(
@hook
),
method: :delete
,
class:
'btn btn-remove pull-right'
,
data:
{
confirm:
'Are you sure?'
}
%hr
...
...
app/views/admin/hooks/index.html.haml
View file @
faadd9e0
...
...
@@ -22,12 +22,12 @@
-
@hooks
.
each
do
|
hook
|
%li
.controls
=
render
'shared/web_hooks/test_button'
,
triggers:
SystemHook
::
TRIGGERS
,
hook:
hook
,
button_class:
'btn-sm'
=
render
'shared/web_hooks/test_button'
,
triggers:
SystemHook
.
triggers
,
hook:
hook
,
button_class:
'btn-sm'
=
link_to
'Edit'
,
edit_admin_hook_path
(
hook
),
class:
'btn btn-sm'
=
link_to
'Remove'
,
admin_hook_path
(
hook
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-remove btn-sm'
.monospace
=
hook
.
url
%div
-
SystemHook
::
TRIGGERS
.
each_value
do
|
event
|
-
SystemHook
.
triggers
.
each_value
do
|
event
|
-
if
hook
.
public_send
(
event
)
%span
.label.label-gray
=
event
.
to_s
.
titleize
%span
.label.label-gray
SSL Verification:
#{
hook
.
enable_ssl_verification
?
'enabled'
:
'disabled'
}
app/views/projects/hooks/edit.html.haml
View file @
faadd9e0
...
...
@@ -12,7 +12,7 @@
=
render
partial:
'shared/web_hooks/form'
,
locals:
{
form:
f
,
hook:
@hook
}
=
f
.
submit
'Save changes'
,
class:
'btn btn-create'
=
render
'shared/web_hooks/test_button'
,
triggers:
ProjectHook
::
TRIGGERS
,
hook:
@hook
=
render
'shared/web_hooks/test_button'
,
triggers:
ProjectHook
.
triggers
,
hook:
@hook
=
link_to
'Remove'
,
project_hook_path
(
@project
,
@hook
),
method: :delete
,
class:
'btn btn-remove pull-right'
,
data:
{
confirm:
'Are you sure?'
}
%hr
...
...
app/views/projects/settings/integrations/_project_hook.html.haml
View file @
faadd9e0
...
...
@@ -3,14 +3,14 @@
.col-md-8.col-lg-7
%strong
.light-header
=
hook
.
url
%div
-
ProjectHook
::
TRIGGERS
.
each_value
do
|
event
|
-
ProjectHook
.
triggers
.
each_value
do
|
event
|
-
if
hook
.
public_send
(
event
)
%span
.label.label-gray.deploy-project-label
=
event
.
to_s
.
titleize
.col-md-4.col-lg-5.text-right-lg.prepend-top-5
%span
.append-right-10.inline
SSL Verification:
#{
hook
.
enable_ssl_verification
?
'enabled'
:
'disabled'
}
=
link_to
'Edit'
,
edit_project_hook_path
(
@project
,
hook
),
class:
'btn btn-sm'
=
render
'shared/web_hooks/test_button'
,
triggers:
ProjectHook
::
TRIGGERS
,
hook:
hook
,
button_class:
'btn-sm'
=
render
'shared/web_hooks/test_button'
,
triggers:
ProjectHook
.
triggers
,
hook:
hook
,
button_class:
'btn-sm'
=
link_to
project_hook_path
(
@project
,
hook
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-transparent'
do
%span
.sr-only
Remove
=
icon
(
'trash'
)
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