-
Notifications
You must be signed in to change notification settings - Fork 7
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
2.1.12 #648
2.1.12 #648
Changes from 19 commits
ec68e97
d2a6eac
f5d8366
24afdcf
286383f
a79b295
9d557b4
4ca0989
5b98b40
1c6350f
a8792a7
da56ec2
503dada
519872a
3ae68be
aa6036e
7fe7f2a
1f4eb88
4397c23
6e804f2
69f2cdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { useEffect } from 'react'; | ||
import { useAppDispatch, useAppSelector } from '../../store'; | ||
import { Link } from 'react-router-dom'; | ||
import styled from '@emotion/styled'; | ||
|
||
// HOPR Components | ||
import SmallActionButton from '../../future-hopr-lib-components/Button/SmallActionButton'; | ||
import { generateBase64Jazz } from '../../utils/functions'; | ||
|
||
//Mui | ||
import CopyIcon from '@mui/icons-material/ContentCopy'; | ||
import LaunchIcon from '@mui/icons-material/Launch'; | ||
|
||
interface Props { | ||
peerId?: string; | ||
nodeAddress?: string; | ||
shortenPeerId?: boolean; | ||
} | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
align-items: center; | ||
.node-jazz-icon { | ||
height: 30px; | ||
width: 30px; | ||
} | ||
`; | ||
|
||
const PeersInfo: React.FC<Props> = (props) => { | ||
const { peerId, nodeAddress, ...rest } = props; | ||
const aliases = useAppSelector((store) => store.node.aliases.data); | ||
const peerIdToAliasLink = useAppSelector((store) => store.node.links.peerIdToAlias); | ||
|
||
const getAliasByPeerId = (peerId: string): string => { | ||
const shortPeerId = peerId && `${peerId.substring(0, 6)}...${peerId.substring(peerId.length - 8, peerId.length)}`; | ||
const displayPeerId = props.shortenPeerId ? shortPeerId : peerId; | ||
if (aliases && peerId && peerIdToAliasLink[peerId]) return `${peerIdToAliasLink[peerId]} (${displayPeerId})`; | ||
return displayPeerId; | ||
}; | ||
|
||
const noCopyPaste = !( | ||
window.location.protocol === 'https:' || | ||
window.location.hostname === 'localhost' || | ||
window.location.hostname === '127.0.0.1' | ||
); | ||
|
||
const icon = nodeAddress && generateBase64Jazz(nodeAddress); | ||
|
||
return ( | ||
<Container> | ||
<img | ||
className={`node-jazz-icon node-jazz-icon-present`} | ||
src={icon || ''} | ||
data-src={nodeAddress} | ||
/> | ||
<div> | ||
<span>{peerId && getAliasByPeerId(peerId)}</span>{' '} | ||
<SmallActionButton | ||
onClick={() => navigator.clipboard.writeText(peerId as string)} | ||
disabled={noCopyPaste} | ||
Comment on lines
+64
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add checks for undefined Since Apply this diff to add null checks: - onClick={() => navigator.clipboard.writeText(peerId as string)}
+ onClick={() => { if (peerId) navigator.clipboard.writeText(peerId); }}
- onClick={() => navigator.clipboard.writeText(nodeAddress as string)}
+ onClick={() => { if (nodeAddress) navigator.clipboard.writeText(nodeAddress); }} Also applies to: 66-67 |
||
tooltip={noCopyPaste ? 'Clipboard not supported on HTTP' : 'Copy Peer Id'} | ||
> | ||
<CopyIcon /> | ||
</SmallActionButton> | ||
<br /> | ||
<span>{nodeAddress}</span>{' '} | ||
<SmallActionButton | ||
onClick={() => navigator.clipboard.writeText(nodeAddress as string)} | ||
disabled={noCopyPaste} | ||
tooltip={noCopyPaste ? 'Clipboard not supported on HTTP' : 'Copy Node Address'} | ||
> | ||
<CopyIcon /> | ||
</SmallActionButton> | ||
<SmallActionButton tooltip={'Open in gnosisscan.io'}> | ||
<Link | ||
to={`https://gnosisscan.io/address/${nodeAddress}`} | ||
target="_blank" | ||
> | ||
<LaunchIcon /> | ||
</Link> | ||
</SmallActionButton> | ||
</div> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default PeersInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug console.log statement
Debug console.log statement should be removed before merging to production.
- console.log(jazzIconFromLocalStorage);