-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37900 - Allow syncing templates through HTTP proxy
- Loading branch information
1 parent
85064cf
commit 12c0989
Showing
16 changed files
with
323 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
webpack/components/NewTemplateSync/components/ProxySettingField.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { get } from 'lodash'; | ||
|
||
import { FieldLevelHelp } from 'patternfly-react'; | ||
import RenderField from './TextButtonField/RenderField'; | ||
import ButtonTooltip from './ButtonTooltip'; | ||
|
||
import { | ||
tooltipContent, | ||
label, | ||
} from './NewTemplateSyncForm/NewTemplateSyncFormHelpers'; | ||
|
||
const ProxySettingField = ({ setting, resetField, field, form, fieldName }) => ( | ||
<RenderField | ||
label={label(setting)} | ||
fieldSelector={_ => 'select'} | ||
tooltipHelp={<FieldLevelHelp content={tooltipContent(setting)} />} | ||
buttonAttrs={{ | ||
buttonText: <ButtonTooltip tooltipId={fieldName} />, | ||
buttonAction: () => | ||
resetField(fieldName, setting.value)(form.setFieldValue), | ||
}} | ||
blank={{}} | ||
item={setting} | ||
disabled={false} | ||
fieldRequired | ||
meta={{ | ||
touched: get(form.touched, fieldName), | ||
error: get(form.errors, fieldName), | ||
}} | ||
input={field} | ||
/> | ||
); | ||
|
||
ProxySettingField.propTypes = { | ||
setting: PropTypes.object.isRequired, | ||
resetField: PropTypes.func.isRequired, | ||
field: PropTypes.object.isRequired, | ||
form: PropTypes.object.isRequired, | ||
fieldName: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ProxySettingField; |
82 changes: 82 additions & 0 deletions
82
webpack/components/NewTemplateSync/components/ProxySettingFields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Field as FormikField } from 'formik'; | ||
|
||
import ProxySettingField from './ProxySettingField'; | ||
|
||
const ProxySettingsFields = ({ | ||
proxyPolicySetting, | ||
proxyIdSetting, | ||
syncType, | ||
resetField, | ||
formProps: { isSubmitting }, | ||
}) => { | ||
if (Object.keys(proxyPolicySetting).length === 0) { | ||
return <></>; | ||
} | ||
const proxyPolicyFieldName = `${syncType}.http_proxy_policy`; | ||
const proxyIdFieldName = `${syncType}.http_proxy_id`; | ||
|
||
// removes the custom proxy option if no proxy is available | ||
if (proxyIdSetting.value === '') { | ||
proxyPolicySetting = proxyPolicySetting.set( | ||
'selection', | ||
proxyPolicySetting.selection.slice(0, 2) | ||
); | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
<FormikField | ||
name={proxyPolicyFieldName} | ||
render={({ field, form }) => ( | ||
<ProxySettingField | ||
setting={proxyPolicySetting} | ||
resetField={resetField} | ||
field={field} | ||
form={form} | ||
fieldName={proxyPolicyFieldName} | ||
/> | ||
)} | ||
/> | ||
<FormikField | ||
name={proxyIdFieldName} | ||
render={({ field, form }) => { | ||
if ( | ||
proxyIdSetting.value !== '' && | ||
// Changing name to camel case here would unnecessarily complicate the code | ||
// eslint-disable-next-line camelcase | ||
form.values[syncType]?.http_proxy_policy === 'selected' | ||
) { | ||
return ( | ||
<ProxySettingField | ||
setting={proxyIdSetting} | ||
resetField={resetField} | ||
field={field} | ||
form={form} | ||
fieldName={proxyIdFieldName} | ||
/> | ||
); | ||
} | ||
return <></>; | ||
}} | ||
/> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
ProxySettingsFields.propTypes = { | ||
proxyPolicySetting: PropTypes.object, | ||
proxyIdSetting: PropTypes.object, | ||
syncType: PropTypes.string.isRequired, | ||
resetField: PropTypes.func.isRequired, | ||
formProps: PropTypes.object, | ||
}; | ||
|
||
ProxySettingsFields.defaultProps = { | ||
formProps: {}, | ||
proxyPolicySetting: {}, | ||
proxyIdSetting: {}, | ||
}; | ||
|
||
export default ProxySettingsFields; |
Oops, something went wrong.