mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
moves validator function
This commit is contained in:
parent
a95632c349
commit
ee6fda9f8a
@ -41,6 +41,5 @@ describe('ErrorDetail', () => {
|
||||
);
|
||||
wrapper.find('Expandable').prop('onToggle')();
|
||||
wrapper.update();
|
||||
// console.log(wrapper.find('ErrorDetail').prop('error'));
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
export default function getErrorMessage(response) {
|
||||
if (typeof response.data === 'string') {
|
||||
return response.data;
|
||||
}
|
||||
if (!response.data) {
|
||||
return null;
|
||||
}
|
||||
if (typeof response.data === 'string') {
|
||||
return response.data;
|
||||
}
|
||||
if (response.data.detail) {
|
||||
return response.data.detail;
|
||||
}
|
||||
|
||||
@ -6,9 +6,11 @@ import InventoryStep from './InventoryStep';
|
||||
import CredentialsStep from './CredentialsStep';
|
||||
import OtherPromptsStep from './OtherPromptsStep';
|
||||
import PreviewStep from './PreviewStep';
|
||||
import { InventoriesAPI } from '@api';
|
||||
import { InventoriesAPI, CredentialsAPI, CredentialTypesAPI } from '@api';
|
||||
|
||||
jest.mock('@api/models/Inventories');
|
||||
jest.mock('@api/models/CredentialTypes');
|
||||
jest.mock('@api/models/Credentials');
|
||||
|
||||
let config;
|
||||
const resource = {
|
||||
@ -25,6 +27,10 @@ describe('LaunchPrompt', () => {
|
||||
count: 1,
|
||||
},
|
||||
});
|
||||
CredentialsAPI.read.mockResolvedValue({
|
||||
data: { results: [{ id: 1 }], count: 1 },
|
||||
});
|
||||
CredentialTypesAPI.loadAllTypes({ data: { results: [{ type: 'ssh' }] } });
|
||||
|
||||
config = {
|
||||
can_start_without_user_input: false,
|
||||
|
||||
@ -322,7 +322,6 @@ exports[`<DeleteRoleConfirmationModal /> should render initially 1`] = `
|
||||
className="pf-c-backdrop"
|
||||
>
|
||||
<FocusTrap
|
||||
_createFocusTrap={[Function]}
|
||||
active={true}
|
||||
className="pf-l-bullseye"
|
||||
focusTrapOptions={
|
||||
@ -331,7 +330,6 @@ exports[`<DeleteRoleConfirmationModal /> should render initially 1`] = `
|
||||
}
|
||||
}
|
||||
paused={false}
|
||||
tag="div"
|
||||
>
|
||||
<div
|
||||
className="pf-l-bullseye"
|
||||
|
||||
@ -13,13 +13,7 @@ import FormField, {
|
||||
FieldTooltip,
|
||||
} from '@components/FormField';
|
||||
import AnsibleSelect from '@components/AnsibleSelect';
|
||||
import {
|
||||
required,
|
||||
noWhiteSpace,
|
||||
combine,
|
||||
maxLength,
|
||||
defaultIsNotAvailable,
|
||||
} from '@util/validators';
|
||||
import { required, noWhiteSpace, combine, maxLength } from '@util/validators';
|
||||
|
||||
function AnswerTypeField({ i18n }) {
|
||||
const [field] = useField({
|
||||
@ -72,6 +66,17 @@ function SurveyQuestionForm({
|
||||
submitError,
|
||||
i18n,
|
||||
}) {
|
||||
const defaultIsNotAvailable = choices => {
|
||||
return defaultValue => {
|
||||
if (!choices.includes(defaultValue)) {
|
||||
return i18n._(
|
||||
t`Default choice must be answered from the choices listed.`
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
initialValues={{
|
||||
|
||||
@ -36,17 +36,6 @@ export function minMaxValue(min, max, i18n) {
|
||||
};
|
||||
}
|
||||
|
||||
export function defaultIsNotAvailable(choices, i18n) {
|
||||
return defaultValue => {
|
||||
if (!choices.includes(defaultValue)) {
|
||||
return i18n._(
|
||||
t`Default choice must be answered from the choices listed.`
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredEmail(i18n) {
|
||||
return value => {
|
||||
if (!value) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user