mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
NewOrgPage: Disable input validation on keypress (#43132)
* NewOrgPage: migrate API function calls to Redux * disable input validation on keypress
This commit is contained in:
parent
159fb4cebb
commit
dfd045a3b3
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user