From 45fc1d6ec356232e51fe4a9cc1f01929e35e8014 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 9 Aug 2017 17:40:01 -0700 Subject: Readd loose label onto accounts. --- ui/app/app.js | 3 +++ ui/app/components/account-dropdowns.js | 20 +++++++++++++++++++- ui/app/components/dropdown.js | 2 +- ui/app/css/lib.css | 5 +++-- 4 files changed, 26 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/app/app.js b/ui/app/app.js index 4565bdd37..2186c85a2 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -42,6 +42,7 @@ function mapStateToProps (state) { identities, accounts, address, + keyrings, } = state.metamask const selected = address || Object.keys(accounts)[0] @@ -69,6 +70,7 @@ function mapStateToProps (state) { // state needed to get account dropdown temporarily rendering from app bar identities, selected, + keyrings, } } @@ -187,6 +189,7 @@ App.prototype.renderAppBar = function () { identities: this.props.identities, selected: this.props.selected, network: this.props.network, + keyrings: this.props.keyrings, }, []), // hamburger diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index b23600e9b..9a68b8f20 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -22,12 +22,19 @@ class AccountDropdowns extends Component { } renderAccounts () { - const { identities, selected } = this.props + const { identities, selected, keyrings } = this.props return Object.keys(identities).map((key, index) => { const identity = identities[key] const isSelected = identity.address === selected + const simpleAddress = identity.address.substring(2).toLowerCase() + + const keyring = keyrings.find((kr) => { + return kr.accounts.includes(simpleAddress) || + kr.accounts.includes(identity.address) + }) + return h( DropdownMenuItem, { @@ -51,6 +58,7 @@ class AccountDropdowns extends Component { }, }, ), + this.indicateIfLoose(keyring.type), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, identity.name || ''), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null), ] @@ -58,6 +66,13 @@ class AccountDropdowns extends Component { }) } + indicateIfLoose (type) { + try { // Sometimes keyrings aren't loaded yet: + const isLoose = type !== 'HD Key Tree' + return isLoose ? h('.keyring-label', 'LOOSE') : null + } catch (e) { return } + } + renderAccountSelector () { const { actions } = this.props const { accountSelectorActive } = this.state @@ -136,6 +151,8 @@ class AccountDropdowns extends Component { ) } + + renderAccountOptions () { const { actions } = this.props const { optionsMenuActive } = this.state @@ -269,6 +286,7 @@ AccountDropdowns.defaultProps = { AccountDropdowns.propTypes = { identities: PropTypes.objectOf(PropTypes.object), selected: PropTypes.string, + keyrings: PropTypes.objectOf(PropTypes.object), } const mapDispatchToProps = (dispatch) => { diff --git a/ui/app/components/dropdown.js b/ui/app/components/dropdown.js index 34c7149ee..73710acc2 100644 --- a/ui/app/components/dropdown.js +++ b/ui/app/components/dropdown.js @@ -32,7 +32,7 @@ class Dropdown extends Component { 'style', ` li.dropdown-menu-item:hover { color:rgb(225, 225, 225); } - li.dropdown-menu-item { color: rgb(185, 185, 185); } + li.dropdown-menu-item { color: rgb(185, 185, 185); position: relative } ` ), ...children, diff --git a/ui/app/css/lib.css b/ui/app/css/lib.css index 81647d1c1..f3acbee76 100644 --- a/ui/app/css/lib.css +++ b/ui/app/css/lib.css @@ -215,12 +215,13 @@ hr.horizontal-line { z-index: 1; font-size: 11px; background: rgba(255,0,0,0.8); - bottom: -47px; color: white; + bottom: 0px; + left: -8px; border-radius: 10px; height: 20px; min-width: 20px; - position: relative; + position: absolute; display: flex; align-items: center; justify-content: center; -- cgit From f0ab4ce52d4383a6b07646b829023ca5217e4e6c Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 7 Sep 2017 11:51:04 -0700 Subject: Change expected type to array. --- ui/app/components/account-dropdowns.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index c23f61c98..a53f3399d 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -295,7 +295,7 @@ AccountDropdowns.defaultProps = { AccountDropdowns.propTypes = { identities: PropTypes.objectOf(PropTypes.object), selected: PropTypes.string, - keyrings: PropTypes.objectOf(PropTypes.object), + keyrings: PropTypes.array, } const mapDispatchToProps = (dispatch) => { -- cgit From 69c7fe24b3f14a885bb2ff0bb936d1a35b521de3 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 7 Sep 2017 12:17:36 -0700 Subject: Place object property retrieval inside try-catch --- ui/app/components/account-dropdowns.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index a53f3399d..b087a40d4 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -58,7 +58,7 @@ class AccountDropdowns extends Component { }, }, ), - this.indicateIfLoose(keyring.type), + this.indicateIfLoose(keyring), h('span', { style: { marginLeft: '20px', @@ -75,8 +75,9 @@ class AccountDropdowns extends Component { }) } - indicateIfLoose (type) { + indicateIfLoose (keyring) { try { // Sometimes keyrings aren't loaded yet: + const type = keyring.type const isLoose = type !== 'HD Key Tree' return isLoose ? h('.keyring-label', 'LOOSE') : null } catch (e) { return } -- cgit