debian-mirror-gitlab/app/controllers/projects/settings/operations_controller.rb

81 lines
2 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Projects
module Settings
class OperationsController < Projects::ApplicationController
2019-12-04 20:38:33 +05:30
before_action :authorize_admin_operations!
2019-02-15 15:39:39 +05:30
helper_method :error_tracking_setting
def show
end
def update
result = ::Projects::Operations::UpdateService.new(project, current_user, update_params).execute
2019-12-21 20:55:43 +05:30
track_events(result)
2019-07-07 11:18:12 +05:30
render_update_response(result)
end
2019-12-21 20:55:43 +05:30
# overridden in EE
def track_events(result)
end
2019-07-07 11:18:12 +05:30
private
# overridden in EE
def render_update_response(result)
respond_to do |format|
format.json do
render_update_json_response(result)
end
end
end
def render_update_json_response(result)
2019-02-15 15:39:39 +05:30
if result[:status] == :success
flash[:notice] = _('Your changes have been saved')
2019-07-07 11:18:12 +05:30
render json: {
status: result[:status]
}
2019-02-15 15:39:39 +05:30
else
2019-07-07 11:18:12 +05:30
render(
status: result[:http_status] || :bad_request,
json: {
status: result[:status],
message: result[:message]
}
)
2019-02-15 15:39:39 +05:30
end
end
def error_tracking_setting
@error_tracking_setting ||= project.error_tracking_setting ||
project.build_error_tracking_setting
end
def update_params
params.require(:project).permit(permitted_project_params)
end
# overridden in EE
def permitted_project_params
2019-07-07 11:18:12 +05:30
{
2019-07-31 22:56:46 +05:30
metrics_setting_attributes: [:external_dashboard_url],
2019-07-07 11:18:12 +05:30
error_tracking_setting_attributes: [
:enabled,
:api_host,
:token,
project: [:slug, :name, :organization_slug, :organization_name]
2019-12-21 20:55:43 +05:30
],
2019-12-26 22:10:19 +05:30
grafana_integration_attributes: [:token, :grafana_url, :enabled]
2019-07-07 11:18:12 +05:30
}
2019-02-15 15:39:39 +05:30
end
end
end
end
2019-12-04 20:38:33 +05:30
Projects::Settings::OperationsController.prepend_if_ee('::EE::Projects::Settings::OperationsController')