mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-11 08:54:00 +00:00
Add links to glossary term cards without counts (#8705)
This commit is contained in:
parent
a78e72caf8
commit
d15f080a45
@ -4,6 +4,8 @@ import { Deprecation, Domain, EntityType, Owner, ParentNodesResult } from '../..
|
|||||||
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
|
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
|
||||||
import { useEntityRegistry } from '../../../useEntityRegistry';
|
import { useEntityRegistry } from '../../../useEntityRegistry';
|
||||||
import { IconStyleType, PreviewType } from '../../Entity';
|
import { IconStyleType, PreviewType } from '../../Entity';
|
||||||
|
import UrlButton from '../../shared/UrlButton';
|
||||||
|
import { getRelatedEntitiesUrl } from '../utils';
|
||||||
|
|
||||||
export const Preview = ({
|
export const Preview = ({
|
||||||
urn,
|
urn,
|
||||||
@ -39,6 +41,9 @@ export const Preview = ({
|
|||||||
deprecation={deprecation}
|
deprecation={deprecation}
|
||||||
parentNodes={parentNodes}
|
parentNodes={parentNodes}
|
||||||
domain={domain}
|
domain={domain}
|
||||||
|
entityTitleSuffix={
|
||||||
|
<UrlButton href={getRelatedEntitiesUrl(entityRegistry, urn)}>View Related Entities</UrlButton>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ import { EmbeddedListSearchSection } from '../../shared/components/styled/search
|
|||||||
import { useEntityData } from '../../shared/EntityContext';
|
import { useEntityData } from '../../shared/EntityContext';
|
||||||
|
|
||||||
export default function GlossaryRelatedEntity() {
|
export default function GlossaryRelatedEntity() {
|
||||||
const { entityData }: any = useEntityData();
|
const { entityData } = useEntityData();
|
||||||
|
|
||||||
const entityUrn = entityData?.urn;
|
const entityUrn = entityData?.urn;
|
||||||
|
|
||||||
|
@ -6,3 +6,7 @@ export function sortGlossaryTerms(entityRegistry: EntityRegistry, nodeA?: Entity
|
|||||||
const nodeBName = entityRegistry.getDisplayName(EntityType.GlossaryTerm, nodeB) || '';
|
const nodeBName = entityRegistry.getDisplayName(EntityType.GlossaryTerm, nodeB) || '';
|
||||||
return nodeAName.localeCompare(nodeBName);
|
return nodeAName.localeCompare(nodeBName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRelatedEntitiesUrl(entityRegistry: EntityRegistry, urn: string) {
|
||||||
|
return `${entityRegistry.getEntityUrl(EntityType.GlossaryTerm, urn)}/${encodeURIComponent('Related Entities')}`;
|
||||||
|
}
|
||||||
|
@ -1,28 +1,11 @@
|
|||||||
import { ArrowRightOutlined } from '@ant-design/icons';
|
|
||||||
import { Button } from 'antd';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components/macro';
|
|
||||||
import { EntityType } from '../../../types.generated';
|
import { EntityType } from '../../../types.generated';
|
||||||
import analytics, { EventType, EntityActionType } from '../../analytics';
|
import analytics, { EventType, EntityActionType } from '../../analytics';
|
||||||
|
import UrlButton from './UrlButton';
|
||||||
|
|
||||||
const GITHUB_LINK = 'github.com';
|
const GITHUB_LINK = 'github.com';
|
||||||
const GITHUB = 'GitHub';
|
const GITHUB = 'GitHub';
|
||||||
|
|
||||||
const ExternalUrlWrapper = styled.span`
|
|
||||||
font-size: 12px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StyledButton = styled(Button)`
|
|
||||||
> :hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
&&& {
|
|
||||||
padding-bottom: 0px;
|
|
||||||
}
|
|
||||||
padding-left: 12px;
|
|
||||||
padding-right: 12px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
externalUrl: string;
|
externalUrl: string;
|
||||||
platformName?: string;
|
platformName?: string;
|
||||||
@ -46,17 +29,8 @@ export default function ExternalUrlButton({ externalUrl, platformName, entityTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExternalUrlWrapper>
|
<UrlButton href={externalUrl} onClick={sendAnalytics}>
|
||||||
<StyledButton
|
{displayedName ? `View in ${displayedName}` : 'View link'}
|
||||||
type="link"
|
</UrlButton>
|
||||||
href={externalUrl}
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer noopener"
|
|
||||||
onClick={sendAnalytics}
|
|
||||||
>
|
|
||||||
{displayedName ? `View in ${displayedName}` : 'View link'}{' '}
|
|
||||||
<ArrowRightOutlined style={{ fontSize: 12 }} />
|
|
||||||
</StyledButton>
|
|
||||||
</ExternalUrlWrapper>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
37
datahub-web-react/src/app/entity/shared/UrlButton.tsx
Normal file
37
datahub-web-react/src/app/entity/shared/UrlButton.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import { ArrowRightOutlined } from '@ant-design/icons';
|
||||||
|
import { Button } from 'antd';
|
||||||
|
import styled from 'styled-components/macro';
|
||||||
|
|
||||||
|
const UrlButtonContainer = styled.span`
|
||||||
|
font-size: 12px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledButton = styled(Button)`
|
||||||
|
> :hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
&&& {
|
||||||
|
padding-bottom: 0px;
|
||||||
|
}
|
||||||
|
padding-left: 12px;
|
||||||
|
padding-right: 12px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
href: string;
|
||||||
|
children: ReactNode;
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NOOP = () => {};
|
||||||
|
|
||||||
|
export default function UrlButton({ href, children, onClick = NOOP }: Props) {
|
||||||
|
return (
|
||||||
|
<UrlButtonContainer>
|
||||||
|
<StyledButton type="link" href={href} target="_blank" rel="noreferrer noopener" onClick={onClick}>
|
||||||
|
{children} <ArrowRightOutlined style={{ fontSize: 12 }} />
|
||||||
|
</StyledButton>
|
||||||
|
</UrlButtonContainer>
|
||||||
|
);
|
||||||
|
}
|
@ -174,6 +174,7 @@ interface Props {
|
|||||||
deprecation?: Deprecation | null;
|
deprecation?: Deprecation | null;
|
||||||
topUsers?: Array<CorpUser> | null;
|
topUsers?: Array<CorpUser> | null;
|
||||||
externalUrl?: string | null;
|
externalUrl?: string | null;
|
||||||
|
entityTitleSuffix?: React.ReactNode;
|
||||||
subHeader?: React.ReactNode;
|
subHeader?: React.ReactNode;
|
||||||
snippet?: React.ReactNode;
|
snippet?: React.ReactNode;
|
||||||
insights?: Array<SearchInsight> | null;
|
insights?: Array<SearchInsight> | null;
|
||||||
@ -226,6 +227,7 @@ export default function DefaultPreviewCard({
|
|||||||
titleSizePx,
|
titleSizePx,
|
||||||
dataTestID,
|
dataTestID,
|
||||||
externalUrl,
|
externalUrl,
|
||||||
|
entityTitleSuffix,
|
||||||
onClick,
|
onClick,
|
||||||
degree,
|
degree,
|
||||||
parentContainers,
|
parentContainers,
|
||||||
@ -306,6 +308,7 @@ export default function DefaultPreviewCard({
|
|||||||
entityType={type}
|
entityType={type}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{entityTitleSuffix}
|
||||||
</EntityTitleContainer>
|
</EntityTitleContainer>
|
||||||
{degree !== undefined && degree !== null && (
|
{degree !== undefined && degree !== null && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user