aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-06-06 03:17:26 +0800
committerGitHub <noreply@github.com>2017-06-06 03:17:26 +0800
commitf5faeed2c96f25333a83631833ccb8805fea3c47 (patch)
tree084a2ea7b674f28301a6eea4cbe6692ab4cd36b2 /ui/app/components
parent9eea990425f1f68eabca8b283bdfc662befcd226 (diff)
parent8dc6aa9c4c4f11e08eee0688c210324b313b710b (diff)
downloadtangerine-wallet-browser-f5faeed2c96f25333a83631833ccb8805fea3c47.tar.gz
tangerine-wallet-browser-f5faeed2c96f25333a83631833ccb8805fea3c47.tar.zst
tangerine-wallet-browser-f5faeed2c96f25333a83631833ccb8805fea3c47.zip
Merge pull request #1542 from MetaMask/i1539-CopyAddresses
Add ability to copy addresses from tx confirmation view
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/copyable.js46
-rw-r--r--ui/app/components/pending-tx.js33
2 files changed, 69 insertions, 10 deletions
diff --git a/ui/app/components/copyable.js b/ui/app/components/copyable.js
new file mode 100644
index 000000000..a4f6f4bc6
--- /dev/null
+++ b/ui/app/components/copyable.js
@@ -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)
+}
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index b46f715bc..4961db5de 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -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, {