-
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
f909477
commit 29dc629
Showing
13 changed files
with
258 additions
and
25 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
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; |
94 changes: 94 additions & 0 deletions
94
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,94 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Field as FormikField } from 'formik'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import CommonForm from 'foremanReact/components/common/forms/CommonForm'; | ||
import { InputGroup } from 'patternfly-react'; | ||
import { FieldLevelHelp } from 'patternfly-react/dist/js/components/FieldLevelHelp'; | ||
|
||
import { | ||
tooltipContent, | ||
label, | ||
} from './NewTemplateSyncForm/NewTemplateSyncFormHelpers'; | ||
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`; | ||
|
||
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 }) => { | ||
// Changing name to camel case here would unnecessarily complicate the code | ||
// eslint-disable-next-line camelcase | ||
if (form.values[syncType]?.http_proxy_policy === 'selected') { | ||
if (proxyIdSetting.value === '') { | ||
return ( | ||
<CommonForm | ||
label={label(proxyIdSetting)} | ||
required | ||
tooltipHelp={ | ||
<FieldLevelHelp content={tooltipContent(proxyIdSetting)} /> | ||
} | ||
> | ||
<InputGroup> | ||
<div>{__('No HTTP proxies available')}</div> | ||
</InputGroup> | ||
</CommonForm> | ||
); | ||
} | ||
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; |
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
Oops, something went wrong.