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