Files
grafana/public/app/features/serviceaccounts/components/ServiceAccountRoleRow.tsx
Ashley Harrison 47f8717149 React: Use new JSX transform (#88802)
* update eslint, tsconfig + esbuild to handle new jsx transform

* remove thing that breaks the new jsx transform

* remove react imports

* adjust grafana-icons build

* is this the correct syntax?

* try this

* well this was much easier than expected...

* change grafana-plugin-configs webpack config

* fixes

* fix lockfile

* fix 2 more violations

* use path.resolve instead of require.resolve

* remove react import

* fix react imports

* more fixes

* remove React import

* remove import React from docs

* remove another react import
2024-06-25 12:43:47 +01:00

53 lines
1.7 KiB
TypeScript

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>
);
};