debian-mirror-gitlab/app/helpers/web_hooks/web_hooks_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
801 B
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
module WebHooks
module WebHooksHelper
def show_project_hook_failed_callout?(project:)
2022-10-11 01:57:18 +05:30
return false if project_hook_page?
2023-05-27 22:25:52 +05:30
show_hook_failed_callout?(project)
end
private
def show_hook_failed_callout?(object)
2022-08-13 15:12:31 +05:30
return false unless current_user
2023-05-27 22:25:52 +05:30
return false unless can_access_web_hooks?(object)
2022-08-13 15:12:31 +05:30
# Assumes include of Users::CalloutsHelper
2023-05-27 22:25:52 +05:30
return false if web_hook_disabled_dismissed?(object)
2022-08-13 15:12:31 +05:30
2023-05-27 22:25:52 +05:30
object.fetch_web_hook_failure
2022-08-13 15:12:31 +05:30
end
2022-10-11 01:57:18 +05:30
def project_hook_page?
current_controller?('projects/hooks') || current_controller?('projects/hook_logs')
end
2023-05-27 22:25:52 +05:30
def can_access_web_hooks?(object)
Ability.allowed?(current_user, :admin_project, object)
end
2022-08-13 15:12:31 +05:30
end
end
2023-05-27 22:25:52 +05:30
WebHooks::WebHooksHelper.prepend_mod