Skip to content

Commit

Permalink
Merge pull request #6714 from skateman/helper-password
Browse files Browse the repository at this point in the history
Implement helperText on the PasswordField component
  • Loading branch information
himdel authored Feb 26, 2020
2 parents 6c1f3bc + 73b2bcd commit 24fc2be
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useContext, Fragment } from 'react';
import { HelpBlock } from 'patternfly-react';
import PropTypes from 'prop-types';
import {
Button,
Expand All @@ -19,6 +20,7 @@ const PasswordField = ({
validate,
cancelEditLabel,
changeEditLabel,
helperText,
...rest
}) => {
const { name: secretKey, edit } = useContext(PasswordContext);
Expand Down Expand Up @@ -62,6 +64,7 @@ const PasswordField = ({
<Button type="button" onClick={() => setEditMode(editMode => !editMode)}>{changeEditLabel}</Button>
</InputGroup.Button>
</InputGroup>
{ helperText && <HelpBlock>{ helperText }</HelpBlock> }
</FormGroup>
)}
{!edit && formOptions.renderForm([secretField], formOptions)}
Expand All @@ -78,13 +81,15 @@ PasswordField.propTypes = {
changeEditLabel: PropTypes.string,
isDisabled: PropTypes.bool,
validate: PropTypes.func,
helperText: PropTypes.string,
};

PasswordField.defaultProps = {
cancelEditLabel: __('Cancel'),
changeEditLabel: __('Change'),
isDisabled: false,
validate: undefined,
helperText: undefined,
};

export default PasswordField;

0 comments on commit 24fc2be

Please sign in to comment.