Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37923 - Set HTTP proxy as default after creating #11183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Katello
module Concerns
module Api
module V2
module HttpProxiesControllerExtensions
extend ::Apipie::DSL::Concern

update_api(:create) do
param :http_proxy, Hash do
param :default_content_proxy, :bool, :required => false, :desc => N_('Set this proxy as the default content proxy')
end
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Katello
module Concerns
module HttpProxiesControllerExtensions
extend ActiveSupport::Concern

included do
after_action :update_content_default_http_proxy, only: :create
end

private

def update_content_default_http_proxy
return unless @http_proxy.persisted?
return unless ActiveRecord::Type::Boolean.new.deserialize(params.dig('http_proxy', 'default_content'))

Setting[:content_default_http_proxy] = @http_proxy.name
end
end
end
end
16 changes: 16 additions & 0 deletions app/views/overrides/http_proxies/_update_setting_input.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% if @http_proxy.new_record? %>
<div class="clearfix">
<div class="form-group ">
<label class="col-md-2 control-label" for="http_proxy_default_content">
Default Content HTTP proxy
</label>
<div class="col-md-4">
<%= check_box_tag 'http_proxy[default_content]',
'1',
params.dig('http_proxy', 'default_content') == '1',
id: 'http_proxy_default_content' %>
Set this proxy as the default for content, updating the 'Default HTTP Proxy' setting.
</div>
</div>
</div>
<% end %>
6 changes: 6 additions & 0 deletions config/initializers/pagelets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
:partial => "overrides/activation_keys/host_environment_select",
:priority => 80
end

Pagelets::Manager.with_key "http_proxies/_form" do |mgr|
mgr.add_pagelet :main_tab_fields,
:partial => "overrides/http_proxies/update_setting_input",
:priority => 80
end
3 changes: 3 additions & 0 deletions lib/katello/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class Engine < ::Rails::Engine
#Controller extensions
::HostsController.include Katello::Concerns::HostsControllerExtensions
::SmartProxiesController.include Katello::Concerns::SmartProxiesControllerExtensions
::HttpProxiesController.include Katello::Concerns::HttpProxiesControllerExtensions
::RegistrationCommandsController.prepend Katello::Concerns::RegistrationCommandsControllerExtensions

#Helper Extensions
Expand Down Expand Up @@ -198,6 +199,8 @@ class Engine < ::Rails::Engine
::Api::V2::HostsBulkActionsController.include Katello::Concerns::Api::V2::HostsBulkActionsControllerExtensions
::Api::V2::HostgroupsController.include Katello::Concerns::Api::V2::HostgroupsControllerExtensions
::Api::V2::SmartProxiesController.include Katello::Concerns::Api::V2::SmartProxiesControllerExtensions
::Api::V2::HttpProxiesController.include Katello::Concerns::HttpProxiesControllerExtensions
::Api::V2::HttpProxiesController.include Katello::Concerns::Api::V2::HttpProxiesControllerExtensions
::Api::V2::RegistrationController.include ::Foreman::Controller::SmartProxyAuth
::Api::V2::RegistrationController.prepend Katello::Concerns::Api::V2::RegistrationControllerExtensions
::Api::V2::RegistrationCommandsController.include Katello::Concerns::Api::V2::RegistrationCommandsControllerExtensions
Expand Down
Loading