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

feat(glossary) Add Source section to sidebar for Glossary Terms #5262

Merged
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -14,7 +14,7 @@ const DescriptionTypography = styled(Typography.Paragraph)`
`;

const SidebarLinkList = styled.div`
margin-left: -15px;
margin: 0 0 10px -15px;
min-width: 0;
`;

Expand All @@ -32,10 +32,14 @@ const LinkButton = styled(Button)`
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
line-height: 1;
}
`;

const SourceButton = styled(LinkButton)`
padding: 0;
margin-top: -5px;
`;

interface Props {
hideLinksButton?: boolean;
}
Expand All @@ -49,6 +53,9 @@ export const SidebarAboutSection = ({ properties }: { properties?: Props }) => {
const description = entityData?.editableProperties?.description || entityData?.properties?.description;
const links = entityData?.institutionalMemory?.elements || [];

const sourceUrl = entityData?.properties?.sourceUrl;
const sourceRef = entityData?.properties?.sourceRef;

const isUntouched = !description && !(links?.length > 0);

return (
Expand Down Expand Up @@ -117,6 +124,23 @@ export const SidebarAboutSection = ({ properties }: { properties?: Props }) => {
)}
</SidebarLinkList>
)}
{sourceRef && (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check that sourceUrl exists also?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Or what will happen?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in theory it could happen, if they only include sourceRef in the yaml and not sourceUrl - however I do have a check that if there isn't a sourceUrl then we just display the ref name with no link (I checked and this is how it used to work on an old component GlossarySidebarAboutSection)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay got it cool

<>
<SidebarHeader title="Source" />
<Typography.Paragraph>
{sourceUrl ? (
<SourceButton type="link" href={sourceUrl} target="_blank" rel="noreferrer">
<LinkOutlined />
{sourceRef}
</SourceButton>
) : (
{
sourceRef,
}
)}
</Typography.Paragraph>
</>
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import styled from 'styled-components/macro';
import { message, Button, List, Typography } from 'antd';
import { LinkOutlined, DeleteOutlined } from '@ant-design/icons';
import { EntityType } from '../../../../../../types.generated';
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export type GenericEntityProperties = {
properties?: Maybe<{
description?: Maybe<string>;
qualifiedName?: Maybe<string>;
sourceUrl?: Maybe<string>;
sourceRef?: Maybe<string>;
}>;
globalTags?: Maybe<GlobalTags>;
glossaryTerms?: Maybe<GlossaryTerms>;
Expand Down