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 'lib/api/error_tracking.rb')
-rw-r--r--lib/api/error_tracking.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/api/error_tracking.rb b/lib/api/error_tracking.rb
index 3abf2831bd3..369efe3bf8c 100644
--- a/lib/api/error_tracking.rb
+++ b/lib/api/error_tracking.rb
@@ -6,24 +6,30 @@ module API
feature_category :error_tracking
+ helpers do
+ def project_setting
+ @project_setting ||= user_project.error_tracking_setting
+ end
+ end
+
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ before do
+ authorize! :admin_operations, user_project
+
+ not_found!('Error Tracking Setting') unless project_setting
+ end
+
desc 'Get error tracking settings for the project' do
detail 'This feature was introduced in GitLab 12.7.'
success Entities::ErrorTracking::ProjectSetting
end
get ':id/error_tracking/settings' do
- authorize! :admin_operations, user_project
-
- setting = user_project.error_tracking_setting
-
- not_found!('Error Tracking Setting') unless setting
-
- present setting, with: Entities::ErrorTracking::ProjectSetting
+ present project_setting, with: Entities::ErrorTracking::ProjectSetting
end
desc 'Enable or disable error tracking settings for the project' do
@@ -36,12 +42,6 @@ module API
end
patch ':id/error_tracking/settings/' do
- authorize! :admin_operations, user_project
-
- setting = user_project.error_tracking_setting
-
- not_found!('Error Tracking Setting') unless setting
-
update_params = {
error_tracking_setting_attributes: { enabled: params[:active] }
}
@@ -53,7 +53,7 @@ module API
result = ::Projects::Operations::UpdateService.new(user_project, current_user, update_params).execute
if result[:status] == :success
- present setting, with: Entities::ErrorTracking::ProjectSetting
+ present project_setting, with: Entities::ErrorTracking::ProjectSetting
else
result
end