Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui) Fix group membership inconsistencies on group page #12704

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
isExternalGroup,
groupName,
}: Props) => {
const groupMemberRelationshipsCount = groupMemberRelationships?.count || 0;
const groupMemberRelationshipsTotal = groupMemberRelationships?.total || 0;

Check warning on line 46 in datahub-web-react/src/app/entityV2/group/GroupInfoHeaderSection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L46 was not covered by tests
return (
<GroupHeader>
<Tooltip title={groupName}>
<GroupName level={3}>{groupName}</GroupName>
</Tooltip>
{groupMemberRelationshipsCount > 0 && <MemberCount>{groupMemberRelationships?.count} members</MemberCount>}
{groupMemberRelationshipsTotal > 0 && <MemberCount>{groupMemberRelationshipsTotal} members</MemberCount>}

Check warning on line 52 in datahub-web-react/src/app/entityV2/group/GroupInfoHeaderSection.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L52 was not covered by tests
{isExternalGroup && (
<Tooltip
title={`Membership for this group cannot be edited in DataHub as it originates from ${externalGroupType}.`}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
import React, { useState } from 'react';
import { Typography } from 'antd';
import { CorpUser, EntityRelationship } from '../../../types.generated';
import { useRouteMatch } from 'react-router-dom';
import { useHistory } from 'react-router';
import { CorpUser, EntityRelationshipsResult } from '../../../types.generated';
import { useEntityRegistry } from '../../useEntityRegistry';
import { TagsSection } from '../shared/SidebarStyledComponents';
import { ShowMoreButton, TagsSection } from '../shared/SidebarStyledComponents';
import { ShowMoreSection } from '../shared/sidebarSection/ShowMoreSection';
import { GroupMemberLink } from './GroupMemberLink';
import { TabType } from './types';

type Props = {
relationships: Array<EntityRelationship>;
groupMemberRelationships: EntityRelationshipsResult;
};
const DEFAULT_MAX_ENTITIES_TO_SHOW = 4;
const DEFAULT_MAX_ENTITIES_TO_SHOW = 5;

export default function GroupMembersSidebarSectionContent({ relationships }: Props) {
export default function GroupMembersSidebarSectionContent({ groupMemberRelationships }: Props) {
const history = useHistory();
const { url } = useRouteMatch();

Check warning on line 19 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L17-L19

Added lines #L17 - L19 were not covered by tests
const [entityCount, setEntityCount] = useState(DEFAULT_MAX_ENTITIES_TO_SHOW);

const entityRegistry = useEntityRegistry();
const relationshipsCount = relationships?.length || 0;
const relationshipsTotal = groupMemberRelationships?.total || 0;
const relationshipsAvailableCount = groupMemberRelationships.relationships?.length || 0;

Check warning on line 24 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L23-L24

Added lines #L23 - L24 were not covered by tests
return (
<>
<TagsSection>
{relationships.length === 0 && (
{relationshipsTotal === 0 && (

Check warning on line 28 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L28

Added line #L28 was not covered by tests
<Typography.Paragraph type="secondary">No members yet.</Typography.Paragraph>
)}
{relationships.length > 0 &&
relationships.map((item, index) => {
{relationshipsTotal > 0 &&
groupMemberRelationships.relationships.map((item, index) => {

Check warning on line 32 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L31-L32

Added lines #L31 - L32 were not covered by tests
const user = item.entity as CorpUser;
return index < entityCount && <GroupMemberLink user={user} entityRegistry={entityRegistry} />;
})}
</TagsSection>
{relationshipsCount > entityCount && (
{relationshipsAvailableCount > entityCount && (

Check warning on line 37 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L37

Added line #L37 was not covered by tests
<ShowMoreSection
totalCount={relationshipsCount}
totalCount={relationshipsAvailableCount}

Check warning on line 39 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L39

Added line #L39 was not covered by tests
entityCount={entityCount}
setEntityCount={setEntityCount}
showMaxEntity={DEFAULT_MAX_ENTITIES_TO_SHOW}
/>
)}
{relationshipsTotal > relationshipsAvailableCount && entityCount >= relationshipsAvailableCount && (
<ShowMoreButton onClick={() => history.replace(`${url}/${TabType.Members.toLocaleLowerCase()}`)}>
View all members
</ShowMoreButton>
)}

Check warning on line 49 in datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupMembersSidebarSectionContent.tsx#L45-L49

Added lines #L45 - L49 were not covered by tests
</>
);
}
8 changes: 2 additions & 6 deletions datahub-web-react/src/app/entityV2/group/GroupProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@
import SidebarCollapsibleHeader from '../shared/containers/profile/sidebar/SidebarCollapsibleHeader';
import { EntitySidebarTabs } from '../shared/containers/profile/sidebar/EntitySidebarTabs';
import { REDESIGN_COLORS } from '../shared/constants';
import { TabType } from './types';

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

export enum TabType {
Assets = 'Owner Of',
Members = 'Members',
}

const ENABLED_TAB_TYPES = [TabType.Assets, TabType.Members];

const MEMBER_PAGE_SIZE = 15;
Expand Down Expand Up @@ -119,7 +115,7 @@
},
{
name: TabType.Members,
path: TabType.Members.toLocaleLowerCase(),
path: TabType.Members.toLocaleLowerCase(), // do not remove toLocaleLowerCase as we link to this tab elsewhere

Check warning on line 118 in datahub-web-react/src/app/entityV2/group/GroupProfile.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L118 was not covered by tests
content: (
<GroupMembers
urn={urn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
<SidebarSection
title="Members"
count={groupMemberRelationships?.total || undefined}
content={
<GroupMembersSideBarSectionContent relationships={groupMemberRelationships?.relationships || []} />
}
showFullCount
content={<GroupMembersSideBarSectionContent groupMemberRelationships={groupMemberRelationships} />}

Check warning on line 16 in datahub-web-react/src/app/entityV2/group/GroupSidebarMembersSection.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/group/GroupSidebarMembersSection.tsx#L15-L16

Added lines #L15 - L16 were not covered by tests
/>
);
};
4 changes: 4 additions & 0 deletions datahub-web-react/src/app/entityV2/group/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum TabType {
Assets = 'Owner Of',
Members = 'Members',
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
collapsedContent?: React.ReactNode;
collapsible?: boolean;
expandedByDefault?: boolean;
showFullCount?: boolean;
};

export const SidebarSection = ({
Expand All @@ -88,6 +89,7 @@
collapsedContent,
collapsible = true,
expandedByDefault = true,
showFullCount,
}: Props) => {
return (
<StyledCollapse
Expand All @@ -102,7 +104,11 @@
<>
<SectionHeader collapsible={collapsible}>
<Title ellipsis={{ tooltip: true }}>{title}</Title>
{count > 0 && <CountStyle> {count > 10 ? '10+' : count}</CountStyle>}
{count > 0 && (
<CountStyle>
{showFullCount ? <>{count}</> : <>{count > 10 ? '10+' : count}</>}
</CountStyle>

Check warning on line 110 in datahub-web-react/src/app/entityV2/shared/containers/profile/sidebar/SidebarSection.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/shared/containers/profile/sidebar/SidebarSection.tsx#L108-L110

Added lines #L108 - L110 were not covered by tests
)}
</SectionHeader>
{collapsedContent}
</>
Expand Down
Loading