mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* RolePicker: Handle inherited with * Small ammendment to Create Service Account layout * RolePicker: introduce maxWidth prop * Clean up * Change VerticalGroup spacing to large on Team Settings page * Introduce constant for submenu width * Update public/app/core/components/RolePicker/RolePicker.tsx Simplify style parameter Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * Add description to the improved calculation Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
|
|
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.isDisabled}
|
|
/>
|
|
</td>
|
|
) : (
|
|
<>
|
|
<td>
|
|
<OrgRolePicker
|
|
width={24}
|
|
inputId={inputId}
|
|
aria-label="Role"
|
|
value={serviceAccount.role}
|
|
disabled={serviceAccount.isDisabled}
|
|
onChange={onRoleChange}
|
|
/>
|
|
</td>
|
|
<td colSpan={2}></td>
|
|
</>
|
|
)}
|
|
</tr>
|
|
);
|
|
};
|