2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-08 08:22:50 +00:00
|
|
|
class Admin::ApplicationSettingsController < Admin::ApplicationController
|
2018-09-19 10:57:14 +00:00
|
|
|
include InternalRedirect
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :set_application_setting
|
2015-01-08 08:22:50 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2018-09-19 10:57:14 +00:00
|
|
|
def integrations
|
|
|
|
end
|
|
|
|
|
|
|
|
def repository
|
2018-09-14 12:37:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def templates
|
|
|
|
end
|
|
|
|
|
2018-09-19 10:57:14 +00:00
|
|
|
def ci_cd
|
|
|
|
end
|
|
|
|
|
|
|
|
def reporting
|
|
|
|
end
|
|
|
|
|
|
|
|
def metrics_and_profiling
|
|
|
|
end
|
|
|
|
|
|
|
|
def network
|
|
|
|
end
|
|
|
|
|
|
|
|
def geo
|
|
|
|
end
|
|
|
|
|
|
|
|
def preferences
|
|
|
|
end
|
|
|
|
|
2015-01-08 08:22:50 +00:00
|
|
|
def update
|
2017-01-20 15:00:19 +00:00
|
|
|
successful = ApplicationSettings::UpdateService
|
|
|
|
.new(@application_setting, current_user, application_setting_params)
|
|
|
|
.execute
|
|
|
|
|
2018-09-07 14:32:28 +00:00
|
|
|
if recheck_user_consent?
|
|
|
|
session[:ask_for_usage_stats_consent] = current_user.requires_usage_stats_consent?
|
|
|
|
end
|
|
|
|
|
2018-09-19 10:57:14 +00:00
|
|
|
redirect_path = referer_path(request) || admin_application_settings_path
|
2018-09-06 13:44:15 +00:00
|
|
|
|
2018-09-07 14:32:28 +00:00
|
|
|
respond_to do |format|
|
|
|
|
if successful
|
|
|
|
format.json { head :ok }
|
2018-09-11 06:43:10 +00:00
|
|
|
format.html { redirect_to redirect_path, notice: 'Application settings saved successfully' }
|
2018-09-07 14:32:28 +00:00
|
|
|
else
|
|
|
|
format.json { head :bad_request }
|
|
|
|
format.html { render :show }
|
|
|
|
end
|
2015-01-08 17:53:35 +00:00
|
|
|
end
|
2015-01-08 08:22:50 +00:00
|
|
|
end
|
|
|
|
|
2017-04-05 12:29:48 +00:00
|
|
|
def usage_data
|
|
|
|
respond_to do |format|
|
2017-03-30 15:48:33 +00:00
|
|
|
format.html do
|
2017-08-17 21:50:29 +00:00
|
|
|
usage_data_json = JSON.pretty_generate(Gitlab::UsageData.data)
|
2017-03-30 15:48:33 +00:00
|
|
|
|
2018-09-06 04:34:25 +00:00
|
|
|
render html: Gitlab::Highlight.highlight('payload.json', usage_data_json, language: 'json')
|
2017-03-30 15:48:33 +00:00
|
|
|
end
|
2017-04-05 12:29:48 +00:00
|
|
|
format.json { render json: Gitlab::UsageData.to_json }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-10 21:57:03 +00:00
|
|
|
def reset_registration_token
|
2015-12-11 09:22:05 +00:00
|
|
|
@application_setting.reset_runners_registration_token!
|
2018-09-10 21:57:03 +00:00
|
|
|
|
2015-12-11 09:22:05 +00:00
|
|
|
flash[:notice] = 'New runners registration token has been generated!'
|
2015-12-14 13:03:58 +00:00
|
|
|
redirect_to admin_runners_path
|
2015-12-11 09:22:05 +00:00
|
|
|
end
|
|
|
|
|
2016-05-09 23:21:22 +00:00
|
|
|
def reset_health_check_token
|
|
|
|
@application_setting.reset_health_check_access_token!
|
|
|
|
flash[:notice] = 'New health check access token has been generated!'
|
2018-12-17 17:36:09 +00:00
|
|
|
redirect_back_or_default
|
2016-05-09 23:21:22 +00:00
|
|
|
end
|
|
|
|
|
2016-04-12 15:32:58 +00:00
|
|
|
def clear_repository_check_states
|
2016-04-13 13:56:05 +00:00
|
|
|
RepositoryCheck::ClearWorker.perform_async
|
2016-04-12 15:32:58 +00:00
|
|
|
|
|
|
|
redirect_to(
|
|
|
|
admin_application_settings_path,
|
2016-04-13 13:56:05 +00:00
|
|
|
notice: 'Started asynchronous removal of all repository check states.'
|
2016-04-12 15:32:58 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2015-01-08 08:22:50 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_application_setting
|
2018-06-25 17:44:03 +00:00
|
|
|
@application_setting = Gitlab::CurrentSettings.current_application_settings
|
2015-01-08 08:22:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def application_setting_params
|
2018-04-11 01:33:11 +00:00
|
|
|
params[:application_setting] ||= {}
|
2015-08-12 06:13:20 +00:00
|
|
|
|
2018-04-13 15:54:08 +00:00
|
|
|
if params[:application_setting].key?(:enabled_oauth_sign_in_sources)
|
|
|
|
enabled_oauth_sign_in_sources = params[:application_setting].delete(:enabled_oauth_sign_in_sources)
|
|
|
|
enabled_oauth_sign_in_sources&.delete("")
|
2016-05-10 08:29:19 +00:00
|
|
|
|
2018-04-13 15:54:08 +00:00
|
|
|
params[:application_setting][:disabled_oauth_sign_in_sources] =
|
|
|
|
AuthHelper.button_based_providers.map(&:to_s) -
|
|
|
|
Array(enabled_oauth_sign_in_sources)
|
|
|
|
end
|
2017-07-05 10:45:58 +00:00
|
|
|
|
2018-04-13 11:52:54 +00:00
|
|
|
params[:application_setting][:import_sources]&.delete("")
|
2017-07-05 10:45:58 +00:00
|
|
|
params[:application_setting][:restricted_visibility_levels]&.delete("")
|
2016-07-14 18:19:40 +00:00
|
|
|
params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file]
|
2016-05-10 08:29:19 +00:00
|
|
|
|
2015-01-08 08:22:50 +00:00
|
|
|
params.require(:application_setting).permit(
|
2017-07-13 16:03:52 +00:00
|
|
|
visible_application_setting_attributes
|
2017-01-10 13:40:08 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-09-07 14:32:28 +00:00
|
|
|
def recheck_user_consent?
|
|
|
|
return false unless session[:ask_for_usage_stats_consent]
|
|
|
|
return false unless params[:application_setting]
|
|
|
|
|
|
|
|
params[:application_setting].key?(:usage_ping_enabled) || params[:application_setting].key?(:version_check_enabled)
|
|
|
|
end
|
|
|
|
|
2017-07-13 16:03:52 +00:00
|
|
|
def visible_application_setting_attributes
|
|
|
|
ApplicationSettingsHelper.visible_attributes + [
|
2016-07-19 22:08:40 +00:00
|
|
|
:domain_blacklist_file,
|
2017-01-10 13:40:08 +00:00
|
|
|
disabled_oauth_sign_in_sources: [],
|
|
|
|
import_sources: [],
|
2016-11-03 14:12:20 +00:00
|
|
|
repository_storages: [],
|
2018-09-14 14:27:31 +00:00
|
|
|
restricted_visibility_levels: []
|
2017-01-10 13:40:08 +00:00
|
|
|
]
|
2015-01-08 08:22:50 +00:00
|
|
|
end
|
|
|
|
end
|