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): Fixing unreleased search preview bugs #5432

Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -885,9 +885,14 @@ private void configureDatasetResolvers(final RuntimeWiring.Builder builder) {
)
.type("DatasetStatsSummary", typeWiring -> typeWiring
.dataFetcher("topUsersLast30Days", new LoadableTypeBatchResolver<>(corpUserType,
(env) -> ((DatasetStatsSummary) env.getSource()).getTopUsersLast30Days().stream()
.map(CorpUser::getUrn)
.collect(Collectors.toList())))
(env) -> {
DatasetStatsSummary summary = ((DatasetStatsSummary) env.getSource());
return summary.getTopUsersLast30Days() != null
? summary.getTopUsersLast30Days().stream()
.map(CorpUser::getUrn)
.collect(Collectors.toList())
: null;
}))
);
}

Expand Down Expand Up @@ -1039,9 +1044,14 @@ private void configureDashboardResolvers(final RuntimeWiring.Builder builder) {
);
builder.type("DashboardStatsSummary", typeWiring -> typeWiring
.dataFetcher("topUsersLast30Days", new LoadableTypeBatchResolver<>(corpUserType,
(env) -> ((DashboardStatsSummary) env.getSource()).getTopUsersLast30Days().stream()
.map(CorpUser::getUrn)
.collect(Collectors.toList())))
(env) -> {
DashboardStatsSummary summary = ((DashboardStatsSummary) env.getSource());
return summary.getTopUsersLast30Days() != null
? summary.getTopUsersLast30Days().stream()
.map(CorpUser::getUrn)
.collect(Collectors.toList())
: null;
}))
);
}

Expand Down
4 changes: 2 additions & 2 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5279,7 +5279,7 @@ type DatasetStatsSummary {
"""
The top users in the past 30 days
"""
topUsersLast30Days: [CorpUser!]!
topUsersLast30Days: [CorpUser!]
}

"""
Expand Down Expand Up @@ -5456,7 +5456,7 @@ type DashboardStatsSummary {
"""
The top users in the past 30 days
"""
topUsersLast30Days: [CorpUser!]!
topUsersLast30Days: [CorpUser!]
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
import { Popover, Typography } from 'antd';
import React from 'react';
import styled from 'styled-components';
import { CorpGroup, CorpUser } from '../../../../../types.generated';
import { ExpandedActor } from './ExpandedActor';

const PopoverActors = styled.div``;

type Props = {
actors: Array<CorpUser | CorpGroup>;
max?: number | null;
onClose?: (actor: CorpUser | CorpGroup) => void;
};

export const ExpandedActorGroup = ({ actors, onClose }: Props) => {
const DEFAULT_MAX = 10;

export const ExpandedActorGroup = ({ actors, max, onClose }: Props) => {
const finalMax = max || DEFAULT_MAX;
jjoyce0510 marked this conversation as resolved.
Show resolved Hide resolved
const finalActors = actors.length > finalMax ? actors.slice(0, finalMax) : actors;
const remainder = actors.length > finalMax ? actors.length - finalMax : undefined;

return (
<>
{actors.map((actor) => (
<ExpandedActor key={actor.urn} actor={actor} onClose={() => onClose?.(actor)} />
))}
</>
<Popover
placement="left"
content={
<PopoverActors>
{actors.map((actor) => (
<ExpandedActor key={actor.urn} actor={actor} onClose={() => onClose?.(actor)} />
))}
</PopoverActors>
}
>
<div style={{ display: 'flex', justifyContent: 'right', flexWrap: 'wrap', alignItems: 'center' }}>
jjoyce0510 marked this conversation as resolved.
Show resolved Hide resolved
{finalActors.map((actor) => (
<ExpandedActor key={actor.urn} actor={actor} onClose={() => onClose?.(actor)} />
))}
</div>
{remainder && (
<Typography.Text style={{ display: 'flex', justifyContent: 'right', marginRight: 8 }} type="secondary">
+ {remainder} more
</Typography.Text>
)}
</Popover>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const EntityHeader = ({ refreshBrowser, headerDropdownItems, isNameEditab
<PlatformContent />
<TitleWrapper>
<EntityName isNameEditable={canEditName} />
{entityData?.deprecation && (
{entityData?.deprecation?.deprecated && (
<DeprecationPill deprecation={entityData?.deprecation} preview={isCompact} />
)}
{entityData?.health?.map((health) => (
Expand Down
14 changes: 7 additions & 7 deletions datahub-web-react/src/app/preview/DefaultPreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const UserListContainer = styled.div`

const UserListDivider = styled(Divider)`
padding: 4px;
height: 60px;
height: auto;
`;

const UserListTitle = styled(Typography.Text)`
Expand Down Expand Up @@ -266,7 +266,7 @@ export default function DefaultPreviewCard({
{name || ' '}
</EntityTitle>
</Link>
{deprecation && <DeprecationPill deprecation={deprecation} preview />}
{deprecation?.deprecated && <DeprecationPill deprecation={deprecation} preview />}
{externalUrl && (
<ExternalUrlContainer>
<ExternalUrlButton type="link" href={externalUrl} target="_blank">
Expand Down Expand Up @@ -324,22 +324,22 @@ export default function DefaultPreviewCard({
)}
</LeftColumn>
<RightColumn>
{topUsers && topUsers.length > 0 && (
{topUsers && topUsers?.length > 0 && (
<>
<UserListContainer>
<UserListTitle strong>Top Users</UserListTitle>
<div>
<ExpandedActorGroup actors={topUsers} />
<ExpandedActorGroup actors={topUsers} max={2} />
</div>
</UserListContainer>
<UserListDivider type="vertical" />
</>
)}
{owners && owners.length > 0 && (
{(topUsers?.length || 0) > 0 && (owners?.length || 0) > 0 && <UserListDivider type="vertical" />}
{owners && owners?.length > 0 && (
<UserListContainer>
<UserListTitle strong>Owners</UserListTitle>
<div>
<ExpandedActorGroup actors={owners.map((owner) => owner.owner)} />
<ExpandedActorGroup actors={owners.map((owner) => owner.owner)} max={2} />
</div>
</UserListContainer>
)}
Expand Down