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

162 lines
4.5 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)
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-08-17 22:00:37 +05:30
application_setting_params_ce
)
end
def application_setting_params_ce
[
:admin_notification_email,
2015-09-11 14:41:01 +05:30
:after_sign_out_path,
2017-08-17 22:00:37 +05:30
:after_sign_up_text,
:akismet_api_key,
:akismet_enabled,
:container_registry_token_expire_delay,
:default_artifacts_expire_in,
:default_branch_protection,
:default_group_visibility,
2015-09-11 14:41:01 +05:30
:default_project_visibility,
2017-08-17 22:00:37 +05:30
:default_projects_limit,
2015-09-11 14:41:01 +05:30
:default_snippet_visibility,
2016-08-24 12:49:21 +05:30
:domain_blacklist_enabled,
:domain_blacklist_file,
2017-08-17 22:00:37 +05:30
:domain_blacklist_raw,
:domain_whitelist_raw,
:email_author_in_body,
:enabled_git_access_protocol,
:gravatar_enabled,
:help_page_text,
:home_page_url,
:housekeeping_bitmaps_enabled,
:housekeeping_enabled,
:housekeeping_full_repack_period,
:housekeeping_gc_period,
:housekeeping_incremental_repack_period,
:html_emails_enabled,
:koding_enabled,
:koding_url,
:plantuml_enabled,
:plantuml_url,
2015-11-26 14:37:03 +05:30
:max_artifacts_size,
2017-08-17 22:00:37 +05:30
:max_attachment_size,
:max_pages_size,
:metrics_enabled,
:metrics_host,
:metrics_method_call_threshold,
2017-08-17 22:00:37 +05:30
:metrics_packet_size,
:metrics_pool_size,
:metrics_port,
:metrics_sample_interval,
2017-08-17 22:00:37 +05:30
:metrics_timeout,
:recaptcha_enabled,
:recaptcha_private_key,
2017-08-17 22:00:37 +05:30
:recaptcha_site_key,
2016-06-02 11:05:42 +05:30
:repository_checks_enabled,
2017-08-17 22:00:37 +05:30
:require_two_factor_authentication,
:session_expire_delay,
:sign_in_text,
:signin_enabled,
:signup_enabled,
:sentry_dsn,
:sentry_enabled,
:clientside_sentry_dsn,
:clientside_sentry_enabled,
2016-06-02 11:05:42 +05:30
:send_user_confirmation_email,
2017-08-17 22:00:37 +05:30
:shared_runners_enabled,
:shared_runners_text,
:sidekiq_throttling_enabled,
:sidekiq_throttling_factor,
:two_factor_grace_period,
:user_default_external,
:user_oauth_applications,
:unique_ips_limit_per_user,
:unique_ips_limit_time_window,
:unique_ips_limit_enabled,
:version_check_enabled,
:terminal_max_session_time,
:polling_interval_multiplier,
:usage_ping_enabled,
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