mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* SignupInvited: replace Form * Chore: replace Form import * Chore: replace HorizontalGroup * Replace the component in OrgProfile
36 lines
1011 B
TypeScript
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;
|