|
|
@ -1,9 +1,13 @@ |
|
|
|
import React, { Component } from 'react' |
|
|
|
import React, { Component } from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import classnames from 'classnames' |
|
|
|
import classnames from 'classnames' |
|
|
|
|
|
|
|
import { matchPath } from 'react-router-dom' |
|
|
|
|
|
|
|
|
|
|
|
const { ENVIRONMENT_TYPE_NOTIFICATION } = require('../../../../app/scripts/lib/enums') |
|
|
|
const { |
|
|
|
const { DEFAULT_ROUTE, CONFIRM_TRANSACTION_ROUTE } = require('../../routes') |
|
|
|
ENVIRONMENT_TYPE_NOTIFICATION, |
|
|
|
|
|
|
|
ENVIRONMENT_TYPE_POPUP, |
|
|
|
|
|
|
|
} = require('../../../../app/scripts/lib/enums') |
|
|
|
|
|
|
|
const { DEFAULT_ROUTE, INITIALIZE_ROUTE, CONFIRM_TRANSACTION_ROUTE } = require('../../routes') |
|
|
|
const Identicon = require('../identicon') |
|
|
|
const Identicon = require('../identicon') |
|
|
|
const NetworkIndicator = require('../network') |
|
|
|
const NetworkIndicator = require('../network') |
|
|
|
|
|
|
|
|
|
|
@ -36,13 +40,23 @@ class AppHeader extends Component { |
|
|
|
: hideNetworkDropdown() |
|
|
|
: hideNetworkDropdown() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isConfirming () { |
|
|
|
|
|
|
|
const { location } = this.props |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Boolean(matchPath(location.pathname, { |
|
|
|
|
|
|
|
path: CONFIRM_TRANSACTION_ROUTE, exact: false, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderAccountMenu () { |
|
|
|
renderAccountMenu () { |
|
|
|
const { isUnlocked, toggleAccountMenu, selectedAddress } = this.props |
|
|
|
const { isUnlocked, toggleAccountMenu, selectedAddress } = this.props |
|
|
|
|
|
|
|
|
|
|
|
return isUnlocked && ( |
|
|
|
return isUnlocked && ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className="account-menu__icon" |
|
|
|
className={classnames('account-menu__icon', { |
|
|
|
onClick={toggleAccountMenu} |
|
|
|
'account-menu__icon--disabled': this.isConfirming(), |
|
|
|
|
|
|
|
})} |
|
|
|
|
|
|
|
onClick={() => this.isConfirming() || toggleAccountMenu()} |
|
|
|
> |
|
|
|
> |
|
|
|
<Identicon |
|
|
|
<Identicon |
|
|
|
address={selectedAddress} |
|
|
|
address={selectedAddress} |
|
|
@ -52,6 +66,26 @@ class AppHeader extends Component { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hideAppHeader () { |
|
|
|
|
|
|
|
const { location } = this.props |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isInitializing = Boolean(matchPath(location.pathname, { |
|
|
|
|
|
|
|
path: INITIALIZE_ROUTE, exact: false, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isInitializing) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (window.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (window.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_POPUP && this.isConfirming()) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|
const { |
|
|
|
const { |
|
|
|
network, |
|
|
|
network, |
|
|
@ -61,7 +95,7 @@ class AppHeader extends Component { |
|
|
|
isUnlocked, |
|
|
|
isUnlocked, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
|
|
|
|
if (window.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) { |
|
|
|
if (this.hideAppHeader()) { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|