This repository has been archived by the owner on Jan 27, 2025. It is now read-only.
forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Display 'View in Github' if externalUrl is link to GitHub (d…
- Loading branch information
1 parent
c5541df
commit d1091d4
Showing
19 changed files
with
94 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
datahub-web-react/src/app/entity/shared/ExternalUrlButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ArrowRightOutlined } from '@ant-design/icons'; | ||
import { Button } from 'antd'; | ||
import React from 'react'; | ||
import styled from 'styled-components/macro'; | ||
import { EntityType } from '../../../types.generated'; | ||
import analytics, { EventType, EntityActionType } from '../../analytics'; | ||
|
||
const GITHUB_LINK = 'github.com'; | ||
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 { | ||
externalUrl: string; | ||
platformName?: string; | ||
entityUrn: string; | ||
entityType?: string; | ||
} | ||
|
||
export default function ExternalUrlButton({ externalUrl, platformName, entityType, entityUrn }: Props) { | ||
function sendAnalytics() { | ||
analytics.event({ | ||
type: EventType.EntityActionEvent, | ||
actionType: EntityActionType.ClickExternalUrl, | ||
entityType: entityType as EntityType, | ||
entityUrn, | ||
}); | ||
} | ||
|
||
let displayedName = platformName; | ||
if (externalUrl.toLocaleLowerCase().includes(GITHUB_LINK)) { | ||
displayedName = GITHUB; | ||
} | ||
|
||
return ( | ||
<ExternalUrlWrapper> | ||
<StyledButton | ||
type="link" | ||
href={externalUrl} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
onClick={sendAnalytics} | ||
> | ||
View in {displayedName} <ArrowRightOutlined style={{ fontSize: 12 }} /> | ||
</StyledButton> | ||
</ExternalUrlWrapper> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters