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>
This commit is contained in:
Cuteivist 2023-07-19 16:05:21 +02:00 committed by GitHub
parent 39117170ab
commit ae6630911e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 50 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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