2023-06-30 04:30:20 -04:00
|
|
|
import moment from 'moment'
|
2023-08-30 11:20:57 -04:00
|
|
|
import { type Dispatch, type SetStateAction } from 'react'
|
2023-06-30 04:30:20 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { User } from '../../../../../../types/group-management/user'
|
|
|
|
import Badge from '../../../../shared/components/badge'
|
|
|
|
import Tooltip from '../../../../shared/components/tooltip'
|
2024-03-27 11:45:09 -04:00
|
|
|
import type { GroupUserAlert } from '../../utils/types'
|
2023-06-30 04:30:20 -04:00
|
|
|
import ManagedUserStatus from './managed-user-status'
|
2023-10-19 08:51:33 -04:00
|
|
|
import SSOStatus from './sso-status'
|
2023-10-27 09:11:34 -04:00
|
|
|
import DropdownButton from './dropdown-button'
|
|
|
|
import SelectUserCheckbox from './select-user-checkbox'
|
2023-10-19 08:51:33 -04:00
|
|
|
import getMeta from '@/utils/meta'
|
2023-06-30 04:30:20 -04:00
|
|
|
|
|
|
|
type ManagedUserRowProps = {
|
|
|
|
user: User
|
2023-07-13 04:50:43 -04:00
|
|
|
openOffboardingModalForUser: (user: User) => void
|
2024-04-03 10:12:09 -04:00
|
|
|
openUnlinkUserModal: (user: User) => void
|
2023-08-22 17:38:37 -04:00
|
|
|
groupId: string
|
2024-03-27 11:45:09 -04:00
|
|
|
setGroupUserAlert: Dispatch<SetStateAction<GroupUserAlert>>
|
2023-06-30 04:30:20 -04:00
|
|
|
}
|
|
|
|
|
2023-10-27 09:11:34 -04:00
|
|
|
export default function MemberRow({
|
2023-06-30 04:30:20 -04:00
|
|
|
user,
|
2023-07-13 04:50:43 -04:00
|
|
|
openOffboardingModalForUser,
|
2024-04-03 10:12:09 -04:00
|
|
|
openUnlinkUserModal,
|
2024-03-27 11:45:09 -04:00
|
|
|
setGroupUserAlert,
|
2023-08-22 17:38:37 -04:00
|
|
|
groupId,
|
2023-06-30 04:30:20 -04:00
|
|
|
}: ManagedUserRowProps) {
|
|
|
|
const { t } = useTranslation()
|
2024-06-18 06:01:37 -04:00
|
|
|
const managedUsersActive = getMeta('ol-managedUsersActive')
|
2023-10-19 08:51:33 -04:00
|
|
|
const groupSSOActive = getMeta('ol-groupSSOActive')
|
2023-08-22 09:30:34 -04:00
|
|
|
|
2023-06-30 04:30:20 -04:00
|
|
|
return (
|
2023-08-25 04:51:45 -04:00
|
|
|
<tr
|
2023-06-30 04:30:20 -04:00
|
|
|
key={`user-${user.email}`}
|
|
|
|
className={`managed-user-row ${user.invite ? 'text-muted' : ''}`}
|
|
|
|
>
|
2023-10-27 09:11:34 -04:00
|
|
|
<SelectUserCheckbox user={user} />
|
|
|
|
<td className="cell-email">
|
2023-08-25 04:51:45 -04:00
|
|
|
<span>
|
|
|
|
{user.email}
|
|
|
|
{user.invite ? (
|
|
|
|
<span>
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
id={`pending-invite-symbol-${user._id}`}
|
|
|
|
description={t('pending_invite')}
|
|
|
|
>
|
2024-04-19 08:30:23 -04:00
|
|
|
<Badge
|
|
|
|
bsStyle={null}
|
2024-05-27 08:46:48 -04:00
|
|
|
className="badge-tag-bs3"
|
2024-04-19 08:30:23 -04:00
|
|
|
aria-label={t('pending_invite')}
|
|
|
|
data-testid="badge-pending-invite"
|
|
|
|
>
|
2023-08-25 04:51:45 -04:00
|
|
|
{t('pending_invite')}
|
|
|
|
</Badge>
|
|
|
|
</Tooltip>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
''
|
|
|
|
)}
|
|
|
|
{user.isEntityAdmin && (
|
|
|
|
<span>
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
id={`group-admin-symbol-${user._id}`}
|
|
|
|
description={t('group_admin')}
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
className="fa fa-user-circle-o"
|
|
|
|
aria-hidden="true"
|
|
|
|
aria-label={t('group_admin')}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td className="cell-name">
|
|
|
|
{user.first_name} {user.last_name}
|
|
|
|
</td>
|
|
|
|
<td className="cell-last-active">
|
|
|
|
{user.last_active_at
|
|
|
|
? moment(user.last_active_at).format('Do MMM YYYY')
|
|
|
|
: 'N/A'}
|
|
|
|
</td>
|
2023-10-19 08:51:33 -04:00
|
|
|
{groupSSOActive && (
|
|
|
|
<td className="cell-security">
|
|
|
|
<div className="managed-user-security">
|
|
|
|
<SSOStatus user={user} />
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
)}
|
2023-10-27 09:11:34 -04:00
|
|
|
{managedUsersActive && (
|
|
|
|
<td className="cell-managed">
|
|
|
|
<div className="managed-user-security">
|
|
|
|
<ManagedUserStatus user={user} />
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
)}
|
2023-08-25 04:51:45 -04:00
|
|
|
<td className="cell-dropdown">
|
2023-10-27 09:11:34 -04:00
|
|
|
<DropdownButton
|
2023-08-25 04:51:45 -04:00
|
|
|
user={user}
|
|
|
|
openOffboardingModalForUser={openOffboardingModalForUser}
|
2024-04-03 10:12:09 -04:00
|
|
|
openUnlinkUserModal={openUnlinkUserModal}
|
2024-03-27 11:45:09 -04:00
|
|
|
setGroupUserAlert={setGroupUserAlert}
|
2023-08-25 04:51:45 -04:00
|
|
|
groupId={groupId}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2023-06-30 04:30:20 -04:00
|
|
|
)
|
|
|
|
}
|