feat(@desktop/wallet): right click context menu - delete account option added

This commit is contained in:
Sale Djenic 2023-03-30 14:55:07 +02:00 committed by saledjenic
parent 0ef3096756
commit 3325241b0f
6 changed files with 166 additions and 2 deletions

View File

@ -73,3 +73,5 @@ proc getCurrencyFormat*(self: Controller, symbol: string): CurrencyFormatDto =
proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairDto] =
return self.walletAccountService.getMigratedKeyPairByKeyUid(keyUid)
proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
return self.walletAccountService.getAccountByAddress(address)

View File

@ -158,6 +158,10 @@ proc authenticateActivityForKeyUid(self: Module, keyUid: string, reason: Authent
self.controller.authenticateKeyPair()
method deleteAccount*(self: Module, keyUid: string, address: string) =
let accountDto = self.controller.getWalletAccount(address)
if accountDto.walletType == WalletTypeWatch:
self.controller.deleteAccount(address)
return
self.processingWalletAccount = WalletAccountDetails(keyUid: keyUid, address: address)
self.authenticateActivityForKeyUid(keyUid, AuthenticationReason.DeleteAccountAuthentication)

View File

@ -136,8 +136,8 @@ QtObject {
walletSection.switchAccountByAddress(address)
}
function deleteAccount(address) {
return walletSectionAccounts.deleteAccount(address)
function deleteAccount(keyUid, address) {
return walletSectionAccounts.deleteAccount(keyUid, address)
}
function updateCurrentAccount(address, accountName, color, emoji) {

View File

@ -13,6 +13,7 @@ import utils 1.0
import shared 1.0
import shared.panels 1.0
import shared.controls 1.0
import shared.popups 1.0
import shared.popups.keycard 1.0
import shared.stores 1.0
@ -64,6 +65,41 @@ Rectangle {
}
}
Loader {
id: removeAccountConfirmation
active: false
property bool simple
property string accountKeyUid
property string accountName
property string accountAddress
property string accountDerivationPath
sourceComponent: RemoveAccountConfirmationPopup {
anchors.centerIn: parent
width: 400
simple: removeAccountConfirmation.simple
accountKeyUid: removeAccountConfirmation.accountKeyUid
accountName: removeAccountConfirmation.accountName
accountAddress: removeAccountConfirmation.accountAddress
accountDerivationPath: removeAccountConfirmation.accountDerivationPath
onClosed: {
removeAccountConfirmation.active = false
}
onRemoveAccount: {
close()
RootStore.deleteAccount(keyUid, address)
}
}
onLoaded: {
removeAccountConfirmation.item.open()
}
}
Connections {
target: walletSection
@ -251,6 +287,12 @@ Rectangle {
}
onDeleteAccountClicked: {
removeAccountConfirmation.simple = model.walletType === Constants.watchWalletType || model.walletType === Constants.keyWalletType
removeAccountConfirmation.accountKeyUid = model.keyUid
removeAccountConfirmation.accountName = model.name
removeAccountConfirmation.accountAddress = model.address
removeAccountConfirmation.accountDerivationPath = model.path
removeAccountConfirmation.active = true
}
onAddNewAccountClicked: {

View File

@ -0,0 +1,115 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
import utils 1.0
import shared.controls 1.0
StatusModal {
id: root
required property bool simple
required property string accountKeyUid
required property string accountName
required property string accountAddress
required property string accountDerivationPath
signal removeAccount(string keyUid, string address)
header.title: qsTr("Remove %1").arg(root.accountName)
focus: visible
padding: Style.current.padding
QtObject {
id: d
readonly property int checkboxHeight: 24
readonly property real lineHeight: 1.2
function confirm() {
if (!root.simple && !derivationPathWritten.checked) {
return
}
root.removeAccount(root.accountKeyUid, root.accountAddress)
}
}
contentItem: ColumnLayout {
spacing: Style.current.halfPadding
StatusBaseText {
Layout.preferredWidth: parent.width
wrapMode: Text.WordWrap
textFormat: Text.RichText
font.pixelSize: Style.current.primaryTextFontSize
lineHeight: d.lineHeight
text: root.simple?
qsTr("Are you sure you want to remove %1?
The account will be removed from all of your synced devices.").arg("<b>%1</b>".arg(root.accountName))
: qsTr("Are you sure you want to remove %1?
The account will be removed from all of your synced devices.
Make sure you have a backup of your keys or recovery phrase before proceeding.
%2
Copying the derivation path to this account now will enable you to import it again
at a later date should you wish to do so:").arg("<b>%1</b>".arg(root.accountName)).arg("<br/><br/>")
}
StatusBaseText {
Layout.preferredWidth: parent.width
Layout.topMargin: Style.current.padding
visible: !root.simple
text: qsTr("Derivation path for %1").arg(root.accountName)
font.pixelSize: Style.current.primaryTextFontSize
lineHeight: d.lineHeight
}
StatusInput {
Layout.preferredWidth: parent.width
visible: !root.simple
input.edit.enabled: false
text: root.accountDerivationPath
input.background.color: "transparent"
input.background.border.color: Theme.palette.baseColor2
input.rightComponent: CopyButton {
textToCopy: root.accountDerivationPath
}
}
StatusCheckBox {
id: derivationPathWritten
Layout.preferredWidth: parent.width
Layout.preferredHeight: d.checkboxHeight
Layout.topMargin: Style.current.padding
visible: !root.simple
spacing: Style.current.padding
font.pixelSize: Style.current.primaryTextFontSize
text: qsTr("I have a pen and paper")
}
}
rightButtons: [
StatusFlatButton {
text: qsTr("Cancel")
type: StatusBaseButton.Type.Normal
onClicked: {
root.close()
}
},
StatusButton {
text: qsTr("Remove %1").arg(root.accountName)
type: StatusBaseButton.Type.Danger
enabled: root.simple || derivationPathWritten.checked
focus: true
Keys.onReturnPressed: function(event) {
d.confirm()
}
onClicked: {
d.confirm()
}
}
]
}

View File

@ -26,3 +26,4 @@ SendContactRequestModal 1.0 SendContactRequestModal.qml
AccountsModalHeader 1.0 AccountsModalHeader.qml
GetSyncCodeInstructionsPopup 1.0 GetSyncCodeInstructionsPopup.qml
NoPermissionsToJoinPopup 1.0 NoPermissionsToJoinPopup.qml
RemoveAccountConfirmationPopup 1.0 RemoveAccountConfirmationPopup.qml