summaryrefslogtreecommitdiff
path: root/app/controllers/projects/settings/operations/error_tracking_controller.rb
blob: 9409fcdc541d2f535c2cacf094db8071c86c1026 (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
34
35
36
37
38
# frozen_string_literal: true

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

        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 check_feature_flag
          render_404 unless Feature.enabled?(:error_tracking, current_user)
        end

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