NewOrgPage: Disable input validation on keypress (#43132)

* NewOrgPage: migrate API function calls to Redux

* disable input validation on keypress
This commit is contained in:
Uchechukwu Obasi 2021-12-21 12:54:14 +01:00 committed by GitHub
parent 159fb4cebb
commit dfd045a3b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
import React, { FC } from 'react';
import { getBackendSrv } from '@grafana/runtime';
import Page from 'app/core/components/Page/Page';
import { Button, Input, Field, Form } from '@grafana/ui';
import { StoreState } from 'app/types';
@ -8,19 +7,6 @@ import { getNavModel } from '../../core/selectors/navModel';
import { createOrganization } from './state/actions';
import { getConfig } from 'app/core/config';
const validateOrg = async (orgName: string) => {
try {
await getBackendSrv().get(`api/orgs/name/${encodeURI(orgName)}`);
} catch (error) {
if (error.status === 404) {
error.isHandled = true;
return true;
}
return 'Something went wrong';
}
return 'Organization already exists';
};
const mapStateToProps = (state: StoreState) => {
return { navModel: getNavModel(state.navIndex, 'global-orgs') };
};
@ -63,7 +49,6 @@ export const NewOrgPage: FC<Props> = ({ navModel, createOrganization }) => {
placeholder="Org name"
{...register('name', {
required: 'Organization name is required',
validate: async (orgName) => await validateOrg(orgName),
})}
/>
</Field>