mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 19:20:05 -03:30
Update validators for Misc Auth Edit
* Update SharedFields to use number validator instead of integer * Use number validation for SESSIONS_PER_USER See: https://github.com/ansible/tower/issues/5396
This commit is contained in:
@@ -22,7 +22,7 @@ import CodeEditor from 'components/CodeEditor';
|
|||||||
import { PasswordInput } from 'components/FormField';
|
import { PasswordInput } from 'components/FormField';
|
||||||
import { FormFullWidthLayout } from 'components/FormLayout';
|
import { FormFullWidthLayout } from 'components/FormLayout';
|
||||||
import Popover from 'components/Popover';
|
import Popover from 'components/Popover';
|
||||||
import { combine, integer, minMaxValue, required, url } from 'util/validators';
|
import { combine, minMaxValue, required, url, number } from 'util/validators';
|
||||||
import AlertModal from 'components/AlertModal';
|
import AlertModal from 'components/AlertModal';
|
||||||
import RevertButton from './RevertButton';
|
import RevertButton from './RevertButton';
|
||||||
|
|
||||||
@@ -365,12 +365,11 @@ const InputField = ({ name, config, type = 'text', isRequired = false }) => {
|
|||||||
const validators = [
|
const validators = [
|
||||||
...(isRequired ? [required(null)] : []),
|
...(isRequired ? [required(null)] : []),
|
||||||
...(type === 'url' ? [url()] : []),
|
...(type === 'url' ? [url()] : []),
|
||||||
...(type === 'number'
|
...(type === 'number' ? [number(), minMaxValue(min_value, max_value)] : []),
|
||||||
? [integer(), minMaxValue(min_value, max_value)]
|
|
||||||
: []),
|
|
||||||
];
|
];
|
||||||
const [field, meta] = useField({ name, validate: combine(validators) });
|
const [field, meta] = useField({ name, validate: combine(validators) });
|
||||||
const isValid = !(meta.touched && meta.error);
|
const isValid = !(meta.touched && meta.error);
|
||||||
|
|
||||||
return config ? (
|
return config ? (
|
||||||
<SettingGroup
|
<SettingGroup
|
||||||
defaultValue={config.default ?? ''}
|
defaultValue={config.default ?? ''}
|
||||||
@@ -382,6 +381,7 @@ const InputField = ({ name, config, type = 'text', isRequired = false }) => {
|
|||||||
validated={isValid ? 'default' : 'error'}
|
validated={isValid ? 'default' : 'error'}
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
type={type}
|
||||||
id={name}
|
id={name}
|
||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
placeholder={config.placeholder}
|
placeholder={config.placeholder}
|
||||||
|
|||||||
Reference in New Issue
Block a user