mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 08:17:39 -02:30
Refactor functions that check typed text in lookups
This commit is contained in:
@@ -57,7 +57,11 @@ function ApplicationLookup({ onChange, value, label, fieldName, validate }) {
|
|||||||
|
|
||||||
const checkApplicationName = useCallback(
|
const checkApplicationName = useCallback(
|
||||||
async name => {
|
async name => {
|
||||||
if (name && name !== '') {
|
if (!name) {
|
||||||
|
onChange(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { results: nameMatchResults, count: nameMatchCount },
|
data: { results: nameMatchResults, count: nameMatchCount },
|
||||||
@@ -66,9 +70,6 @@ function ApplicationLookup({ onChange, value, label, fieldName, validate }) {
|
|||||||
} catch {
|
} catch {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
onChange(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -114,7 +114,11 @@ function CredentialLookup({
|
|||||||
|
|
||||||
const checkCredentialName = useCallback(
|
const checkCredentialName = useCallback(
|
||||||
async name => {
|
async name => {
|
||||||
if (name && name !== '') {
|
if (!name) {
|
||||||
|
onChange(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const typeIdParams = credentialTypeId
|
const typeIdParams = credentialTypeId
|
||||||
? { credential_type: credentialTypeId }
|
? { credential_type: credentialTypeId }
|
||||||
@@ -138,9 +142,6 @@ function CredentialLookup({
|
|||||||
} catch {
|
} catch {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
onChange(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[onChange, credentialTypeId, credentialTypeKind, credentialTypeNamespace]
|
[onChange, credentialTypeId, credentialTypeKind, credentialTypeNamespace]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -116,7 +116,11 @@ function ExecutionEnvironmentLookup({
|
|||||||
|
|
||||||
const checkExecutionEnvironmentName = useCallback(
|
const checkExecutionEnvironmentName = useCallback(
|
||||||
async name => {
|
async name => {
|
||||||
if (name && name !== '') {
|
if (!name) {
|
||||||
|
onChange(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { results: nameMatchResults, count: nameMatchCount },
|
data: { results: nameMatchResults, count: nameMatchCount },
|
||||||
@@ -125,9 +129,6 @@ function ExecutionEnvironmentLookup({
|
|||||||
} catch {
|
} catch {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
onChange(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -76,7 +76,11 @@ function InventoryLookup({
|
|||||||
|
|
||||||
const checkInventoryName = useCallback(
|
const checkInventoryName = useCallback(
|
||||||
async name => {
|
async name => {
|
||||||
if (name && name !== '') {
|
if (!name) {
|
||||||
|
onChange(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { results: nameMatchResults, count: nameMatchCount },
|
data: { results: nameMatchResults, count: nameMatchCount },
|
||||||
@@ -85,9 +89,6 @@ function InventoryLookup({
|
|||||||
} catch {
|
} catch {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
onChange(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -71,7 +71,11 @@ function OrganizationLookup({
|
|||||||
|
|
||||||
const checkOrganizationName = useCallback(
|
const checkOrganizationName = useCallback(
|
||||||
async name => {
|
async name => {
|
||||||
if (name && name !== '') {
|
if (!name) {
|
||||||
|
onChange(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { results: nameMatchResults, count: nameMatchCount },
|
data: { results: nameMatchResults, count: nameMatchCount },
|
||||||
@@ -80,9 +84,6 @@ function OrganizationLookup({
|
|||||||
} catch {
|
} catch {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
onChange(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -75,7 +75,11 @@ function ProjectLookup({
|
|||||||
|
|
||||||
const checkProjectName = useCallback(
|
const checkProjectName = useCallback(
|
||||||
async name => {
|
async name => {
|
||||||
if (name && name !== '') {
|
if (!name) {
|
||||||
|
onChange(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { results: nameMatchResults, count: nameMatchCount },
|
data: { results: nameMatchResults, count: nameMatchCount },
|
||||||
@@ -84,9 +88,6 @@ function ProjectLookup({
|
|||||||
} catch {
|
} catch {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
onChange(null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user