diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2017-10-23 23:58:29 +0300 |
---|---|---|
committer | Andrew Newdigate <andrew@gitlab.com> | 2017-10-23 23:58:29 +0300 |
commit | d6d5b6fd7588a7b3528e7d69ef308ce43560033e (patch) | |
tree | ab7cd5946d07032d289a0844c667b15542692f24 | |
parent | 743050cede59d4ffbd45f2ed0dc4d7f20b75c6bd (diff) |
Performance bar on by default in dev environments
-rw-r--r-- | app/assets/javascripts/shortcuts.js | 8 | ||||
-rw-r--r-- | app/controllers/concerns/with_performance_bar.rb | 15 | ||||
-rw-r--r-- | lib/gitlab/performance_bar.rb | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/app/assets/javascripts/shortcuts.js b/app/assets/javascripts/shortcuts.js index ebe7a99ffae..d93ff9d267e 100644 --- a/app/assets/javascripts/shortcuts.js +++ b/app/assets/javascripts/shortcuts.js @@ -57,11 +57,9 @@ export default class Shortcuts { static onTogglePerfBar(e) { e.preventDefault(); const performanceBarCookieName = 'perf_bar_enabled'; - if (Cookies.get(performanceBarCookieName) === 'true') { - Cookies.remove(performanceBarCookieName, { path: '/' }); - } else { - Cookies.set(performanceBarCookieName, 'true', { path: '/' }); - } + const value = String(Cookies.get(performanceBarCookieName) !== 'true') + Cookies.set(performanceBarCookieName, value, { path: '/' }); + gl.utils.refreshCurrentPage(); } diff --git a/app/controllers/concerns/with_performance_bar.rb b/app/controllers/concerns/with_performance_bar.rb index ed253042701..8961359781f 100644 --- a/app/controllers/concerns/with_performance_bar.rb +++ b/app/controllers/concerns/with_performance_bar.rb @@ -8,10 +8,17 @@ module WithPerformanceBar def peek_enabled? return false unless Gitlab::PerformanceBar.enabled?(current_user) - if RequestStore.active? - RequestStore.fetch(:peek_enabled) { cookies[:perf_bar_enabled].present? } - else - cookies[:perf_bar_enabled].present? + cookie = cookies[:perf_bar_enabled] + + if !cookie.present? + if Rails.env.development? + cookies[:perf_bar_enabled] = 'true' + return true + else + return false + end end + + cookie === 'true' end end diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb index e73245b82c1..9841e1a0934 100644 --- a/lib/gitlab/performance_bar.rb +++ b/lib/gitlab/performance_bar.rb @@ -6,6 +6,8 @@ module Gitlab EXPIRY_TIME = 5.minutes def self.enabled?(user = nil) + return true if Rails.env.development? + return false unless user && allowed_group_id allowed_user_ids.include?(user.id) |