import React, { useState } from 'react'; import { ConfirmButton, RadioButtonGroup, Icon } from '@grafana/ui'; import { contextSrv } from 'app/core/core'; import { AccessControlAction } from 'app/types'; interface Props { isGrafanaAdmin: boolean; onGrafanaAdminChange: (isGrafanaAdmin: boolean) => void; } const adminOptions = [ { label: 'Yes', value: true }, { label: 'No', value: false }, ]; export function UserPermissions({ isGrafanaAdmin, onGrafanaAdminChange }: Props) { const [isEditing, setIsEditing] = useState(false); const [currentAdminOption, setCurrentAdminOption] = useState(isGrafanaAdmin); const onChangeClick = () => setIsEditing(true); const onCancelClick = () => { setIsEditing(false); setCurrentAdminOption(isGrafanaAdmin); }; const handleGrafanaAdminChange = () => onGrafanaAdminChange(currentAdminOption); const canChangePermissions = contextSrv.hasPermission(AccessControlAction.UsersPermissionsUpdate); return ( <>

Permissions

{isEditing ? ( ) : ( )}
Grafana Admin {isGrafanaAdmin ? ( <> Yes ) : ( <>No )} {canChangePermissions && ( Change )}
); }