2024-03-16 08:48:05 +01:00
|
|
|
import { Input, Field, FieldSet, Button } from '@grafana/ui';
|
|
|
|
|
import { Form } from 'app/core/components/Form/Form';
|
2021-11-18 14:10:38 +01:00
|
|
|
import { contextSrv } from 'app/core/core';
|
|
|
|
|
import { AccessControlAction } from 'app/types';
|
2018-10-25 16:56:49 +02:00
|
|
|
|
2018-10-29 13:46:12 +01:00
|
|
|
export interface Props {
|
2018-10-25 16:56:49 +02:00
|
|
|
orgName: string;
|
2020-06-24 10:55:39 +02:00
|
|
|
onSubmit: (orgName: string) => void;
|
2018-10-25 16:56:49 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-24 10:55:39 +02:00
|
|
|
interface FormDTO {
|
|
|
|
|
orgName: string;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 07:38:21 -07:00
|
|
|
const OrgProfile = ({ onSubmit, orgName }: Props) => {
|
2021-11-18 14:10:38 +01:00
|
|
|
const canWriteOrg = contextSrv.hasPermission(AccessControlAction.OrgsWrite);
|
|
|
|
|
|
2018-10-25 16:56:49 +02:00
|
|
|
return (
|
2020-06-24 10:55:39 +02:00
|
|
|
<Form defaultValues={{ orgName }} onSubmit={({ orgName }: FormDTO) => onSubmit(orgName)}>
|
|
|
|
|
{({ register }) => (
|
2021-11-18 14:10:38 +01:00
|
|
|
<FieldSet label="Organization profile" disabled={!canWriteOrg}>
|
2020-06-24 10:55:39 +02:00
|
|
|
<Field label="Organization name">
|
2021-10-01 15:58:18 +01:00
|
|
|
<Input id="org-name-input" type="text" {...register('orgName', { required: true })} />
|
2020-06-24 10:55:39 +02:00
|
|
|
</Field>
|
|
|
|
|
|
|
|
|
|
<Button type="submit">Update organization name</Button>
|
|
|
|
|
</FieldSet>
|
|
|
|
|
)}
|
|
|
|
|
</Form>
|
2018-10-25 16:56:49 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default OrgProfile;
|