mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-21 15:48:05 +00:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
![]() |
import React, { useState } from 'react';
|
||
|
import styled from 'styled-components';
|
||
|
import { Tooltip } from 'antd';
|
||
|
import { CheckOutlined, MailOutlined } from '@ant-design/icons';
|
||
|
import EmailShare from 'react-email-share-link';
|
||
|
import MenuItem from 'antd/lib/menu/MenuItem';
|
||
|
import { ANTD_GRAY } from '../../../entity/shared/constants';
|
||
|
|
||
|
interface EmailMenuItemProps {
|
||
|
urn: string;
|
||
|
name: string;
|
||
|
type: string;
|
||
|
key: string;
|
||
|
}
|
||
|
|
||
|
const StyledMenuItem = styled(MenuItem)`
|
||
|
&& {
|
||
|
color: ${ANTD_GRAY[8]};
|
||
|
}
|
||
|
`;
|
||
|
|
||
|
export default function EmailMenuItem({ urn, name, type, key }: EmailMenuItemProps) {
|
||
|
/**
|
||
|
* Whether button has been clicked
|
||
|
*/
|
||
|
const [isClicked, setIsClicked] = useState(false);
|
||
|
const linkText = window.location.href;
|
||
|
|
||
|
return (
|
||
|
<StyledMenuItem
|
||
|
key={key}
|
||
|
onClick={() => {
|
||
|
navigator.clipboard.writeText(urn);
|
||
|
setIsClicked(true);
|
||
|
}}
|
||
|
>
|
||
|
<EmailShare subject={`${name} | ${type}`} body={`Check out this ${type} on DataHub: ${linkText}`}>
|
||
|
{(link) => (
|
||
|
<Tooltip title={`Share this ${type} via email`}>
|
||
|
{isClicked ? <CheckOutlined /> : <MailOutlined />}
|
||
|
<span>
|
||
|
<a href={link} style={{ color: 'inherit' }}>
|
||
|
<b>Email</b>
|
||
|
</a>
|
||
|
</span>
|
||
|
</Tooltip>
|
||
|
)}
|
||
|
</EmailShare>
|
||
|
</StyledMenuItem>
|
||
|
);
|
||
|
}
|