mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
35 lines
963 B
TypeScript
35 lines
963 B
TypeScript
import React from 'react';
|
|
|
|
import { Input, Field, FieldSet, Button, Form } from '@grafana/ui';
|
|
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;
|