import { Controller } from 'react-hook-form'; import { locationUtil, SelectableValue } from '@grafana/data'; import { Trans, t } from '@grafana/i18n'; import { locationService } from '@grafana/runtime'; import { Button, LinkButton, Input, Switch, RadioButtonGroup, Field, FieldSet, Icon, TextLink, Tooltip, Label, Stack, } from '@grafana/ui'; import { getConfig } from 'app/core/config'; import { OrgRole, useDispatch } from 'app/types'; import { Form } from '../../core/components/Form/Form'; import { addInvitee } from '../invites/state/actions'; const tooltipMessage = ( <> You can now select the "No basic role" option and add permissions to your custom needs. You can find more information in  our documentation . ); const roles: Array> = Object.values(OrgRole).map((r) => ({ label: r === OrgRole.None ? 'No basic role' : r, value: r, })); export interface FormModel { role: OrgRole; name: string; loginOrEmail?: string; sendEmail: boolean; email: string; } const defaultValues: FormModel = { name: '', email: '', role: OrgRole.Editor, sendEmail: true, }; export const UserInviteForm = () => { const dispatch = useDispatch(); const onSubmit = async (formData: FormModel) => { await dispatch(addInvitee(formData)).unwrap(); locationService.push('/admin/users/'); }; return (
{({ register, control, errors }) => { return ( <>
{/* eslint-disable-next-line @grafana/i18n/no-untranslated-strings */} Role {tooltipMessage && ( )} } > } control={control} name="role" />
Back ); }}
); }; export default UserInviteForm;