mirror of
https://github.com/ansible/awx.git
synced 2026-05-25 09:37:45 -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(
|
||||
async name => {
|
||||
if (name && name !== '') {
|
||||
if (!name) {
|
||||
onChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const {
|
||||
data: { results: nameMatchResults, count: nameMatchCount },
|
||||
@@ -66,9 +70,6 @@ function ApplicationLookup({ onChange, value, label, fieldName, validate }) {
|
||||
} catch {
|
||||
onChange(null);
|
||||
}
|
||||
} else {
|
||||
onChange(null);
|
||||
}
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
@@ -114,7 +114,11 @@ function CredentialLookup({
|
||||
|
||||
const checkCredentialName = useCallback(
|
||||
async name => {
|
||||
if (name && name !== '') {
|
||||
if (!name) {
|
||||
onChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const typeIdParams = credentialTypeId
|
||||
? { credential_type: credentialTypeId }
|
||||
@@ -138,9 +142,6 @@ function CredentialLookup({
|
||||
} catch {
|
||||
onChange(null);
|
||||
}
|
||||
} else {
|
||||
onChange(null);
|
||||
}
|
||||
},
|
||||
[onChange, credentialTypeId, credentialTypeKind, credentialTypeNamespace]
|
||||
);
|
||||
|
||||
@@ -116,7 +116,11 @@ function ExecutionEnvironmentLookup({
|
||||
|
||||
const checkExecutionEnvironmentName = useCallback(
|
||||
async name => {
|
||||
if (name && name !== '') {
|
||||
if (!name) {
|
||||
onChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const {
|
||||
data: { results: nameMatchResults, count: nameMatchCount },
|
||||
@@ -125,9 +129,6 @@ function ExecutionEnvironmentLookup({
|
||||
} catch {
|
||||
onChange(null);
|
||||
}
|
||||
} else {
|
||||
onChange(null);
|
||||
}
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
@@ -76,7 +76,11 @@ function InventoryLookup({
|
||||
|
||||
const checkInventoryName = useCallback(
|
||||
async name => {
|
||||
if (name && name !== '') {
|
||||
if (!name) {
|
||||
onChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const {
|
||||
data: { results: nameMatchResults, count: nameMatchCount },
|
||||
@@ -85,9 +89,6 @@ function InventoryLookup({
|
||||
} catch {
|
||||
onChange(null);
|
||||
}
|
||||
} else {
|
||||
onChange(null);
|
||||
}
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
@@ -71,7 +71,11 @@ function OrganizationLookup({
|
||||
|
||||
const checkOrganizationName = useCallback(
|
||||
async name => {
|
||||
if (name && name !== '') {
|
||||
if (!name) {
|
||||
onChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const {
|
||||
data: { results: nameMatchResults, count: nameMatchCount },
|
||||
@@ -80,9 +84,6 @@ function OrganizationLookup({
|
||||
} catch {
|
||||
onChange(null);
|
||||
}
|
||||
} else {
|
||||
onChange(null);
|
||||
}
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
@@ -75,7 +75,11 @@ function ProjectLookup({
|
||||
|
||||
const checkProjectName = useCallback(
|
||||
async name => {
|
||||
if (name && name !== '') {
|
||||
if (!name) {
|
||||
onChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const {
|
||||
data: { results: nameMatchResults, count: nameMatchCount },
|
||||
@@ -84,9 +88,6 @@ function ProjectLookup({
|
||||
} catch {
|
||||
onChange(null);
|
||||
}
|
||||
} else {
|
||||
onChange(null);
|
||||
}
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user