Skip to content

Commit

Permalink
refs #37923 - Bug fixes & improvements for the Default HTTP proxy
Browse files Browse the repository at this point in the history
Follow up on PR#11183 with:
* Unified naming of the parameter ('content_default_http_proxy')
* On edit form showing information if the capsule is default
* Fixed API + extended show with 'content_default_http_proxy'
  • Loading branch information
stejskalleos committed Dec 18, 2024
1 parent b551d41 commit 55c376d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module V2
module HttpProxiesControllerExtensions
extend ::Apipie::DSL::Concern

update_api(:create) do
update_api(:create, :show) do
param :http_proxy, Hash do
param :default_content_proxy, :bool, :required => false, :desc => N_('Set this HTTP proxy as the default content HTTP proxy')
param :content_default_http_proxy, :bool, :required => false, :desc => N_('Set this HTTP proxy as the default content HTTP proxy')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module HttpProxiesControllerExtensions

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

Setting[:content_default_http_proxy] = @http_proxy.name
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/katello/concerns/http_proxy_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def name_and_url
uri.user = nil
"#{name} (#{uri})"
end

def content_default_http_proxy?
Setting[:content_default_http_proxy] == name
end
end
end
end
1 change: 1 addition & 0 deletions app/views/katello/api/v2/http_proxies/show.json.rabl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node(:content_default_http_proxy) { |sp| sp.content_default_http_proxy? }
30 changes: 16 additions & 14 deletions app/views/overrides/http_proxies/_update_setting_input.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<% 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 class="clearfix">
<div class="form-group ">
<label class="col-md-2 control-label" for="http_proxy_content_default_http_proxy">
Default content HTTP proxy
</label>
<div class="col-md-4">
<% if @http_proxy.new_record? %>
<%= check_box_tag 'http_proxy[content_default_http_proxy]',
'1',
params.dig('http_proxy', 'content_default_http_proxy') == '1',
id: 'content_default_http_proxy' %>
Set this proxy as the default for content, updating the 'Default HTTP Proxy' setting.
<% else %>
<%= @http_proxy.content_default_http_proxy? ? _('Yes') : _('No') %>
<% end %>
</div>
</div>
<% end %>
</div>
1 change: 1 addition & 0 deletions lib/katello/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
extend_rabl_template 'api/v2/smart_proxies/main', 'katello/api/v2/smart_proxies/pulp_info'
extend_rabl_template 'api/v2/hosts/show', 'katello/api/v2/hosts/host_collections'
extend_rabl_template 'api/v2/hosts/show', 'katello/api/v2/hosts/show'
extend_rabl_template 'api/v2/http_proxies/show', 'katello/api/v2/http_proxies/show'

# Katello variables for Host Registration
extend_allowed_registration_vars :activation_keys
Expand Down

0 comments on commit 55c376d

Please sign in to comment.