Skip to content

Commit 6a8254c

Browse files
authoredFeb 26, 2025··
fix(ui) Fix group membership inconsistencies on group page (#12704)
1 parent eaa17a0 commit 6a8254c

File tree

6 files changed

+39
-23
lines changed

6 files changed

+39
-23
lines changed
 

‎datahub-web-react/src/app/entityV2/group/GroupInfoHeaderSection.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ export const GroupInfoHeaderSection = ({
4343
isExternalGroup,
4444
groupName,
4545
}: Props) => {
46-
const groupMemberRelationshipsCount = groupMemberRelationships?.count || 0;
46+
const groupMemberRelationshipsTotal = groupMemberRelationships?.total || 0;
4747
return (
4848
<GroupHeader>
4949
<Tooltip title={groupName}>
5050
<GroupName level={3}>{groupName}</GroupName>
5151
</Tooltip>
52-
{groupMemberRelationshipsCount > 0 && <MemberCount>{groupMemberRelationships?.count} members</MemberCount>}
52+
{groupMemberRelationshipsTotal > 0 && <MemberCount>{groupMemberRelationshipsTotal} members</MemberCount>}
5353
{isExternalGroup && (
5454
<Tooltip
5555
title={`Membership for this group cannot be edited in DataHub as it originates from ${externalGroupType}.`}
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,52 @@
11
import React, { useState } from 'react';
22
import { Typography } from 'antd';
3-
import { CorpUser, EntityRelationship } from '../../../types.generated';
3+
import { useRouteMatch } from 'react-router-dom';
4+
import { useHistory } from 'react-router';
5+
import { CorpUser, EntityRelationshipsResult } from '../../../types.generated';
46
import { useEntityRegistry } from '../../useEntityRegistry';
5-
import { TagsSection } from '../shared/SidebarStyledComponents';
7+
import { ShowMoreButton, TagsSection } from '../shared/SidebarStyledComponents';
68
import { ShowMoreSection } from '../shared/sidebarSection/ShowMoreSection';
79
import { GroupMemberLink } from './GroupMemberLink';
10+
import { TabType } from './types';
811

912
type Props = {
10-
relationships: Array<EntityRelationship>;
13+
groupMemberRelationships: EntityRelationshipsResult;
1114
};
12-
const DEFAULT_MAX_ENTITIES_TO_SHOW = 4;
15+
const DEFAULT_MAX_ENTITIES_TO_SHOW = 5;
1316

14-
export default function GroupMembersSidebarSectionContent({ relationships }: Props) {
17+
export default function GroupMembersSidebarSectionContent({ groupMemberRelationships }: Props) {
18+
const history = useHistory();
19+
const { url } = useRouteMatch();
1520
const [entityCount, setEntityCount] = useState(DEFAULT_MAX_ENTITIES_TO_SHOW);
1621

1722
const entityRegistry = useEntityRegistry();
18-
const relationshipsCount = relationships?.length || 0;
23+
const relationshipsTotal = groupMemberRelationships?.total || 0;
24+
const relationshipsAvailableCount = groupMemberRelationships.relationships?.length || 0;
1925
return (
2026
<>
2127
<TagsSection>
22-
{relationships.length === 0 && (
28+
{relationshipsTotal === 0 && (
2329
<Typography.Paragraph type="secondary">No members yet.</Typography.Paragraph>
2430
)}
25-
{relationships.length > 0 &&
26-
relationships.map((item, index) => {
31+
{relationshipsTotal > 0 &&
32+
groupMemberRelationships.relationships.map((item, index) => {
2733
const user = item.entity as CorpUser;
2834
return index < entityCount && <GroupMemberLink user={user} entityRegistry={entityRegistry} />;
2935
})}
3036
</TagsSection>
31-
{relationshipsCount > entityCount && (
37+
{relationshipsAvailableCount > entityCount && (
3238
<ShowMoreSection
33-
totalCount={relationshipsCount}
39+
totalCount={relationshipsAvailableCount}
3440
entityCount={entityCount}
3541
setEntityCount={setEntityCount}
3642
showMaxEntity={DEFAULT_MAX_ENTITIES_TO_SHOW}
3743
/>
3844
)}
45+
{relationshipsTotal > relationshipsAvailableCount && entityCount >= relationshipsAvailableCount && (
46+
<ShowMoreButton onClick={() => history.replace(`${url}/${TabType.Members.toLocaleLowerCase()}`)}>
47+
View all members
48+
</ShowMoreButton>
49+
)}
3950
</>
4051
);
4152
}

‎datahub-web-react/src/app/entityV2/group/GroupProfile.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ import EntitySidebarContext from '../../sharedV2/EntitySidebarContext';
2626
import SidebarCollapsibleHeader from '../shared/containers/profile/sidebar/SidebarCollapsibleHeader';
2727
import { EntitySidebarTabs } from '../shared/containers/profile/sidebar/EntitySidebarTabs';
2828
import { REDESIGN_COLORS } from '../shared/constants';
29+
import { TabType } from './types';
2930

3031
const messageStyle = { marginTop: '10%' };
3132

32-
export enum TabType {
33-
Assets = 'Owner Of',
34-
Members = 'Members',
35-
}
36-
3733
const ENABLED_TAB_TYPES = [TabType.Assets, TabType.Members];
3834

3935
const MEMBER_PAGE_SIZE = 15;
@@ -119,7 +115,7 @@ export default function GroupProfile({ urn }: Props) {
119115
},
120116
{
121117
name: TabType.Members,
122-
path: TabType.Members.toLocaleLowerCase(),
118+
path: TabType.Members.toLocaleLowerCase(), // do not remove toLocaleLowerCase as we link to this tab elsewhere
123119
content: (
124120
<GroupMembers
125121
urn={urn}

‎datahub-web-react/src/app/entityV2/group/GroupSidebarMembersSection.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ export const GroupSidebarMembersSection = ({ groupMemberRelationships }: Props)
1212
<SidebarSection
1313
title="Members"
1414
count={groupMemberRelationships?.total || undefined}
15-
content={
16-
<GroupMembersSideBarSectionContent relationships={groupMemberRelationships?.relationships || []} />
17-
}
15+
showFullCount
16+
content={<GroupMembersSideBarSectionContent groupMemberRelationships={groupMemberRelationships} />}
1817
/>
1918
);
2019
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum TabType {
2+
Assets = 'Owner Of',
3+
Members = 'Members',
4+
}

‎datahub-web-react/src/app/entityV2/shared/containers/profile/sidebar/SidebarSection.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type Props = {
7878
collapsedContent?: React.ReactNode;
7979
collapsible?: boolean;
8080
expandedByDefault?: boolean;
81+
showFullCount?: boolean;
8182
};
8283

8384
export const SidebarSection = ({
@@ -88,6 +89,7 @@ export const SidebarSection = ({
8889
collapsedContent,
8990
collapsible = true,
9091
expandedByDefault = true,
92+
showFullCount,
9193
}: Props) => {
9294
return (
9395
<StyledCollapse
@@ -102,7 +104,11 @@ export const SidebarSection = ({
102104
<>
103105
<SectionHeader collapsible={collapsible}>
104106
<Title ellipsis={{ tooltip: true }}>{title}</Title>
105-
{count > 0 && <CountStyle> {count > 10 ? '10+' : count}</CountStyle>}
107+
{count > 0 && (
108+
<CountStyle>
109+
{showFullCount ? <>{count}</> : <>{count > 10 ? '10+' : count}</>}
110+
</CountStyle>
111+
)}
106112
</SectionHeader>
107113
{collapsedContent}
108114
</>

0 commit comments

Comments
 (0)
Please sign in to comment.