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
end
def authenticate_user!
render_404 unless current_user.admin?
render_404 if ApplicationSettingsHelper.hide_instance_statistics?(current_user)
end
end
......@@ -15,6 +15,10 @@ 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
......@@ -247,6 +251,7 @@ module ApplicationSettingsHelper
:unique_ips_limit_per_user,
:unique_ips_limit_time_window,
:usage_ping_enabled,
:instance_statistics_visibility_private,
:user_default_external,
:user_oauth_applications,
:version_check_enabled,
......
......@@ -290,6 +290,7 @@ class ApplicationSetting < ActiveRecord::Base
user_default_external: false,
polling_interval_multiplier: 1,
usage_ping_enabled: Settings.gitlab['usage_ping_enabled'],
instance_statistics_visibility_private: false,
gitaly_timeout_fast: 10,
gitaly_timeout_medium: 30,
gitaly_timeout_default: 55,
......
......@@ -30,6 +30,9 @@
form. For more information, see the documentation on
= succeed '.' do
= 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"
......@@ -70,8 +70,12 @@
= 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?
= 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?
%li
= link_to sherlock_transactions_path, class: 'admin-icon', title: _('Sherlock Transactions'),
data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('tachometer fw')
= icon('tachometer fw')
\ No newline at end of file
# 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