import React, { Component } from 'react' import PropTypes from 'prop-types' import classnames from 'classnames' import { MAINNET_CODE, ROPSTEN_CODE, RINKEYBY_CODE, KOVAN_CODE, } from '../../../../app/scripts/controllers/network/enums' const networkToClassHash = { [MAINNET_CODE]: 'mainnet', [ROPSTEN_CODE]: 'ropsten', [RINKEYBY_CODE]: 'rinkeby', [KOVAN_CODE]: 'kovan', } export default class NetworkDisplay extends Component { static defaultProps = { colored: true, } static propTypes = { colored: PropTypes.bool, network: PropTypes.string, provider: PropTypes.object, } static contextTypes = { t: PropTypes.func, } renderNetworkIcon () { const { network } = this.props const networkClass = networkToClassHash[network] return networkClass ?
:
} render () { const { colored, network, provider: { type, nickname } } = this.props const networkClass = networkToClassHash[network] return (
{ networkClass ?
:
}
{ type === 'rpc' && nickname ? nickname : this.context.t(type) }
) } }