Commit c469cc72 authored by Peter Leitzen's avatar Peter Leitzen

Move settings operations controller from EE to CE

For more information see the CE MR:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24147
parent c7abcd31
# frozen_string_literal: true
module EE
module Projects
module Settings
module OperationsController
extend ::Gitlab::Utils::Override
extend ActiveSupport::Concern
prepended do
helper_method :tracing_setting
def tracing_setting
@tracing_setting ||= project.tracing_setting || project.build_tracing_setting
end
private :tracing_setting
end
override :permitted_project_params
def permitted_project_params
super.merge(tracing_setting_attributes: [:external_url])
end
end
end
end
end
# frozen_string_literal: true
module Projects
module Settings
class OperationsController < Projects::ApplicationController
before_action :check_license
before_action :authorize_update_environment!
def show
end
def update
result = ::Projects::Operations::UpdateService.new(project, current_user, update_params).execute
if result[:status] == :success
flash[:notice] = _('Your changes have been saved')
redirect_to project_settings_operations_path(@project)
else
render 'show'
end
end
private
helper_method :tracing_setting
def tracing_setting
@tracing_setting ||= project.tracing_setting || project.build_tracing_setting
end
def update_params
params.require(:project).permit(tracing_setting_attributes: [:external_url])
end
def check_license
render_404 unless @project.feature_available?(:tracing, current_user)
end
end
end
end
......@@ -202,5 +202,11 @@ module EE
}
end
end
def settings_operations_available?
return true if super
@project.feature_available?(:tracing, current_user) && can?(current_user, :read_environment, @project)
end
end
end
# frozen_string_literal: true
module EE
module Projects
module Operations
module UpdateService
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
override :project_update_params
def project_update_params
super.merge(tracing_setting_params)
end
private
def tracing_setting_params
attr = params[:tracing_setting_attributes]
return {} unless attr
destroy = attr[:external_url].blank?
{ tracing_setting_attributes: attr.merge(_destroy: destroy) }
end
end
end
end
end
# frozen_string_literal: true
module Projects
module Operations
class UpdateService < BaseService
def execute
Projects::UpdateService
.new(project, current_user, project_update_params)
.execute
end
private
def project_update_params
tracing_setting_params(params)
end
def tracing_setting_params(params)
attr = params[:tracing_setting_attributes]
return params unless attr
destroy = attr[:external_url].blank?
{ tracing_setting_attributes: attr.merge(_destroy: destroy) }
end
end
end
end
- return unless @project.feature_available?(:tracing, current_user)
- setting = tracing_setting
- has_jaeger_url = setting.external_url.present?
%section
......
- @content_class = "limit-container-width" unless fluid_layout
- page_title _("Operations")
- if @project.feature_available?(:tracing, current_user)
= render_if_exists 'projects/settings/operations/tracing', setting: tracing_setting
- return unless @project.feature_available?(:tracing)
= nav_link(controller: [:operations]) do
= link_to project_settings_operations_path(@project), title: _('Operations') do
= _('Operations')
......@@ -11,10 +11,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :tracing, only: [:show]
namespace :settings do
resource :operations, only: [:show, :update]
end
resources :autocomplete_sources, only: [] do
collection do
get 'epics'
......
......@@ -10099,9 +10099,6 @@ msgstr ""
msgid "Your changes have been committed. Commit %{commitId} %{commitStats}"
msgstr ""
msgid "Your changes have been saved"
msgstr ""
msgid "Your comment will not be visible to the public."
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment