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

Add parent container hierarchy label to the container #11705

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8457b94
Advance search - Added case sensitive flag for CONTAINS
kanavnarula Aug 30, 2024
fe84c68
Merge branch 'master' into master
kanavnarula Aug 30, 2024
7d91099
Merge branch 'master' into master
kanavnarula Sep 10, 2024
c600aa5
Spotless fix
Sep 14, 2024
34a8348
Merge branch 'master' into master
kanavnarula Sep 14, 2024
8181eb8
Merge branch 'master' into master
kanavnarula Sep 17, 2024
59674e8
Merge branch 'master' into master
david-leifker Sep 17, 2024
86caccc
test cases
Sep 17, 2024
253b54b
Merge branch 'master' into master
kanavnarula Sep 17, 2024
21e47b2
Merge branch 'master' into master
kanavnarula Sep 17, 2024
78678a5
Merge branch 'master' into master
kanavnarula Sep 17, 2024
77a0372
Merge branch 'master' into master
kanavnarula Sep 18, 2024
5cf0d60
Merge branch 'master' into master
kanavnarula Sep 18, 2024
4256026
Merge branch 'datahub-project:master' into master
kanavnarula Sep 20, 2024
dfd0b70
Show user name while removing user from the group
kanavnarula Sep 20, 2024
042d241
Fix linting issue
kanavnarula Sep 20, 2024
b2107d8
Fix prettier issue
Sep 20, 2024
8edeb3b
remove double quotes
Sep 20, 2024
15e23e1
Merge branch 'master' into master
kanavnarula Sep 20, 2024
e58e02e
Merge branch 'master' into master
kanavnarula Sep 20, 2024
7bc95ce
Display username instead of urn
kanavnarula Sep 21, 2024
5ef48ee
display name in place of urn
Sep 21, 2024
332015f
Merge branch 'master' into master
kanavnarula Sep 24, 2024
35847e7
Merge branch 'master' into master
kanavnarula Oct 22, 2024
392b35e
Use displayName method to pull corp user name
kanavnarula Oct 23, 2024
f77adf9
Merge branch 'master' into master
kanavnarula Oct 23, 2024
9619e81
Merge branch 'datahub-project:master' into master
kanavnarula Oct 24, 2024
b9af57e
Add parent container hierarchy label to the container
kanavnarula Oct 24, 2024
f2f1290
Add parent container hierarchy label to the container
kanavnarula Oct 24, 2024
77de859
Update GroupMembers.tsx
kanavnarula Oct 24, 2024
fbff6a9
Linting fix: Add parent container hierarchy
kanavnarula Oct 24, 2024
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 @@ -5,6 +5,8 @@ import { useGetSearchResultsLazyQuery } from '../../../../../../../graphql/searc
import { Container, Entity, EntityType } from '../../../../../../../types.generated';
import { useEnterKeyListener } from '../../../../../../shared/useEnterKeyListener';
import { useEntityRegistry } from '../../../../../../useEntityRegistry';
import { getParentEntities } from '../../../../../../search/filters/utils';
import ParentEntities from '../../../../../../search/filters/ParentEntities';

type Props = {
onCloseModal: () => void;
Expand All @@ -26,14 +28,18 @@ const StyleTag = styled(Tag)`
align-items: center;
`;

const PreviewImage = styled.img`
export const PreviewImage = styled.img`
max-height: 18px;
width: auto;
object-fit: contain;
background-color: transparent;
margin-right: 4px;
`;

export const ParentWrapper = styled.div`
max-width: 400px;
`;

export const ContainerSelectModal = ({ onCloseModal, defaultValues, onOkOverride, titleOverride }: Props) => {
const [containerSearch, { data: platforSearchData }] = useGetSearchResultsLazyQuery();
const entityRegistry = useEntityRegistry();
Expand Down Expand Up @@ -65,10 +71,16 @@ export const ContainerSelectModal = ({ onCloseModal, defaultValues, onOkOverride
// Renders a search result in the select dropdown.
const renderSearchResult = (entity: Container) => {
const displayName = entityRegistry.getDisplayName(EntityType.Container, entity);
const parentEntities: Entity[] = getParentEntities(entity as Entity) || [];

const truncatedDisplayName = displayName.length > 25 ? `${displayName.slice(0, 25)}...` : displayName;
return (
<Tooltip title={displayName}>
{parentEntities.length > 0 && (
<ParentWrapper>
<ParentEntities parentEntities={parentEntities} />
</ParentWrapper>
)}
<PreviewImage src={entity.platform?.properties?.logoUrl || undefined} alt={entity.properties?.name} />
<span>{truncatedDisplayName}</span>
</Tooltip>
Expand Down
11 changes: 10 additions & 1 deletion datahub-web-react/src/app/search/SearchFilterLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import CustomAvatar from '../shared/avatar/CustomAvatar';
import { IconStyleType } from '../entity/Entity';
import { formatNumber } from '../shared/formatNumber';
import useGetBrowseV2LabelOverride from './filters/useGetBrowseV2LabelOverride';
import { getParentEntities } from './filters/utils';
import { ParentWrapper } from '../entity/shared/containers/profile/sidebar/Container/ContainerSelectModal';
import ParentEntities from './filters/ParentEntities';

type Props = {
field: string;
Expand Down Expand Up @@ -157,11 +160,17 @@ export const SearchFilterLabel = ({ field, value, entity, count, hideCount }: Pr
if (entity?.type === EntityType.Container) {
const container = entity as Container;
const displayName = entityRegistry.getDisplayName(EntityType.Container, container);
const parentEntities: Entity[] = getParentEntities(container as Entity) || [];
const truncatedDisplayName = displayName.length > 25 ? `${displayName.slice(0, 25)}...` : displayName;
return (
<Tooltip title={displayName}>
{!!container.platform?.properties?.logoUrl && (
<PreviewImage src={container.platform?.properties?.logoUrl} alt={container.properties?.name} />
<>
<ParentWrapper style={{ width: '200px' }}>
<ParentEntities parentEntities={parentEntities} />
</ParentWrapper>
<PreviewImage src={container.platform?.properties?.logoUrl} alt={container.properties?.name} />
</>
)}
<span>
{truncatedDisplayName}
Expand Down
3 changes: 2 additions & 1 deletion datahub-web-react/src/app/search/filters/FilterOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { generateColor } from '../../entity/shared/components/styled/StyledTag';
import { ANTD_GRAY } from '../../entity/shared/constants';
import { useEntityRegistry } from '../../useEntityRegistry';
import {
CONTAINER_FILTER_NAME,
ENTITY_SUB_TYPE_FILTER_NAME,
MAX_COUNT_VAL,
PLATFORM_FILTER_NAME,
Expand Down Expand Up @@ -125,7 +126,7 @@ export default function FilterOption({
const { field, value, count, entity } = filterOption;
const entityRegistry = useEntityRegistry();
const { icon, label } = getFilterIconAndLabel(field, value, entityRegistry, entity || null, 14);
const shouldShowIcon = field === PLATFORM_FILTER_NAME && icon !== null;
const shouldShowIcon = (field === PLATFORM_FILTER_NAME || field === CONTAINER_FILTER_NAME) && icon !== null;
const shouldShowTagColor = field === TAGS_FILTER_NAME && entity?.type === EntityType.Tag;
const isSubTypeFilter = field === TYPE_NAMES_FILTER_NAME;
const parentEntities: Entity[] = getParentEntities(entity as Entity) || [];
Expand Down
32 changes: 24 additions & 8 deletions datahub-web-react/src/app/search/filters/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
FacetFilterInput,
FacetMetadata,
GlossaryTerm,
Container,
} from '../../../types.generated';
import { IconStyleType } from '../../entity/Entity';
import {
Expand Down Expand Up @@ -190,14 +191,26 @@ export function getFilterIconAndLabel(
icon = <FolderFilled size={size} color="black" />;
label = getLastBrowseEntryFromFilterValue(filterValue);
} else if (filterEntity) {
const { icon: newIcon, label: newLabel } = getFilterWithEntityIconAndLabel(
filterValue,
entityRegistry,
filterEntity,
size,
);
icon = newIcon;
label = newLabel;
// Scenario where the filter entity exists and filterField is container
if (filterField === CONTAINER_FILTER_NAME) {
const logoUrl = (filterEntity as Container)?.platform?.properties?.logoUrl;
icon = logoUrl ? (
<PlatformIcon src={logoUrl} size={size} />
) : (
entityRegistry.getIcon(EntityType.DataPlatform, size || 12, IconStyleType.ACCENT, ANTD_GRAY[9])
);
label = entityRegistry.getDisplayName(filterEntity.type, filterEntity);
} else {
const { icon: newIcon, label: newLabel } = getFilterWithEntityIconAndLabel(
filterValue,
entityRegistry,
filterEntity,
size,
);

icon = newIcon;
label = newLabel;
}
} else {
label = filterValue;
}
Expand Down Expand Up @@ -344,6 +357,9 @@ export function getParentEntities(entity: Entity): Entity[] | null {
if (entity.type === EntityType.Domain) {
return (entity as Domain).parentDomains?.domains || [];
}
if (entity.type === EntityType.Container) {
return (entity as Container).parentContainers?.containers || [];
}
return null;
}

Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ fragment entityContainer on Container {

fragment parentContainerFields on Container {
urn
type
properties {
name
}
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,9 @@ fragment facetFields on FacetMetadata {
properties {
name
}
parentContainers {
...parentContainersFields
}
}
... on CorpUser {
username
Expand Down
Loading