2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
module HooksHelper
|
|
|
|
def link_to_test_hook(hook, trigger)
|
2019-12-16 04:08:10 -05:00
|
|
|
path = test_hook_path(hook, trigger)
|
2017-07-20 11:12:06 -04:00
|
|
|
trigger_human_name = trigger.to_s.tr('_', ' ').camelize
|
|
|
|
|
2018-06-21 04:38:59 -04:00
|
|
|
link_to path, rel: 'nofollow', method: :post do
|
2017-07-20 11:12:06 -04:00
|
|
|
content_tag(:span, trigger_human_name)
|
|
|
|
end
|
|
|
|
end
|
2019-12-16 04:08:10 -05:00
|
|
|
|
|
|
|
def test_hook_path(hook, trigger)
|
|
|
|
case hook
|
|
|
|
when ProjectHook
|
|
|
|
test_project_hook_path(hook.project, hook, trigger: trigger)
|
|
|
|
when SystemHook
|
|
|
|
test_admin_hook_path(hook, trigger: trigger)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_hook_path(hook)
|
|
|
|
case hook
|
|
|
|
when ProjectHook
|
|
|
|
edit_project_hook_path(hook.project, hook)
|
|
|
|
when SystemHook
|
|
|
|
edit_admin_hook_path(hook)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy_hook_path(hook)
|
|
|
|
case hook
|
|
|
|
when ProjectHook
|
|
|
|
project_hook_path(hook.project, hook)
|
|
|
|
when SystemHook
|
|
|
|
admin_hook_path(hook)
|
|
|
|
end
|
|
|
|
end
|
2021-10-11 08:11:56 -04:00
|
|
|
|
|
|
|
def hook_log_path(hook, hook_log)
|
|
|
|
case hook
|
2022-01-10 19:13:53 -05:00
|
|
|
when ProjectHook, ServiceHook
|
2021-10-11 08:11:56 -04:00
|
|
|
hook_log.present.details_path
|
|
|
|
when SystemHook
|
|
|
|
admin_hook_hook_log_path(hook, hook_log)
|
|
|
|
end
|
|
|
|
end
|
2017-07-20 11:12:06 -04:00
|
|
|
end
|
2019-12-16 04:08:10 -05:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
HooksHelper.prepend_mod_with('HooksHelper')
|