grafana/public/app/features/org/NewOrgPage.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

69 lines
2.1 KiB
TypeScript

import React, { FC } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import { Button, Input, Field, Form } from '@grafana/ui';
import Page from 'app/core/components/Page/Page';
import { getConfig } from 'app/core/config';
import { StoreState } from 'app/types';
import { getNavModel } from '../../core/selectors/navModel';
import { createOrganization } from './state/actions';
const mapStateToProps = (state: StoreState) => {
return { navModel: getNavModel(state.navIndex, 'global-orgs') };
};
const mapDispatchToProps = {
createOrganization,
};
const connector = connect(mapStateToProps, mapDispatchToProps);
type Props = ConnectedProps<typeof connector>;
interface CreateOrgFormDTO {
name: string;
}
export const NewOrgPage: FC<Props> = ({ navModel, createOrganization }) => {
const createOrg = async (newOrg: { name: string }) => {
await createOrganization(newOrg);
window.location.href = getConfig().appSubUrl + '/org';
};
return (
<Page navModel={navModel}>
<Page.Contents>
<h3 className="page-sub-heading">New organization</h3>
<p className="playlist-description">
Each organization contains their own dashboards, data sources, and configuration, which cannot be shared
shared between organizations. While users might belong to more than one organization, multiple organizations
are most frequently used in multi-tenant deployments.{' '}
</p>
<Form<CreateOrgFormDTO> onSubmit={createOrg}>
{({ register, errors }) => {
return (
<>
<Field label="Organization name" invalid={!!errors.name} error={errors.name && errors.name.message}>
<Input
placeholder="Org name"
{...register('name', {
required: 'Organization name is required',
})}
/>
</Field>
<Button type="submit">Create</Button>
</>
);
}}
</Form>
</Page.Contents>
</Page>
);
};
export default connector(NewOrgPage);