mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Convert AccountPanel component to ES6 class (#7775)
This commit is contained in:
parent
92971d3c87
commit
6947ff49e0
@ -1,55 +1,48 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { inherits } from 'util'
|
|
||||||
import Identicon from '../ui/identicon'
|
import Identicon from '../ui/identicon'
|
||||||
import { addressSummary, formatBalance } from '../../helpers/utils/util'
|
import { addressSummary, formatBalance } from '../../helpers/utils/util'
|
||||||
|
|
||||||
export default AccountPanel
|
export default class AccountPanel extends Component {
|
||||||
|
render () {
|
||||||
|
const state = this.props
|
||||||
|
const identity = state.identity || {}
|
||||||
|
const account = state.account || {}
|
||||||
|
const isFauceting = state.isFauceting
|
||||||
|
|
||||||
|
const panelState = {
|
||||||
|
key: `accountPanel${identity.address}`,
|
||||||
|
identiconKey: identity.address,
|
||||||
|
identiconLabel: identity.name || '',
|
||||||
|
attributes: [
|
||||||
|
{
|
||||||
|
key: 'ADDRESS',
|
||||||
|
value: addressSummary(identity.address),
|
||||||
|
},
|
||||||
|
balanceOrFaucetingIndication(account, isFauceting),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
inherits(AccountPanel, Component)
|
return (
|
||||||
function AccountPanel () {
|
<div
|
||||||
Component.call(this)
|
className="identity-panel flex-row flex-space-between"
|
||||||
}
|
style={{ flex: '1 0 auto', cursor: panelState.onClick ? 'pointer' : undefined }}
|
||||||
|
onClick={panelState.onClick}
|
||||||
AccountPanel.prototype.render = function () {
|
>
|
||||||
const state = this.props
|
<div className="identicon-wrapper flex-column select-none">
|
||||||
const identity = state.identity || {}
|
<Identicon address={panelState.identiconKey} imageify={state.imageifyIdenticons} />
|
||||||
const account = state.account || {}
|
<span className="font-small">{panelState.identiconLabel.substring(0, 7) + '...'}</span>
|
||||||
const isFauceting = state.isFauceting
|
</div>
|
||||||
|
<div className="identity-data flex-column flex-justify-center flex-grow select-none">
|
||||||
const panelState = {
|
{panelState.attributes.map((attr, index) => (
|
||||||
key: `accountPanel${identity.address}`,
|
<div className="flex-row flex-space-between" key={index}>
|
||||||
identiconKey: identity.address,
|
<label className="font-small no-select">{attr.key}</label>
|
||||||
identiconLabel: identity.name || '',
|
<span className="font-small">{attr.value}</span>
|
||||||
attributes: [
|
</div>
|
||||||
{
|
))}
|
||||||
key: 'ADDRESS',
|
</div>
|
||||||
value: addressSummary(identity.address),
|
</div>
|
||||||
},
|
)
|
||||||
balanceOrFaucetingIndication(account, isFauceting),
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="identity-panel flex-row flex-space-between"
|
|
||||||
style={{ flex: '1 0 auto', cursor: panelState.onClick ? 'pointer' : undefined }}
|
|
||||||
onClick={panelState.onClick}
|
|
||||||
>
|
|
||||||
<div className="identicon-wrapper flex-column select-none">
|
|
||||||
<Identicon address={panelState.identiconKey} imageify={state.imageifyIdenticons} />
|
|
||||||
<span className="font-small">{panelState.identiconLabel.substring(0, 7) + '...'}</span>
|
|
||||||
</div>
|
|
||||||
<div className="identity-data flex-column flex-justify-center flex-grow select-none">
|
|
||||||
{panelState.attributes.map((attr, index) => (
|
|
||||||
<div className="flex-row flex-space-between" key={index}>
|
|
||||||
<label className="font-small no-select">{attr.key}</label>
|
|
||||||
<span className="font-small">{attr.value}</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function balanceOrFaucetingIndication (account) {
|
function balanceOrFaucetingIndication (account) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user