2015-01-08 03:22:50 -05:00
|
|
|
class Admin::ApplicationSettingsController < Admin::ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :set_application_setting
|
2015-01-08 03:22:50 -05:00
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2017-01-20 10:00:19 -05:00
|
|
|
successful = ApplicationSettings::UpdateService
|
|
|
|
.new(@application_setting, current_user, application_setting_params)
|
|
|
|
.execute
|
|
|
|
|
|
|
|
if successful
|
2015-01-08 12:53:35 -05:00
|
|
|
redirect_to admin_application_settings_path,
|
|
|
|
notice: 'Application settings saved successfully'
|
|
|
|
else
|
|
|
|
render :show
|
|
|
|
end
|
2015-01-08 03:22:50 -05:00
|
|
|
end
|
|
|
|
|
2015-12-11 04:22:05 -05:00
|
|
|
def reset_runners_token
|
|
|
|
@application_setting.reset_runners_registration_token!
|
|
|
|
flash[:notice] = 'New runners registration token has been generated!'
|
2015-12-14 08:03:58 -05:00
|
|
|
redirect_to admin_runners_path
|
2015-12-11 04:22:05 -05:00
|
|
|
end
|
|
|
|
|
2016-05-09 19:21:22 -04:00
|
|
|
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
|
|
|
|
|
2016-04-12 11:32:58 -04:00
|
|
|
def clear_repository_check_states
|
2016-04-13 09:56:05 -04:00
|
|
|
RepositoryCheck::ClearWorker.perform_async
|
2016-04-12 11:32:58 -04:00
|
|
|
|
|
|
|
redirect_to(
|
|
|
|
admin_application_settings_path,
|
2016-04-13 09:56:05 -04:00
|
|
|
notice: 'Started asynchronous removal of all repository check states.'
|
2016-04-12 11:32:58 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2015-01-08 03:22:50 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_application_setting
|
2015-01-08 14:26:16 -05:00
|
|
|
@application_setting = ApplicationSetting.current
|
2015-01-08 03:22:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def application_setting_params
|
2015-03-01 10:06:46 -05:00
|
|
|
restricted_levels = params[:application_setting][:restricted_visibility_levels]
|
2015-03-16 15:59:50 -04:00
|
|
|
if restricted_levels.nil?
|
|
|
|
params[:application_setting][:restricted_visibility_levels] = []
|
|
|
|
else
|
2015-03-01 10:06:46 -05:00
|
|
|
restricted_levels.map! do |level|
|
|
|
|
level.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-12 02:13:20 -04:00
|
|
|
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-05-12 02:37:15 -04:00
|
|
|
enabled_oauth_sign_in_sources = params[:application_setting].delete(:enabled_oauth_sign_in_sources)
|
2016-05-10 04:29:19 -04:00
|
|
|
|
|
|
|
params[:application_setting][:disabled_oauth_sign_in_sources] =
|
|
|
|
AuthHelper.button_based_providers.map(&:to_s) -
|
2016-05-10 11:45:39 -04:00
|
|
|
Array(enabled_oauth_sign_in_sources)
|
2016-07-14 14:19:40 -04:00
|
|
|
params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file]
|
2016-05-10 04:29:19 -04:00
|
|
|
|
2015-01-08 03:22:50 -05:00
|
|
|
params.require(:application_setting).permit(
|
2017-01-10 08:40:08 -05:00
|
|
|
application_setting_params_ce
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def application_setting_params_ce
|
|
|
|
[
|
|
|
|
:admin_notification_email,
|
2015-05-29 11:42:27 -04:00
|
|
|
:after_sign_out_path,
|
2017-01-10 08:40:08 -05:00
|
|
|
:after_sign_up_text,
|
|
|
|
:akismet_api_key,
|
|
|
|
:akismet_enabled,
|
|
|
|
:container_registry_token_expire_delay,
|
|
|
|
:default_branch_protection,
|
|
|
|
:default_group_visibility,
|
2015-04-26 01:01:52 -04:00
|
|
|
:default_project_visibility,
|
2017-01-10 08:40:08 -05:00
|
|
|
:default_projects_limit,
|
2015-04-26 01:01:52 -04:00
|
|
|
:default_snippet_visibility,
|
2016-07-19 18:08:40 -04:00
|
|
|
:domain_blacklist_enabled,
|
|
|
|
:domain_blacklist_file,
|
2017-01-10 08:40:08 -05:00
|
|
|
: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,
|
2016-11-28 12:41:29 -05:00
|
|
|
:plantuml_enabled,
|
|
|
|
:plantuml_url,
|
2015-10-12 17:47:32 -04:00
|
|
|
:max_artifacts_size,
|
2017-01-10 08:40:08 -05:00
|
|
|
:max_attachment_size,
|
2015-11-03 15:28:07 -05:00
|
|
|
:max_pages_size,
|
2015-12-28 12:00:32 -05:00
|
|
|
:metrics_enabled,
|
|
|
|
:metrics_host,
|
|
|
|
:metrics_method_call_threshold,
|
2017-01-10 08:40:08 -05:00
|
|
|
:metrics_packet_size,
|
|
|
|
:metrics_pool_size,
|
|
|
|
:metrics_port,
|
2016-01-13 06:29:48 -05:00
|
|
|
:metrics_sample_interval,
|
2017-01-10 08:40:08 -05:00
|
|
|
:metrics_timeout,
|
2015-12-28 15:21:34 -05:00
|
|
|
:recaptcha_enabled,
|
|
|
|
:recaptcha_private_key,
|
2017-01-10 08:40:08 -05:00
|
|
|
:recaptcha_site_key,
|
2016-04-12 11:32:58 -04:00
|
|
|
:repository_checks_enabled,
|
2017-01-10 08:40:08 -05:00
|
|
|
:require_two_factor_authentication,
|
|
|
|
:session_expire_delay,
|
|
|
|
:sign_in_text,
|
|
|
|
:signin_enabled,
|
|
|
|
:signup_enabled,
|
|
|
|
:sentry_dsn,
|
|
|
|
:sentry_enabled,
|
2016-04-28 16:09:15 -04:00
|
|
|
:send_user_confirmation_email,
|
2017-01-10 08:40:08 -05:00
|
|
|
:shared_runners_enabled,
|
|
|
|
:shared_runners_text,
|
2016-11-04 14:53:12 -04:00
|
|
|
:sidekiq_throttling_enabled,
|
2016-11-04 18:54:24 -04:00
|
|
|
:sidekiq_throttling_factor,
|
2017-01-10 08:40:08 -05:00
|
|
|
:two_factor_grace_period,
|
|
|
|
:user_default_external,
|
|
|
|
:user_oauth_applications,
|
|
|
|
:version_check_enabled,
|
2017-01-26 13:16:50 -05:00
|
|
|
:terminal_max_session_time,
|
2017-01-10 08:40:08 -05:00
|
|
|
|
|
|
|
disabled_oauth_sign_in_sources: [],
|
|
|
|
import_sources: [],
|
2016-11-03 10:12:20 -04:00
|
|
|
repository_storages: [],
|
2015-05-02 09:53:32 -04:00
|
|
|
restricted_visibility_levels: [],
|
2016-11-04 18:54:24 -04:00
|
|
|
sidekiq_throttling_queues: []
|
2017-01-10 08:40:08 -05:00
|
|
|
]
|
2015-01-08 03:22:50 -05:00
|
|
|
end
|
|
|
|
end
|