1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 06:00:06 +02:00

fix(cp-frontend): handle error validating name

This commit is contained in:
Sérgio Ramos 2017-08-03 13:42:39 +01:00
parent 2b552360e0
commit 0cf61c628a

View File

@ -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!` };
} }