OrgProfile.tsx 975 B

12345678910111213141516171819202122232425262728293031323334
  1. import React, { FC } from 'react';
  2. import { Input, Field, FieldSet, Button, Form } from '@grafana/ui';
  3. import { contextSrv } from 'app/core/core';
  4. import { AccessControlAction } from 'app/types';
  5. export interface Props {
  6. orgName: string;
  7. onSubmit: (orgName: string) => void;
  8. }
  9. interface FormDTO {
  10. orgName: string;
  11. }
  12. const OrgProfile: FC<Props> = ({ onSubmit, orgName }) => {
  13. const canWriteOrg = contextSrv.hasPermission(AccessControlAction.OrgsWrite);
  14. return (
  15. <Form defaultValues={{ orgName }} onSubmit={({ orgName }: FormDTO) => onSubmit(orgName)}>
  16. {({ register }) => (
  17. <FieldSet label="Organization profile" disabled={!canWriteOrg}>
  18. <Field label="Organization name">
  19. <Input id="org-name-input" type="text" {...register('orgName', { required: true })} />
  20. </Field>
  21. <Button type="submit">Update organization name</Button>
  22. </FieldSet>
  23. )}
  24. </Form>
  25. );
  26. };
  27. export default OrgProfile;