mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #1790 from sdtsui/newui-account-dropdowns
[newui] - Implement Advanced Option Menu & Account Switching Menu
This commit is contained in:
commit
199587383b
@ -85,7 +85,7 @@
|
|||||||
"inject-css": "^0.1.1",
|
"inject-css": "^0.1.1",
|
||||||
"jazzicon": "^1.2.0",
|
"jazzicon": "^1.2.0",
|
||||||
"loglevel": "^1.4.1",
|
"loglevel": "^1.4.1",
|
||||||
"menu-droppo": "^1.1.0",
|
"menu-droppo": "1.1.6",
|
||||||
"metamask-logo": "^2.1.2",
|
"metamask-logo": "^2.1.2",
|
||||||
"mississippi": "^1.2.0",
|
"mississippi": "^1.2.0",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
|
@ -9,14 +9,18 @@ const Dropdown = require(path.join(__dirname, '..', '..', '..', '..', 'ui', 'res
|
|||||||
const DropdownMenuItem = require(path.join(__dirname, '..', '..', '..', '..', 'ui', 'responsive', 'app', 'components', 'dropdown.js')).DropdownMenuItem;
|
const DropdownMenuItem = require(path.join(__dirname, '..', '..', '..', '..', 'ui', 'responsive', 'app', 'components', 'dropdown.js')).DropdownMenuItem;
|
||||||
|
|
||||||
describe('Dropdown components', function () {
|
describe('Dropdown components', function () {
|
||||||
it('can render two items', function () {
|
let onClickOutside;
|
||||||
|
let closeMenu;
|
||||||
|
let onClick;
|
||||||
|
|
||||||
|
let dropdownComponentProps;
|
||||||
const renderer = ReactTestUtils.createRenderer()
|
const renderer = ReactTestUtils.createRenderer()
|
||||||
|
beforeEach(function () {
|
||||||
|
onClickOutside = sinon.spy();
|
||||||
|
closeMenu = sinon.spy();
|
||||||
|
onClick = sinon.spy();
|
||||||
|
|
||||||
const onClickOutside = sinon.spy();
|
dropdownComponentProps = {
|
||||||
const closeMenu = sinon.spy();
|
|
||||||
const onClick = sinon.spy();
|
|
||||||
|
|
||||||
const dropdownComponent = h(Dropdown, {
|
|
||||||
isOpen: true,
|
isOpen: true,
|
||||||
zIndex: 11,
|
zIndex: 11,
|
||||||
onClickOutside,
|
onClickOutside,
|
||||||
@ -26,26 +30,86 @@ describe('Dropdown components', function () {
|
|||||||
top: '36px',
|
top: '36px',
|
||||||
},
|
},
|
||||||
innerStyle: {},
|
innerStyle: {},
|
||||||
}, [ // DROP MENU ITEMS
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can render two items', function () {
|
||||||
|
const dropdownComponent = h(
|
||||||
|
Dropdown,
|
||||||
|
dropdownComponentProps,
|
||||||
|
[
|
||||||
h('style', `
|
h('style', `
|
||||||
.drop-menu-item:hover { background:rgb(235, 235, 235); }
|
.drop-menu-item:hover { background:rgb(235, 235, 235); }
|
||||||
.drop-menu-item i { margin: 11px; }
|
.drop-menu-item i { margin: 11px; }
|
||||||
`),
|
`),
|
||||||
|
|
||||||
h(DropdownMenuItem, {
|
h(DropdownMenuItem, {
|
||||||
closeMenu,
|
closeMenu,
|
||||||
onClick,
|
onClick,
|
||||||
}, 'Item 1'),
|
}, 'Item 1'),
|
||||||
|
|
||||||
h(DropdownMenuItem, {
|
h(DropdownMenuItem, {
|
||||||
closeMenu,
|
closeMenu,
|
||||||
onClick,
|
onClick,
|
||||||
}, 'Item 2'),
|
}, 'Item 2'),
|
||||||
])
|
]
|
||||||
|
)
|
||||||
|
|
||||||
const component = additions.renderIntoDocument(dropdownComponent);
|
const component = additions.renderIntoDocument(dropdownComponent);
|
||||||
renderer.render(dropdownComponent);
|
renderer.render(dropdownComponent);
|
||||||
const items = additions.find(component, 'li');
|
const items = additions.find(component, 'li');
|
||||||
assert.equal(items.length, 2);
|
assert.equal(items.length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('closes when item clicked', function() {
|
||||||
|
const dropdownComponent = h(
|
||||||
|
Dropdown,
|
||||||
|
dropdownComponentProps,
|
||||||
|
[
|
||||||
|
h('style', `
|
||||||
|
.drop-menu-item:hover { background:rgb(235, 235, 235); }
|
||||||
|
.drop-menu-item i { margin: 11px; }
|
||||||
|
`),
|
||||||
|
h(DropdownMenuItem, {
|
||||||
|
closeMenu,
|
||||||
|
onClick,
|
||||||
|
}, 'Item 1'),
|
||||||
|
h(DropdownMenuItem, {
|
||||||
|
closeMenu,
|
||||||
|
onClick,
|
||||||
|
}, 'Item 2'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
const component = additions.renderIntoDocument(dropdownComponent);
|
||||||
|
renderer.render(dropdownComponent);
|
||||||
|
const items = additions.find(component, 'li');
|
||||||
|
const node = items[0];
|
||||||
|
ReactTestUtils.Simulate.click(node);
|
||||||
|
assert.equal(closeMenu.calledOnce, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('invokes click handler when item clicked', function() {
|
||||||
|
const dropdownComponent = h(
|
||||||
|
Dropdown,
|
||||||
|
dropdownComponentProps,
|
||||||
|
[
|
||||||
|
h('style', `
|
||||||
|
.drop-menu-item:hover { background:rgb(235, 235, 235); }
|
||||||
|
.drop-menu-item i { margin: 11px; }
|
||||||
|
`),
|
||||||
|
h(DropdownMenuItem, {
|
||||||
|
closeMenu,
|
||||||
|
onClick,
|
||||||
|
}, 'Item 1'),
|
||||||
|
h(DropdownMenuItem, {
|
||||||
|
closeMenu,
|
||||||
|
onClick,
|
||||||
|
}, 'Item 2'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
const component = additions.renderIntoDocument(dropdownComponent);
|
||||||
|
renderer.render(dropdownComponent);
|
||||||
|
const items = additions.find(component, 'li');
|
||||||
|
const node = items[0];
|
||||||
|
ReactTestUtils.Simulate.click(node);
|
||||||
|
assert.equal(onClick.calledOnce, true);
|
||||||
|
});
|
||||||
});
|
});
|
@ -39,7 +39,6 @@ Network.prototype.render = function () {
|
|||||||
}),
|
}),
|
||||||
h('i.fa.fa-sort-desc'),
|
h('i.fa.fa-sort-desc'),
|
||||||
])
|
])
|
||||||
|
|
||||||
} else if (providerName === 'mainnet') {
|
} else if (providerName === 'mainnet') {
|
||||||
hoverText = 'Main Ethereum Network'
|
hoverText = 'Main Ethereum Network'
|
||||||
iconName = 'ethereum-network'
|
iconName = 'ethereum-network'
|
||||||
|
@ -3,21 +3,18 @@ const extend = require('xtend')
|
|||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const CopyButton = require('./components/copyButton')
|
|
||||||
const AccountInfoLink = require('./components/account-info-link')
|
|
||||||
const actions = require('./actions')
|
const actions = require('./actions')
|
||||||
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
|
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
|
||||||
const valuesFor = require('./util').valuesFor
|
const valuesFor = require('./util').valuesFor
|
||||||
|
|
||||||
const Identicon = require('./components/identicon')
|
const Identicon = require('./components/identicon')
|
||||||
const EthBalance = require('./components/eth-balance')
|
const EthBalance = require('./components/eth-balance')
|
||||||
const TransactionList = require('./components/transaction-list')
|
const TransactionList = require('./components/transaction-list')
|
||||||
const ExportAccountView = require('./components/account-export')
|
const ExportAccountView = require('./components/account-export')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const EditableLabel = require('./components/editable-label')
|
const EditableLabel = require('./components/editable-label')
|
||||||
const Tooltip = require('./components/tooltip')
|
|
||||||
const TabBar = require('./components/tab-bar')
|
const TabBar = require('./components/tab-bar')
|
||||||
const TokenList = require('./components/token-list')
|
const TokenList = require('./components/token-list')
|
||||||
|
const AccountDropdowns = require('./components/account-dropdowns').AccountDropdowns
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(AccountDetailScreen)
|
module.exports = connect(mapStateToProps)(AccountDetailScreen)
|
||||||
|
|
||||||
@ -99,7 +96,41 @@ AccountDetailScreen.prototype.render = function () {
|
|||||||
|
|
||||||
// What is shown when not editing + edit text:
|
// What is shown when not editing + edit text:
|
||||||
h('label.editing-label', [h('.edit-text', 'edit')]),
|
h('label.editing-label', [h('.edit-text', 'edit')]),
|
||||||
h('h2.font-medium.color-forest', {name: 'edit'}, identity && identity.name),
|
h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(
|
||||||
|
'h2.font-medium.color-forest',
|
||||||
|
{
|
||||||
|
name: 'edit',
|
||||||
|
style: {
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[
|
||||||
|
identity && identity.name,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
AccountDropdowns,
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
marginRight: '8px',
|
||||||
|
marginLeft: 'auto',
|
||||||
|
},
|
||||||
|
selected,
|
||||||
|
network,
|
||||||
|
identities: props.identities,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
h('.flex-row', {
|
h('.flex-row', {
|
||||||
style: {
|
style: {
|
||||||
@ -125,56 +156,6 @@ AccountDetailScreen.prototype.render = function () {
|
|||||||
color: '#AEAEAE',
|
color: '#AEAEAE',
|
||||||
},
|
},
|
||||||
}, checksumAddress),
|
}, checksumAddress),
|
||||||
|
|
||||||
// copy and export
|
|
||||||
|
|
||||||
h('.flex-row', {
|
|
||||||
style: {
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
|
|
||||||
h(AccountInfoLink, { selected, network }),
|
|
||||||
|
|
||||||
h(CopyButton, {
|
|
||||||
value: checksumAddress,
|
|
||||||
}),
|
|
||||||
|
|
||||||
h(Tooltip, {
|
|
||||||
title: 'QR Code',
|
|
||||||
}, [
|
|
||||||
h('i.fa.fa-qrcode.pointer.pop-hover', {
|
|
||||||
onClick: () => props.dispatch(actions.showQrView(selected, identity ? identity.name : '')),
|
|
||||||
style: {
|
|
||||||
fontSize: '18px',
|
|
||||||
position: 'relative',
|
|
||||||
color: 'rgb(247, 134, 28)',
|
|
||||||
top: '5px',
|
|
||||||
marginLeft: '3px',
|
|
||||||
marginRight: '3px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h(Tooltip, {
|
|
||||||
title: 'Export Private Key',
|
|
||||||
}, [
|
|
||||||
h('div', {
|
|
||||||
style: {
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
h('img.cursor-pointer.color-orange', {
|
|
||||||
src: 'images/key-32.png',
|
|
||||||
onClick: () => this.requestAccountExport(selected),
|
|
||||||
style: {
|
|
||||||
height: '19px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// account ballence
|
// account ballence
|
||||||
@ -306,7 +287,3 @@ AccountDetailScreen.prototype.transactionList = function () {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountDetailScreen.prototype.requestAccountExport = function () {
|
|
||||||
this.props.dispatch(actions.requestExportAccount())
|
|
||||||
}
|
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
const Component = require('react').Component
|
|
||||||
const h = require('react-hyperscript')
|
|
||||||
const inherits = require('util').inherits
|
|
||||||
const ethUtil = require('ethereumjs-util')
|
|
||||||
|
|
||||||
const EthBalance = require('../components/eth-balance')
|
|
||||||
const CopyButton = require('../components/copyButton')
|
|
||||||
const Identicon = require('../components/identicon')
|
|
||||||
|
|
||||||
module.exports = AccountListItem
|
|
||||||
|
|
||||||
inherits(AccountListItem, Component)
|
|
||||||
function AccountListItem () {
|
|
||||||
Component.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountListItem.prototype.render = function () {
|
|
||||||
const { identity, selectedAddress, accounts, onShowDetail,
|
|
||||||
conversionRate, currentCurrency } = this.props
|
|
||||||
|
|
||||||
const checksumAddress = identity && identity.address && ethUtil.toChecksumAddress(identity.address)
|
|
||||||
const isSelected = selectedAddress === identity.address
|
|
||||||
const account = accounts[identity.address]
|
|
||||||
const selectedClass = isSelected ? '.selected' : ''
|
|
||||||
|
|
||||||
return (
|
|
||||||
h(`.accounts-list-option.flex-row.flex-space-between.pointer.hover-white${selectedClass}`, {
|
|
||||||
key: `account-panel-${identity.address}`,
|
|
||||||
onClick: (event) => onShowDetail(identity.address, event),
|
|
||||||
}, [
|
|
||||||
|
|
||||||
h('.identicon-wrapper.flex-column.flex-center.select-none', [
|
|
||||||
this.pendingOrNot(),
|
|
||||||
this.indicateIfLoose(),
|
|
||||||
h(Identicon, {
|
|
||||||
address: identity.address,
|
|
||||||
imageify: true,
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
|
|
||||||
// account address, balance
|
|
||||||
h('.identity-data.flex-column.flex-justify-center.flex-grow.select-none', {
|
|
||||||
style: {
|
|
||||||
width: '200px',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
h('span', identity.name),
|
|
||||||
h('span.font-small', {
|
|
||||||
style: {
|
|
||||||
overflow: 'hidden',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
},
|
|
||||||
}, checksumAddress),
|
|
||||||
h(EthBalance, {
|
|
||||||
value: account && account.balance,
|
|
||||||
currentCurrency,
|
|
||||||
conversionRate,
|
|
||||||
style: {
|
|
||||||
lineHeight: '7px',
|
|
||||||
marginTop: '10px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
|
|
||||||
// copy button
|
|
||||||
h('.identity-copy.flex-column', {
|
|
||||||
style: {
|
|
||||||
margin: '0 20px',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
h(CopyButton, {
|
|
||||||
value: checksumAddress,
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountListItem.prototype.indicateIfLoose = function () {
|
|
||||||
try { // Sometimes keyrings aren't loaded yet:
|
|
||||||
const type = this.props.keyring.type
|
|
||||||
const isLoose = type !== 'HD Key Tree'
|
|
||||||
return isLoose ? h('.keyring-label', 'LOOSE') : null
|
|
||||||
} catch (e) { return }
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountListItem.prototype.pendingOrNot = function () {
|
|
||||||
const pending = this.props.pending
|
|
||||||
if (pending.length === 0) return null
|
|
||||||
return h('.pending-dot', pending.length)
|
|
||||||
}
|
|
@ -1,163 +0,0 @@
|
|||||||
const inherits = require('util').inherits
|
|
||||||
const Component = require('react').Component
|
|
||||||
const h = require('react-hyperscript')
|
|
||||||
const connect = require('react-redux').connect
|
|
||||||
const actions = require('../actions')
|
|
||||||
const valuesFor = require('../util').valuesFor
|
|
||||||
const findDOMNode = require('react-dom').findDOMNode
|
|
||||||
const AccountListItem = require('./account-list-item')
|
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(AccountsScreen)
|
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
|
||||||
const pendingTxs = valuesFor(state.metamask.unapprovedTxs)
|
|
||||||
.filter(txMeta => txMeta.metamaskNetworkId === state.metamask.network)
|
|
||||||
const pendingMsgs = valuesFor(state.metamask.unapprovedMsgs)
|
|
||||||
const pending = pendingTxs.concat(pendingMsgs)
|
|
||||||
|
|
||||||
return {
|
|
||||||
accounts: state.metamask.accounts,
|
|
||||||
identities: state.metamask.identities,
|
|
||||||
unapprovedTxs: state.metamask.unapprovedTxs,
|
|
||||||
selectedAddress: state.metamask.selectedAddress,
|
|
||||||
scrollToBottom: state.appState.scrollToBottom,
|
|
||||||
pending,
|
|
||||||
keyrings: state.metamask.keyrings,
|
|
||||||
conversionRate: state.metamask.conversionRate,
|
|
||||||
currentCurrency: state.metamask.currentCurrency,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inherits(AccountsScreen, Component)
|
|
||||||
function AccountsScreen () {
|
|
||||||
Component.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountsScreen.prototype.render = function () {
|
|
||||||
const props = this.props
|
|
||||||
const { keyrings, conversionRate, currentCurrency } = props
|
|
||||||
const identityList = valuesFor(props.identities)
|
|
||||||
const unapprovedTxList = valuesFor(props.unapprovedTxs)
|
|
||||||
|
|
||||||
return (
|
|
||||||
|
|
||||||
h('.accounts-section.flex-grow', [
|
|
||||||
|
|
||||||
// subtitle and nav
|
|
||||||
h('.section-title.flex-center', [
|
|
||||||
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
|
||||||
onClick: this.goHome.bind(this),
|
|
||||||
}),
|
|
||||||
h('h2.page-subtitle', 'Select Account'),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('hr.horizontal-line'),
|
|
||||||
|
|
||||||
// identity selection
|
|
||||||
h('section.identity-section', {
|
|
||||||
style: {
|
|
||||||
overflowY: 'auto',
|
|
||||||
overflowX: 'hidden',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[
|
|
||||||
identityList.map((identity) => {
|
|
||||||
const pending = this.props.pending.filter((txOrMsg) => {
|
|
||||||
if ('txParams' in txOrMsg) {
|
|
||||||
return txOrMsg.txParams.from === identity.address
|
|
||||||
} else if ('msgParams' in txOrMsg) {
|
|
||||||
return txOrMsg.msgParams.from === identity.address
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const simpleAddress = identity.address.substring(2).toLowerCase()
|
|
||||||
const keyring = keyrings.find((kr) => {
|
|
||||||
return kr.accounts.includes(simpleAddress) ||
|
|
||||||
kr.accounts.includes(identity.address)
|
|
||||||
})
|
|
||||||
|
|
||||||
return h(AccountListItem, {
|
|
||||||
key: `acct-panel-${identity.address}`,
|
|
||||||
identity,
|
|
||||||
selectedAddress: this.props.selectedAddress,
|
|
||||||
conversionRate,
|
|
||||||
currentCurrency,
|
|
||||||
accounts: this.props.accounts,
|
|
||||||
onShowDetail: this.onShowDetail.bind(this),
|
|
||||||
pending,
|
|
||||||
keyring,
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
|
|
||||||
h('hr.horizontal-line'),
|
|
||||||
h('div.footer.hover-white.pointer', {
|
|
||||||
key: 'reveal-account-bar',
|
|
||||||
onClick: () => {
|
|
||||||
this.addNewAccount()
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
display: 'flex',
|
|
||||||
height: '40px',
|
|
||||||
padding: '10px',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
h('i.fa.fa-plus.fa-lg', {key: ''}),
|
|
||||||
]),
|
|
||||||
h('hr.horizontal-line'),
|
|
||||||
]),
|
|
||||||
|
|
||||||
unapprovedTxList.length ? (
|
|
||||||
|
|
||||||
h('.unconftx-link.flex-row.flex-center', {
|
|
||||||
onClick: this.navigateToConfTx.bind(this),
|
|
||||||
}, [
|
|
||||||
h('span', 'Unconfirmed Txs'),
|
|
||||||
h('i.fa.fa-arrow-right.fa-lg'),
|
|
||||||
])
|
|
||||||
|
|
||||||
) : (
|
|
||||||
null
|
|
||||||
),
|
|
||||||
])
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a new account was revealed, scroll to the bottom
|
|
||||||
AccountsScreen.prototype.componentDidUpdate = function () {
|
|
||||||
const scrollToBottom = this.props.scrollToBottom
|
|
||||||
|
|
||||||
if (scrollToBottom) {
|
|
||||||
var container = findDOMNode(this)
|
|
||||||
var scrollable = container.querySelector('.identity-section')
|
|
||||||
scrollable.scrollTop = scrollable.scrollHeight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountsScreen.prototype.navigateToConfTx = function () {
|
|
||||||
event.stopPropagation()
|
|
||||||
this.props.dispatch(actions.showConfTxPage())
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountsScreen.prototype.onShowDetail = function (address, event) {
|
|
||||||
event.stopPropagation()
|
|
||||||
this.props.dispatch(actions.showAccountDetail(address))
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountsScreen.prototype.addNewAccount = function () {
|
|
||||||
this.props.dispatch(actions.addNewAccount(0))
|
|
||||||
}
|
|
||||||
|
|
||||||
/* An optional view proposed in this design:
|
|
||||||
* https://consensys.quip.com/zZVrAysM5znY
|
|
||||||
AccountsScreen.prototype.addNewAccount = function () {
|
|
||||||
this.props.dispatch(actions.navigateToNewAccountScreen())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
AccountsScreen.prototype.goHome = function () {
|
|
||||||
this.props.dispatch(actions.goHome())
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ const NewKeyChainScreen = require('./new-keychain')
|
|||||||
// unlock
|
// unlock
|
||||||
const UnlockScreen = require('./unlock')
|
const UnlockScreen = require('./unlock')
|
||||||
// accounts
|
// accounts
|
||||||
const AccountsScreen = require('./accounts')
|
|
||||||
const AccountDetailScreen = require('./account-detail')
|
const AccountDetailScreen = require('./account-detail')
|
||||||
const SendTransactionScreen = require('./send')
|
const SendTransactionScreen = require('./send')
|
||||||
const ConfirmTxScreen = require('./conf-tx')
|
const ConfirmTxScreen = require('./conf-tx')
|
||||||
@ -24,10 +23,9 @@ const Import = require('./accounts/import')
|
|||||||
const InfoScreen = require('./info')
|
const InfoScreen = require('./info')
|
||||||
const Loading = require('./components/loading')
|
const Loading = require('./components/loading')
|
||||||
const SandwichExpando = require('sandwich-expando')
|
const SandwichExpando = require('sandwich-expando')
|
||||||
const MenuDroppo = require('menu-droppo')
|
const Dropdown = require('./components/dropdown').Dropdown
|
||||||
const DropMenuItem = require('./components/drop-menu-item')
|
const DropdownMenuItem = require('./components/dropdown').DropdownMenuItem
|
||||||
const NetworkIndicator = require('./components/network')
|
const NetworkIndicator = require('./components/network')
|
||||||
const Tooltip = require('./components/tooltip')
|
|
||||||
const BuyView = require('./components/buy-button-subview')
|
const BuyView = require('./components/buy-button-subview')
|
||||||
const QrView = require('./components/qr-code')
|
const QrView = require('./components/qr-code')
|
||||||
const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete')
|
const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete')
|
||||||
@ -125,7 +123,7 @@ App.prototype.renderAppBar = function () {
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
visibility: props.isUnlocked ? 'visible' : 'none',
|
visibility: props.isUnlocked ? 'visible' : 'none',
|
||||||
background: props.isUnlocked ? 'white' : 'none',
|
background: props.isUnlocked ? 'white' : 'none',
|
||||||
height: '36px',
|
height: '38px',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
zIndex: 12,
|
zIndex: 12,
|
||||||
},
|
},
|
||||||
@ -173,21 +171,6 @@ App.prototype.renderAppBar = function () {
|
|||||||
},
|
},
|
||||||
}, [
|
}, [
|
||||||
|
|
||||||
// small accounts nav
|
|
||||||
props.isUnlocked && h(Tooltip, { title: 'Switch Accounts' }, [
|
|
||||||
h('img.cursor-pointer.color-orange', {
|
|
||||||
src: 'images/switch_acc.svg',
|
|
||||||
style: {
|
|
||||||
width: '23.5px',
|
|
||||||
marginRight: '8px',
|
|
||||||
},
|
|
||||||
onClick: (event) => {
|
|
||||||
event.stopPropagation()
|
|
||||||
this.props.dispatch(actions.showAccountsPage())
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
|
|
||||||
// hamburger
|
// hamburger
|
||||||
props.isUnlocked && h(SandwichExpando, {
|
props.isUnlocked && h(SandwichExpando, {
|
||||||
width: 16,
|
width: 16,
|
||||||
@ -209,11 +192,12 @@ App.prototype.renderAppBar = function () {
|
|||||||
|
|
||||||
App.prototype.renderNetworkDropdown = function () {
|
App.prototype.renderNetworkDropdown = function () {
|
||||||
const props = this.props
|
const props = this.props
|
||||||
|
const { provider: { type: providerType, rpcTarget: activeNetwork } } = props
|
||||||
const rpcList = props.frequentRpcList
|
const rpcList = props.frequentRpcList
|
||||||
const state = this.state || {}
|
const state = this.state || {}
|
||||||
const isOpen = state.isNetworkMenuOpen
|
const isOpen = state.isNetworkMenuOpen
|
||||||
|
|
||||||
return h(MenuDroppo, {
|
return h(Dropdown, {
|
||||||
isOpen,
|
isOpen,
|
||||||
onClickOutside: (event) => {
|
onClickOutside: (event) => {
|
||||||
this.setState({ isNetworkMenuOpen: !isOpen })
|
this.setState({ isNetworkMenuOpen: !isOpen })
|
||||||
@ -221,72 +205,92 @@ App.prototype.renderNetworkDropdown = function () {
|
|||||||
zIndex: 11,
|
zIndex: 11,
|
||||||
style: {
|
style: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: 0,
|
left: '2px',
|
||||||
top: '36px',
|
top: '36px',
|
||||||
},
|
},
|
||||||
innerStyle: {
|
innerStyle: {},
|
||||||
background: 'white',
|
}, [
|
||||||
boxShadow: '1px 1px 2px rgba(0,0,0,0.1)',
|
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
|
||||||
|
onClick: () => props.dispatch(actions.setProviderType('mainnet')),
|
||||||
},
|
},
|
||||||
}, [ // DROP MENU ITEMS
|
[
|
||||||
h('style', `
|
h('.menu-icon.diamond'),
|
||||||
.drop-menu-item:hover { background:rgb(235, 235, 235); }
|
'Main Ethereum Network',
|
||||||
.drop-menu-item i { margin: 11px; }
|
providerType === 'mainnet' ? h('.check', '✓') : null,
|
||||||
`),
|
]
|
||||||
|
),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(
|
||||||
label: 'Main Ethereum Network',
|
DropdownMenuItem,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
{
|
||||||
action: () => props.dispatch(actions.setProviderType('mainnet')),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
|
||||||
icon: h('.menu-icon.diamond'),
|
onClick: () => props.dispatch(actions.setProviderType('ropsten')),
|
||||||
activeNetworkRender: props.network,
|
},
|
||||||
provider: props.provider,
|
[
|
||||||
}),
|
h('.menu-icon.red-dot'),
|
||||||
|
'Ropsten Test Network',
|
||||||
|
providerType === 'ropsten' ? h('.check', '✓') : null,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(
|
||||||
label: 'Ropsten Test Network',
|
DropdownMenuItem,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
{
|
||||||
action: () => props.dispatch(actions.setProviderType('ropsten')),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
|
||||||
icon: h('.menu-icon.red-dot'),
|
onClick: () => props.dispatch(actions.setProviderType('kovan')),
|
||||||
activeNetworkRender: props.network,
|
},
|
||||||
provider: props.provider,
|
[
|
||||||
}),
|
h('.menu-icon.hollow-diamond'),
|
||||||
|
'Kovan Test Network',
|
||||||
|
providerType === 'kovan' ? h('.check', '✓') : null,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(
|
||||||
label: 'Kovan Test Network',
|
DropdownMenuItem,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false}),
|
{
|
||||||
action: () => props.dispatch(actions.setProviderType('kovan')),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
|
||||||
icon: h('.menu-icon.hollow-diamond'),
|
onClick: () => props.dispatch(actions.setProviderType('rinkeby')),
|
||||||
activeNetworkRender: props.network,
|
},
|
||||||
provider: props.provider,
|
[
|
||||||
}),
|
h('.menu-icon.golden-square'),
|
||||||
|
'Rinkeby Test Network',
|
||||||
|
providerType === 'rinkeby' ? h('.check', '✓') : null,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(
|
||||||
label: 'Rinkeby Test Network',
|
DropdownMenuItem,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false}),
|
{
|
||||||
action: () => props.dispatch(actions.setProviderType('rinkeby')),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
|
||||||
icon: h('.menu-icon.golden-square'),
|
onClick: () => props.dispatch(actions.setDefaultRpcTarget(rpcList)),
|
||||||
activeNetworkRender: props.network,
|
},
|
||||||
provider: props.provider,
|
[
|
||||||
}),
|
h('i.fa.fa-question-circle.fa-lg.menu-icon'),
|
||||||
|
'Localhost 8545',
|
||||||
h(DropMenuItem, {
|
activeNetwork === 'http://localhost:8545' ? h('.check', '✓') : null,
|
||||||
label: 'Localhost 8545',
|
]
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
),
|
||||||
action: () => props.dispatch(actions.setDefaultRpcTarget(rpcList)),
|
|
||||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
|
||||||
activeNetworkRender: props.provider.rpcTarget,
|
|
||||||
}),
|
|
||||||
|
|
||||||
this.renderCustomOption(props.provider),
|
this.renderCustomOption(props.provider),
|
||||||
this.renderCommonRpc(rpcList, props.provider),
|
this.renderCommonRpc(rpcList, props.provider),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(
|
||||||
label: 'Custom RPC',
|
DropdownMenuItem,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
{
|
||||||
action: () => this.props.dispatch(actions.showConfigPage()),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
|
||||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
onClick: () => this.props.dispatch(actions.showConfigPage()),
|
||||||
}),
|
},
|
||||||
|
[
|
||||||
|
h('i.fa.fa-question-circle.fa-lg.menu-icon'),
|
||||||
|
'Custom RPC',
|
||||||
|
activeNetwork === 'custom' ? h('.check', '✓') : null,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
@ -295,7 +299,7 @@ App.prototype.renderDropdown = function () {
|
|||||||
const state = this.state || {}
|
const state = this.state || {}
|
||||||
const isOpen = state.isMainMenuOpen
|
const isOpen = state.isMainMenuOpen
|
||||||
|
|
||||||
return h(MenuDroppo, {
|
return h(Dropdown, {
|
||||||
isOpen: isOpen,
|
isOpen: isOpen,
|
||||||
zIndex: 11,
|
zIndex: 11,
|
||||||
onClickOutside: (event) => {
|
onClickOutside: (event) => {
|
||||||
@ -303,46 +307,30 @@ App.prototype.renderDropdown = function () {
|
|||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 0,
|
right: '2px',
|
||||||
top: '36px',
|
top: '38px',
|
||||||
},
|
},
|
||||||
innerStyle: {
|
innerStyle: {},
|
||||||
background: 'white',
|
}, [
|
||||||
boxShadow: '1px 1px 2px rgba(0,0,0,0.1)',
|
h(DropdownMenuItem, {
|
||||||
},
|
|
||||||
}, [ // DROP MENU ITEMS
|
|
||||||
h('style', `
|
|
||||||
.drop-menu-item:hover { background:rgb(235, 235, 235); }
|
|
||||||
.drop-menu-item i { margin: 11px; }
|
|
||||||
`),
|
|
||||||
|
|
||||||
h(DropMenuItem, {
|
|
||||||
label: 'Settings',
|
|
||||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.showConfigPage()),
|
onClick: () => { this.props.dispatch(actions.showConfigPage()) },
|
||||||
icon: h('i.fa.fa-gear.fa-lg'),
|
}, 'Settings'),
|
||||||
}),
|
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(DropdownMenuItem, {
|
||||||
label: 'Import Account',
|
|
||||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.showImportPage()),
|
onClick: () => { this.props.dispatch(actions.showImportPage()) },
|
||||||
icon: h('i.fa.fa-arrow-circle-o-up.fa-lg'),
|
}, 'Import Account'),
|
||||||
}),
|
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(DropdownMenuItem, {
|
||||||
label: 'Lock',
|
|
||||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.lockMetamask()),
|
onClick: () => { this.props.dispatch(actions.lockMetamask()) },
|
||||||
icon: h('i.fa.fa-lock.fa-lg'),
|
}, 'Lock'),
|
||||||
}),
|
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(DropdownMenuItem, {
|
||||||
label: 'Info/Help',
|
|
||||||
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.showInfoPage()),
|
onClick: () => { this.props.dispatch(actions.showInfoPage()) },
|
||||||
icon: h('i.fa.fa-question.fa-lg'),
|
}, 'Info/Help'),
|
||||||
}),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,10 +416,6 @@ App.prototype.renderPrimary = function () {
|
|||||||
// show current view
|
// show current view
|
||||||
switch (props.currentView.name) {
|
switch (props.currentView.name) {
|
||||||
|
|
||||||
case 'accounts':
|
|
||||||
log.debug('rendering accounts screen')
|
|
||||||
return h(AccountsScreen, {key: 'accounts'})
|
|
||||||
|
|
||||||
case 'accountDetail':
|
case 'accountDetail':
|
||||||
log.debug('rendering account detail screen')
|
log.debug('rendering account detail screen')
|
||||||
return h(AccountDetailScreen, {key: 'account-detail'})
|
return h(AccountDetailScreen, {key: 'account-detail'})
|
||||||
@ -534,13 +518,18 @@ App.prototype.renderCustomOption = function (provider) {
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return h(DropMenuItem, {
|
return h(
|
||||||
label,
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
key: rpcTarget,
|
key: rpcTarget,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
||||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
},
|
||||||
activeNetworkRender: 'custom',
|
[
|
||||||
})
|
h('i.fa.fa-question-circle.fa-lg.menu-icon'),
|
||||||
|
label,
|
||||||
|
h('.check', '✓'),
|
||||||
|
]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,14 +562,19 @@ App.prototype.renderCommonRpc = function (rpcList, provider) {
|
|||||||
if ((rpc === 'http://localhost:8545') || (rpc === rpcTarget)) {
|
if ((rpc === 'http://localhost:8545') || (rpc === rpcTarget)) {
|
||||||
return null
|
return null
|
||||||
} else {
|
} else {
|
||||||
return h(DropMenuItem, {
|
return h(
|
||||||
label: rpc,
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
key: rpc,
|
key: rpc,
|
||||||
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),
|
||||||
action: () => props.dispatch(actions.setRpcTarget(rpc)),
|
action: () => props.dispatch(actions.setRpcTarget(rpc)),
|
||||||
icon: h('i.fa.fa-question-circle.fa-lg'),
|
},
|
||||||
activeNetworkRender: rpc,
|
[
|
||||||
})
|
h('i.fa.fa-question-circle.fa-lg.menu-icon'),
|
||||||
|
rpc,
|
||||||
|
h('.check', '✓'),
|
||||||
|
]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
227
ui/responsive/app/components/account-dropdowns.js
Normal file
227
ui/responsive/app/components/account-dropdowns.js
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
const Component = require('react').Component
|
||||||
|
const PropTypes = require('react').PropTypes
|
||||||
|
const h = require('react-hyperscript')
|
||||||
|
const actions = require('../actions')
|
||||||
|
const genAccountLink = require('../../lib/account-link.js')
|
||||||
|
const connect = require('react-redux').connect
|
||||||
|
const Dropdown = require('./dropdown').Dropdown
|
||||||
|
const DropdownMenuItem = require('./dropdown').DropdownMenuItem
|
||||||
|
const Identicon = require('./identicon')
|
||||||
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
|
|
||||||
|
class AccountDropdowns extends Component {
|
||||||
|
constructor (props) {
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
accountSelectorActive: false,
|
||||||
|
optionsMenuActive: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderAccounts () {
|
||||||
|
const { identities, selected } = this.props
|
||||||
|
|
||||||
|
return Object.keys(identities).map((key) => {
|
||||||
|
const identity = identities[key]
|
||||||
|
const isSelected = identity.address === selected
|
||||||
|
|
||||||
|
return h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => {
|
||||||
|
this.props.actions.showAccountDetail(identity.address)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(
|
||||||
|
Identicon,
|
||||||
|
{
|
||||||
|
address: identity.address,
|
||||||
|
diameter: 16,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
h('span', { style: { marginLeft: '10px' } }, identity.name || ''),
|
||||||
|
h('span', { style: { marginLeft: '10px' } }, isSelected ? h('.check', '✓') : null),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
renderAccountSelector () {
|
||||||
|
const { actions } = this.props
|
||||||
|
const { accountSelectorActive } = this.state
|
||||||
|
|
||||||
|
return h(
|
||||||
|
Dropdown,
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
marginLeft: '-125px',
|
||||||
|
minWidth: '180px',
|
||||||
|
},
|
||||||
|
isOpen: accountSelectorActive,
|
||||||
|
onClickOutside: () => { this.setState({ accountSelectorActive: false }) },
|
||||||
|
},
|
||||||
|
[
|
||||||
|
...this.renderAccounts(),
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => actions.addNewAccount(),
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(
|
||||||
|
Identicon,
|
||||||
|
{
|
||||||
|
diameter: 16,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
h('span', { style: { marginLeft: '10px' } }, 'Create Account'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => actions.showImportPage(),
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(
|
||||||
|
Identicon,
|
||||||
|
{
|
||||||
|
diameter: 16,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
h('span', { style: { marginLeft: '10px' } }, 'Import Account'),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
renderAccountOptions () {
|
||||||
|
const { actions } = this.props
|
||||||
|
const { optionsMenuActive } = this.state
|
||||||
|
|
||||||
|
return h(
|
||||||
|
Dropdown,
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
marginLeft: '-162px',
|
||||||
|
minWidth: '180px',
|
||||||
|
},
|
||||||
|
isOpen: optionsMenuActive,
|
||||||
|
onClickOutside: () => { this.setState({ optionsMenuActive: false }) },
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => actions.showConfigPage(),
|
||||||
|
},
|
||||||
|
'Account Settings',
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => {
|
||||||
|
const { selected, network } = this.props
|
||||||
|
const url = genAccountLink(selected, network)
|
||||||
|
global.platform.openWindow({ url })
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'View account on Etherscan',
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => {
|
||||||
|
const { selected } = this.props
|
||||||
|
const checkSumAddress = selected && ethUtil.toChecksumAddress(selected)
|
||||||
|
copyToClipboard(checkSumAddress)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'Copy Address to clipboard',
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
DropdownMenuItem,
|
||||||
|
{
|
||||||
|
closeMenu: () => {},
|
||||||
|
onClick: () => {
|
||||||
|
actions.requestAccountExport()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'Export Private Key',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { style } = this.props
|
||||||
|
const { optionsMenuActive, accountSelectorActive } = this.state
|
||||||
|
|
||||||
|
return h(
|
||||||
|
'span',
|
||||||
|
{
|
||||||
|
style: style,
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h(
|
||||||
|
'i.fa.fa-angle-down',
|
||||||
|
{
|
||||||
|
style: {},
|
||||||
|
onClick: (event) => {
|
||||||
|
event.stopPropagation()
|
||||||
|
this.setState({
|
||||||
|
accountSelectorActive: !accountSelectorActive,
|
||||||
|
optionsMenuActive: false,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
this.renderAccountSelector(),
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
'i.fa.fa-ellipsis-h',
|
||||||
|
{
|
||||||
|
style: { 'marginLeft': '10px'},
|
||||||
|
onClick: (event) => {
|
||||||
|
event.stopPropagation()
|
||||||
|
this.setState({
|
||||||
|
accountSelectorActive: false,
|
||||||
|
optionsMenuActive: !optionsMenuActive,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
this.renderAccountOptions()
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountDropdowns.propTypes = {
|
||||||
|
identities: PropTypes.objectOf(PropTypes.object),
|
||||||
|
selected: PropTypes.string,
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => {
|
||||||
|
return {
|
||||||
|
actions: {
|
||||||
|
showConfigPage: () => dispatch(actions.showConfigPage()),
|
||||||
|
requestAccountExport: () => dispatch(actions.requestExportAccount()),
|
||||||
|
showAccountDetail: (address) => dispatch(actions.showAccountDetail(address)),
|
||||||
|
addNewAccount: () => dispatch(actions.addNewAccount()),
|
||||||
|
showImportPage: () => dispatch(actions.showImportPage()),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
AccountDropdowns: connect(null, mapDispatchToProps)(AccountDropdowns),
|
||||||
|
}
|
@ -1,41 +0,0 @@
|
|||||||
const Component = require('react').Component
|
|
||||||
const h = require('react-hyperscript')
|
|
||||||
const inherits = require('util').inherits
|
|
||||||
const Tooltip = require('./tooltip')
|
|
||||||
const genAccountLink = require('../../lib/account-link')
|
|
||||||
|
|
||||||
module.exports = AccountInfoLink
|
|
||||||
|
|
||||||
inherits(AccountInfoLink, Component)
|
|
||||||
function AccountInfoLink () {
|
|
||||||
Component.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountInfoLink.prototype.render = function () {
|
|
||||||
const { selected, network } = this.props
|
|
||||||
const title = 'View account on Etherscan'
|
|
||||||
const url = genAccountLink(selected, network)
|
|
||||||
|
|
||||||
if (!url) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return h('.account-info-link', {
|
|
||||||
style: {
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
|
|
||||||
h(Tooltip, {
|
|
||||||
title,
|
|
||||||
}, [
|
|
||||||
h('i.fa.fa-info-circle.cursor-pointer.color-orange', {
|
|
||||||
style: {
|
|
||||||
margin: '5px',
|
|
||||||
},
|
|
||||||
onClick () { global.platform.openWindow({ url }) },
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
const Component = require('react').Component
|
|
||||||
const h = require('react-hyperscript')
|
|
||||||
const inherits = require('util').inherits
|
|
||||||
|
|
||||||
module.exports = DropMenuItem
|
|
||||||
|
|
||||||
inherits(DropMenuItem, Component)
|
|
||||||
function DropMenuItem () {
|
|
||||||
Component.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
DropMenuItem.prototype.render = function () {
|
|
||||||
return h('li.drop-menu-item', {
|
|
||||||
onClick: () => {
|
|
||||||
this.props.closeMenu()
|
|
||||||
this.props.action()
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
listStyle: 'none',
|
|
||||||
padding: '6px 16px 6px 5px',
|
|
||||||
fontFamily: 'Montserrat Regular',
|
|
||||||
color: 'rgb(125, 128, 130)',
|
|
||||||
cursor: 'pointer',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'flex-start',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
this.props.icon,
|
|
||||||
this.props.label,
|
|
||||||
this.activeNetworkRender(),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
DropMenuItem.prototype.activeNetworkRender = function () {
|
|
||||||
const activeNetwork = this.props.activeNetworkRender
|
|
||||||
const { provider } = this.props
|
|
||||||
const providerType = provider ? provider.type : null
|
|
||||||
if (activeNetwork === undefined) return
|
|
||||||
|
|
||||||
switch (this.props.label) {
|
|
||||||
case 'Main Ethereum Network':
|
|
||||||
if (providerType === 'mainnet') return h('.check', '✓')
|
|
||||||
break
|
|
||||||
case 'Ropsten Test Network':
|
|
||||||
if (providerType === 'ropsten') return h('.check', '✓')
|
|
||||||
break
|
|
||||||
case 'Kovan Test Network':
|
|
||||||
if (providerType === 'kovan') return h('.check', '✓')
|
|
||||||
break
|
|
||||||
case 'Rinkeby Test Network':
|
|
||||||
if (providerType === 'rinkeby') return h('.check', '✓')
|
|
||||||
break
|
|
||||||
case 'Localhost 8545':
|
|
||||||
if (activeNetwork === 'http://localhost:8545') return h('.check', '✓')
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
if (activeNetwork === 'custom') return h('.check', '✓')
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,13 @@
|
|||||||
const Component = require('react').Component;
|
const Component = require('react').Component
|
||||||
const PropTypes = require('react').PropTypes;
|
const PropTypes = require('react').PropTypes
|
||||||
const h = require('react-hyperscript');
|
const h = require('react-hyperscript')
|
||||||
const MenuDroppo = require('menu-droppo');
|
const MenuDroppo = require('menu-droppo')
|
||||||
|
|
||||||
|
const noop = () => {}
|
||||||
|
|
||||||
class Dropdown extends Component {
|
class Dropdown extends Component {
|
||||||
render () {
|
render () {
|
||||||
const { isOpen, onClickOutside, style, children } = this.props;
|
const { isOpen, onClickOutside, style, children } = this.props
|
||||||
|
|
||||||
return h(
|
return h(
|
||||||
MenuDroppo,
|
MenuDroppo,
|
||||||
@ -30,13 +32,18 @@ class Dropdown extends Component {
|
|||||||
`
|
`
|
||||||
),
|
),
|
||||||
...children,
|
...children,
|
||||||
],
|
]
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dropdown.defaultProps = {
|
||||||
|
isOpen: false,
|
||||||
|
onClick: noop,
|
||||||
|
}
|
||||||
|
|
||||||
Dropdown.propTypes = {
|
Dropdown.propTypes = {
|
||||||
isOpen: PropTypes.func.isRequired,
|
isOpen: PropTypes.bool.isRequired,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
style: PropTypes.object.isRequired,
|
style: PropTypes.object.isRequired,
|
||||||
@ -44,13 +51,15 @@ Dropdown.propTypes = {
|
|||||||
|
|
||||||
class DropdownMenuItem extends Component {
|
class DropdownMenuItem extends Component {
|
||||||
render () {
|
render () {
|
||||||
const { onClick, closeMenu, children } = this.props;
|
const { onClick, closeMenu, children } = this.props
|
||||||
|
|
||||||
return h(
|
return h(
|
||||||
'li.dropdown-menu-item',
|
'li.dropdown-menu-item',
|
||||||
{
|
{
|
||||||
onClick,
|
onClick: () => {
|
||||||
closeMenu,
|
onClick()
|
||||||
|
closeMenu()
|
||||||
|
},
|
||||||
style: {
|
style: {
|
||||||
listStyle: 'none',
|
listStyle: 'none',
|
||||||
padding: '8px 0px 8px 0px',
|
padding: '8px 0px 8px 0px',
|
||||||
@ -60,10 +69,11 @@ class DropdownMenuItem extends Component {
|
|||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'flex-start',
|
justifyContent: 'flex-start',
|
||||||
|
alignItems: 'center',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
children
|
children
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +81,9 @@ DropdownMenuItem.propTypes = {
|
|||||||
closeMenu: PropTypes.func.isRequired,
|
closeMenu: PropTypes.func.isRequired,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Dropdown,
|
Dropdown,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
};
|
}
|
||||||
|
@ -30,7 +30,12 @@ EditableLabel.prototype.render = function () {
|
|||||||
} else {
|
} else {
|
||||||
return h('div.name-label', {
|
return h('div.name-label', {
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
|
const nameAttribute = event.target.getAttribute('name')
|
||||||
|
// checks for class to handle smaller CTA above the account name
|
||||||
|
const classAttribute = event.target.getAttribute('class')
|
||||||
|
if (nameAttribute === 'edit' || classAttribute === 'edit-text') {
|
||||||
this.setState({ isEditingLabel: true })
|
this.setState({ isEditingLabel: true })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}, this.props.children)
|
}, this.props.children)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ Network.prototype.render = function () {
|
|||||||
}),
|
}),
|
||||||
h('i.fa.fa-sort-desc'),
|
h('i.fa.fa-sort-desc'),
|
||||||
])
|
])
|
||||||
|
|
||||||
} else if (providerName === 'mainnet') {
|
} else if (providerName === 'mainnet') {
|
||||||
hoverText = 'Main Ethereum Network'
|
hoverText = 'Main Ethereum Network'
|
||||||
iconName = 'ethereum-network'
|
iconName = 'ethereum-network'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user