The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/serviceaccounts/components/ServiceAccountRoleRow.tsx

52 lines
1.7 KiB

import { Label } from '@grafana/ui';
import { UserRolePicker } from 'app/core/components/RolePicker/UserRolePicker';
import { contextSrv } from 'app/core/core';
import { OrgRolePicker } from 'app/features/admin/OrgRolePicker';
import { AccessControlAction, OrgRole, Role, ServiceAccountDTO } from 'app/types';
interface Props {
label: string;
serviceAccount: ServiceAccountDTO;
onRoleChange: (role: OrgRole) => void;
roleOptions: Role[];
}
export const ServiceAccountRoleRow = ({ label, serviceAccount, roleOptions, onRoleChange }: Props): JSX.Element => {
const inputId = `${label}-input`;
const canUpdateRole = contextSrv.hasPermissionInMetadata(AccessControlAction.ServiceAccountsWrite, serviceAccount);
return (
<tr>
<td>
<Label htmlFor={inputId}>{label}</Label>
</td>
{contextSrv.licensedAccessControlEnabled() ? (
<td colSpan={3}>
<UserRolePicker
userId={serviceAccount.id}
orgId={serviceAccount.orgId}
basicRole={serviceAccount.role}
onBasicRoleChange={onRoleChange}
roleOptions={roleOptions}
basicRoleDisabled={!canUpdateRole}
disabled={serviceAccount.isExternal || serviceAccount.isDisabled}
/>
</td>
) : (
<>
<td>
<OrgRolePicker
width={24}
inputId={inputId}
aria-label="Role"
value={serviceAccount.role}
disabled={serviceAccount.isExternal || serviceAccount.isDisabled}
onChange={onRoleChange}
/>
</td>
<td colSpan={2}></td>
</>
)}
</tr>
);
};