Skip to content

Commit

Permalink
Fixes #38195 - Hide http proxy setting when syncing through ssh
Browse files Browse the repository at this point in the history
Currently, the HTTP proxy policy setting in ui is displayed at all
times. However it only goes into effect when syncing through HTTP or
HTTPS. SSH sync does not use the proxy, therefore the user shoudn't be
able to see the proxy policy if a protocol different from HTTP(S) is
specified in the repo url.
  • Loading branch information
adamlazik1 authored and adamruzicka committed Feb 10, 2025
1 parent f0f1a68 commit 43b0907
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/controllers/api/v2/template_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class TemplateController < ::Api::V2::BaseController
param :filter, String, :required => false, :desc => N_("Export templates with names matching this regex (case-insensitive; snippets are not filtered).")
param :negate, :bool, :required => false, :desc => N_("Negate the prefix (for purging).")
param :dirname, String, :required => false, :desc => N_("Directory within Git repo containing the templates.")
param :http_proxy_policy, ForemanTemplates.http_proxy_policy_types.keys, :required => false, :desc => N_("HTTP proxy policy for template sync. If you choose 'selected', provide the `http_proxy_id` parameter.")
param :http_proxy_policy, ForemanTemplates.http_proxy_policy_types.keys, :required => false, :desc => N_("HTTP proxy policy for template sync. \
Use only when synchronizing templates through the HTTP or the HTTPS protocol. If you choose 'selected', provide the `http_proxy_id` parameter.")
param :http_proxy_id, :number, :required => false, :desc => N_("ID of an HTTP proxy to use for template sync. Use this parameter together with `'http_proxy_policy':'selected'`")
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ const ProxySettingsFields = ({
<React.Fragment>
<FormikField
name={proxyPolicyFieldName}
render={({ field, form }) => (
<ProxySettingField
setting={proxyPolicySetting}
resetField={resetField}
field={field}
form={form}
fieldName={proxyPolicyFieldName}
/>
)}
render={({ field, form }) => {
if (form.values[syncType]?.repo?.match(/^https?:\/\//))
return (
<ProxySettingField
setting={proxyPolicySetting}
resetField={resetField}
field={field}
form={form}
fieldName={proxyPolicyFieldName}
/>
);
return <></>;
}}
/>
<FormikField
name={proxyIdFieldName}
Expand Down

0 comments on commit 43b0907

Please sign in to comment.