Skip to content

Commit

Permalink
Fixes #37923 - Set HTTP proxy as default after creating
Browse files Browse the repository at this point in the history
  • Loading branch information
stejskalleos committed Nov 14, 2024
1 parent 640ef71 commit e320acd
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
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

0 comments on commit e320acd

Please sign in to comment.