summaryrefslogtreecommitdiff
path: root/app/controllers/projects/settings/operations/error_tracking_controller.rb
blob: d0f4b6f287cc88c54014a2d9c52c643544ba1d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Projects
  module Settings
    module Operations
      class ErrorTrackingController < Projects::ApplicationController
        before_action :authorize_update_environment!

        def create
          result = ::Projects::ErrorTracking::SettingService
            .new(project, current_user, setting_params)
            .execute

          if result[:status] == :success
            flash[:notice] = _('Your changes have been saved')
          else
            flash[:alert] = result[:message]
          end

          redirect_to project_settings_operations_path(project)
        end

        private

        def setting_params
          params
            .require(:error_tracking_setting)
            .permit(:enabled, :uri, :token)
        end
      end
    end
  end
end