mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 13:09:22 -06:00
3b515e650c
* Update hook form * Update Form component * Update ChangePassword.tsx * Update custom types * Update SaveDashboardForm * Update form story * Update FieldArray.story.tsx * Bump hook form version * Update typescript to v4.2.4 * Update ForgottenPassword.tsx * Update LoginForm.tsx * Update SignupPage.tsx * Update VerifyEmail.tsx * Update AdminEditOrgPage.tsx * Update UserCreatePage.tsx * Update BasicSettings.tsx * Update NotificationChannelForm.tsx * Update NotificationChannelOptions.tsx * Update NotificationSettings.tsx * Update OptionElement.tsx * Update AlertRuleForm.tsx * Update AlertTypeStep.tsx * Update AnnotationsField.tsx * Update ConditionField.tsx * Update ConditionsStep.tsx * Update GroupAndNamespaceFields.tsx * Update LabelsField.tsx * Update QueryStep.tsx * Update RowOptionsForm.tsx * Update SaveDashboardAsForm.tsx * Update NewDashboardsFolder.tsx * Update ImportDashboardForm.tsx * Update DashboardImportPage.tsx * Update NewOrgPage.tsx * Update OrgProfile.tsx * Update UserInviteForm.tsx * Update PlaylistForm.tsx * Update ChangePasswordForm.tsx * Update UserProfileEditForm.tsx * Update TeamSettings.tsx * Update SignupInvited.tsx * Expose setValue from the Form * Update typescript to v4.2.4 * Remove ref from field props * Fix tests * Revert TS update * Use exact version * Update latest batch of changes * Reduce the number of strict TS errors * Fix defaults * more type error fixes * Update CreateTeam * fix folder picker in rule form * fixes for hook form 7 * Update docs Co-authored-by: Domas <domasx2@gmail.com>
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import Page from 'app/core/components/Page/Page';
|
|
import { hot } from 'react-hot-loader';
|
|
import { Button, Form, Field, Input, FieldSet, Label, Tooltip, Icon } from '@grafana/ui';
|
|
import { NavModel } from '@grafana/data';
|
|
import { getBackendSrv, locationService } from '@grafana/runtime';
|
|
import { connect } from 'react-redux';
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
import { StoreState } from 'app/types';
|
|
|
|
export interface Props {
|
|
navModel: NavModel;
|
|
}
|
|
|
|
interface TeamDTO {
|
|
name: string;
|
|
email: string;
|
|
}
|
|
|
|
export class CreateTeam extends PureComponent<Props> {
|
|
create = async (formModel: TeamDTO) => {
|
|
const result = await getBackendSrv().post('/api/teams', formModel);
|
|
if (result.teamId) {
|
|
locationService.push(`/org/teams/edit/${result.teamId}`);
|
|
}
|
|
};
|
|
render() {
|
|
const { navModel } = this.props;
|
|
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents>
|
|
<Form onSubmit={this.create}>
|
|
{({ register }) => (
|
|
<FieldSet label="New Team">
|
|
<Field label="Name">
|
|
<Input {...register('name', { required: true })} width={60} />
|
|
</Field>
|
|
<Field
|
|
label={
|
|
<Label>
|
|
<span>Email</span>
|
|
<Tooltip content="This is optional and is primarily used for allowing custom team avatars.">
|
|
<Icon name="info-circle" style={{ marginLeft: 6 }} />
|
|
</Tooltip>
|
|
</Label>
|
|
}
|
|
>
|
|
<Input {...register('email')} type="email" placeholder="email@test.com" width={60} />
|
|
</Field>
|
|
<div className="gf-form-button-row">
|
|
<Button type="submit" variant="primary">
|
|
Create
|
|
</Button>
|
|
</div>
|
|
</FieldSet>
|
|
)}
|
|
</Form>
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state: StoreState) {
|
|
return {
|
|
navModel: getNavModel(state.navIndex, 'teams'),
|
|
};
|
|
}
|
|
|
|
export default hot(module)(connect(mapStateToProps)(CreateTeam));
|