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
Boxiang Sun
gitlab-ce
Commits
01fd71ad
Commit
01fd71ad
authored
Jul 23, 2018
by
Luke Bennett
Committed by
Bob Van Landuyt
Jul 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add read_instance_statistics global policy
parent
626d5caf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
10 deletions
+5
-10
app/controllers/instance_statistics/application_controller.rb
...controllers/instance_statistics/application_controller.rb
+1
-5
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+0
-4
app/policies/global_policy.rb
app/policies/global_policy.rb
+3
-0
app/views/layouts/nav/_dashboard.html.haml
app/views/layouts/nav/_dashboard.html.haml
+1
-1
No files found.
app/controllers/instance_statistics/application_controller.rb
View file @
01fd71ad
...
...
@@ -2,11 +2,7 @@ class InstanceStatistics::ApplicationController < ApplicationController
before_action
:authenticate_user!
layout
'instance_statistics'
def
index
redirect_to
instance_statistics_conversations_development_index_index_path
end
def
authenticate_user!
render_404
if
ApplicationSettingsHelper
.
hide_instance_statistics?
(
current_user
)
render_404
unless
can?
(
current_user
,
:read_instance_statistics
)
end
end
app/helpers/application_settings_helper.rb
View file @
01fd71ad
...
...
@@ -15,10 +15,6 @@ module ApplicationSettingsHelper
def
allowed_protocols_present?
Gitlab
::
CurrentSettings
.
enabled_git_access_protocol
.
present?
end
def
hide_instance_statistics?
(
user
=
current_user
)
Gitlab
::
CurrentSettings
.
instance_statistics_visibility_private?
&&
!
user
.
admin?
end
def
enabled_protocol
case
Gitlab
::
CurrentSettings
.
enabled_git_access_protocol
...
...
app/policies/global_policy.rb
View file @
01fd71ad
...
...
@@ -19,6 +19,9 @@ class GlobalPolicy < BasePolicy
@user
&
.
required_terms_not_accepted?
end
condition
(
:private_instance_statistics
,
score:
0
)
{
Gitlab
::
CurrentSettings
.
instance_statistics_visibility_private?
}
rule
{
admin
|
~
private_instance_statistics
}.
enable
:read_instance_statistics
rule
{
anonymous
}.
policy
do
prevent
:log_in
prevent
:receive_notifications
...
...
app/views/layouts/nav/_dashboard.html.haml
View file @
01fd71ad
...
...
@@ -70,7 +70,7 @@
=
nav_link
(
controller:
'admin/dashboard'
)
do
=
link_to
admin_root_path
,
class:
'admin-icon qa-admin-area-link'
,
title:
_
(
'Admin area'
),
aria:
{
label:
_
(
"Admin area"
)
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
sprite_icon
(
'admin'
,
size:
18
)
-
unless
hide_instance_statistics?
-
if
can?
(
current_user
,
:read_instance_statistics
)
=
nav_link
(
controller: :instance_statistics
)
do
=
link_to
instance_statistics_root_path
,
title:
'Instance statistics'
,
aria:
{
label:
'Instance statistics'
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
sprite_icon
(
'chart'
,
size:
18
)
...
...
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