mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Merge pull request #1542 from MetaMask/i1539-CopyAddresses
Add ability to copy addresses from tx confirmation view
This commit is contained in:
commit
f5faeed2c9
46
ui/app/components/copyable.js
Normal file
46
ui/app/components/copyable.js
Normal file
@ -0,0 +1,46 @@
|
||||
const Component = require('react').Component
|
||||
const h = require('react-hyperscript')
|
||||
const inherits = require('util').inherits
|
||||
|
||||
const Tooltip = require('./tooltip')
|
||||
const copyToClipboard = require('copy-to-clipboard')
|
||||
|
||||
module.exports = Copyable
|
||||
|
||||
inherits(Copyable, Component)
|
||||
function Copyable () {
|
||||
Component.call(this)
|
||||
this.state = {
|
||||
copied: false,
|
||||
}
|
||||
}
|
||||
|
||||
Copyable.prototype.render = function () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
const { value, children } = props
|
||||
const { copied } = state
|
||||
|
||||
return h(Tooltip, {
|
||||
title: copied ? 'Copied!' : 'Copy',
|
||||
position: 'bottom',
|
||||
}, h('span', {
|
||||
style: {
|
||||
cursor: 'pointer',
|
||||
},
|
||||
onClick: (event) => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
copyToClipboard(value)
|
||||
this.debounceRestore()
|
||||
},
|
||||
}, children))
|
||||
}
|
||||
|
||||
Copyable.prototype.debounceRestore = function () {
|
||||
this.setState({ copied: true })
|
||||
clearTimeout(this.timeout)
|
||||
this.timeout = setTimeout(() => {
|
||||
this.setState({ copied: false })
|
||||
}, 850)
|
||||
}
|
@ -9,6 +9,7 @@ const BN = ethUtil.BN
|
||||
const hexToBn = require('../../../app/scripts/lib/hex-to-bn')
|
||||
|
||||
const MiniAccountPanel = require('./mini-account-panel')
|
||||
const Copyable = require('./copyable')
|
||||
const EthBalance = require('./eth-balance')
|
||||
const util = require('../util')
|
||||
const addressSummary = util.addressSummary
|
||||
@ -93,11 +94,16 @@ PendingTx.prototype.render = function () {
|
||||
fontFamily: 'Montserrat Bold, Montserrat, sans-serif',
|
||||
},
|
||||
}, identity.name),
|
||||
h('span.font-small', {
|
||||
style: {
|
||||
fontFamily: 'Montserrat Light, Montserrat, sans-serif',
|
||||
},
|
||||
}, addressSummary(address, 6, 4, false)),
|
||||
|
||||
h(Copyable, {
|
||||
value: ethUtil.toChecksumAddress(address),
|
||||
}, [
|
||||
h('span.font-small', {
|
||||
style: {
|
||||
fontFamily: 'Montserrat Light, Montserrat, sans-serif',
|
||||
},
|
||||
}, addressSummary(address, 6, 4, false)),
|
||||
]),
|
||||
|
||||
h('span.font-small', {
|
||||
style: {
|
||||
@ -322,16 +328,23 @@ PendingTx.prototype.miniAccountPanelForRecipient = function () {
|
||||
imageSeed: txParams.to,
|
||||
picOrder: 'left',
|
||||
}, [
|
||||
|
||||
h('span.font-small', {
|
||||
style: {
|
||||
fontFamily: 'Montserrat Bold, Montserrat, sans-serif',
|
||||
},
|
||||
}, nameForAddress(txParams.to, props.identities)),
|
||||
h('span.font-small', {
|
||||
style: {
|
||||
fontFamily: 'Montserrat Light, Montserrat, sans-serif',
|
||||
},
|
||||
}, addressSummary(txParams.to, 6, 4, false)),
|
||||
|
||||
h(Copyable, {
|
||||
value: ethUtil.toChecksumAddress(txParams.to),
|
||||
}, [
|
||||
h('span.font-small', {
|
||||
style: {
|
||||
fontFamily: 'Montserrat Light, Montserrat, sans-serif',
|
||||
},
|
||||
}, addressSummary(txParams.to, 6, 4, false)),
|
||||
]),
|
||||
|
||||
])
|
||||
} else {
|
||||
return h(MiniAccountPanel, {
|
||||
|
Loading…
Reference in New Issue
Block a user