-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e64e71e
commit d96241c
Showing
4 changed files
with
357 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { CorpGroup, CorpUser, EntityType, Maybe } from '../../types.generated'; | ||
import EntityRegistry from '../entity/EntityRegistry'; | ||
import { CustomAvatar } from '../shared/avatar'; | ||
import { SpacedAvatarGroup } from '../shared/avatar/SpaceAvatarGroup'; | ||
|
||
type Props = { | ||
users?: Maybe<Array<CorpUser>>; | ||
groups?: Maybe<Array<CorpGroup>>; | ||
entityRegistry: EntityRegistry; | ||
maxCount?: number; | ||
size?: number; | ||
}; | ||
|
||
/** | ||
* Component used for displaying the users and groups in policies table | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export default function AvatarsGroup({ users, groups, entityRegistry, maxCount = 6, size }: Props) { | ||
return ( | ||
<SpacedAvatarGroup maxCount={maxCount}> | ||
{users && | ||
users?.length > 0 && | ||
(users || [])?.map((user, key) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<div data-testid={`avatar-tag-${user.urn}`} key={`${user.urn}-${key}`}> | ||
<CustomAvatar | ||
size={size} | ||
name={user?.username} | ||
url={`/${entityRegistry.getPathName(EntityType.CorpUser)}/${user.urn}`} | ||
photoUrl={ | ||
user?.editableProperties?.pictureLink || user?.editableInfo?.pictureLink || undefined | ||
} | ||
/> | ||
</div> | ||
))} | ||
{groups && | ||
groups.length > 0 && | ||
(groups || [])?.map((group, key) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<div data-testid={`avatar-tag-${group.urn}`} key={`${group.urn}-${key}`}> | ||
<CustomAvatar | ||
size={size} | ||
name={group?.name} | ||
url={`/${entityRegistry.getPathName(EntityType.CorpGroup)}/${group.urn}`} | ||
isGroup | ||
/> | ||
</div> | ||
))} | ||
</SpacedAvatarGroup> | ||
); | ||
} |
Oops, something went wrong.