summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/with_performance_bar.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/with_performance_bar.rb')
-rw-r--r--app/controllers/concerns/with_performance_bar.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/controllers/concerns/with_performance_bar.rb b/app/controllers/concerns/with_performance_bar.rb
index 4e0ae3c59eb..93ded59900d 100644
--- a/app/controllers/concerns/with_performance_bar.rb
+++ b/app/controllers/concerns/with_performance_bar.rb
@@ -3,15 +3,25 @@
module WithPerformanceBar
extend ActiveSupport::Concern
- def peek_enabled?
- return false unless Gitlab::PerformanceBar.enabled?(current_user)
+ included do
+ before_action :set_peek_enabled_for_current_request
+ end
+
+ private
+ def set_peek_enabled_for_current_request
Gitlab::SafeRequestStore.fetch(:peek_enabled) { cookie_or_default_value }
end
- private
+ # Needed for Peek's routing to work;
+ # Peek::ResultsController#restrict_non_access calls this method.
+ def peek_enabled?
+ Gitlab::PerformanceBar.enabled_for_request?
+ end
def cookie_or_default_value
+ return false unless Gitlab::PerformanceBar.enabled_for_user?(current_user)
+
if cookies[:perf_bar_enabled].present?
cookies[:perf_bar_enabled] == 'true'
else