Files
grafana/public/app/features/org/NewOrgPage.tsx
Ashley Harrison 47f8717149 React: Use new JSX transform (#88802)
* update eslint, tsconfig + esbuild to handle new jsx transform

* remove thing that breaks the new jsx transform

* remove react imports

* adjust grafana-icons build

* is this the correct syntax?

* try this

* well this was much easier than expected...

* change grafana-plugin-configs webpack config

* fixes

* fix lockfile

* fix 2 more violations

* use path.resolve instead of require.resolve

* remove react import

* fix react imports

* more fixes

* remove React import

* remove import React from docs

* remove another react import
2024-06-25 12:43:47 +01:00

69 lines
2.0 KiB
TypeScript

import { connect, ConnectedProps } from 'react-redux';
import { NavModelItem } from '@grafana/data';
import { Button, Input, Field, FieldSet } from '@grafana/ui';
import { Form } from 'app/core/components/Form/Form';
import { Page } from 'app/core/components/Page/Page';
import { getConfig } from 'app/core/config';
import { createOrganization } from './state/actions';
const mapDispatchToProps = {
createOrganization,
};
const connector = connect(undefined, mapDispatchToProps);
type Props = ConnectedProps<typeof connector>;
interface CreateOrgFormDTO {
name: string;
}
const pageNav: NavModelItem = {
icon: 'building',
id: 'org-new',
text: 'New organization',
};
export const NewOrgPage = ({ createOrganization }: Props) => {
const createOrg = async (newOrg: { name: string }) => {
await createOrganization(newOrg);
window.location.href = getConfig().appSubUrl + '/org';
};
return (
<Page navId="global-orgs" pageNav={pageNav}>
<Page.Contents>
<p className="muted">
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 (
<>
<FieldSet>
<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>
</FieldSet>
<Button type="submit">Create</Button>
</>
);
}}
</Form>
</Page.Contents>
</Page>
);
};
export default connector(NewOrgPage);