@@ -19,6 +19,8 @@ import CopyToClipBoard from '../../CopyToClipboard/'
1919import { useEditable } from '../../hooks'
2020import Button from '../../Forms/Button'
2121import RequestCertificate from './RequestCertificate'
22+ import useNetworkInfo from '../../NetworkInformation/useNetworkInfo'
23+ import { ReactComponent as ExternalLinkIcon } from '../../Icons/externalLink.svg'
2224
2325export const RecordsItem = styled ( DetailsItem ) `
2426 ${ p => ! p . hasRecord && 'display: none;' }
@@ -135,6 +137,25 @@ const NotSet = styled('div')`
135137 color: #ccc;
136138`
137139
140+ const LinkContainer = styled ( 'a' ) `
141+ display: inline-block;
142+ align-items: center;
143+ text-overflow: ellipsis;
144+ white-space: nowrap;
145+ overflow: hidden;
146+ svg {
147+ margin-left: 10px;
148+ transition: 0.1s;
149+ opacity: 0;
150+ }
151+
152+ &:hover {
153+ svg {
154+ opacity: 1;
155+ }
156+ }
157+ `
158+
138159const Uploadable = ( { startUploading, keyName, value } ) => {
139160 if ( value && ! value . error ) {
140161 return (
@@ -172,7 +193,7 @@ const ContentHashEditable = ({
172193} ) => {
173194 const { t } = useTranslation ( )
174195 const { state, actions } = useEditable ( )
175-
196+ const { contentType } = domain
176197 const { authorized, uploading, newValue } = state
177198
178199 const {
@@ -205,14 +226,11 @@ const ContentHashEditable = ({
205226 value === 'undefined' ? (
206227 < NotSet > Not set</ NotSet >
207228 ) : (
208- < >
209- < ContentHashLink
210- value = { value }
211- contentType = { domain . contentType }
212- domain = { domain }
213- />
214- < CopyToClipBoard value = { value } />
215- </ >
229+ < ContentHashLinkWithEthLink
230+ value = { value }
231+ contentType = { contentType }
232+ domain = { domain }
233+ />
216234 ) }
217235 </ RecordsValue >
218236 ) }
@@ -322,6 +340,39 @@ const ContentHashEditable = ({
322340 )
323341}
324342
343+ function ContentHashLinkWithEthLink ( { value, contentType, domain } ) {
344+ const { networkId } = useNetworkInfo ( )
345+ const displayEthLink =
346+ ! ! domain . name . match ( '.eth$' ) && networkId === 1 && value ?. match ( / ^ i p / )
347+ return (
348+ < >
349+ < div >
350+ < ContentHashLink
351+ value = { value }
352+ contentType = { contentType }
353+ domain = { domain }
354+ />
355+ { displayEthLink && (
356+ < div >
357+ < LinkContainer
358+ target = "_blank"
359+ rel = "noopener"
360+ href = { `https://${ domain . name } .link` }
361+ >
362+ ({ `https://${ domain . name } .link` } )
363+ < ExternalLinkIcon />
364+ </ LinkContainer >
365+ </ div >
366+ ) }
367+ </ div >
368+ < div >
369+ < CopyToClipBoard value = { value } />
370+ < div > { displayEthLink && < > </ > } </ div >
371+ </ div >
372+ </ >
373+ )
374+ }
375+
325376function ContentHashViewOnly ( { keyName, value, type, domain, account } ) {
326377 const { name, contentType } = domain
327378 const { t } = useTranslation ( )
@@ -333,14 +384,11 @@ function ContentHashViewOnly({ keyName, value, type, domain, account }) {
333384 < RecordsKey > { t ( `c.${ keyName } ` ) } </ RecordsKey >
334385 < RecordsValue >
335386 { value !== '' ? (
336- < >
337- < ContentHashLink
338- value = { value }
339- contentType = { contentType }
340- domain = { domain }
341- />
342- < CopyToClipBoard value = { value } />
343- </ >
387+ < ContentHashLinkWithEthLink
388+ value = { value }
389+ contentType = { contentType }
390+ domain = { domain }
391+ />
344392 ) : (
345393 < NotSet > Not set</ NotSet >
346394 ) }
0 commit comments