Fixes console errors thrown about isValid on the credential form

This commit is contained in:
mabashian
2020-07-28 11:26:48 -04:00
parent 7bec29bac7
commit e6e79227e5
5 changed files with 13 additions and 12 deletions

View File

@@ -208,8 +208,10 @@ describe('<CredentialForm />', () => {
}); });
wrapper.update(); wrapper.update();
expect( expect(
wrapper.find('FormGroup[fieldId="credential-gce-file"]').prop('isValid') wrapper
).toBe(false); .find('FormGroup[fieldId="credential-gce-file"]')
.prop('validated')
).toBe('error');
expect( expect(
wrapper wrapper

View File

@@ -41,7 +41,7 @@ function BecomeMethodField({ fieldOptions, isRequired }) {
) )
} }
isRequired={isRequired} isRequired={isRequired}
isValid={!(meta.touched && meta.error)} validated={!(meta.touched && meta.error) ? 'default' : 'error'}
> >
<Select <Select
maxHeight={200} maxHeight={200}

View File

@@ -29,7 +29,7 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
onChange={(value, event) => { onChange={(value, event) => {
subFormField.onChange(event); subFormField.onChange(event);
}} }}
isValid={isValid} validated={isValid ? 'default' : 'error'}
/> />
); );
} }
@@ -38,7 +38,6 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
<PasswordInput <PasswordInput
{...subFormField} {...subFormField}
id={`credential-${fieldOptions.id}`} id={`credential-${fieldOptions.id}`}
isValid={isValid}
{...rest} {...rest}
/> />
); );
@@ -55,7 +54,7 @@ function CredentialInput({ fieldOptions, credentialKind, ...rest }) {
onChange={(value, event) => { onChange={(value, event) => {
subFormField.onChange(event); subFormField.onChange(event);
}} }}
isValid={isValid} validated={isValid ? 'default' : 'error'}
/> />
); );
} }
@@ -107,7 +106,7 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
helperTextInvalid={meta.error} helperTextInvalid={meta.error}
label={fieldOptions.label} label={fieldOptions.label}
isRequired={isRequired} isRequired={isRequired}
isValid={isValid} validated={isValid ? 'default' : 'error'}
> >
<AnsibleSelect <AnsibleSelect
{...subFormField} {...subFormField}
@@ -132,7 +131,7 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
) )
} }
isRequired={isRequired} isRequired={isRequired}
isValid={isValid} validated={isValid ? 'default' : 'error'}
> >
<CredentialInput <CredentialInput
credentialKind={credentialType.kind} credentialKind={credentialType.kind}
@@ -150,7 +149,7 @@ function CredentialField({ credentialType, fieldOptions, i18n }) {
<CredentialPluginField <CredentialPluginField
fieldOptions={fieldOptions} fieldOptions={fieldOptions}
isRequired={isRequired} isRequired={isRequired}
isValid={isValid} validated={isValid ? 'default' : 'error'}
> >
<CredentialInput fieldOptions={fieldOptions} /> <CredentialInput fieldOptions={fieldOptions} />
</CredentialPluginField> </CredentialPluginField>

View File

@@ -43,7 +43,7 @@ function CredentialPluginInput(props) {
{React.cloneElement(children, { {React.cloneElement(children, {
...inputField, ...inputField,
isRequired, isRequired,
isValid, validated: isValid ? 'default' : 'error',
isDisabled: !!passwordPromptField.value, isDisabled: !!passwordPromptField.value,
onChange: (_, event) => { onChange: (_, event) => {
inputField.onChange(event); inputField.onChange(event);
@@ -125,7 +125,7 @@ function CredentialPluginField(props) {
fieldId={`credential-${fieldOptions.id}`} fieldId={`credential-${fieldOptions.id}`}
helperTextInvalid={meta.error} helperTextInvalid={meta.error}
isRequired={isRequired} isRequired={isRequired}
isValid={isValid} validated={isValid ? 'default' : 'error'}
label={fieldOptions.label} label={fieldOptions.label}
labelIcon={ labelIcon={
fieldOptions.help_text && ( fieldOptions.help_text && (

View File

@@ -20,7 +20,7 @@ function GceFileUploadField({ i18n }) {
return ( return (
<FormGroup <FormGroup
fieldId="credential-gce-file" fieldId="credential-gce-file"
isValid={!fileError} validated={!fileError ? 'default' : 'error'}
label={i18n._(t`Service account JSON file`)} label={i18n._(t`Service account JSON file`)}
helperText={i18n._( helperText={i18n._(
t`Select a JSON formatted service account key to autopopulate the following fields.` t`Select a JSON formatted service account key to autopopulate the following fields.`