Skip to content

Commit

Permalink
Merge pull request #11269 from brave/pr11234_uplift
Browse files Browse the repository at this point in the history
(uplift 1.33.x) 10973 and 11234
  • Loading branch information
kjozwiak authored Nov 27, 2021
2 parents 02f133f + 2d79b3c commit 32095be
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
padding-inline-end: var(--cr-section-padding);
padding-inline-start: var(--cr-section-indent-padding);
}
.hovered {
cursor: pointer;
}
</style>

<div id="networks-section" class="flex-container">
Expand All @@ -33,15 +36,30 @@
<template>
<div on-dblclick=onItemDoubleClick>
<div class="settings-box">
<div class="flex cr-padded-text">
<div class$=[[getNetworkItemClass(item.chainId)]]>
<div><span hidden="[[hideNativeCurrencyInfo]]">({{item.nativeCurrency.name}}) </span>{{item.chainName}}</div>
<div class="secondary">[[getItemDescritionText(item)]]</div>
</div>
<cr-icon-button class="icon-picture-delete"
hidden=[[isDefaultNetwork(item.chainId)]]
on-click="onDeleteActionTapped_">
<cr-icon-button class="icon-more-vert"
on-click="onNetworkMenuTapped_"
itemName=[[item.name]]
hidden=[[isDefaultNetwork(item.chainId)]]
focus-type="menu">
</cr-icon-button>
</div>
<cr-lazy-render id="network-menu">
<template>
<cr-action-menu role-description="$i18n{menu}">
<button class="dropdown-item" on-click="onEditTap_">
$i18n{walletNetworkEdit}
</button>
<button class="dropdown-item" id="remove"
on-click="onDeleteActionTapped_">
$i18n{walletNetworkRemove}
</button>
</cr-action-menu>
</template>
</cr-lazy-render>
</div>
</template>
</iron-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
this.updateNetworks()
}

getNetworkItemClass(chainId) {
if (!this.isDefaultNetwork(chainId)) {
return "flex cr-padded-text hovered"
}
return "flex cr-padded-text"
}

isDefaultNetwork(chainId) {
return (chainId ===
this.getPref('brave.wallet.wallet_current_chain_id').value)
Expand All @@ -79,12 +86,20 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
}

onDeleteActionTapped_(event) {
const chainId = this.selectedNetwork.chainId
const chainName = this.selectedNetwork.chainName
this.selectedNetwork = {}
this.$$('cr-action-menu').close();
if (this.isDefaultNetwork(chainId)) {
this.updateNetworks()
return
}
var message = this.i18n('walletDeleteNetworkConfirmation',
event.model.item.chainName)
chainName)
if (!window.confirm(message))
return

this.browserProxy_.removeEthereumChain(event.model.item.chainId).
this.browserProxy_.removeEthereumChain(chainId).
then(success => { this.updateNetworks() })
}

Expand All @@ -93,6 +108,10 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
}

onItemDoubleClick(event) {
if (this.isDefaultNetwork(event.model.item.chainId)) {
this.updateNetworks()
return
}
this.selectedNetwork = event.model.item
this.showAddWalletNetworkDialog_ = true
}
Expand All @@ -111,6 +130,22 @@ class SettingsWalletNetworksSubpage extends SettingsWalletNetworksSubpageBase {
this.selectedNetwork = {}
this.updateNetworks()
}

onNetworkMenuTapped_(event) {
this.selectedNetwork = event.model.item
const actionMenu =
/** @type {!CrActionMenuElement} */ (this.$$('#network-menu').get());
actionMenu.showAt(event.target);
}

onEditTap_() {
this.$$('cr-action-menu').close();
this.showAddWalletNetworkDialog_ = true
}

onNetworkActionTapped_(event) {
this.showAddWalletNetworkDialog_ = true
}
}

customElements.define(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
{"walletAddNetworkDialogFillNativeCurrencyInfo",
IDS_SETTINGS_WALLET_NETWORKS_NATIVE_CURRENCY_ERROR},
{"walletAddNetworkDialogReplaceNetwork",
IDS_SETTINGS_WALLET_NETWORKS_REPLACE}
IDS_SETTINGS_WALLET_NETWORKS_REPLACE},
{"walletNetworkEdit", IDS_BRAVE_WALLET_NETWORK_EDIT},
{"walletNetworkRemove", IDS_BRAVE_WALLET_NETWORK_REMOVE},
};

html_source->AddLocalizedStrings(localized_strings);
Expand Down
2 changes: 2 additions & 0 deletions components/resources/wallet_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,6 @@
<message name="IDS_BRAVE_WALLET_HARDWARE_TRANSACTION_NO_MESSAGE_TO_SIGN_ERROR" desc="Unable to get raw messagse to sign for hardware transaction during signing process">Error processing the transaction, please try again</message>
<message name="IDS_BRAVE_WALLET_HARDWARE_SIGN_MESSAGE_ERROR" desc="Unable to sign personal messagse on hardware device">Error signing message, please try again</message>
<message name="IDS_BRAVE_WALLET_HARDWARE_UNKNOWN_KEYRING_ERROR" desc="Error when requested unknown keyring">Error signing message, unknown keyring requested, please try again</message>
<message name="IDS_BRAVE_WALLET_NETWORK_EDIT" desc="Edit custom network button title">Edit</message>
<message name="IDS_BRAVE_WALLET_NETWORK_REMOVE" desc="Remove custom network button title">Remove</message>
</grit-part>

0 comments on commit 32095be

Please sign in to comment.