Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
19b8d8af
Commit
19b8d8af
authored
Jun 30, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide 'peek' by using 'performance bar' instead
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
c8ce1f0d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
41 deletions
+32
-41
app/controllers/concerns/with_performance_bar.rb
app/controllers/concerns/with_performance_bar.rb
+2
-0
app/helpers/nav_helper.rb
app/helpers/nav_helper.rb
+1
-1
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+2
-2
config/initializers/flipper.rb
config/initializers/flipper.rb
+2
-0
lib/feature.rb
lib/feature.rb
+2
-4
lib/gitlab/performance_bar.rb
lib/gitlab/performance_bar.rb
+5
-8
spec/lib/gitlab/performance_bar_spec.rb
spec/lib/gitlab/performance_bar_spec.rb
+18
-26
No files found.
app/controllers/concerns/with_performance_bar.rb
View file @
19b8d8af
...
@@ -3,6 +3,8 @@ module WithPerformanceBar
...
@@ -3,6 +3,8 @@ module WithPerformanceBar
included
do
included
do
include
Peek
::
Rblineprof
::
CustomControllerHelpers
include
Peek
::
Rblineprof
::
CustomControllerHelpers
alias_method
:performance_bar_enabled?
,
:peek_enabled?
helper_method
:performance_bar_enabled?
end
end
def
peek_enabled?
def
peek_enabled?
...
...
app/helpers/nav_helper.rb
View file @
19b8d8af
...
@@ -23,7 +23,7 @@ module NavHelper
...
@@ -23,7 +23,7 @@ module NavHelper
def
nav_header_class
def
nav_header_class
class_name
=
''
class_name
=
''
class_name
<<
" with-horizontal-nav"
if
defined?
(
nav
)
&&
nav
class_name
<<
" with-horizontal-nav"
if
defined?
(
nav
)
&&
nav
class_name
<<
" with-peek"
if
pe
ek
_enabled?
class_name
<<
" with-peek"
if
pe
rformance_bar
_enabled?
class_name
class_name
end
end
...
...
app/views/layouts/_head.html.haml
View file @
19b8d8af
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
=
stylesheet_link_tag
"application"
,
media:
"all"
=
stylesheet_link_tag
"application"
,
media:
"all"
=
stylesheet_link_tag
"print"
,
media:
"print"
=
stylesheet_link_tag
"print"
,
media:
"print"
=
stylesheet_link_tag
"test"
,
media:
"all"
if
Rails
.
env
.
test?
=
stylesheet_link_tag
"test"
,
media:
"all"
if
Rails
.
env
.
test?
=
stylesheet_link_tag
'peek'
if
pe
ek
_enabled?
=
stylesheet_link_tag
'peek'
if
pe
rformance_bar
_enabled?
-
if
show_new_nav?
-
if
show_new_nav?
=
stylesheet_link_tag
"new_nav"
,
media:
"all"
=
stylesheet_link_tag
"new_nav"
,
media:
"all"
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
=
webpack_bundle_tag
"main"
=
webpack_bundle_tag
"main"
=
webpack_bundle_tag
"raven"
if
current_application_settings
.
clientside_sentry_enabled
=
webpack_bundle_tag
"raven"
if
current_application_settings
.
clientside_sentry_enabled
=
webpack_bundle_tag
"test"
if
Rails
.
env
.
test?
=
webpack_bundle_tag
"test"
if
Rails
.
env
.
test?
=
webpack_bundle_tag
'peek'
if
pe
ek
_enabled?
=
webpack_bundle_tag
'peek'
if
pe
rformance_bar
_enabled?
-
if
content_for?
(
:page_specific_javascripts
)
-
if
content_for?
(
:page_specific_javascripts
)
=
yield
:page_specific_javascripts
=
yield
:page_specific_javascripts
...
...
config/initializers/flipper.rb
View file @
19b8d8af
...
@@ -3,4 +3,6 @@ require 'flipper/middleware/memoizer'
...
@@ -3,4 +3,6 @@ require 'flipper/middleware/memoizer'
unless
Rails
.
env
.
test?
unless
Rails
.
env
.
test?
Rails
.
application
.
config
.
middleware
.
use
Flipper
::
Middleware
::
Memoizer
,
Rails
.
application
.
config
.
middleware
.
use
Flipper
::
Middleware
::
Memoizer
,
lambda
{
Feature
.
flipper
}
lambda
{
Feature
.
flipper
}
Feature
.
register_feature_groups
end
end
lib/feature.rb
View file @
19b8d8af
...
@@ -54,15 +54,13 @@ class Feature
...
@@ -54,15 +54,13 @@ class Feature
adapter
=
Flipper
::
Adapters
::
ActiveRecord
.
new
(
adapter
=
Flipper
::
Adapters
::
ActiveRecord
.
new
(
feature_class:
FlipperFeature
,
gate_class:
FlipperGate
)
feature_class:
FlipperFeature
,
gate_class:
FlipperGate
)
Flipper
.
new
(
adapter
).
tap
do
Flipper
.
new
(
adapter
)
register_feature_groups
end
end
end
end
end
def
register_feature_groups
def
register_feature_groups
Flipper
.
register
(
:performance_team
)
do
|
actor
|
Flipper
.
register
(
:performance_team
)
do
|
actor
|
Gitlab
::
PerformanceBar
.
allowed_actor?
(
actor
)
actor
.
thing
&
.
is_a?
(
User
)
&&
Gitlab
::
PerformanceBar
.
allowed_user?
(
actor
.
thing
)
end
end
end
end
end
end
...
...
lib/gitlab/performance_bar.rb
View file @
19b8d8af
...
@@ -4,15 +4,15 @@ module Gitlab
...
@@ -4,15 +4,15 @@ module Gitlab
Feature
.
enabled?
(
:gitlab_performance_bar
,
current_user
)
Feature
.
enabled?
(
:gitlab_performance_bar
,
current_user
)
end
end
def
self
.
allowed_
actor?
(
acto
r
)
def
self
.
allowed_
user?
(
use
r
)
return
false
unless
a
ctor
.
thing
&
.
is_a?
(
User
)
&&
a
llowed_group
return
false
unless
allowed_group
if
RequestStore
.
active?
if
RequestStore
.
active?
RequestStore
.
fetch
(
'performance_bar:user_member_of_allowed_group'
)
do
RequestStore
.
fetch
(
'performance_bar:user_member_of_allowed_group'
)
do
user_member_of_allowed_group?
(
actor
.
thing
)
user_member_of_allowed_group?
(
user
)
end
end
else
else
user_member_of_allowed_group?
(
actor
.
thing
)
user_member_of_allowed_group?
(
user
)
end
end
end
end
...
@@ -29,10 +29,7 @@ module Gitlab
...
@@ -29,10 +29,7 @@ module Gitlab
end
end
def
self
.
user_member_of_allowed_group?
(
user
)
def
self
.
user_member_of_allowed_group?
(
user
)
GroupMembersFinder
.
new
(
allowed_group
)
GroupMembersFinder
.
new
(
allowed_group
).
execute
.
exists?
(
user_id:
user
.
id
)
.
execute
.
where
(
user_id:
user
.
id
)
.
any?
end
end
end
end
end
end
spec/lib/gitlab/performance_bar_spec.rb
View file @
19b8d8af
...
@@ -25,43 +25,35 @@ describe Gitlab::PerformanceBar do
...
@@ -25,43 +25,35 @@ describe Gitlab::PerformanceBar do
end
end
end
end
describe
'.allowed_actor?'
do
describe
'.allowed_user?'
do
it
'returns false when given actor is not a User'
do
let
(
:user
)
{
create
(
:user
)
}
actor
=
double
(
'actor'
,
thing:
double
)
expect
(
described_class
.
allowed_actor?
(
actor
)).
to
be_falsy
before
do
stub_performance_bar_setting
(
allowed_group:
'my-group'
)
end
end
context
'when given actor is a User'
do
context
'when allowed group does not exist'
do
let
(
:actor
)
{
double
(
'actor'
,
thing:
create
(
:user
))
}
it
'returns false'
do
expect
(
described_class
.
allowed_user?
(
user
)).
to
be_falsy
before
do
stub_performance_bar_setting
(
allowed_group:
'my-group'
)
end
end
end
context
'when allowed group does not exist'
do
context
'when allowed group exists'
do
let!
(
:my_group
)
{
create
(
:group
,
path:
'my-group'
)
}
context
'when user is not a member of the allowed group'
do
it
'returns false'
do
it
'returns false'
do
expect
(
described_class
.
allowed_
actor?
(
acto
r
)).
to
be_falsy
expect
(
described_class
.
allowed_
user?
(
use
r
)).
to
be_falsy
end
end
end
end
context
'when allowed group exists'
do
context
'when user is a member of the allowed group'
do
let!
(
:my_group
)
{
create
(
:group
,
path:
'my-group'
)
}
before
do
my_group
.
add_developer
(
user
)
context
'when user is not a member of the allowed group'
do
it
'returns false'
do
expect
(
described_class
.
allowed_actor?
(
actor
)).
to
be_falsy
end
end
end
context
'when user is a member of the allowed group'
do
it
'returns true'
do
before
do
expect
(
described_class
.
allowed_user?
(
user
)).
to
be_truthy
my_group
.
add_developer
(
actor
.
thing
)
end
it
'returns true'
do
expect
(
described_class
.
allowed_actor?
(
actor
)).
to
be_truthy
end
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment