mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-04 20:58:36 +00:00
feat(): Add parent container hierarchy label to the container (#11705)
Co-authored-by: mac <mac@192.168.1.7> Co-authored-by: david-leifker <114954101+david-leifker@users.noreply.github.com> Co-authored-by: Kanav Narula <kanav_narula@optum.com> Co-authored-by: mac <mac@192.168.1.2> Co-authored-by: mac <mac@192.168.1.6>
This commit is contained in:
parent
bb67af03c5
commit
8a1c1804b7
@ -5,6 +5,8 @@ import { useGetSearchResultsLazyQuery } from '../../../../../../../graphql/searc
|
|||||||
import { Container, Entity, EntityType } from '../../../../../../../types.generated';
|
import { Container, Entity, EntityType } from '../../../../../../../types.generated';
|
||||||
import { useEnterKeyListener } from '../../../../../../shared/useEnterKeyListener';
|
import { useEnterKeyListener } from '../../../../../../shared/useEnterKeyListener';
|
||||||
import { useEntityRegistry } from '../../../../../../useEntityRegistry';
|
import { useEntityRegistry } from '../../../../../../useEntityRegistry';
|
||||||
|
import { getParentEntities } from '../../../../../../search/filters/utils';
|
||||||
|
import ParentEntities from '../../../../../../search/filters/ParentEntities';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onCloseModal: () => void;
|
onCloseModal: () => void;
|
||||||
@ -26,7 +28,7 @@ const StyleTag = styled(Tag)`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PreviewImage = styled.img`
|
export const PreviewImage = styled.img`
|
||||||
max-height: 18px;
|
max-height: 18px;
|
||||||
width: auto;
|
width: auto;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
@ -34,6 +36,10 @@ const PreviewImage = styled.img`
|
|||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const ParentWrapper = styled.div`
|
||||||
|
max-width: 400px;
|
||||||
|
`;
|
||||||
|
|
||||||
export const ContainerSelectModal = ({ onCloseModal, defaultValues, onOkOverride, titleOverride }: Props) => {
|
export const ContainerSelectModal = ({ onCloseModal, defaultValues, onOkOverride, titleOverride }: Props) => {
|
||||||
const [containerSearch, { data: platforSearchData }] = useGetSearchResultsLazyQuery();
|
const [containerSearch, { data: platforSearchData }] = useGetSearchResultsLazyQuery();
|
||||||
const entityRegistry = useEntityRegistry();
|
const entityRegistry = useEntityRegistry();
|
||||||
@ -65,10 +71,16 @@ export const ContainerSelectModal = ({ onCloseModal, defaultValues, onOkOverride
|
|||||||
// Renders a search result in the select dropdown.
|
// Renders a search result in the select dropdown.
|
||||||
const renderSearchResult = (entity: Container) => {
|
const renderSearchResult = (entity: Container) => {
|
||||||
const displayName = entityRegistry.getDisplayName(EntityType.Container, entity);
|
const displayName = entityRegistry.getDisplayName(EntityType.Container, entity);
|
||||||
|
const parentEntities: Entity[] = getParentEntities(entity as Entity) || [];
|
||||||
|
|
||||||
const truncatedDisplayName = displayName.length > 25 ? `${displayName.slice(0, 25)}...` : displayName;
|
const truncatedDisplayName = displayName.length > 25 ? `${displayName.slice(0, 25)}...` : displayName;
|
||||||
return (
|
return (
|
||||||
<Tooltip title={displayName}>
|
<Tooltip title={displayName}>
|
||||||
|
{parentEntities.length > 0 && (
|
||||||
|
<ParentWrapper>
|
||||||
|
<ParentEntities parentEntities={parentEntities} />
|
||||||
|
</ParentWrapper>
|
||||||
|
)}
|
||||||
<PreviewImage src={entity.platform?.properties?.logoUrl || undefined} alt={entity.properties?.name} />
|
<PreviewImage src={entity.platform?.properties?.logoUrl || undefined} alt={entity.properties?.name} />
|
||||||
<span>{truncatedDisplayName}</span>
|
<span>{truncatedDisplayName}</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@ -23,6 +23,9 @@ import CustomAvatar from '../shared/avatar/CustomAvatar';
|
|||||||
import { IconStyleType } from '../entity/Entity';
|
import { IconStyleType } from '../entity/Entity';
|
||||||
import { formatNumber } from '../shared/formatNumber';
|
import { formatNumber } from '../shared/formatNumber';
|
||||||
import useGetBrowseV2LabelOverride from './filters/useGetBrowseV2LabelOverride';
|
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 = {
|
type Props = {
|
||||||
field: string;
|
field: string;
|
||||||
@ -157,11 +160,17 @@ export const SearchFilterLabel = ({ field, value, entity, count, hideCount }: Pr
|
|||||||
if (entity?.type === EntityType.Container) {
|
if (entity?.type === EntityType.Container) {
|
||||||
const container = entity as Container;
|
const container = entity as Container;
|
||||||
const displayName = entityRegistry.getDisplayName(EntityType.Container, 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;
|
const truncatedDisplayName = displayName.length > 25 ? `${displayName.slice(0, 25)}...` : displayName;
|
||||||
return (
|
return (
|
||||||
<Tooltip title={displayName}>
|
<Tooltip title={displayName}>
|
||||||
{!!container.platform?.properties?.logoUrl && (
|
{!!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>
|
<span>
|
||||||
{truncatedDisplayName}
|
{truncatedDisplayName}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { generateColor } from '../../entity/shared/components/styled/StyledTag';
|
|||||||
import { ANTD_GRAY } from '../../entity/shared/constants';
|
import { ANTD_GRAY } from '../../entity/shared/constants';
|
||||||
import { useEntityRegistry } from '../../useEntityRegistry';
|
import { useEntityRegistry } from '../../useEntityRegistry';
|
||||||
import {
|
import {
|
||||||
|
CONTAINER_FILTER_NAME,
|
||||||
ENTITY_SUB_TYPE_FILTER_NAME,
|
ENTITY_SUB_TYPE_FILTER_NAME,
|
||||||
MAX_COUNT_VAL,
|
MAX_COUNT_VAL,
|
||||||
PLATFORM_FILTER_NAME,
|
PLATFORM_FILTER_NAME,
|
||||||
@ -125,7 +126,7 @@ export default function FilterOption({
|
|||||||
const { field, value, count, entity } = filterOption;
|
const { field, value, count, entity } = filterOption;
|
||||||
const entityRegistry = useEntityRegistry();
|
const entityRegistry = useEntityRegistry();
|
||||||
const { icon, label } = getFilterIconAndLabel(field, value, entityRegistry, entity || null, 14);
|
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 shouldShowTagColor = field === TAGS_FILTER_NAME && entity?.type === EntityType.Tag;
|
||||||
const isSubTypeFilter = field === TYPE_NAMES_FILTER_NAME;
|
const isSubTypeFilter = field === TYPE_NAMES_FILTER_NAME;
|
||||||
const parentEntities: Entity[] = getParentEntities(entity as Entity) || [];
|
const parentEntities: Entity[] = getParentEntities(entity as Entity) || [];
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import {
|
|||||||
FacetFilterInput,
|
FacetFilterInput,
|
||||||
FacetMetadata,
|
FacetMetadata,
|
||||||
GlossaryTerm,
|
GlossaryTerm,
|
||||||
|
Container,
|
||||||
} from '../../../types.generated';
|
} from '../../../types.generated';
|
||||||
import { IconStyleType } from '../../entity/Entity';
|
import { IconStyleType } from '../../entity/Entity';
|
||||||
import {
|
import {
|
||||||
@ -186,6 +187,15 @@ export function getFilterIconAndLabel(
|
|||||||
entityRegistry.getIcon(EntityType.DataPlatform, size || 12, IconStyleType.ACCENT, ANTD_GRAY[9])
|
entityRegistry.getIcon(EntityType.DataPlatform, size || 12, IconStyleType.ACCENT, ANTD_GRAY[9])
|
||||||
);
|
);
|
||||||
label = filterEntity ? entityRegistry.getDisplayName(EntityType.DataPlatform, filterEntity) : filterValue;
|
label = filterEntity ? entityRegistry.getDisplayName(EntityType.DataPlatform, filterEntity) : filterValue;
|
||||||
|
} else if (filterField === CONTAINER_FILTER_NAME) {
|
||||||
|
// Scenario where the filter entity exists and filterField is container
|
||||||
|
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(EntityType.Container, filterEntity);
|
||||||
} else if (filterField === BROWSE_PATH_V2_FILTER_NAME) {
|
} else if (filterField === BROWSE_PATH_V2_FILTER_NAME) {
|
||||||
icon = <FolderFilled size={size} color="black" />;
|
icon = <FolderFilled size={size} color="black" />;
|
||||||
label = getLastBrowseEntryFromFilterValue(filterValue);
|
label = getLastBrowseEntryFromFilterValue(filterValue);
|
||||||
@ -196,6 +206,7 @@ export function getFilterIconAndLabel(
|
|||||||
filterEntity,
|
filterEntity,
|
||||||
size,
|
size,
|
||||||
);
|
);
|
||||||
|
|
||||||
icon = newIcon;
|
icon = newIcon;
|
||||||
label = newLabel;
|
label = newLabel;
|
||||||
} else {
|
} else {
|
||||||
@ -344,6 +355,9 @@ export function getParentEntities(entity: Entity): Entity[] | null {
|
|||||||
if (entity.type === EntityType.Domain) {
|
if (entity.type === EntityType.Domain) {
|
||||||
return (entity as Domain).parentDomains?.domains || [];
|
return (entity as Domain).parentDomains?.domains || [];
|
||||||
}
|
}
|
||||||
|
if (entity.type === EntityType.Container) {
|
||||||
|
return (entity as Container).parentContainers?.containers || [];
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1010,6 +1010,7 @@ fragment entityContainer on Container {
|
|||||||
|
|
||||||
fragment parentContainerFields on Container {
|
fragment parentContainerFields on Container {
|
||||||
urn
|
urn
|
||||||
|
type
|
||||||
properties {
|
properties {
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
|||||||
@ -910,6 +910,9 @@ fragment facetFields on FacetMetadata {
|
|||||||
properties {
|
properties {
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
parentContainers {
|
||||||
|
...parentContainersFields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
... on CorpUser {
|
... on CorpUser {
|
||||||
username
|
username
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user