Module: HooksHelper
- Defined in:
- app/helpers/hooks_helper.rb
Instance Method Summary collapse
- #destroy_hook_path(hook) ⇒ Object
- #edit_hook_path(hook) ⇒ Object
- #hook_log_path(hook, hook_log) ⇒ Object
- #test_hook_path(hook, trigger) ⇒ Object
- #webhook_form_data(hook) ⇒ Object
- #webhook_test_items(hook, triggers) ⇒ Object
Instance Method Details
#destroy_hook_path(hook) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/helpers/hooks_helper.rb', line 44 def destroy_hook_path(hook) case hook when ProjectHook project_hook_path(hook.project, hook) when SystemHook admin_hook_path(hook) end end |
#edit_hook_path(hook) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/helpers/hooks_helper.rb', line 35 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 |
#hook_log_path(hook, hook_log) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/helpers/hooks_helper.rb', line 53 def hook_log_path(hook, hook_log) case hook when ProjectHook, ServiceHook hook_log.present.details_path when SystemHook admin_hook_hook_log_path(hook, hook_log) end end |
#test_hook_path(hook, trigger) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/helpers/hooks_helper.rb', line 26 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 |
#webhook_form_data(hook) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/hooks_helper.rb', line 4 def webhook_form_data(hook) { name: hook.name, description: hook.description, secret_token: hook.masked_token, # always use masked_token to avoid exposing secret_token to frontend url: hook.url, url_variables: Gitlab::Json.dump(hook.url_variables.keys.map { { key: _1 } }), custom_headers: Gitlab::Json.dump(hook.custom_headers.keys.map { { key: _1, value: WebHook::SECRET_MASK } }), is_new_hook: hook.new_record?.to_s, triggers: Gitlab::Json.dump(all_triggers(hook)) } end |
#webhook_test_items(hook, triggers) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/helpers/hooks_helper.rb', line 17 def webhook_test_items(hook, triggers) triggers.map do |trigger| { href: test_hook_path(hook, trigger), text: integration_webhook_event_human_name(trigger) } end end |