Commit cac2d06e authored by Luke Bennett's avatar Luke Bennett Committed by Bob Van Landuyt

Add instance_statistics_visibility_private application setting and top nav icon

parent 602a1c34
...@@ -9,6 +9,6 @@ class InstanceStatistics::ApplicationController < ApplicationController ...@@ -9,6 +9,6 @@ class InstanceStatistics::ApplicationController < ApplicationController
end end
def authenticate_user! def authenticate_user!
render_404 unless current_user.admin? render_404 if ApplicationSettingsHelper.hide_instance_statistics?(current_user)
end end
end end
...@@ -16,6 +16,10 @@ module ApplicationSettingsHelper ...@@ -16,6 +16,10 @@ module ApplicationSettingsHelper
Gitlab::CurrentSettings.enabled_git_access_protocol.present? Gitlab::CurrentSettings.enabled_git_access_protocol.present?
end end
def hide_instance_statistics?(user = current_user)
Gitlab::CurrentSettings.instance_statistics_visibility_private? && !user.admin?
end
def enabled_protocol def enabled_protocol
case Gitlab::CurrentSettings.enabled_git_access_protocol case Gitlab::CurrentSettings.enabled_git_access_protocol
when 'http' when 'http'
...@@ -247,6 +251,7 @@ module ApplicationSettingsHelper ...@@ -247,6 +251,7 @@ module ApplicationSettingsHelper
:unique_ips_limit_per_user, :unique_ips_limit_per_user,
:unique_ips_limit_time_window, :unique_ips_limit_time_window,
:usage_ping_enabled, :usage_ping_enabled,
:instance_statistics_visibility_private,
:user_default_external, :user_default_external,
:user_oauth_applications, :user_oauth_applications,
:version_check_enabled, :version_check_enabled,
......
...@@ -290,6 +290,7 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -290,6 +290,7 @@ class ApplicationSetting < ActiveRecord::Base
user_default_external: false, user_default_external: false,
polling_interval_multiplier: 1, polling_interval_multiplier: 1,
usage_ping_enabled: Settings.gitlab['usage_ping_enabled'], usage_ping_enabled: Settings.gitlab['usage_ping_enabled'],
instance_statistics_visibility_private: false,
gitaly_timeout_fast: 10, gitaly_timeout_fast: 10,
gitaly_timeout_medium: 30, gitaly_timeout_medium: 30,
gitaly_timeout_default: 55, gitaly_timeout_default: 55,
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
form. For more information, see the documentation on form. For more information, see the documentation on
= succeed '.' do = succeed '.' do
= link_to 'deactivating the usage ping', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'deactivate-the-usage-ping') = link_to 'deactivating the usage ping', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'deactivate-the-usage-ping')
.form-group
= f.label :instance_statistics_visibility_private, 'Instance Statistics visibility'
= f.select :instance_statistics_visibility_private, options_for_select({'All users' => false, 'Only admins' => true}, Gitlab::CurrentSettings.instance_statistics_visibility_private?), {}, class: 'form-control'
= f.submit 'Save changes', class: "btn btn-success" = f.submit 'Save changes', class: "btn btn-success"
...@@ -70,6 +70,10 @@ ...@@ -70,6 +70,10 @@
= nav_link(controller: 'admin/dashboard') do = 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 = 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) = sprite_icon('admin', size: 18)
- unless hide_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)
- if Gitlab::Sherlock.enabled? - if Gitlab::Sherlock.enabled?
%li %li
= link_to sherlock_transactions_path, class: 'admin-icon', title: _('Sherlock Transactions'), = link_to sherlock_transactions_path, class: 'admin-icon', title: _('Sherlock Transactions'),
......
# frozen_string_literal: true
class AddInstanceStatisticsVisibilityToApplicationSetting < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :instance_statistics_visibility_private,
:boolean,
default: false,
allow_null: false)
end
def down
remove_column(:application_settings, :instance_statistics_visibility_private)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment