Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin/application_settings_controller.rb')
-rw-r--r--app/controllers/admin/application_settings_controller.rb83
1 files changed, 39 insertions, 44 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 57b976b9121..42634bf611e 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -6,56 +6,19 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :set_application_setting
before_action :whitelist_query_limiting, only: [:usage_data]
- def show
- end
-
- def integrations
- end
-
- def repository
- end
-
- def templates
- end
-
- def ci_cd
- end
-
- def reporting
- end
-
- def metrics_and_profiling
- end
-
- def network
- end
+ VALID_SETTING_PANELS = %w(show integrations repository templates
+ ci_cd reporting metrics_and_profiling
+ network geo preferences).freeze
- def geo
+ def show
end
- def preferences
+ (VALID_SETTING_PANELS - %w(show)).each do |action|
+ define_method(action) { perform_update if submitted? }
end
def update
- successful = ApplicationSettings::UpdateService
- .new(@application_setting, current_user, application_setting_params)
- .execute
-
- if recheck_user_consent?
- session[:ask_for_usage_stats_consent] = current_user.requires_usage_stats_consent?
- end
-
- redirect_path = referer_path(request) || admin_application_settings_path
-
- respond_to do |format|
- if successful
- format.json { head :ok }
- format.html { redirect_to redirect_path, notice: _('Application settings saved successfully') }
- else
- format.json { head :bad_request }
- format.html { render :show }
- end
- end
+ perform_update
end
def usage_data
@@ -149,6 +112,38 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
]
end
+ def submitted?
+ request.patch?
+ end
+
+ def perform_update
+ successful = ApplicationSettings::UpdateService
+ .new(@application_setting, current_user, application_setting_params)
+ .execute
+
+ if recheck_user_consent?
+ session[:ask_for_usage_stats_consent] = current_user.requires_usage_stats_consent?
+ end
+
+ redirect_path = referer_path(request) || admin_application_settings_path
+
+ respond_to do |format|
+ if successful
+ format.json { head :ok }
+ format.html { redirect_to redirect_path, notice: _('Application settings saved successfully') }
+ else
+ format.json { head :bad_request }
+ format.html { render_update_error }
+ end
+ end
+ end
+
+ def render_update_error
+ action = VALID_SETTING_PANELS.include?(action_name) ? action_name : :show
+
+ render action
+ end
+
def lets_encrypt_visible_attributes
return [] unless Feature.enabled?(:pages_auto_ssl)