grafana/public/app/features/org/OrgProfile.tsx
Alex Khomenko 1714d52f17
Chore: Replace deprecated Form imports (#84537)
* SignupInvited: replace Form

* Chore: replace Form import

* Chore: replace HorizontalGroup

* Replace the component in OrgProfile
2024-03-16 09:48:05 +02:00

36 lines
1011 B
TypeScript

import React from 'react';
import { Input, Field, FieldSet, Button } from '@grafana/ui';
import { Form } from 'app/core/components/Form/Form';
import { contextSrv } from 'app/core/core';
import { AccessControlAction } from 'app/types';
export interface Props {
orgName: string;
onSubmit: (orgName: string) => void;
}
interface FormDTO {
orgName: string;
}
const OrgProfile = ({ onSubmit, orgName }: Props) => {
const canWriteOrg = contextSrv.hasPermission(AccessControlAction.OrgsWrite);
return (
<Form defaultValues={{ orgName }} onSubmit={({ orgName }: FormDTO) => onSubmit(orgName)}>
{({ register }) => (
<FieldSet label="Organization profile" disabled={!canWriteOrg}>
<Field label="Organization name">
<Input id="org-name-input" type="text" {...register('orgName', { required: true })} />
</Field>
<Button type="submit">Update organization name</Button>
</FieldSet>
)}
</Form>
);
};
export default OrgProfile;