grafana/public/app/features/admin/ldap/LdapUserPermissions.tsx
Tobias Skarhed add5a5c01e
LDAP: Use InteractiveTable and remove gf-form usage (#80291)
* Use InteractiveTable

* Remove unused return

* Fix icon alignment

* InteractiveTable in LdapUserMappingInfo

* Update no teams text

* InteractiveTable in LdapUserGroups

* Remove unused code

* Cleanup

* LdapSyncInfo to InteractiveTable

* Update more tables

* Memoize

* Fix connection status

* Update lockfile

* Refactor LdapSyncInfo

* Fix lockfile

* Remove showAttributeMapping as it is always true
2024-01-25 17:01:22 +01:00

60 lines
1.2 KiB
TypeScript

import React, { useMemo } from 'react';
import { Column, Icon, InteractiveTable } from '@grafana/ui';
import { LdapPermissions } from 'app/types';
interface Props {
permissions: LdapPermissions;
}
interface TableRow {
permission: string;
value: React.ReactNode;
}
export const LdapUserPermissions = ({ permissions }: Props) => {
const columns = useMemo<Array<Column<TableRow>>>(
() => [
{
id: 'permission',
header: 'Permissions',
disableGrow: true,
},
{
id: 'value',
},
],
[]
);
const data = useMemo<TableRow[]>(
() => [
{
permission: 'Grafana admin',
value: permissions.isGrafanaAdmin ? (
<>
<Icon name="shield" /> Yes
</>
) : (
'No'
),
},
{
permission: 'Status',
value: permissions.isDisabled ? (
<>
<Icon name="times" /> Inactive
</>
) : (
<>
<Icon name="check" /> Active
</>
),
},
],
[permissions]
);
return <InteractiveTable data={data} columns={columns} getRowId={(row) => row.permission} />;
};