debian-mirror-gitlab/app/controllers/admin/application_settings_controller.rb

94 lines
2.6 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Admin::ApplicationSettingsController < Admin::ApplicationController
2015-09-11 14:41:01 +05:30
before_action :set_application_setting
2015-04-26 12:48:37 +05:30
def show
end
def update
2017-08-17 22:00:37 +05:30
successful = ApplicationSettings::UpdateService
.new(@application_setting, current_user, application_setting_params)
.execute
if successful
2015-04-26 12:48:37 +05:30
redirect_to admin_application_settings_path,
notice: 'Application settings saved successfully'
else
render :show
end
end
2017-08-17 22:00:37 +05:30
def usage_data
respond_to do |format|
format.html do
usage_data = Gitlab::UsageData.data
usage_data_json = params[:pretty] ? JSON.pretty_generate(usage_data) : usage_data.to_json
render html: Gitlab::Highlight.highlight('payload.json', usage_data_json)
end
format.json { render json: Gitlab::UsageData.to_json }
end
end
2015-12-23 02:04:40 +05:30
def reset_runners_token
@application_setting.reset_runners_registration_token!
flash[:notice] = 'New runners registration token has been generated!'
redirect_to admin_runners_path
end
2016-06-02 11:05:42 +05:30
def reset_health_check_token
@application_setting.reset_health_check_access_token!
flash[:notice] = 'New health check access token has been generated!'
redirect_to :back
end
def clear_repository_check_states
RepositoryCheck::ClearWorker.perform_async
redirect_to(
admin_application_settings_path,
notice: 'Started asynchronous removal of all repository check states.'
)
end
2015-04-26 12:48:37 +05:30
private
def set_application_setting
@application_setting = ApplicationSetting.current
end
def application_setting_params
2015-09-25 12:07:36 +05:30
import_sources = params[:application_setting][:import_sources]
if import_sources.nil?
params[:application_setting][:import_sources] = []
else
import_sources.map! do |source|
source.to_str
end
end
2016-06-02 11:05:42 +05:30
enabled_oauth_sign_in_sources = params[:application_setting].delete(:enabled_oauth_sign_in_sources)
params[:application_setting][:disabled_oauth_sign_in_sources] =
AuthHelper.button_based_providers.map(&:to_s) -
Array(enabled_oauth_sign_in_sources)
2017-09-10 17:25:29 +05:30
params[:application_setting][:restricted_visibility_levels]&.delete("")
2016-08-24 12:49:21 +05:30
params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file]
2016-06-02 11:05:42 +05:30
2015-04-26 12:48:37 +05:30
params.require(:application_setting).permit(
2017-09-10 17:25:29 +05:30
visible_application_setting_attributes
2017-08-17 22:00:37 +05:30
)
end
2017-09-10 17:25:29 +05:30
def visible_application_setting_attributes
ApplicationSettingsHelper.visible_attributes + [
2016-08-24 12:49:21 +05:30
:domain_blacklist_file,
2017-08-17 22:00:37 +05:30
disabled_oauth_sign_in_sources: [],
import_sources: [],
2016-11-24 13:41:30 +05:30
repository_storages: [],
2015-09-11 14:41:01 +05:30
restricted_visibility_levels: [],
2017-08-17 22:00:37 +05:30
sidekiq_throttling_queues: []
]
2015-04-26 12:48:37 +05:30
end
end