fix(cp-frontend): handle error validating name
This commit is contained in:
parent
2b552360e0
commit
0cf61c628a
@ -38,15 +38,15 @@ class DeploymentGroupEditOrCreate extends Component {
|
|||||||
destroyOnUnmount: true,
|
destroyOnUnmount: true,
|
||||||
forceUnregisterOnUnmount: true,
|
forceUnregisterOnUnmount: true,
|
||||||
asyncValidate: async ({ name = '' }) => {
|
asyncValidate: async ({ name = '' }) => {
|
||||||
const { data } = await client.query({
|
const [err] = await intercept(client.query({
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
query: DeploymentGroupBySlugQuery,
|
query: DeploymentGroupBySlugQuery,
|
||||||
variables: {
|
variables: {
|
||||||
slug: paramCase(name.trim())
|
slug: paramCase(name.trim())
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
if (data.deploymentGroups.length) {
|
if (!err) {
|
||||||
// eslint-disable-next-line no-throw-literal
|
// eslint-disable-next-line no-throw-literal
|
||||||
throw { name: `"${name}" already exists!` };
|
throw { name: `"${name}" already exists!` };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user