From ef52c22ad381db469a225b38920429d5ee3cf250 Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Thu, 23 May 2019 01:14:48 -0700 Subject: [PATCH 1/4] Add delete to custom rpc form --- app/_locales/en/messages.json | 3 +++ app/_locales/zh_TW/messages.json | 3 +++ .../page-container-footer.component.js | 4 +++- ui/app/pages/settings/networks-tab/index.scss | 2 +- .../network-form/network-form.component.js | 20 ++++++++++++++++--- .../networks-tab/networks-tab.component.js | 5 +++++ .../networks-tab/networks-tab.container.js | 4 ++++ 7 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 41ba7ef7a36f..5eaaadc28edf 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -454,6 +454,9 @@ "defaultNetwork": { "message": "The default network for Ether transactions is Main Net." }, + "delete": { + "message": "Delete" + }, "denExplainer": { "message": "Your DEN is your password-encrypted storage within MetaMask." }, diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index c645f2af123c..4df95f72f308 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -366,6 +366,9 @@ "defaultNetwork": { "message": "預設乙太幣交易網路為主網路" }, + "delete": { + "message": "刪除" + }, "denExplainer": { "message": "您的 DEN 是 MetaMask 中您的的密碼加密儲存庫。" }, diff --git a/ui/app/components/ui/page-container/page-container-footer/page-container-footer.component.js b/ui/app/components/ui/page-container/page-container-footer/page-container-footer.component.js index 4ef2035217e2..a2cf0100bf22 100644 --- a/ui/app/components/ui/page-container/page-container-footer/page-container-footer.component.js +++ b/ui/app/components/ui/page-container/page-container-footer/page-container-footer.component.js @@ -8,6 +8,7 @@ export default class PageContainerFooter extends Component { children: PropTypes.node, onCancel: PropTypes.func, cancelText: PropTypes.string, + cancelButtonType: PropTypes.string, onSubmit: PropTypes.func, submitText: PropTypes.string, disabled: PropTypes.bool, @@ -29,6 +30,7 @@ export default class PageContainerFooter extends Component { disabled, submitButtonType, hideCancel, + cancelButtonType, } = this.props return ( @@ -36,7 +38,7 @@ export default class PageContainerFooter extends Component {
{!hideCancel && + ) + } + + + + {/* !hideCancel && delRpcTarget(rpcUrl)}*/} + {/* onSubmit={() => {*/} + {/* if (propsRpcUrl && rpcUrl !== propsRpcUrl) {*/} + {/* editRpc(propsRpcUrl, rpcUrl, chainId, ticker, networkName, {*/} + {/* blockExplorerUrl: blockExplorerUrl || rpcPrefs.blockExplorerUrl,*/} + {/* ...rpcPrefs,*/} + {/* })*/} + {/* } else {*/} + {/* setRpcTarget(rpcUrl, chainId, ticker, networkName, {*/} + {/* blockExplorerUrl: blockExplorerUrl || rpcPrefs.blockExplorerUrl,*/} + {/* ...rpcPrefs,*/} + {/* })*/} + {/* }*/} + {/* }}*/} + {/* submitText={this.context.t('save')}*/} + {/* submitButtonType={'confirm'}*/} + {/* disabled={viewOnly || this.stateIsUnchanged() || Object.values(errors).some(x => x) || !rpcUrl}*/} + {/*/>*/} ) } diff --git a/ui/app/pages/settings/networks-tab/networks-tab.component.js b/ui/app/pages/settings/networks-tab/networks-tab.component.js index 4e07b5e87708..561dd8abcdf5 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.component.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.component.js @@ -128,15 +128,36 @@ export default class NetworksTab extends PureComponent { const { networksToRender, selectedNetwork, networkIsSelected, networksTabIsInAddMode, networkDefaultedToProvider } = this.props return ( -
+
{ networksToRender.map(network => this.renderNetworkListItem(network, selectedNetwork.rpcUrl)) } + { + networksTabIsInAddMode && ( +
+ +
+ { this.context.t('newNetwork') } +
+
+
+ ) + }
) } renderNetworksTabContent () { + const { t } = this.context const { setRpcTarget, delRpcTarget, @@ -157,31 +178,37 @@ export default class NetworksTab extends PureComponent { networkDefaultedToProvider, providerUrl, } = this.props + const envIsPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP + const shouldRenderNetworkForm = networksTabIsInAddMode || !envIsPopup || (envIsPopup && !networkDefaultedToProvider) return (
- {this.renderNetworksList()} - {networksTabIsInAddMode || !envIsPopup || (envIsPopup && !networkDefaultedToProvider) - ? { - setNetworksTabAddMode(false) - setSelectedSettingsRpcUrl(null) - }} - delRpcTarget={delRpcTarget} - viewOnly={viewOnly} - isCurrentRpcTarget={providerUrl === rpcUrl} - networksTabIsInAddMode={networksTabIsInAddMode} - rpcPrefs={rpcPrefs} - blockExplorerUrl={blockExplorerUrl} - /> - : null + { this.renderNetworksList() } + { + shouldRenderNetworkForm + ? ( + { + setNetworksTabAddMode(false) + setSelectedSettingsRpcUrl(null) + }} + delRpcTarget={delRpcTarget} + viewOnly={viewOnly} + isCurrentRpcTarget={providerUrl === rpcUrl} + networksTabIsInAddMode={networksTabIsInAddMode} + rpcPrefs={rpcPrefs} + blockExplorerUrl={blockExplorerUrl} + cancelText={t('cancel')} + /> + ) + : null }
) From 63491c117de63544d45c3d89f623f4497e3465ee Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Wed, 12 Jun 2019 18:54:50 -0700 Subject: [PATCH 4/4] Add goerli --- .../network-form/network-form.component.js | 36 ++++++------------- .../networks-tab/networks-tab.component.js | 2 +- .../networks-tab/networks-tab.constants.js | 9 +++++ 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index b92f6b10b26c..73750ac4f352 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -80,7 +80,7 @@ export default class NetworkForm extends PureComponent { ticker, networkName, blockExplorerUrl, - } = this.props; + } = this.props this.setState({ rpcUrl, chainId, ticker, networkName, blockExplorerUrl, errors: {} }) } @@ -91,6 +91,8 @@ export default class NetworkForm extends PureComponent { rpcUrl: propsRpcUrl, editRpc, rpcPrefs = {}, + onClear, + networksTabIsInAddMode, } = this.props const { networkName, @@ -110,6 +112,10 @@ export default class NetworkForm extends PureComponent { ...rpcPrefs, }) } + + if (networksTabIsInAddMode) { + onClear() + } } onCancel = () => { @@ -126,8 +132,10 @@ export default class NetworkForm extends PureComponent { } onDelete = () => { - const { delRpcTarget, rpcUrl } = this.props + const { delRpcTarget, rpcUrl, onClear } = this.props delRpcTarget(rpcUrl) + this.resetForm() + onClear() } stateIsUnchanged () { @@ -285,7 +293,7 @@ export default class NetworkForm extends PureComponent { @@ -297,28 +305,6 @@ export default class NetworkForm extends PureComponent { { t('save') }
- {/* !hideCancel && delRpcTarget(rpcUrl)}*/} - {/* onSubmit={() => {*/} - {/* if (propsRpcUrl && rpcUrl !== propsRpcUrl) {*/} - {/* editRpc(propsRpcUrl, rpcUrl, chainId, ticker, networkName, {*/} - {/* blockExplorerUrl: blockExplorerUrl || rpcPrefs.blockExplorerUrl,*/} - {/* ...rpcPrefs,*/} - {/* })*/} - {/* } else {*/} - {/* setRpcTarget(rpcUrl, chainId, ticker, networkName, {*/} - {/* blockExplorerUrl: blockExplorerUrl || rpcPrefs.blockExplorerUrl,*/} - {/* ...rpcPrefs,*/} - {/* })*/} - {/* }*/} - {/* }}*/} - {/* submitText={this.context.t('save')}*/} - {/* submitButtonType={'confirm'}*/} - {/* disabled={viewOnly || this.stateIsUnchanged() || Object.values(errors).some(x => x) || !rpcUrl}*/} - {/*/>*/}
) } diff --git a/ui/app/pages/settings/networks-tab/networks-tab.component.js b/ui/app/pages/settings/networks-tab/networks-tab.component.js index 561dd8abcdf5..f6c8443cf2fc 100644 --- a/ui/app/pages/settings/networks-tab/networks-tab.component.js +++ b/ui/app/pages/settings/networks-tab/networks-tab.component.js @@ -126,7 +126,7 @@ export default class NetworksTab extends PureComponent { renderNetworksList () { const { networksToRender, selectedNetwork, networkIsSelected, networksTabIsInAddMode, networkDefaultedToProvider } = this.props - + console.log(networksToRender) return (