|
|
@ -2,7 +2,10 @@ import React, { PureComponent } from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import classnames from 'classnames' |
|
|
|
import classnames from 'classnames' |
|
|
|
import { SETTINGS_ROUTE } from '../../../helpers/constants/routes' |
|
|
|
import { SETTINGS_ROUTE } from '../../../helpers/constants/routes' |
|
|
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../../app/scripts/lib/enums' |
|
|
|
import { |
|
|
|
|
|
|
|
ENVIRONMENT_TYPE_FULLSCREEN, |
|
|
|
|
|
|
|
ENVIRONMENT_TYPE_POPUP, |
|
|
|
|
|
|
|
} from '../../../../../app/scripts/lib/enums' |
|
|
|
import { getEnvironmentType } from '../../../../../app/scripts/lib/util' |
|
|
|
import { getEnvironmentType } from '../../../../../app/scripts/lib/util' |
|
|
|
import Button from '../../../components/ui/button' |
|
|
|
import Button from '../../../components/ui/button' |
|
|
|
import LockIcon from '../../../components/ui/lock-icon' |
|
|
|
import LockIcon from '../../../components/ui/lock-icon' |
|
|
@ -32,8 +35,13 @@ export default class NetworksTab extends PureComponent { |
|
|
|
networkDefaultedToProvider: PropTypes.bool, |
|
|
|
networkDefaultedToProvider: PropTypes.bool, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UNSAFE_componentWillMount () { |
|
|
|
state = { |
|
|
|
this.props.setSelectedSettingsRpcUrl(null) |
|
|
|
isFullScreen: getEnvironmentType() === ENVIRONMENT_TYPE_FULLSCREEN, |
|
|
|
|
|
|
|
isPopup: getEnvironmentType() === ENVIRONMENT_TYPE_POPUP, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount () { |
|
|
|
|
|
|
|
this.props.setSelectedSettingsRpcUrl('') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isCurrentPath (pathname) { |
|
|
|
isCurrentPath (pathname) { |
|
|
@ -56,7 +64,7 @@ export default class NetworksTab extends PureComponent { |
|
|
|
onClick={(networkIsSelected && !networkDefaultedToProvider) || networksTabIsInAddMode |
|
|
|
onClick={(networkIsSelected && !networkDefaultedToProvider) || networksTabIsInAddMode |
|
|
|
? () => { |
|
|
|
? () => { |
|
|
|
setNetworksTabAddMode(false) |
|
|
|
setNetworksTabAddMode(false) |
|
|
|
setSelectedSettingsRpcUrl(null) |
|
|
|
setSelectedSettingsRpcUrl('') |
|
|
|
} |
|
|
|
} |
|
|
|
: () => this.props.history.push(SETTINGS_ROUTE) |
|
|
|
: () => this.props.history.push(SETTINGS_ROUTE) |
|
|
|
} |
|
|
|
} |
|
|
@ -67,7 +75,7 @@ export default class NetworksTab extends PureComponent { |
|
|
|
type="secondary" |
|
|
|
type="secondary" |
|
|
|
onClick={(event) => { |
|
|
|
onClick={(event) => { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
setSelectedSettingsRpcUrl(null) |
|
|
|
setSelectedSettingsRpcUrl('') |
|
|
|
setNetworksTabAddMode(true) |
|
|
|
setNetworksTabAddMode(true) |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
@ -167,7 +175,7 @@ export default class NetworksTab extends PureComponent { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderNetworksTabContent () { |
|
|
|
renderNetworksTabContent (isPopup) { |
|
|
|
const { t } = this.context |
|
|
|
const { t } = this.context |
|
|
|
const { |
|
|
|
const { |
|
|
|
setRpcTarget, |
|
|
|
setRpcTarget, |
|
|
@ -190,12 +198,12 @@ export default class NetworksTab extends PureComponent { |
|
|
|
providerUrl, |
|
|
|
providerUrl, |
|
|
|
networksToRender, |
|
|
|
networksToRender, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
|
|
|
|
const { isFullScreen } = this.state |
|
|
|
|
|
|
|
|
|
|
|
const envIsPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP |
|
|
|
const shouldRenderNetworkForm = networksTabIsInAddMode || !isPopup || (isPopup && !networkDefaultedToProvider) |
|
|
|
const shouldRenderNetworkForm = networksTabIsInAddMode || !envIsPopup || (envIsPopup && !networkDefaultedToProvider) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="networks-tab__content"> |
|
|
|
<> |
|
|
|
{ this.renderNetworksList() } |
|
|
|
{ this.renderNetworksList() } |
|
|
|
{ |
|
|
|
{ |
|
|
|
shouldRenderNetworkForm |
|
|
|
shouldRenderNetworkForm |
|
|
@ -210,7 +218,7 @@ export default class NetworksTab extends PureComponent { |
|
|
|
ticker={ticker} |
|
|
|
ticker={ticker} |
|
|
|
onClear={() => { |
|
|
|
onClear={() => { |
|
|
|
setNetworksTabAddMode(false) |
|
|
|
setNetworksTabAddMode(false) |
|
|
|
setSelectedSettingsRpcUrl(null) |
|
|
|
setSelectedSettingsRpcUrl('') |
|
|
|
}} |
|
|
|
}} |
|
|
|
showConfirmDeleteNetworkModal={showConfirmDeleteNetworkModal} |
|
|
|
showConfirmDeleteNetworkModal={showConfirmDeleteNetworkModal} |
|
|
|
viewOnly={viewOnly} |
|
|
|
viewOnly={viewOnly} |
|
|
@ -218,22 +226,24 @@ export default class NetworksTab extends PureComponent { |
|
|
|
networksTabIsInAddMode={networksTabIsInAddMode} |
|
|
|
networksTabIsInAddMode={networksTabIsInAddMode} |
|
|
|
rpcPrefs={rpcPrefs} |
|
|
|
rpcPrefs={rpcPrefs} |
|
|
|
blockExplorerUrl={blockExplorerUrl} |
|
|
|
blockExplorerUrl={blockExplorerUrl} |
|
|
|
cancelText={t('cancel')} |
|
|
|
isFullScreen={isFullScreen} |
|
|
|
/> |
|
|
|
/> |
|
|
|
) |
|
|
|
) |
|
|
|
: null |
|
|
|
: null |
|
|
|
} |
|
|
|
} |
|
|
|
</div> |
|
|
|
</> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|
const { setNetworksTabAddMode, setSelectedSettingsRpcUrl, networkIsSelected, networksTabIsInAddMode } = this.props |
|
|
|
const { setNetworksTabAddMode, setSelectedSettingsRpcUrl, networkIsSelected, networksTabIsInAddMode } = this.props |
|
|
|
|
|
|
|
const { isFullScreen, isPopup } = this.state |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="networks-tab__body"> |
|
|
|
<div className="networks-tab__body"> |
|
|
|
{this.renderSubHeader()} |
|
|
|
{isFullScreen && this.renderSubHeader()} |
|
|
|
{this.renderNetworksTabContent()} |
|
|
|
<div className="networks-tab__content"> |
|
|
|
|
|
|
|
{this.renderNetworksTabContent(isPopup)} |
|
|
|
{!networkIsSelected && !networksTabIsInAddMode |
|
|
|
{!networkIsSelected && !networksTabIsInAddMode |
|
|
|
? ( |
|
|
|
? ( |
|
|
|
<div className="networks-tab__add-network-button-wrapper"> |
|
|
|
<div className="networks-tab__add-network-button-wrapper"> |
|
|
@ -241,7 +251,7 @@ export default class NetworksTab extends PureComponent { |
|
|
|
type="primary" |
|
|
|
type="primary" |
|
|
|
onClick={(event) => { |
|
|
|
onClick={(event) => { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
setSelectedSettingsRpcUrl(null) |
|
|
|
setSelectedSettingsRpcUrl('') |
|
|
|
setNetworksTabAddMode(true) |
|
|
|
setNetworksTabAddMode(true) |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
@ -252,6 +262,7 @@ export default class NetworksTab extends PureComponent { |
|
|
|
: null |
|
|
|
: null |
|
|
|
} |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|