From ae6630911e4e7a33c369620297abde6c7a32e8fe Mon Sep 17 00:00:00 2001 From: Cuteivist Date: Wed, 19 Jul 2023 16:05:21 +0200 Subject: [PATCH] feat(@desktop/wallet): Adjust options in wallet account menu (#11368) * feat(@desktop/wallet): Adjust options in wallet account menu closes #10682 * test(wallet suite) Fix failed test (#11577) --------- Co-authored-by: Vladimir Druzhinin <128374224+StateOf-Vlado@users.noreply.github.com> --- .../ui-test/src/screens/StatusWalletScreen.py | 4 -- .../Wallet/views/AccountContextMenu.qml | 7 +- .../AppLayouts/Wallet/views/LeftTabView.qml | 65 +++++++------------ 3 files changed, 26 insertions(+), 50 deletions(-) diff --git a/test/ui-test/src/screens/StatusWalletScreen.py b/test/ui-test/src/screens/StatusWalletScreen.py index c4c0222d4c..0351f1a6b2 100644 --- a/test/ui-test/src/screens/StatusWalletScreen.py +++ b/test/ui-test/src/screens/StatusWalletScreen.py @@ -36,10 +36,6 @@ class MainWalletContextMenu(ContextMenu): self._add_watch_only_account_menu_item = BaseElement('mainWallet_AddWatchOnlyAccount_MenuItem') self._delete_menu_item = BaseElement('mainWallet_DeleteAccount_MenuItem') - def wait_until_appears(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC): - self._add_new_account_menu_item.wait_until_appears(timeout_msec) - return self - def select(self, menu_item: BaseElement): menu_item.wait_until_appears() menu_item.click() diff --git a/ui/app/AppLayouts/Wallet/views/AccountContextMenu.qml b/ui/app/AppLayouts/Wallet/views/AccountContextMenu.qml index fc7f8a4c1e..fcc07f2acb 100644 --- a/ui/app/AppLayouts/Wallet/views/AccountContextMenu.qml +++ b/ui/app/AppLayouts/Wallet/views/AccountContextMenu.qml @@ -8,7 +8,6 @@ import "../stores" StatusMenu { id: root - required property string uniqueIdentifier // unique idetifier added as postfix to options' objectName (used for ui tests) property var account signal editAccountClicked() @@ -54,13 +53,10 @@ StatusMenu { } } - StatusMenuSeparator { - visible: !!root.account - } - StatusAction { objectName: "AccountMenu-AddNewAccountAction-%1".arg(root.uniqueIdentifier) text: qsTr("Add new account") + enabled: !root.account icon.name: "add" onTriggered: { root.addNewAccountClicked() @@ -70,6 +66,7 @@ StatusMenu { StatusAction { objectName: "AccountMenu-AddWatchOnlyAccountAction-%1".arg(root.uniqueIdentifier) text: qsTr("Add watch-only account") + enabled: !root.account icon.name: "show" onTriggered: { root.addWatchOnlyAccountClicked() diff --git a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml index 76a73d666d..8188828827 100644 --- a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml @@ -66,13 +66,12 @@ Rectangle { } Loader { - id: walletBckgAccountContextMenu + id: walletAccountContextMenu + active: false sourceComponent: AccountContextMenu { - uniqueIdentifier: "wallet-background" - onClosed: { - walletBckgAccountContextMenu.active = false + walletAccountContextMenu.active = false } onAddNewAccountClicked: { @@ -82,6 +81,22 @@ Rectangle { onAddWatchOnlyAccountClicked: { RootStore.runAddWatchOnlyAccountPopup() } + + onEditAccountClicked: { + if (!account) + return + RootStore.runEditAccountPopup(account.address) + } + + onDeleteAccountClicked: { + if (!account) + return + removeAccountConfirmation.simple = account.walletType === Constants.watchWalletType || account.walletType === Constants.keyWalletType + removeAccountConfirmation.accountName = account.name + removeAccountConfirmation.accountAddress = account.address + removeAccountConfirmation.accountDerivationPath = account.path + removeAccountConfirmation.active = true + } } } @@ -137,8 +152,8 @@ Rectangle { onClicked: { if (mouse.button === Qt.RightButton) { - walletBckgAccountContextMenu.active = true - walletBckgAccountContextMenu.item.popup(mouse.x, mouse.y) + walletAccountContextMenu.active = true + walletAccountContextMenu.item.popup(mouse.x, mouse.y) } } } @@ -221,8 +236,9 @@ Rectangle { errorIcon.tooltip.text: networkConnectionStore.accountBalanceNotAvailableText onClicked: { if (mouse.button === Qt.RightButton) { - accountContextMenu.active = true - accountContextMenu.item.popup(mouse.x, mouse.y) + walletAccountContextMenu.active = true + walletAccountContextMenu.item.account = model + walletAccountContextMenu.item.popup(this, mouse.x, mouse.y) return } root.showSavedAddresses = false @@ -243,39 +259,6 @@ Rectangle { icon: model.keycardAccount ? "keycard" : "" } ] - - Loader { - id: accountContextMenu - sourceComponent: AccountContextMenu { - - uniqueIdentifier: model.name - account: model - - onClosed: { - accountContextMenu.active = false - } - - onEditAccountClicked: { - RootStore.runEditAccountPopup(model.address) - } - - onDeleteAccountClicked: { - removeAccountConfirmation.simple = model.walletType === Constants.watchWalletType || model.walletType === Constants.keyWalletType - removeAccountConfirmation.accountName = model.name - removeAccountConfirmation.accountAddress = model.address - removeAccountConfirmation.accountDerivationPath = model.path - removeAccountConfirmation.active = true - } - - onAddNewAccountClicked: { - RootStore.runAddAccountPopup() - } - - onAddWatchOnlyAccountClicked: { - RootStore.runAddWatchOnlyAccountPopup() - } - } - } } readonly property bool footerOverlayed: contentHeight > availableHeight