diff --git a/app/images/remove.svg b/app/images/remove.svg new file mode 100644 index 000000000000..038fb96a7616 --- /dev/null +++ b/app/images/remove.svg @@ -0,0 +1,3 @@ + + + diff --git a/old-ui/app/app.js b/old-ui/app/app.js index 54296c251a2f..00276694f7dc 100644 --- a/old-ui/app/app.js +++ b/old-ui/app/app.js @@ -266,6 +266,7 @@ App.prototype.renderNetworkDropdown = function () { position: 'absolute', left: '2px', top: '36px', + width: '270px', }, innerStyle: { padding: '2px 16px 2px 0px', @@ -706,6 +707,14 @@ App.prototype.renderCustomOption = function (provider) { }, [h('div.selected-network'), label, + h('.remove-rpc', { + onClick: (event) => { + event.preventDefault() + event.stopPropagation() + this.setState({ isNetworkMenuOpen: false }) + props.dispatch(actions.showDeleteRPC(label)) + }, + }), ] ) } @@ -757,6 +766,14 @@ App.prototype.renderCommonRpc = function (rpcList, provider) { }, [ rpc, + h('.remove-rpc', { + onClick: (event) => { + event.preventDefault() + event.stopPropagation() + this.setState({ isNetworkMenuOpen: false }) + props.dispatch(actions.showDeleteRPC(rpc)) + }, + }), ] ) } diff --git a/old-ui/app/components/delete-rpc.js b/old-ui/app/components/delete-rpc.js index 304c996e10af..cefa1e16d23e 100644 --- a/old-ui/app/components/delete-rpc.js +++ b/old-ui/app/components/delete-rpc.js @@ -8,7 +8,9 @@ module.exports = connect(mapStateToProps)(DeleteRpc) function mapStateToProps (state) { return { - url: state.metamask.provider.rpcTarget, + metamask: state.metamask, + url: state.appState.RPC_URL ? state.appState.RPC_URL : state.metamask.provider.rpcTarget, + provider: state.metamask.provider, } } @@ -51,7 +53,7 @@ DeleteRpc.prototype.render = function () { margin: '20px', }, onClick: () => { - this.props.dispatch(actions.removeCustomRPC(this.props.url)) + this.props.dispatch(actions.removeCustomRPC(this.props.url, this.props.provider)) .then(() => { this.props.dispatch(actions.showConfigPage()) }) diff --git a/old-ui/app/css/index.css b/old-ui/app/css/index.css index 214c2e9314f6..457c5f645b77 100644 --- a/old-ui/app/css/index.css +++ b/old-ui/app/css/index.css @@ -329,6 +329,18 @@ app sections background-position: right; } +.remove-rpc { + background-image: url('../images/remove.svg'); + background-size: 12px 12px; + background-repeat: no-repeat; + background-position: center; + width: 12px; + height: 12px; + position: absolute; + right: 0; +} + + @media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6/2), (-webkit-min-device-pixel-ratio: 1.3), diff --git a/ui/app/actions.js b/ui/app/actions.js index acf70be563fd..a8c1ab3205b7 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -2279,19 +2279,22 @@ function clearPendingTokens () { } } -function showDeleteRPC (transitionForward = true) { +function showDeleteRPC (RPC_URL, transitionForward = true) { return { type: actions.SHOW_DELETE_RPC, value: transitionForward, + RPC_URL, } } -function removeCustomRPC (url) { +function removeCustomRPC (url, provider) { return (dispatch) => { dispatch(actions.showLoadingIndication()) return new Promise((resolve, reject) => { - background.removeRpcUrl(url, (err, url) => { - dispatch(actions.setProviderType('poa')) + background.removeRpcUrl(url, (err, _url) => { + if (provider.type === 'rpc' && url === provider.rpcTarget) { + dispatch(actions.setProviderType('poa')) + } dispatch(actions.hideLoadingIndication()) if (err) { dispatch(actions.displayWarning(err.message)) diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 2cd2210a73d8..2d2dcbb4a6ee 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -717,6 +717,7 @@ function reduceApp (state, action) { context: appState.currentView.context, }, transForward: action.value, + RPC_URL: action.RPC_URL, }) default: