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
1
Merge Requests
1
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
nexedi
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
Show 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
included
do
include
Peek
::
Rblineprof
::
CustomControllerHelpers
alias_method
:performance_bar_enabled?
,
:peek_enabled?
helper_method
:performance_bar_enabled?
end
def
peek_enabled?
...
...
app/helpers/nav_helper.rb
View file @
19b8d8af
...
...
@@ -23,7 +23,7 @@ module NavHelper
def
nav_header_class
class_name
=
''
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
end
...
...
app/views/layouts/_head.html.haml
View file @
19b8d8af
...
...
@@ -30,7 +30,7 @@
=
stylesheet_link_tag
"application"
,
media:
"all"
=
stylesheet_link_tag
"print"
,
media:
"print"
=
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?
=
stylesheet_link_tag
"new_nav"
,
media:
"all"
...
...
@@ -44,7 +44,7 @@
=
webpack_bundle_tag
"main"
=
webpack_bundle_tag
"raven"
if
current_application_settings
.
clientside_sentry_enabled
=
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
)
=
yield
:page_specific_javascripts
...
...
config/initializers/flipper.rb
View file @
19b8d8af
...
...
@@ -3,4 +3,6 @@ require 'flipper/middleware/memoizer'
unless
Rails
.
env
.
test?
Rails
.
application
.
config
.
middleware
.
use
Flipper
::
Middleware
::
Memoizer
,
lambda
{
Feature
.
flipper
}
Feature
.
register_feature_groups
end
lib/feature.rb
View file @
19b8d8af
...
...
@@ -54,15 +54,13 @@ class Feature
adapter
=
Flipper
::
Adapters
::
ActiveRecord
.
new
(
feature_class:
FlipperFeature
,
gate_class:
FlipperGate
)
Flipper
.
new
(
adapter
).
tap
do
register_feature_groups
end
Flipper
.
new
(
adapter
)
end
end
def
register_feature_groups
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
...
...
lib/gitlab/performance_bar.rb
View file @
19b8d8af
...
...
@@ -4,15 +4,15 @@ module Gitlab
Feature
.
enabled?
(
:gitlab_performance_bar
,
current_user
)
end
def
self
.
allowed_
actor?
(
acto
r
)
return
false
unless
a
ctor
.
thing
&
.
is_a?
(
User
)
&&
a
llowed_group
def
self
.
allowed_
user?
(
use
r
)
return
false
unless
allowed_group
if
RequestStore
.
active?
RequestStore
.
fetch
(
'performance_bar:user_member_of_allowed_group'
)
do
user_member_of_allowed_group?
(
actor
.
thing
)
user_member_of_allowed_group?
(
user
)
end
else
user_member_of_allowed_group?
(
actor
.
thing
)
user_member_of_allowed_group?
(
user
)
end
end
...
...
@@ -29,10 +29,7 @@ module Gitlab
end
def
self
.
user_member_of_allowed_group?
(
user
)
GroupMembersFinder
.
new
(
allowed_group
)
.
execute
.
where
(
user_id:
user
.
id
)
.
any?
GroupMembersFinder
.
new
(
allowed_group
).
execute
.
exists?
(
user_id:
user
.
id
)
end
end
end
spec/lib/gitlab/performance_bar_spec.rb
View file @
19b8d8af
...
...
@@ -25,15 +25,8 @@ describe Gitlab::PerformanceBar do
end
end
describe
'.allowed_actor?'
do
it
'returns false when given actor is not a User'
do
actor
=
double
(
'actor'
,
thing:
double
)
expect
(
described_class
.
allowed_actor?
(
actor
)).
to
be_falsy
end
context
'when given actor is a User'
do
let
(
:actor
)
{
double
(
'actor'
,
thing:
create
(
:user
))
}
describe
'.allowed_user?'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_performance_bar_setting
(
allowed_group:
'my-group'
)
...
...
@@ -41,7 +34,7 @@ describe Gitlab::PerformanceBar do
context
'when allowed group does not exist'
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
...
...
@@ -50,18 +43,17 @@ describe Gitlab::PerformanceBar do
context
'when user is not a member of the allowed group'
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
context
'when user is a member of the allowed group'
do
before
do
my_group
.
add_developer
(
actor
.
thing
)
my_group
.
add_developer
(
user
)
end
it
'returns true'
do
expect
(
described_class
.
allowed_actor?
(
actor
)).
to
be_truthy
end
expect
(
described_class
.
allowed_user?
(
user
)).
to
be_truthy
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