2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
module HooksHelper
|
|
|
|
def link_to_test_hook(hook, trigger)
|
2020-01-01 13:55:28 +05:30
|
|
|
path = test_hook_path(hook, trigger)
|
2017-09-10 17:25:29 +05:30
|
|
|
trigger_human_name = trigger.to_s.tr('_', ' ').camelize
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
link_to path, rel: 'nofollow', method: :post do
|
2017-09-10 17:25:29 +05:30
|
|
|
content_tag(:span, trigger_human_name)
|
|
|
|
end
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
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-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
def hook_log_path(hook, hook_log)
|
|
|
|
case hook
|
2022-03-02 08:16:31 +05:30
|
|
|
when ProjectHook, ServiceHook
|
2021-11-18 22:05:49 +05:30
|
|
|
hook_log.present.details_path
|
|
|
|
when SystemHook
|
|
|
|
admin_hook_hook_log_path(hook, hook_log)
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
HooksHelper.prepend_mod_with('HooksHelper')
|