Add instance_statistics_visibility_private application setting and top nav icon

This commit is contained in:
Luke Bennett 2018-07-18 02:41:40 +01:00 committed by Bob Van Landuyt
parent f8f2d0f9e1
commit 866429f789
6 changed files with 33 additions and 2 deletions

View file

@ -7,6 +7,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

View file

@ -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,

View file

@ -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,

View file

@ -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"

View file

@ -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')

View file

@ -0,0 +1,18 @@
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