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
|
2015-01-08 12:53:35 -05: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 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-05-10 04:29:19 -04:00
|
|
|
|
2015-01-08 03:22:50 -05:00
|
|
|
params.require(:application_setting).permit(
|
|
|
|
:default_projects_limit,
|
2015-01-25 10:33:54 -05:00
|
|
|
:default_branch_protection,
|
2015-01-08 03:22:50 -05:00
|
|
|
:signup_enabled,
|
|
|
|
:signin_enabled,
|
2015-12-24 01:18:34 -05:00
|
|
|
:require_two_factor_authentication,
|
|
|
|
:two_factor_grace_period,
|
2015-01-08 03:22:50 -05:00
|
|
|
:gravatar_enabled,
|
|
|
|
:sign_in_text,
|
2016-05-09 11:12:53 -04:00
|
|
|
:after_sign_up_text,
|
2015-09-16 07:51:42 -04:00
|
|
|
:help_page_text,
|
2015-03-01 10:06:46 -05:00
|
|
|
:home_page_url,
|
2015-05-29 11:42:27 -04:00
|
|
|
:after_sign_out_path,
|
2015-03-20 08:11:12 -04:00
|
|
|
:max_attachment_size,
|
2015-06-05 13:16:32 -04:00
|
|
|
:session_expire_delay,
|
2015-04-26 01:01:52 -04:00
|
|
|
:default_project_visibility,
|
|
|
|
:default_snippet_visibility,
|
2016-03-08 19:01:33 -05:00
|
|
|
:default_group_visibility,
|
2015-05-02 09:53:32 -04:00
|
|
|
:restricted_signup_domains_raw,
|
2015-05-08 09:47:00 -04:00
|
|
|
:version_check_enabled,
|
2015-10-08 11:13:28 -04:00
|
|
|
:admin_notification_email,
|
2015-05-29 07:29:16 -04:00
|
|
|
:user_oauth_applications,
|
2015-11-03 08:45:41 -05:00
|
|
|
:shared_runners_enabled,
|
2016-04-15 09:51:41 -04:00
|
|
|
:shared_runners_text,
|
2015-10-12 17:47:32 -04:00
|
|
|
:max_artifacts_size,
|
2015-12-28 12:00:32 -05:00
|
|
|
:metrics_enabled,
|
|
|
|
:metrics_host,
|
2015-12-29 07:40:42 -05:00
|
|
|
:metrics_port,
|
2015-12-28 12:00:32 -05:00
|
|
|
:metrics_pool_size,
|
|
|
|
:metrics_timeout,
|
|
|
|
:metrics_method_call_threshold,
|
2016-01-13 06:29:48 -05:00
|
|
|
:metrics_sample_interval,
|
2015-12-28 15:21:34 -05:00
|
|
|
:recaptcha_enabled,
|
|
|
|
:recaptcha_site_key,
|
|
|
|
:recaptcha_private_key,
|
2016-01-18 11:15:10 -05:00
|
|
|
:sentry_enabled,
|
|
|
|
:sentry_dsn,
|
2016-01-09 14:30:34 -05:00
|
|
|
:akismet_enabled,
|
|
|
|
:akismet_api_key,
|
2016-01-26 08:34:42 -05:00
|
|
|
:email_author_in_body,
|
2016-04-12 11:32:58 -04:00
|
|
|
:repository_checks_enabled,
|
2016-04-19 08:27:08 -04:00
|
|
|
:metrics_packet_size,
|
2016-04-28 16:09:15 -04:00
|
|
|
:send_user_confirmation_email,
|
2016-05-30 11:12:50 -04:00
|
|
|
:container_registry_token_expire_delay,
|
2015-05-02 09:53:32 -04:00
|
|
|
restricted_visibility_levels: [],
|
2016-05-04 06:08:06 -04:00
|
|
|
import_sources: [],
|
|
|
|
disabled_oauth_sign_in_sources: []
|
2015-01-08 03:22:50 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|