-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from jtomasek/proxy-toggle
Add checkbox to enable proxy configuration on discovery ISO dialog
- Loading branch information
Showing
9 changed files
with
121 additions
and
19 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
29 changes: 29 additions & 0 deletions
29
src/components/clusterConfiguration/DiscoveryProxyFields.tsx
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,29 @@ | ||
import React from 'react'; | ||
import { useFormikContext } from 'formik'; | ||
import { InputField, CheckboxField } from '../ui/formik'; | ||
import { DiscoveryImageFormValues } from './types'; | ||
|
||
const DiscoveryProxyFields: React.FC = () => { | ||
const { setFieldValue, values } = useFormikContext<DiscoveryImageFormValues>(); | ||
const resetProxy = () => setFieldValue('proxyUrl', ''); | ||
return ( | ||
<> | ||
<CheckboxField | ||
label="Configure HTTP Proxy" | ||
name="enableProxy" | ||
helperText="If hosts are behind a firewall that requires the use of a proxy, provide additional information about the proxy." | ||
onChange={(value: boolean) => !value && resetProxy()} | ||
/> | ||
{values.enableProxy && ( | ||
<InputField | ||
label="HTTP Proxy URL" | ||
name="proxyUrl" | ||
placeholder="http://<user>:<password>@<ipaddr>:<port>" | ||
helperText="HTTP proxy URL that agents should use to access the discovery service" | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default DiscoveryProxyFields; |
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,5 @@ | ||
import { ImageCreateParams } from '../../api/types'; | ||
|
||
export type DiscoveryImageFormValues = ImageCreateParams & { | ||
enableProxy: boolean; | ||
}; |
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,40 @@ | ||
import * as React from 'react'; | ||
import { useField } from 'formik'; | ||
import { Checkbox } from '@patternfly/react-core'; | ||
import { CheckboxFieldProps } from './types'; | ||
import { getFieldId } from './utils'; | ||
import HelperText from './HelperText'; | ||
|
||
const CheckboxField: React.FC<CheckboxFieldProps> = ({ | ||
label, | ||
helperText, | ||
onChange, | ||
validate, | ||
...props | ||
}) => { | ||
const [field] = useField({ name: props.name, validate }); | ||
const fieldId = getFieldId(props.name, 'input'); | ||
return ( | ||
<Checkbox | ||
{...field} | ||
{...props} | ||
id={fieldId} | ||
label={label} | ||
aria-describedby={`${fieldId}-helper`} | ||
description={ | ||
typeof helperText === 'string' ? ( | ||
helperText | ||
) : ( | ||
<HelperText fieldId={fieldId}>{helperText}</HelperText> | ||
) | ||
} | ||
isChecked={field.value} | ||
onChange={(value, event) => { | ||
field.onChange(event); | ||
onChange && onChange(value, event); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default CheckboxField; |
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,18 @@ | ||
import React from 'react'; | ||
import { css } from '@patternfly/react-styles'; | ||
|
||
type HelperTextProps = { | ||
fieldId: string; | ||
}; | ||
|
||
/** | ||
* HelperText component standardizes the format of non string helperText prop on FormGroup | ||
* which is otherwise rendered 'as is' in FormGroup | ||
*/ | ||
const HelperText: React.FC<HelperTextProps> = ({ fieldId, children }) => ( | ||
<div className={css('pf-c-form__helper-text')} id={`${fieldId}-helper`} aria-live="polite"> | ||
{children} | ||
</div> | ||
); | ||
|
||
export default HelperText; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as InputField } from './InputField'; | ||
export { default as CheckboxField } from './CheckboxField'; | ||
export { default as TextAreaField } from './TextAreaField'; | ||
export { default as SelectField } from './SelectField'; | ||
export { default as TextAreaSecretField } from './TextAreaSecretField'; |
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