Skip to content

Commit

Permalink
Merge pull request #129 from neojunjie/frontend-changes
Browse files Browse the repository at this point in the history
feat(ui): Sort user's groups in their profile
  • Loading branch information
danielkoh94 authored Oct 24, 2023
2 parents 3ce43eb + 2fbac74 commit 3f82423
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions datahub-web-react/src/app/entity/shared/EntityGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ type Props = {
*/
export default function EntityGroups({ readMore, setReadMore, groupMemberRelationships }: Props) {
const entityRegistry = useEntityRegistry();
const sortedGroupMemberRelationships = groupMemberRelationships?.sort((group1, group2) => {
const groupName1 = entityRegistry.getDisplayName(EntityType.CorpGroup, group1?.entity) ?? '';
const groupName2 = entityRegistry.getDisplayName(EntityType.CorpGroup, group2?.entity) ?? '';
if (groupName1 < groupName2) {
return -1;
}
return 1;
});

return (
<TagsSection>
{groupMemberRelationships?.length === 0 && <EmptyValue />}
{!readMore &&
groupMemberRelationships?.slice(0, 2).map((item) => {
sortedGroupMemberRelationships?.slice(0, 2).map((item) => {
if (!item?.entity?.urn) return null;
const entityUrn = entityRegistry.getEntityUrl(EntityType.CorpGroup, item?.entity?.urn);
return (
Expand All @@ -34,7 +42,7 @@ export default function EntityGroups({ readMore, setReadMore, groupMemberRelatio
})}
{readMore &&
groupMemberRelationships?.length > 2 &&
groupMemberRelationships?.map((item) => {
sortedGroupMemberRelationships?.map((item) => {
if (!item?.entity?.urn) return null;
const entityUrn = entityRegistry.getEntityUrl(EntityType.CorpGroup, item.entity.urn);
return (
Expand Down

0 comments on commit 3f82423

Please sign in to comment.