-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #32930 - Add new OVAL content page (#486)
- Loading branch information
Showing
17 changed files
with
517 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { Button } from '@patternfly/react-core'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const LinkButton = ({ path, btnVariant, btnText, isDisabled }) => ( | ||
<Link to={path}> | ||
<Button variant={btnVariant} isDisabled={isDisabled}> | ||
{btnText} | ||
</Button> | ||
</Link> | ||
); | ||
|
||
LinkButton.propTypes = { | ||
path: PropTypes.string.isRequired, | ||
btnText: PropTypes.string.isRequired, | ||
btnVariant: PropTypes.string, | ||
isDisabled: PropTypes.bool, | ||
}; | ||
|
||
LinkButton.defaultProps = { | ||
btnVariant: 'primary', | ||
isDisabled: false, | ||
}; | ||
|
||
export default LinkButton; |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { FormGroup, TextInput } from '@patternfly/react-core'; | ||
import { ExclamationCircleIcon } from '@patternfly/react-icons'; | ||
|
||
const wrapFieldProps = fieldProps => { | ||
const { onChange } = fieldProps; | ||
// modify onChange args to correctly wire formik with pf4 input handlers | ||
const wrappedOnChange = (value, event) => { | ||
onChange(event); | ||
}; | ||
|
||
return { ...fieldProps, onChange: wrappedOnChange }; | ||
}; | ||
|
||
const shouldValidate = (form, fieldName) => { | ||
if (form.touched[fieldName]) { | ||
return form.errors[fieldName] ? 'error' : 'success'; | ||
} | ||
|
||
return 'noval'; | ||
}; | ||
|
||
const fieldWithHandlers = Component => { | ||
const Subcomponent = ({ label, form, field, isRequired, ...rest }) => { | ||
const fieldProps = wrapFieldProps(field); | ||
const valid = shouldValidate(form, field.name); | ||
|
||
return ( | ||
<FormGroup | ||
label={label} | ||
isRequired={isRequired} | ||
helperTextInvalid={form.errors[field.name]} | ||
helperTextInvalidIcon={<ExclamationCircleIcon />} | ||
validated={valid} | ||
> | ||
<Component | ||
aria-label={fieldProps.name} | ||
{...fieldProps} | ||
{...rest} | ||
validated={valid} | ||
isDisabled={form.isSubmitting} | ||
/> | ||
</FormGroup> | ||
); | ||
}; | ||
|
||
Subcomponent.propTypes = { | ||
form: PropTypes.object.isRequired, | ||
field: PropTypes.object.isRequired, | ||
label: PropTypes.string.isRequired, | ||
isRequired: PropTypes.bool, | ||
}; | ||
|
||
Subcomponent.defaultProps = { | ||
isRequired: false, | ||
}; | ||
|
||
return Subcomponent; | ||
}; | ||
|
||
export const TextField = fieldWithHandlers(TextInput); |
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
Oops, something went wrong.