feat(savedaddresses): context menu - remove saved address
Closes #13093
This commit is contained in:
parent
e35bc9db40
commit
cf09505071
|
@ -73,8 +73,11 @@ method savedAddressUpdated*(self: Module, name: string, address: string, ens: st
|
|||
self.view.savedAddressAddedOrUpdated(item.isEmpty(), name, address, ens, errorMsg)
|
||||
|
||||
method savedAddressDeleted*(self: Module, address: string, ens: string, errorMsg: string) =
|
||||
var item = self.view.getModel().getItemByEnsOrAddress(address)
|
||||
if item.isEmpty():
|
||||
item = self.view.getModel().getItemByEnsOrAddress(ens)
|
||||
self.loadSavedAddresses()
|
||||
self.view.savedAddressDeleted(address, ens, errorMsg)
|
||||
self.view.savedAddressDeleted(item.getName(), address, ens, errorMsg)
|
||||
|
||||
method savedAddressNameExists*(self: Module, name: string): bool =
|
||||
return self.view.getModel().nameExists(name)
|
||||
|
|
|
@ -46,7 +46,7 @@ QtObject:
|
|||
favourite: bool, chainShortNames: string) {.slot.} =
|
||||
self.delegate.createOrUpdateSavedAddress(name, address, ens, colorId, favourite, chainShortNames)
|
||||
|
||||
proc savedAddressDeleted*(self: View, address: string, ens: string, errorMsg: string) {.signal.}
|
||||
proc savedAddressDeleted*(self: View, name: string, address: string, ens: string, errorMsg: string) {.signal.}
|
||||
|
||||
proc deleteSavedAddress*(self: View, address: string, ens: string) {.slot.} =
|
||||
self.delegate.deleteSavedAddress(address, ens)
|
||||
|
|
|
@ -240,7 +240,7 @@ class AddressesView(BaseElement):
|
|||
self._delete_saved_address_menu_item.wait_until_appears()
|
||||
self._delete_saved_address_menu_item.click()
|
||||
self._delete_saved_address_menu_item.wait_until_hidden()
|
||||
ConfirmationPopup().wait_until_appears().confirm()
|
||||
ConfirmationPopup().wait_until_appears().confirmWithButton(Button('mainWallet_Saved_Addreses_More_Confirm_Delete'))
|
||||
|
||||
|
||||
class WalletAccountView(BaseElement):
|
||||
|
|
|
@ -10,3 +10,7 @@ class ConfirmationPopup(BaseElement):
|
|||
def confirm(self):
|
||||
self._confirm_button.click()
|
||||
self.wait_until_hidden()
|
||||
|
||||
def confirmWithButton(self, button):
|
||||
button.click()
|
||||
self.wait_until_hidden()
|
||||
|
|
|
@ -90,7 +90,7 @@ edit_TextEdit = {"container": statusDesktop_mainWindow_overlay, "type": "TextEdi
|
|||
# Wallet Settings:
|
||||
mainWallet_Saved_Addreses_More_Edit = {"container": statusDesktop_mainWindow, "objectName": "editSavedAddress", "type": "StatusMenuItem"}
|
||||
mainWallet_Saved_Addreses_More_Delete = {"container": statusDesktop_mainWindow, "objectName": "deleteSavedAddress", "type": "StatusMenuItem"}
|
||||
mainWallet_Saved_Addreses_More_Confirm_Delete = {"container": statusDesktop_mainWindow, "objectName": "confirmDeleteSavedAddress", "type": "StatusButton"}
|
||||
mainWallet_Saved_Addreses_More_Confirm_Delete = {"container": statusDesktop_mainWindow, "objectName": "RemoveAccountPopup-ConfirmButton", "type": "StatusButton"}
|
||||
settings_Wallet_MainView_GeneratedAccounts = {"container": statusDesktop_mainWindow, "objectName": 'generatedAccounts', "type": 'Repeater'}
|
||||
settings_Wallet_AccountView_DeleteAccount = {"container": statusDesktop_mainWindow, "type": "StatusButton", "objectName": "deleteAccountButton"}
|
||||
settings_Wallet_AccountView_DeleteAccount_Confirm = {"container": statusDesktop_mainWindow, "type": "StatusButton", "objectName": "confirmDeleteAccountButton"}
|
||||
|
|
|
@ -29,6 +29,7 @@ send_StatusRoundButton = {"container": "", "type": "StatusRoundButton", "unnamed
|
|||
savedAddressView_Delegate_menuButton = {"container": "", "objectName": RegularExpression("savedAddressView_Delegate_menuButton*"), "type": "StatusRoundButton", "visible": True}
|
||||
mainWallet_Saved_Addreses_More_Edit = {"container": statusDesktop_mainWindow, "objectName": "editSavedAddress", "type": "StatusMenuItem"}
|
||||
mainWallet_Saved_Addreses_More_Delete = {"container": statusDesktop_mainWindow, "objectName": "deleteSavedAddress", "type": "StatusMenuItem"}
|
||||
mainWallet_Saved_Addreses_More_Confirm_Delete = {"container": statusDesktop_mainWindow, "objectName": "RemoveSavedAddressPopup-ConfirmButton", "type": "StatusButton"}
|
||||
|
||||
# Wallet Account View
|
||||
mainWindow_StatusSectionLayout_ContentItem = {"container": statusDesktop_mainWindow, "objectName": "StatusSectionLayout", "type": "ContentItem", "visible": True}
|
||||
|
|
|
@ -86,7 +86,7 @@ StatusListItem {
|
|||
radius: 8
|
||||
icon.name: "more"
|
||||
onClicked: {
|
||||
editDeleteMenu.openMenu(this, x - editDeleteMenu.width - statusListItemComponentsSlot.spacing, y + height + Style.current.halfPadding,
|
||||
menu.openMenu(this, x - menu.width - statusListItemComponentsSlot.spacing, y + height + Style.current.halfPadding,
|
||||
{
|
||||
name: root.name,
|
||||
address: root.address,
|
||||
|
@ -102,12 +102,12 @@ StatusListItem {
|
|||
]
|
||||
|
||||
StatusMenu {
|
||||
id: editDeleteMenu
|
||||
property string contactName
|
||||
property string contactAddress
|
||||
id: menu
|
||||
property string name
|
||||
property string address
|
||||
property bool storeFavourite
|
||||
property string contactChainShortNames
|
||||
property string contactEns
|
||||
property string chainShortNames
|
||||
property string ens
|
||||
property string colorId
|
||||
|
||||
readonly property int maxHeight: 341
|
||||
|
@ -115,20 +115,21 @@ StatusListItem {
|
|||
contentWidth: 216
|
||||
|
||||
function openMenu(parent, x, y, model) {
|
||||
contactName = model.name;
|
||||
contactAddress = model.address;
|
||||
storeFavourite = model.favourite;
|
||||
contactChainShortNames = model.chainShortNames;
|
||||
contactEns = model.ens;
|
||||
colorId = model.colorId;
|
||||
menu.name = model.name;
|
||||
menu.address = model.address;
|
||||
menu.storeFavourite = model.favourite;
|
||||
menu.chainShortNames = model.chainShortNames;
|
||||
menu.ens = model.ens;
|
||||
menu.colorId = model.colorId;
|
||||
popup(parent, x, y);
|
||||
}
|
||||
onClosed: {
|
||||
contactName = "";
|
||||
contactAddress = "";
|
||||
storeFavourite = false;
|
||||
contactChainShortNames = ""
|
||||
contactEns = ""
|
||||
menu.name = "";
|
||||
menu.address = "";
|
||||
menu.storeFavourite = false;
|
||||
menu.chainShortNames = ""
|
||||
menu.ens = ""
|
||||
menu.colorId = ""
|
||||
}
|
||||
StatusAction {
|
||||
text: qsTr("Edit saved address")
|
||||
|
@ -137,12 +138,12 @@ StatusListItem {
|
|||
onTriggered: {
|
||||
Global.openAddEditSavedAddressesPopup({
|
||||
edit: true,
|
||||
address: editDeleteMenu.contactAddress,
|
||||
name: editDeleteMenu.contactName,
|
||||
favourite: editDeleteMenu.storeFavourite,
|
||||
chainShortNames: editDeleteMenu.contactChainShortNames,
|
||||
ens: editDeleteMenu.contactEns,
|
||||
colorId: editDeleteMenu.colorId
|
||||
address: menu.address,
|
||||
name: menu.name,
|
||||
favourite: menu.storeFavourite,
|
||||
chainShortNames: menu.chainShortNames,
|
||||
ens: menu.ens,
|
||||
colorId: menu.colorId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -216,10 +217,11 @@ StatusListItem {
|
|||
objectName: "deleteSavedAddress"
|
||||
onTriggered: {
|
||||
Global.openDeleteSavedAddressesPopup({
|
||||
name: editDeleteMenu.contactName,
|
||||
address: editDeleteMenu.contactAddress,
|
||||
favourite: editDeleteMenu.storeFavourite,
|
||||
ens: editDeleteMenu.contactEns
|
||||
name: menu.name,
|
||||
address: menu.address,
|
||||
ens: menu.ens,
|
||||
colorId: menu.colorId,
|
||||
chainShortNames: menu.chainShortNames
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQml.Models 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Popups.Dialog 0.1
|
||||
|
||||
import AppLayouts.Wallet 1.0
|
||||
|
||||
import utils 1.0
|
||||
import shared.controls 1.0
|
||||
|
||||
StatusDialog {
|
||||
id: root
|
||||
|
||||
property string name
|
||||
property string address
|
||||
property string ens
|
||||
property string colorId
|
||||
property string chainShortNames
|
||||
|
||||
signal removeSavedAddress(string address, string ens)
|
||||
|
||||
width: 521
|
||||
focus: visible
|
||||
padding: Style.current.padding
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
readonly property real lineHeight: 1.2
|
||||
|
||||
function confirm() {
|
||||
root.removeSavedAddress(root.address, root.ens)
|
||||
}
|
||||
}
|
||||
|
||||
header: StatusDialogHeader {
|
||||
headline.title: qsTr("Remove %1").arg(root.name)
|
||||
headline.subtitle: {
|
||||
if (root.ens.length > 0)
|
||||
return root.ens
|
||||
|
||||
return WalletUtils.colorizedChainPrefix(root.chainShortNames) + Utils.richColorText(StatusQUtils.Utils.elideText(root.address, 6, 4), Theme.palette.directColor1)
|
||||
}
|
||||
actions.closeButton.onClicked: root.close()
|
||||
|
||||
leftComponent: StatusSmartIdenticon {
|
||||
name: root.name
|
||||
asset {
|
||||
color: Utils.getColorForId(root.colorId)
|
||||
charactersLen: {
|
||||
let parts = root.name.split(" ")
|
||||
if (parts.length > 1) {
|
||||
return 2
|
||||
}
|
||||
return 1
|
||||
}
|
||||
isLetterIdenticon: true
|
||||
useAcronymForLetterIdenticon: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: Style.current.halfPadding
|
||||
|
||||
StatusBaseText {
|
||||
objectName: "RemoveSavedAddressPopup-Notification"
|
||||
Layout.preferredWidth: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
textFormat: Text.RichText
|
||||
font.pixelSize: Style.current.primaryTextFontSize
|
||||
lineHeight: d.lineHeight
|
||||
text: qsTr("Are you sure you want to remove %1 from your saved addresses? Transaction history relating to this address will no longer be labelled %1.").arg("<b>%1</b>".arg(root.name))
|
||||
}
|
||||
}
|
||||
|
||||
footer: StatusDialogFooter {
|
||||
spacing: Style.current.padding
|
||||
rightButtons: ObjectModel {
|
||||
StatusFlatButton {
|
||||
objectName: "RemoveSavedAddressPopup-CancelButton"
|
||||
text: qsTr("Cancel")
|
||||
type: StatusBaseButton.Type.Normal
|
||||
onClicked: {
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
StatusButton {
|
||||
objectName: "RemoveSavedAddressPopup-ConfirmButton"
|
||||
text: qsTr("Remove saved address")
|
||||
type: StatusBaseButton.Type.Danger
|
||||
focus: true
|
||||
Keys.onReturnPressed: function(event) {
|
||||
d.confirm()
|
||||
}
|
||||
onClicked: {
|
||||
d.confirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,3 +4,4 @@ ActivityPeriodFilterSubMenu 1.0 filterSubMenus/ActivityPeriodFilterSubMenu.qml
|
|||
ActivityTypeFilterSubMenu 1.0 filterSubMenus/ActivityTypeFilterSubMenu.qml
|
||||
ReceiveModal 1.0 ReceiveModal.qml
|
||||
AddEditSavedAddressPopup 1.0 AddEditSavedAddressPopup.qml
|
||||
RemoveSavedAddressPopup 1.0 RemoveSavedAddressPopup.qml
|
||||
|
|
|
@ -1725,7 +1725,7 @@ Item {
|
|||
mode = qsTr("editing")
|
||||
}
|
||||
|
||||
Global.displayToastMessage(qsTr("An error occurred while %1 %2 addresses").arg(mode).arg(name),
|
||||
Global.displayToastMessage(qsTr("An error occurred while %1 %2 address").arg(mode).arg(name),
|
||||
"",
|
||||
"warning",
|
||||
false,
|
||||
|
@ -1771,63 +1771,49 @@ Item {
|
|||
deleteSavedAddress.item.address = deleteSavedAddress.params.address?? ""
|
||||
deleteSavedAddress.item.ens = deleteSavedAddress.params.ens?? ""
|
||||
deleteSavedAddress.item.name = deleteSavedAddress.params.name?? ""
|
||||
deleteSavedAddress.item.favourite = deleteSavedAddress.params.favourite?? false
|
||||
deleteSavedAddress.item.colorId = deleteSavedAddress.params.colorId?? "blue"
|
||||
deleteSavedAddress.item.chainShortNames = deleteSavedAddress.params.chainShortNames?? ""
|
||||
|
||||
deleteSavedAddress.item.open()
|
||||
}
|
||||
|
||||
sourceComponent: StatusModal {
|
||||
|
||||
property string address
|
||||
property string ens
|
||||
property string name
|
||||
property bool favourite
|
||||
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
headerSettings.title: qsTr("Are you sure?")
|
||||
headerSettings.subTitle: name
|
||||
|
||||
|
||||
contentItem: StatusBaseText {
|
||||
anchors.centerIn: parent
|
||||
height: contentHeight + topPadding + bottomPadding
|
||||
text: qsTr("Are you sure you want to remove '%1' from your saved addresses?").arg(name)
|
||||
font.pixelSize: 15
|
||||
color: Theme.palette.directColor1
|
||||
wrapMode: Text.Wrap
|
||||
topPadding: Style.current.padding
|
||||
rightPadding: Style.current.padding
|
||||
bottomPadding: Style.current.padding
|
||||
leftPadding: Style.current.padding
|
||||
}
|
||||
|
||||
sourceComponent: WalletPopups.RemoveSavedAddressPopup {
|
||||
onClosed: {
|
||||
deleteSavedAddress.close()
|
||||
}
|
||||
|
||||
rightButtons: [
|
||||
StatusButton {
|
||||
text: qsTr("Cancel")
|
||||
onClicked: close()
|
||||
},
|
||||
StatusButton {
|
||||
type: StatusBaseButton.Type.Danger
|
||||
objectName: "confirmDeleteSavedAddress"
|
||||
text: qsTr("Delete")
|
||||
onClicked: {
|
||||
WalletStore.RootStore.deleteSavedAddress(address, ens)
|
||||
close()
|
||||
}
|
||||
}
|
||||
]
|
||||
onRemoveSavedAddress: {
|
||||
WalletStore.RootStore.deleteSavedAddress(address, ens)
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: WalletStore.RootStore.walletSectionSavedAddressesInst
|
||||
|
||||
function onSavedAddressDeleted(address: string, ens: string, errorMsg: string) {
|
||||
function onSavedAddressDeleted(name: string, address: string, ens: string, errorMsg: string) {
|
||||
WalletStore.RootStore.deletingSavedAddress = false
|
||||
WalletStore.RootStore.lastDeletedSavedAddress = { address: address, ens: ens, error: errorMsg }
|
||||
|
||||
if (!!errorMsg) {
|
||||
|
||||
Global.displayToastMessage(qsTr("An error occurred while removing %1 address").arg(name),
|
||||
"",
|
||||
"warning",
|
||||
false,
|
||||
Constants.ephemeralNotificationType.danger,
|
||||
""
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
Global.displayToastMessage(qsTr("%1 was successfully removed from your saved addresses").arg(name),
|
||||
"",
|
||||
"checkmark-circle",
|
||||
false,
|
||||
Constants.ephemeralNotificationType.success,
|
||||
""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue