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