@ -55,12 +55,17 @@ export default class SettingsTab extends PureComponent {
sendHexData : PropTypes . bool ,
currentCurrency : PropTypes . string ,
conversionDate : PropTypes . number ,
useETHAsPrimaryCurrency : PropTypes . bool ,
setUseETHAsPrimaryCurrencyPreference : PropTypes . func ,
nativeCurrency : PropTypes . string ,
useNativeCurrencyAsPrimaryCurrency : PropTypes . bool ,
setUseNativeCurrencyAsPrimaryCurrencyPreference : PropTypes . func ,
}
state = {
newRpc : '' ,
chainId : '' ,
showOptions : false ,
ticker : '' ,
nickname : '' ,
}
renderCurrentConversion ( ) {
@ -121,37 +126,98 @@ export default class SettingsTab extends PureComponent {
renderNewRpcUrl ( ) {
const { t } = this . context
const { newRpc } = this . state
const { newRpc , chainId , ticker , nickname } = this . state
return (
< div className = "settings-page__content-row" >
< div className = "settings-page__content-item" >
< span > { t ( 'newRPC ' ) } < / s p a n >
< span > { t ( 'newNetwork ' ) } < / s p a n >
< / d i v >
< div className = "settings-page__content-item" >
< div className = "settings-page__content-item-col" >
< TextField
type = "text"
id = "new-rpc"
placeholder = { t ( 'newRPC ' ) }
placeholder = { t ( 'rpcURL ' ) }
value = { newRpc }
onChange = { e => this . setState ( { newRpc : e . target . value } ) }
onKeyPress = { e => {
if ( e . key === 'Enter' ) {
this . validateRpc ( newRpc )
this . validateRpc ( newRpc , chainId , ticker , nickname )
}
} }
fullWidth
margin = "non e"
margin = "dens e"
/ >
< div
className = "settings-tab__rpc-save-button"
onClick = { e => {
e . preventDefault ( )
this . validateRpc ( newRpc )
< TextField
type = "text"
id = "chainid"
placeholder = { t ( 'optionalChainId' ) }
value = { chainId }
onChange = { e => this . setState ( { chainId : e . target . value } ) }
onKeyPress = { e => {
if ( e . key === 'Enter' ) {
this . validateRpc ( newRpc , chainId , ticker , nickname )
}
} }
>
{ t ( 'save' ) }
style = { {
display : this . state . showOptions ? null : 'none' ,
} }
fullWidth
margin = "dense"
/ >
< TextField
type = "text"
id = "ticker"
placeholder = { t ( 'optionalSymbol' ) }
value = { ticker }
onChange = { e => this . setState ( { ticker : e . target . value } ) }
onKeyPress = { e => {
if ( e . key === 'Enter' ) {
this . validateRpc ( newRpc , chainId , ticker , nickname )
}
} }
style = { {
display : this . state . showOptions ? null : 'none' ,
} }
fullWidth
margin = "dense"
/ >
< TextField
type = "text"
id = "nickname"
placeholder = { t ( 'optionalNickname' ) }
value = { nickname }
onChange = { e => this . setState ( { nickname : e . target . value } ) }
onKeyPress = { e => {
if ( e . key === 'Enter' ) {
this . validateRpc ( newRpc , chainId , ticker , nickname )
}
} }
style = { {
display : this . state . showOptions ? null : 'none' ,
} }
fullWidth
margin = "dense"
/ >
< div className = "flex-row flex-align-center space-between" >
< span className = "settings-tab__advanced-link"
onClick = { e => {
e . preventDefault ( )
this . setState ( { showOptions : ! this . state . showOptions } )
} }
>
{ t ( this . state . showOptions ? 'hideAdvancedOptions' : 'showAdvancedOptions' ) }
< / s p a n >
< button
className = "button btn-primary settings-tab__rpc-save-button"
onClick = { e => {
e . preventDefault ( )
this . validateRpc ( newRpc , chainId , ticker , nickname )
} }
>
{ t ( 'save' ) }
< / b u t t o n >
< / d i v >
< / d i v >
< / d i v >
@ -159,11 +225,11 @@ export default class SettingsTab extends PureComponent {
)
}
validateRpc ( newRpc ) {
validateRpc ( newRpc , chainId , ticker = 'ETH' , nickname ) {
const { setRpcTarget , displayWarning } = this . props
if ( validUrl . isWebUri ( newRpc ) ) {
setRpcTarget ( newRpc )
setRpcTarget ( newRpc , chainId , ticker , nickname )
} else {
const appendedRpc = ` http:// ${ newRpc } `
@ -341,9 +407,13 @@ export default class SettingsTab extends PureComponent {
)
}
renderUseEthAs PrimaryCurrency ( ) {
renderUsePrimaryCurrencyOptions ( ) {
const { t } = this . context
const { useETHAsPrimaryCurrency , setUseETHAsPrimaryCurrencyPreference } = this . props
const {
nativeCurrency ,
setUseNativeCurrencyAsPrimaryCurrencyPreference ,
useNativeCurrencyAsPrimaryCurrency ,
} = this . props
return (
< div className = "settings-page__content-row" >
@ -359,23 +429,23 @@ export default class SettingsTab extends PureComponent {
< div className = "settings-tab__radio-button" >
< input
type = "radio"
id = "eth -primary-currency"
onChange = { ( ) => setUseETH AsPrimaryCurrencyPreference ( true ) }
checked = { Boolean ( useETH AsPrimaryCurrency ) }
id = "nativ e-primary-currency"
onChange = { ( ) => setUseNativeCurrency AsPrimaryCurrencyPreference ( true ) }
checked = { Boolean ( useNativeCurrency AsPrimaryCurrency ) }
/ >
< label
htmlFor = "eth -primary-currency"
htmlFor = "nativ e-primary-currency"
className = "settings-tab__radio-label"
>
{ t ( 'eth' ) }
{ nativeCurrency }
< / l a b e l >
< / d i v >
< div className = "settings-tab__radio-button" >
< input
type = "radio"
id = "fiat-primary-currency"
onChange = { ( ) => setUseETH AsPrimaryCurrencyPreference ( false ) }
checked = { ! useETH AsPrimaryCurrency }
onChange = { ( ) => setUseNativeCurrency AsPrimaryCurrencyPreference ( false ) }
checked = { ! useNativeCurrency AsPrimaryCurrency }
/ >
< label
htmlFor = "fiat-primary-currency"
@ -398,7 +468,7 @@ export default class SettingsTab extends PureComponent {
< div className = "settings-page__content" >
{ warning && < div className = "settings-tab__error" > { warning } < / d i v > }
{ this . renderCurrentConversion ( ) }
{ this . renderUseEthAs PrimaryCurrency ( ) }
{ this . renderUsePrimaryCurrencyOptions ( ) }
{ this . renderCurrentLocale ( ) }
{ this . renderNewRpcUrl ( ) }
{ this . renderStateLogs ( ) }