aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/accounts.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-04-14 06:28:44 +0800
committerDan Finlay <dan@danfinlay.com>2016-04-14 06:28:44 +0800
commitd814a45dffa6a872f6e336cad33ca41ffb102887 (patch)
treed8cdd0c4b8c6559efaf6846b24f0d6440f3c94f5 /ui/app/accounts.js
parent9f1438b85b3dac8f1dd98f7bd6e101035cfce0a5 (diff)
downloadtangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.gz
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.bz2
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.lz
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.xz
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.zst
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.zip
Moved UI into repo with its own dependency stack
Diffstat (limited to 'ui/app/accounts.js')
-rw-r--r--ui/app/accounts.js116
1 files changed, 116 insertions, 0 deletions
diff --git a/ui/app/accounts.js b/ui/app/accounts.js
new file mode 100644
index 000000000..d35e80678
--- /dev/null
+++ b/ui/app/accounts.js
@@ -0,0 +1,116 @@
+const inherits = require('util').inherits
+const Component = require('react').Component
+const h = require('react-hyperscript')
+const connect = require('react-redux').connect
+const extend = require('xtend')
+const actions = require('./actions')
+const AccountPanel = require('./components/account-panel')
+const valuesFor = require('./util').valuesFor
+
+module.exports = connect(mapStateToProps)(AccountsScreen)
+
+
+function mapStateToProps(state) {
+ return {
+ accounts: state.metamask.accounts,
+ identities: state.metamask.identities,
+ unconfTxs: state.metamask.unconfTxs,
+ selectedAddress: state.metamask.selectedAddress,
+ currentDomain: state.appState.currentDomain,
+ }
+}
+
+inherits(AccountsScreen, Component)
+function AccountsScreen() {
+ Component.call(this)
+}
+
+
+AccountsScreen.prototype.render = function() {
+ var state = this.props
+ var identityList = valuesFor(state.identities)
+ var unconfTxList = valuesFor(state.unconfTxs)
+ var actions = {
+ onSelect: this.onSelect.bind(this),
+ onShowDetail: this.onShowDetail.bind(this),
+ }
+ return (
+
+ h('.accounts-section.flex-column.flex-grow', [
+
+ // subtitle and nav
+ h('.section-title.flex-column.flex-center', [
+ h('h2.page-subtitle', 'Accounts'),
+ ]),
+
+ // current domain
+ /* AUDIT
+ * Temporarily removed
+ * since accounts are currently injected
+ * regardless of the current domain.
+ */
+ h('.current-domain-panel.flex-center.font-small', [
+ h('spam', 'Selected address is visible to all sites you visit.'),
+ // h('span', state.currentDomain),
+ ]),
+
+ // identity selection
+ h('section.identity-section.flex-column', {
+ style: {
+ maxHeight: '290px',
+ overflowY: 'auto',
+ overflowX: 'hidden',
+ }
+ },
+ identityList.map(renderAccountPanel)
+ ),
+
+ unconfTxList.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
+ ),
+
+
+ ])
+
+ )
+
+ function renderAccountPanel(identity){
+ var mayBeFauceting = identity.mayBeFauceting
+ var isSelected = state.selectedAddress === identity.address
+ var account = state.accounts[identity.address]
+ var isFauceting = mayBeFauceting && account.balance === '0x0'
+ var componentState = extend(actions, {
+ identity: identity,
+ account: account,
+ isSelected: isSelected,
+ isFauceting: isFauceting,
+ })
+ return h(AccountPanel, componentState)
+ }
+}
+
+AccountsScreen.prototype.navigateToConfTx = function(){
+ event.stopPropagation()
+ this.props.dispatch(actions.showConfTxPage())
+}
+
+AccountsScreen.prototype.onSelect = function(address, event){
+ event.stopPropagation()
+ // if already selected, deselect
+ if (this.props.selectedAddress === address) address = null
+ this.props.dispatch(actions.setSelectedAddress(address))
+}
+
+AccountsScreen.prototype.onShowDetail = function(address, event){
+ event.stopPropagation()
+ this.props.dispatch(actions.showAccountDetail(address))
+}