diff options
Diffstat (limited to 'app/helpers/users/callouts_helper.rb')
-rw-r--r-- | app/helpers/users/callouts_helper.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/app/helpers/users/callouts_helper.rb b/app/helpers/users/callouts_helper.rb index 87c8bf5cb28..3dd6b3f4a80 100644 --- a/app/helpers/users/callouts_helper.rb +++ b/app/helpers/users/callouts_helper.rb @@ -11,6 +11,7 @@ module Users UNFINISHED_TAG_CLEANUP_CALLOUT = 'unfinished_tag_cleanup_callout' SECURITY_NEWSLETTER_CALLOUT = 'security_newsletter_callout' REGISTRATION_ENABLED_CALLOUT_ALLOWED_CONTROLLER_PATHS = [/^root/, /^dashboard\S*/, /^admin\S*/].freeze + WEB_HOOK_DISABLED = 'web_hook_disabled' def show_gke_cluster_integration_callout?(project) active_nav_link?(controller: sidebar_operations_paths) && @@ -60,12 +61,31 @@ module Users !user_dismissed?(SECURITY_NEWSLETTER_CALLOUT) end + def web_hook_disabled_dismissed?(project) + return false unless project + + last_failure = Gitlab::Redis::SharedState.with do |redis| + key = "web_hooks:last_failure:project-#{project.id}" + redis.get(key) + end + + last_failure = DateTime.parse(last_failure) if last_failure + + user_dismissed?(WEB_HOOK_DISABLED, last_failure, namespace: project.namespace) + end + private - def user_dismissed?(feature_name, ignore_dismissal_earlier_than = nil) + def user_dismissed?(feature_name, ignore_dismissal_earlier_than = nil, namespace: nil) return false unless current_user - current_user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: ignore_dismissal_earlier_than) + query = { feature_name: feature_name, ignore_dismissal_earlier_than: ignore_dismissal_earlier_than } + + if namespace + current_user.dismissed_callout_for_namespace?(namespace: namespace, **query) + else + current_user.dismissed_callout?(**query) + end end end end |