2015-01-08 08:22:50 +00:00
|
|
|
class Admin::ApplicationSettingsController < Admin::ApplicationController
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :set_application_setting
|
2015-01-08 08:22:50 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-01-08 17:53:35 +00:00
|
|
|
if @application_setting.update_attributes(application_setting_params)
|
|
|
|
redirect_to admin_application_settings_path,
|
|
|
|
notice: 'Application settings saved successfully'
|
|
|
|
else
|
|
|
|
render :show
|
|
|
|
end
|
2015-01-08 08:22:50 +00:00
|
|
|
end
|
|
|
|
|
2015-12-11 09:22:05 +00:00
|
|
|
def reset_runners_token
|
|
|
|
@application_setting.reset_runners_registration_token!
|
|
|
|
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!'
|
|
|
|
redirect_to :back
|
|
|
|
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
|
2015-01-08 19:26:16 +00:00
|
|
|
@application_setting = ApplicationSetting.current
|
2015-01-08 08:22:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def application_setting_params
|
2015-03-01 15:06:46 +00:00
|
|
|
restricted_levels = params[:application_setting][:restricted_visibility_levels]
|
2015-03-16 19:59:50 +00:00
|
|
|
if restricted_levels.nil?
|
|
|
|
params[:application_setting][:restricted_visibility_levels] = []
|
|
|
|
else
|
2015-03-01 15:06:46 +00:00
|
|
|
restricted_levels.map! do |level|
|
|
|
|
level.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-12 06:13:20 +00: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 06:37:15 +00:00
|
|
|
enabled_oauth_sign_in_sources = params[:application_setting].delete(:enabled_oauth_sign_in_sources)
|
2016-05-10 08:29:19 +00:00
|
|
|
|
|
|
|
params[:application_setting][:disabled_oauth_sign_in_sources] =
|
|
|
|
AuthHelper.button_based_providers.map(&:to_s) -
|
2016-05-10 15:45:39 +00:00
|
|
|
Array(enabled_oauth_sign_in_sources)
|
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(
|
|
|
|
:default_projects_limit,
|
2015-01-25 15:33:54 +00:00
|
|
|
:default_branch_protection,
|
2015-01-08 08:22:50 +00:00
|
|
|
:signup_enabled,
|
|
|
|
:signin_enabled,
|
2015-12-24 06:18:34 +00:00
|
|
|
:require_two_factor_authentication,
|
|
|
|
:two_factor_grace_period,
|
2015-01-08 08:22:50 +00:00
|
|
|
:gravatar_enabled,
|
|
|
|
:sign_in_text,
|
2016-05-09 15:12:53 +00:00
|
|
|
:after_sign_up_text,
|
2015-09-16 11:51:42 +00:00
|
|
|
:help_page_text,
|
2015-03-01 15:06:46 +00:00
|
|
|
:home_page_url,
|
2015-05-29 15:42:27 +00:00
|
|
|
:after_sign_out_path,
|
2015-03-20 12:11:12 +00:00
|
|
|
:max_attachment_size,
|
2015-06-05 17:16:32 +00:00
|
|
|
:session_expire_delay,
|
2015-04-26 05:01:52 +00:00
|
|
|
:default_project_visibility,
|
|
|
|
:default_snippet_visibility,
|
2016-03-09 00:01:33 +00:00
|
|
|
:default_group_visibility,
|
2016-07-15 23:30:38 +00:00
|
|
|
:domain_whitelist_raw,
|
2016-07-19 22:08:40 +00:00
|
|
|
:domain_blacklist_enabled,
|
|
|
|
:domain_blacklist_raw,
|
|
|
|
:domain_blacklist_file,
|
2015-05-08 13:47:00 +00:00
|
|
|
:version_check_enabled,
|
2015-10-08 15:13:28 +00:00
|
|
|
:admin_notification_email,
|
2015-05-29 11:29:16 +00:00
|
|
|
:user_oauth_applications,
|
2016-07-06 17:46:41 +00:00
|
|
|
:user_default_external,
|
2015-11-03 13:45:41 +00:00
|
|
|
:shared_runners_enabled,
|
2016-04-15 13:51:41 +00:00
|
|
|
:shared_runners_text,
|
2015-10-12 21:47:32 +00:00
|
|
|
:max_artifacts_size,
|
2015-12-28 17:00:32 +00:00
|
|
|
:metrics_enabled,
|
|
|
|
:metrics_host,
|
2015-12-29 12:40:42 +00:00
|
|
|
:metrics_port,
|
2015-12-28 17:00:32 +00:00
|
|
|
:metrics_pool_size,
|
|
|
|
:metrics_timeout,
|
|
|
|
:metrics_method_call_threshold,
|
2016-01-13 11:29:48 +00:00
|
|
|
:metrics_sample_interval,
|
2015-12-28 20:21:34 +00:00
|
|
|
:recaptcha_enabled,
|
|
|
|
:recaptcha_site_key,
|
|
|
|
:recaptcha_private_key,
|
2016-01-18 16:15:10 +00:00
|
|
|
:sentry_enabled,
|
|
|
|
:sentry_dsn,
|
2016-01-09 19:30:34 +00:00
|
|
|
:akismet_enabled,
|
|
|
|
:akismet_api_key,
|
2016-07-26 03:59:39 +00:00
|
|
|
:koding_enabled,
|
|
|
|
:koding_url,
|
2016-01-26 13:34:42 +00:00
|
|
|
:email_author_in_body,
|
2016-11-28 22:00:03 +00:00
|
|
|
:html_emails_enabled,
|
2016-04-12 15:32:58 +00:00
|
|
|
:repository_checks_enabled,
|
2016-04-19 12:27:08 +00:00
|
|
|
:metrics_packet_size,
|
2016-04-28 20:09:15 +00:00
|
|
|
:send_user_confirmation_email,
|
2016-05-30 15:12:50 +00:00
|
|
|
:container_registry_token_expire_delay,
|
2016-06-30 20:11:52 +00:00
|
|
|
:enabled_git_access_protocol,
|
2016-11-04 18:53:12 +00:00
|
|
|
:sidekiq_throttling_enabled,
|
2016-11-04 22:54:24 +00:00
|
|
|
:sidekiq_throttling_factor,
|
2016-10-27 12:59:52 +00:00
|
|
|
:housekeeping_enabled,
|
|
|
|
:housekeeping_bitmaps_enabled,
|
|
|
|
:housekeeping_incremental_repack_period,
|
|
|
|
:housekeeping_full_repack_period,
|
|
|
|
:housekeeping_gc_period,
|
2016-11-03 14:12:20 +00:00
|
|
|
repository_storages: [],
|
2015-05-02 13:53:32 +00:00
|
|
|
restricted_visibility_levels: [],
|
2016-05-04 10:08:06 +00:00
|
|
|
import_sources: [],
|
2016-11-04 22:54:24 +00:00
|
|
|
disabled_oauth_sign_in_sources: [],
|
|
|
|
sidekiq_throttling_queues: []
|
2015-01-08 08:22:50 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|