Form migrations: Last components from Forms namespace (#23556)

* Migrate RadioButtonGroup

* Migrate Label

* Migrate Form

* Migrate Field

* Missing Form import

* Migrate InputControl

* Migrate Checkbox

* Move InputControl and uncomment

* Fix small issues

* inor fix

* Fix import

* Fix stuff
This commit is contained in:
Tobias Skarhed
2020-04-14 18:52:56 +02:00
committed by GitHub
parent a28dfaf177
commit f15593684a
32 changed files with 238 additions and 233 deletions

View File

@@ -1,7 +1,7 @@
import React, { useCallback } from 'react';
import { hot } from 'react-hot-loader';
import { connect } from 'react-redux';
import { Forms, Button, Input } from '@grafana/ui';
import { Form, Button, Input, Field } from '@grafana/ui';
import { NavModel } from '@grafana/data';
import { getBackendSrv } from '@grafana/runtime';
import { StoreState } from '../../types';
@@ -32,22 +32,22 @@ const UserCreatePage: React.FC<UserCreatePageProps> = ({ navModel, updateLocatio
<Page navModel={navModel}>
<Page.Contents>
<h1>Add new user</h1>
<Forms.Form onSubmit={onSubmit} validateOn="onBlur">
<Form onSubmit={onSubmit} validateOn="onBlur">
{({ register, errors }) => {
return (
<>
<Forms.Field label="Name" required invalid={!!errors.name} error={!!errors.name && 'Name is required'}>
<Field label="Name" required invalid={!!errors.name} error={!!errors.name && 'Name is required'}>
<Input name="name" size="md" ref={register({ required: true })} />
</Forms.Field>
</Field>
<Forms.Field label="E-mail">
<Field label="E-mail">
<Input name="email" size="md" ref={register} />
</Forms.Field>
</Field>
<Forms.Field label="Username">
<Field label="Username">
<Input name="login" size="md" ref={register} />
</Forms.Field>
<Forms.Field
</Field>
<Field
label="Password"
required
invalid={!!errors.password}
@@ -61,12 +61,12 @@ const UserCreatePage: React.FC<UserCreatePageProps> = ({ navModel, updateLocatio
validate: value => value.trim() !== '' && value.length >= 4,
})}
/>
</Forms.Field>
</Field>
<Button type="submit">Create user</Button>
</>
);
}}
</Forms.Form>
</Form>
</Page.Contents>
</Page>
);

View File

@@ -7,9 +7,9 @@ import {
withTheme,
ConfirmButton,
Button,
Forms,
HorizontalGroup,
Container,
Field,
} from '@grafana/ui';
import { GrafanaTheme } from '@grafana/data';
import { UserOrg, Organization, OrgRole } from 'app/types';
@@ -225,12 +225,12 @@ export class AddToOrgModal extends PureComponent<AddToOrgModalProps, AddToOrgMod
return (
<Modal className={styles.modal} title="Add to an organization" isOpen={isOpen} onDismiss={this.onCancel}>
<Forms.Field label="Organisation">
<Field label="Organisation">
<OrgPicker onSelected={this.onOrgSelect} />
</Forms.Field>
<Forms.Field label="Role">
</Field>
<Field label="Role">
<OrgRolePicker value={role} onChange={this.onOrgRoleChange} />
</Forms.Field>
</Field>
<Container padding="md">
<HorizontalGroup spacing="md" justify="center">
<Button variant="primary" onClick={this.onAddUserToOrg}>