Skip to content

Commit

Permalink
remove link
Browse files Browse the repository at this point in the history
  • Loading branch information
asikowitz committed Feb 4, 2025
1 parent d63cb09 commit 97acaac
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default function EntitySearchInputResultV2({ entity }: Props) {
}
contentRef={contentRef}
isContentTruncated={isContentTruncated}
linksDisabled
/>
</TextWrapper>
</Wrapper>
Expand Down
18 changes: 13 additions & 5 deletions datahub-web-react/src/app/previewV2/BrowsePaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,25 @@ interface Props {
browsePaths?: Maybe<BrowsePathV2> | undefined;
contentRef: React.RefObject<HTMLDivElement>;
isContentTruncated: boolean;
linksDisabled?: boolean;
}

const BrowsePathSection = ({ path }: { path: BrowsePathEntry }) => {
const BrowsePathSection = ({ path, linksDisabled }: { path: BrowsePathEntry } & Pick<Props, 'linksDisabled'>) => {
if (!path.entity) {
return <PlatFormTitle>{path.name}</PlatFormTitle>;
}
return <ContextPathEntityLink key={path?.entity?.urn} entity={path?.entity} style={{ fontSize: '12px' }} />;
return (
<ContextPathEntityLink
key={path?.entity?.urn}
entity={path?.entity}

Check warning on line 77 in datahub-web-react/src/app/previewV2/BrowsePaths.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/previewV2/BrowsePaths.tsx#L74-L77

Added lines #L74 - L77 were not covered by tests
style={{ fontSize: '12px' }}
linkDisabled={linksDisabled}
/>
);
};

function BrowsePaths(props: Props) {
const { previewType, browsePaths, contentRef, isContentTruncated } = props;
const { previewType, browsePaths, contentRef, isContentTruncated, linksDisabled } = props;

const parentPath = browsePaths?.path?.[0];
const remainingParentPaths = browsePaths?.path && browsePaths.path.slice(1, browsePaths.path.length);
Expand All @@ -91,15 +99,15 @@ function BrowsePaths(props: Props) {
<ParentNodesWrapper ref={contentRef}>
{parentPath && (
<PlatformText>
<BrowsePathSection path={parentPath} />
<BrowsePathSection path={parentPath} linksDisabled={linksDisabled} />
{remainingParentPaths && remainingParentPaths?.length > 0 && <ContextPathSeparator />}
</PlatformText>
)}
{remainingParentPaths &&
remainingParentPaths.map((container, index) => {
return (
<PlatformText>
<BrowsePathSection path={container} />
<BrowsePathSection path={container} linksDisabled={linksDisabled} />

Check warning on line 110 in datahub-web-react/src/app/previewV2/BrowsePaths.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/previewV2/BrowsePaths.tsx#L110

Added line #L110 was not covered by tests
{index < remainingParentPaths.length - 1 && <ContextPathSeparator />}
</PlatformText>
);
Expand Down
5 changes: 4 additions & 1 deletion datahub-web-react/src/app/previewV2/ContextPath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ interface Props {
browsePaths?: Maybe<BrowsePathV2> | undefined;
contentRef: React.RefObject<HTMLDivElement>;
isContentTruncated?: boolean;
linksDisabled?: boolean;
}

function ContextPath(props: Props) {
Expand All @@ -108,6 +109,7 @@ function ContextPath(props: Props) {
isCompactView,
contentRef,
isContentTruncated = false,
linksDisabled,
} = props;

const entityRegistry = useEntityRegistryV2();
Expand Down Expand Up @@ -146,9 +148,10 @@ function ContextPath(props: Props) {
previewType={previewType}
contentRef={contentRef}
isContentTruncated={isContentTruncated}
linksDisabled={linksDisabled}
/>
) : (
<ParentEntities parentEntities={parentEntities || []} numVisible={3} />
<ParentEntities parentEntities={parentEntities || []} numVisible={3} linksDisabled={linksDisabled} />
)}
</PlatformContentWrapper>
);
Expand Down
16 changes: 11 additions & 5 deletions datahub-web-react/src/app/previewV2/ContextPathEntityLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ContainerText = styled.span`
max-width: 150px; // TODO: Remove in favor of smart truncation
`;

const StyledLink = styled(Link)`
const StyledLink = styled(Link)<{ $disabled?: boolean }>`
white-space: nowrap;
border-radius: 4px;
overflow: hidden;
Expand All @@ -44,21 +44,22 @@ const StyledLink = styled(Link)`
}
:hover {
color: ${colors.violet[500]};
color: ${({ $disabled }) => ($disabled ? REDESIGN_COLORS.LINK_GREY : colors.violet[500])};
&& svg {
color: ${colors.violet[500]};
color: ${({ $disabled }) => ($disabled ? REDESIGN_COLORS.LINK_GREY : colors.violet[500])};
}
}
`;

interface Props {
entity: Maybe<Entity>;
linkDisabled?: boolean;
style?: React.CSSProperties;
}

function ContextPathEntityLink(props: Props) {
const { entity, style } = props;
const { entity, linkDisabled, style } = props;

Check warning on line 62 in datahub-web-react/src/app/previewV2/ContextPathEntityLink.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/previewV2/ContextPathEntityLink.tsx#L62

Added line #L62 was not covered by tests
const entityRegistry = useEntityRegistry();
const linkProps = useEmbeddedProfileLinkProps();

Expand All @@ -69,7 +70,12 @@ function ContextPathEntityLink(props: Props) {

return (
<Path style={style}>
<StyledLink to={containerUrl} data-testid="container" {...linkProps}>
<StyledLink
to={linkDisabled ? null : containerUrl}
data-testid="container"
$disabled={linkDisabled}
{...linkProps}
>

Check warning on line 78 in datahub-web-react/src/app/previewV2/ContextPathEntityLink.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/previewV2/ContextPathEntityLink.tsx#L73-L78

Added lines #L73 - L78 were not covered by tests
<ContextPathEntityIcon entity={entity} />
<ContainerText title={containerName}>{containerName}</ContainerText>
</StyledLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ const DEFAULT_NUM_VISIBLE = 2;
interface Props {
parentEntities: Entity[];
numVisible?: number;
linksDisabled?: boolean; // don't allow links to parent entities
}

export default function ParentEntities({ parentEntities, numVisible = DEFAULT_NUM_VISIBLE }: Props) {
export default function ParentEntities({ parentEntities, numVisible = DEFAULT_NUM_VISIBLE, linksDisabled }: Props) {
const entityRegistry = useEntityRegistry();

// parent nodes/domains are returned with direct parent first
Expand Down Expand Up @@ -72,6 +73,7 @@ export default function ParentEntities({ parentEntities, numVisible = DEFAULT_NU
<ContextPathEntityLink
key={parentEntity.urn}
entity={parentEntity}
linkDisabled={linksDisabled}

Check warning on line 76 in datahub-web-react/src/app/searchV2/filters/ParentEntities.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/searchV2/filters/ParentEntities.tsx#L76

Added line #L76 was not covered by tests
style={{ fontSize: '12px' }}
/>
{index !== visibleNodes.length - 1 && <ContextPathSeparator />}
Expand Down

0 comments on commit 97acaac

Please sign in to comment.