Skip to content

Commit 8aab4dd

Browse files
scsabaalextsg
authored andcommitted
View address of an added token (#4591)
* adding menu actions for tokens * apply common style
1 parent 01c9d81 commit 8aab4dd

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

app/_locales/en/messages.json

+6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@
146146
"copy": {
147147
"message": "Copy"
148148
},
149+
"copyContractAddress": {
150+
"message": "Copy Contract Address"
151+
},
149152
"copyToClipboard": {
150153
"message": "Copy to clipboard"
151154
},
@@ -955,6 +958,9 @@
955958
"viewAccount": {
956959
"message": "View Account"
957960
},
961+
"viewOnEtherscan": {
962+
"message": "View on Etherscan"
963+
},
958964
"visitWebSite": {
959965
"message": "Visit our web site"
960966
},

ui/app/components/dropdowns/token-menu-dropdown.js

+36-17
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ const h = require('react-hyperscript')
44
const inherits = require('util').inherits
55
const connect = require('react-redux').connect
66
const actions = require('../../actions')
7-
7+
const genAccountLink = require('etherscan-link').createAccountLink
8+
const copyToClipboard = require('copy-to-clipboard')
9+
const { Menu, Item, CloseArea } = require('./components/menu')
810

911
TokenMenuDropdown.contextTypes = {
1012
t: PropTypes.func,
1113
}
1214

13-
module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)
15+
module.exports = connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown)
1416

17+
function mapStateToProps (state) {
18+
return {
19+
network: state.metamask.network,
20+
}
21+
}
1522

1623
function mapDispatchToProps (dispatch) {
1724
return {
@@ -37,22 +44,34 @@ TokenMenuDropdown.prototype.onClose = function (e) {
3744
TokenMenuDropdown.prototype.render = function () {
3845
const { showHideTokenConfirmationModal } = this.props
3946

40-
return h('div.token-menu-dropdown', {}, [
41-
h('div.token-menu-dropdown__close-area', {
47+
return h(Menu, { className: 'token-menu-dropdown', isShowing: true }, [
48+
h(CloseArea, {
4249
onClick: this.onClose,
4350
}),
44-
h('div.token-menu-dropdown__container', {}, [
45-
h('div.token-menu-dropdown__options', {}, [
46-
47-
h('div.token-menu-dropdown__option', {
48-
onClick: (e) => {
49-
e.stopPropagation()
50-
showHideTokenConfirmationModal(this.props.token)
51-
this.props.onClose()
52-
},
53-
}, this.context.t('hideToken')),
54-
55-
]),
56-
]),
51+
h(Item, {
52+
onClick: (e) => {
53+
e.stopPropagation()
54+
showHideTokenConfirmationModal(this.props.token)
55+
this.props.onClose()
56+
},
57+
text: this.context.t('hideToken'),
58+
}),
59+
h(Item, {
60+
onClick: (e) => {
61+
e.stopPropagation()
62+
copyToClipboard(this.props.token.address)
63+
this.props.onClose()
64+
},
65+
text: this.context.t('copyContractAddress'),
66+
}),
67+
h(Item, {
68+
onClick: (e) => {
69+
e.stopPropagation()
70+
const url = genAccountLink(this.props.token.address, this.props.network)
71+
global.platform.openWindow({ url })
72+
this.props.onClose()
73+
},
74+
text: this.context.t('viewOnEtherscan'),
75+
}),
5776
])
5877
}

ui/app/css/itcss/components/token-list.scss

+1-5
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,9 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
8181
}
8282

8383
.token-menu-dropdown {
84-
height: 55px;
8584
width: 80%;
86-
border-radius: 4px;
87-
background-color: rgba(0, 0, 0, .82);
88-
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .5);
8985
position: absolute;
90-
top: 60px;
86+
top: 52px;
9187
right: 25px;
9288
z-index: 2000;
9389

0 commit comments

Comments
 (0)