Users: OSS not using Orgs for users table showing (#80719)

* fix: for removing column

* linting
This commit is contained in:
Eric Leijonmarck 2024-01-18 09:09:36 +00:00 committed by GitHub
parent 59d997e5a5
commit ef0dfff756
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import React, { useMemo } from 'react';
import { UseTableRowProps } from 'react-table';
import {
Avatar,
@ -38,6 +39,7 @@ export const UsersTable = ({
fetchData,
}: UsersTableProps) => {
const showLicensedRole = useMemo(() => users.some((user) => user.licensedRole), [users]);
const showBelongsTo = useMemo(() => users.some((user) => user.orgs), [users]);
const columns: Array<Column<UserDTO>> = useMemo(
() => [
{
@ -63,23 +65,28 @@ export const UsersTable = ({
cell: ({ cell: { value } }: Cell<'name'>) => value,
sortType: 'string',
},
{
id: 'orgs',
header: 'Belongs to',
cell: ({ cell: { value, row } }: Cell<'orgs'>) => {
return (
<Stack alignItems={'center'}>
<OrgUnits units={value} icon={'building'} />
{row.original.isAdmin && (
<Tooltip placement="top" content="Grafana Admin">
<Icon name="shield" />
</Tooltip>
)}
</Stack>
);
},
sortType: (a, b) => (a.original.orgs?.length || 0) - (b.original.orgs?.length || 0),
},
...(showBelongsTo
? [
{
id: 'orgs',
header: 'Belongs to',
cell: ({ cell: { value, row } }: Cell<'orgs'>) => {
return (
<Stack alignItems={'center'}>
<OrgUnits units={value} icon={'building'} />
{row.original.isAdmin && (
<Tooltip placement="top" content="Grafana Admin">
<Icon name="shield" />
</Tooltip>
)}
</Stack>
);
},
sortType: (a: UseTableRowProps<UserDTO>, b: UseTableRowProps<UserDTO>) =>
(a.original.orgs?.length || 0) - (b.original.orgs?.length || 0),
},
]
: []),
...(showLicensedRole
? [
{
@ -140,7 +147,7 @@ export const UsersTable = ({
},
},
],
[showLicensedRole]
[showLicensedRole, showBelongsTo]
);
return (
<Stack direction={'column'} gap={2}>