Add identifier of private network to the network loading screen message.

feature/default_network_editable
Dan Miller 6 years ago
parent 47501a6f7a
commit 0e5e51b8ff
  1. 3
      app/_locales/en/messages.json
  2. 8
      ui/app/app.js
  3. 11
      ui/app/components/network.js
  4. 8
      ui/app/selectors.js

@ -242,6 +242,9 @@
"connecting": { "connecting": {
"message": "Connecting..." "message": "Connecting..."
}, },
"connectingTo": {
"message": "Connecting to $1"
},
"connectingToKovan": { "connectingToKovan": {
"message": "Connecting to Kovan Test Network" "message": "Connecting to Kovan Test Network"
}, },

@ -7,7 +7,7 @@ const h = require('react-hyperscript')
const actions = require('./actions') const actions = require('./actions')
const classnames = require('classnames') const classnames = require('classnames')
const log = require('loglevel') const log = require('loglevel')
const { getMetaMaskAccounts } = require('./selectors') const { getMetaMaskAccounts, getNetworkIdentifier } = require('./selectors')
// init // init
const InitializeScreen = require('../../mascara/src/app/first-time').default const InitializeScreen = require('../../mascara/src/app/first-time').default
@ -196,7 +196,7 @@ class App extends Component {
if (loadingMessage) { if (loadingMessage) {
return loadingMessage return loadingMessage
} }
const { provider } = this.props const { provider, providerId } = this.props
const providerName = provider.type const providerName = provider.type
let name let name
@ -210,7 +210,7 @@ class App extends Component {
} else if (providerName === 'rinkeby') { } else if (providerName === 'rinkeby') {
name = this.context.t('connectingToRinkeby') name = this.context.t('connectingToRinkeby')
} else { } else {
name = this.context.t('connectingToUnknown') name = this.context.t('connectingTo', [providerId])
} }
return name return name
@ -279,6 +279,7 @@ App.propTypes = {
isMouseUser: PropTypes.bool, isMouseUser: PropTypes.bool,
setMouseUserState: PropTypes.func, setMouseUserState: PropTypes.func,
t: PropTypes.func, t: PropTypes.func,
providerId: PropTypes.string,
} }
function mapStateToProps (state) { function mapStateToProps (state) {
@ -348,6 +349,7 @@ function mapStateToProps (state) {
isRevealingSeedWords: state.metamask.isRevealingSeedWords, isRevealingSeedWords: state.metamask.isRevealingSeedWords,
Qr: state.appState.Qr, Qr: state.appState.Qr,
welcomeScreenSeen: state.metamask.welcomeScreenSeen, welcomeScreenSeen: state.metamask.welcomeScreenSeen,
providerId: getNetworkIdentifier(state),
// state needed to get account dropdown temporarily rendering from app bar // state needed to get account dropdown temporarily rendering from app bar
identities, identities,

@ -23,14 +23,17 @@ Network.prototype.render = function () {
const props = this.props const props = this.props
const context = this.context const context = this.context
const networkNumber = props.network const networkNumber = props.network
let providerName, providerNick let providerName, providerNick, providerUrl
try { try {
providerName = props.provider.type providerName = props.provider.type
providerNick = props.provider.nickname || '' providerNick = props.provider.nickname || ''
providerUrl = props.provider.rpcTarget
} catch (e) { } catch (e) {
providerName = null providerName = null
} }
let iconName, hoverText const providerId = providerNick || providerName || providerUrl || null
let iconName
let hoverText
if (providerName === 'mainnet') { if (providerName === 'mainnet') {
hoverText = context.t('mainnet') hoverText = context.t('mainnet')
@ -48,8 +51,8 @@ Network.prototype.render = function () {
hoverText = context.t('rinkeby') hoverText = context.t('rinkeby')
iconName = 'rinkeby-test-network' iconName = 'rinkeby-test-network'
} else { } else {
hoverText = context.t('unknownNetwork') hoverText = providerId
iconName = 'unknown-private-network' iconName = 'private-network'
} }
return ( return (

@ -36,10 +36,18 @@ const selectors = {
preferencesSelector, preferencesSelector,
getMetaMaskAccounts, getMetaMaskAccounts,
getCurrentEthBalance, getCurrentEthBalance,
getNetworkIdentifier,
} }
module.exports = selectors module.exports = selectors
function getNetworkIdentifier (state) {
const { metamask: { provider: { type, nickname, rpcTarget } } } = state
return nickname || rpcTarget || type
}
function getSelectedAddress (state) { function getSelectedAddress (state) {
const selectedAddress = state.metamask.selectedAddress || Object.keys(getMetaMaskAccounts(state))[0] const selectedAddress = state.metamask.selectedAddress || Object.keys(getMetaMaskAccounts(state))[0]

Loading…
Cancel
Save