mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-19 18:18:38 +00:00
fix(AddEditSavedAddressPopup): hide network selector for ENS names
- fix some typos, add some forgotten `qsTr()` calls - improve SB page with create/edit modes Fixes #14909
This commit is contained in:
parent
00272d05c8
commit
c4f7c9732d
160
storybook/pages/AddEditSavedAddressPopupPage.qml
Normal file
160
storybook/pages/AddEditSavedAddressPopupPage.qml
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
|
import Storybook 1.0
|
||||||
|
import Models 1.0
|
||||||
|
import AppLayouts.Wallet.popups 1.0
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
|
SplitView {
|
||||||
|
orientation: Qt.Horizontal
|
||||||
|
|
||||||
|
Logs { id: logs }
|
||||||
|
|
||||||
|
PopupBackground {
|
||||||
|
id: popupBg
|
||||||
|
|
||||||
|
SplitView.fillWidth: true
|
||||||
|
SplitView.fillHeight: true
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: reopenButton
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "Reopen"
|
||||||
|
|
||||||
|
onClicked: popupBg.openDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDialog() {
|
||||||
|
popupComponent.createObject(popupBg)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: openDialog()
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: popupComponent
|
||||||
|
AddEditSavedAddressPopup {
|
||||||
|
visible: true
|
||||||
|
destroyOnClose: true
|
||||||
|
modal: false
|
||||||
|
closePolicy: Popup.NoAutoClose
|
||||||
|
|
||||||
|
flatNetworks: SortFilterProxyModel {
|
||||||
|
sourceModel: NetworksModel.flatNetworks
|
||||||
|
filters: ValueFilter { roleName: "isTest"; value: false }
|
||||||
|
}
|
||||||
|
|
||||||
|
store: QtObject {
|
||||||
|
function savedAddressNameExists(name) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
function createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames) {
|
||||||
|
logs.logEvent("createOrUpdateSavedAddress", ["name", "address", "ens", "colorId", "chainShortNames"], arguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emulate resolving ENS by simple validation
|
||||||
|
QtObject {
|
||||||
|
id: mainModule
|
||||||
|
|
||||||
|
function resolveENS(name, uuid) {
|
||||||
|
if (Utils.isValidEns(name)) {
|
||||||
|
resolvedENS("", "0x1234567890123456789012345678901234567890", uuid)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolvedENS("", "", uuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
signal resolvedENS(string pubkey, string address, string uuid)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: initWithParams({edit: ctrlIsEdit.checked,
|
||||||
|
name: ctrlIsEdit.checked ? ctrlName.text : "",
|
||||||
|
address: ctrlIsEdit.checked ? (ctrlAddressRadio.checked ? ctrlAddress.text : ctrlEnsAddress.text)
|
||||||
|
: "",
|
||||||
|
colorId : ctrlIsEdit.checked ? "magenta" : ""})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogsAndControlsPanel {
|
||||||
|
SplitView.minimumWidth: 300
|
||||||
|
SplitView.preferredWidth: 300
|
||||||
|
|
||||||
|
logsView.logText: logs.logText
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: ctrlIsEdit
|
||||||
|
text: "Is edit?"
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.leftMargin: 8
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: ctrlIsEdit.checked
|
||||||
|
Label { text: "Name:" }
|
||||||
|
TextField {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
id: ctrlName
|
||||||
|
text: "cool name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.leftMargin: 8
|
||||||
|
visible: ctrlIsEdit.checked
|
||||||
|
text: "Address:"
|
||||||
|
}
|
||||||
|
ButtonGroup { id: addressButtonGroup }
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
visible: ctrlIsEdit.checked
|
||||||
|
Layout.leftMargin: 8
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
RadioButton {
|
||||||
|
id: ctrlAddressRadio
|
||||||
|
checked: true
|
||||||
|
ButtonGroup.group: addressButtonGroup
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
id: ctrlAddress
|
||||||
|
text: "0x1234567890123456789012345678901234567891"
|
||||||
|
placeholderText: "Regular address"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
visible: ctrlIsEdit.checked
|
||||||
|
Layout.leftMargin: 8
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
RadioButton {
|
||||||
|
id: ctrlEnsRadio
|
||||||
|
ButtonGroup.group: addressButtonGroup
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
id: ctrlEnsAddress
|
||||||
|
text: "me.eth"
|
||||||
|
placeholderText: "ENS address"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item { Layout.fillHeight: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// category: Popups
|
||||||
|
|
||||||
|
// https://www.figma.com/file/idUoxN7OIW2Jpp3PMJ1Rl8/%E2%9A%99%EF%B8%8F-Settings-%7C-Desktop?type=design&node-id=23256-263282&mode=design&t=0DRwQJKDGYJPHkq1-4
|
@ -1,74 +0,0 @@
|
|||||||
import QtQuick 2.15
|
|
||||||
import QtQuick.Controls 2.15
|
|
||||||
import QtQuick.Layouts 1.15
|
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
|
||||||
|
|
||||||
import Storybook 1.0
|
|
||||||
import Models 1.0
|
|
||||||
import AppLayouts.Wallet.popups 1.0
|
|
||||||
|
|
||||||
import utils 1.0
|
|
||||||
|
|
||||||
SplitView {
|
|
||||||
orientation: Qt.Horizontal
|
|
||||||
|
|
||||||
PopupBackground {
|
|
||||||
id: popupBg
|
|
||||||
|
|
||||||
property var popupIntance: null
|
|
||||||
|
|
||||||
SplitView.fillWidth: true
|
|
||||||
SplitView.fillHeight: true
|
|
||||||
|
|
||||||
Button {
|
|
||||||
id: reopenButton
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: "Reopen"
|
|
||||||
enabled: !dialog.visible
|
|
||||||
|
|
||||||
onClicked: dialog.open()
|
|
||||||
}
|
|
||||||
|
|
||||||
AddEditSavedAddressPopup {
|
|
||||||
id: dialog
|
|
||||||
|
|
||||||
visible: true
|
|
||||||
flatNetworks: SortFilterProxyModel {
|
|
||||||
sourceModel: NetworksModel.flatNetworks
|
|
||||||
filters: ValueFilter { roleName: "isTest"; value: false }
|
|
||||||
}
|
|
||||||
|
|
||||||
store: QtObject {
|
|
||||||
property var savedAddressNameExists: function() { return false }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emulate resoling ENS by simple validation
|
|
||||||
QtObject {
|
|
||||||
id: mainModule
|
|
||||||
|
|
||||||
function resolveENS(name, uuid) {
|
|
||||||
if (Utils.isValidEns(name)) {
|
|
||||||
resolvedENS("", "0x1234567890123456789012345678901234567890", uuid)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolvedENS("", "", uuid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signal resolvedENS(string pubkey, string address, string uuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: initWithParams()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pane {
|
|
||||||
SplitView.minimumWidth: 300
|
|
||||||
SplitView.preferredWidth: 300
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// category: Popups
|
|
||||||
|
|
||||||
// https://www.figma.com/file/idUoxN7OIW2Jpp3PMJ1Rl8/%E2%9A%99%EF%B8%8F-Settings-%7C-Desktop?type=design&node-id=23256-263282&mode=design&t=0DRwQJKDGYJPHkq1-4
|
|
@ -38,10 +38,6 @@ StatusModal {
|
|||||||
|
|
||||||
property var store: RootStore
|
property var store: RootStore
|
||||||
|
|
||||||
onClosed: {
|
|
||||||
root.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
function initWithParams(params = {}) {
|
function initWithParams(params = {}) {
|
||||||
d.storedName = params.name?? ""
|
d.storedName = params.name?? ""
|
||||||
d.storedColorId = params.colorId?? ""
|
d.storedColorId = params.colorId?? ""
|
||||||
@ -73,7 +69,7 @@ StatusModal {
|
|||||||
.arg(d.chainShortNames)
|
.arg(d.chainShortNames)
|
||||||
.arg(d.address == Constants.zeroAddress? "" : d.address))
|
.arg(d.address == Constants.zeroAddress? "" : d.address))
|
||||||
|
|
||||||
nameInput.input.edit.forceActiveFocus(Qt.MouseFocusReason)
|
nameInput.input.edit.forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CardType {
|
enum CardType {
|
||||||
@ -132,7 +128,7 @@ StatusModal {
|
|||||||
property bool checkingContactsAddressInProgress: false
|
property bool checkingContactsAddressInProgress: false
|
||||||
property int contactsWithSameAddress: 0
|
property int contactsWithSameAddress: 0
|
||||||
|
|
||||||
function checkIfAddressIsAlreadyAdddedToWallet(address) {
|
function checkIfAddressIsAlreadyAddedToWallet(address) {
|
||||||
let account = root.store.getWalletAccount(address)
|
let account = root.store.getWalletAccount(address)
|
||||||
d.cardsModel.clear()
|
d.cardsModel.clear()
|
||||||
d.addressAlreadyAddedToWalletError = !!account.name
|
d.addressAlreadyAddedToWalletError = !!account.name
|
||||||
@ -149,7 +145,7 @@ StatusModal {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIfAddressIsAlreadyAdddedToSavedAddresses(address) {
|
function checkIfAddressIsAlreadyAddedToSavedAddresses(address) {
|
||||||
let savedAddress = root.store.getSavedAddress(address)
|
let savedAddress = root.store.getSavedAddress(address)
|
||||||
d.cardsModel.clear()
|
d.cardsModel.clear()
|
||||||
d.addressAlreadyAddedToSavedAddressesError = !!savedAddress.address
|
d.addressAlreadyAddedToSavedAddressesError = !!savedAddress.address
|
||||||
@ -200,13 +196,13 @@ StatusModal {
|
|||||||
d.addressAlreadyAddedToSavedAddressesError = false
|
d.addressAlreadyAddedToSavedAddressesError = false
|
||||||
|
|
||||||
if (d.addressInputIsAddress) {
|
if (d.addressInputIsAddress) {
|
||||||
d.checkIfAddressIsAlreadyAdddedToWallet(d.address)
|
d.checkIfAddressIsAlreadyAddedToWallet(d.address)
|
||||||
if (d.addressAlreadyAddedToWalletError) {
|
if (d.addressAlreadyAddedToWalletError) {
|
||||||
addressInput.errorMessageCmp.text = qsTr("You cannot add your own account as a saved address")
|
addressInput.errorMessageCmp.text = qsTr("You cannot add your own account as a saved address")
|
||||||
addressInput.errorMessageCmp.visible = true
|
addressInput.errorMessageCmp.visible = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
d.checkIfAddressIsAlreadyAdddedToSavedAddresses(d.address)
|
d.checkIfAddressIsAlreadyAddedToSavedAddresses(d.address)
|
||||||
if (d.addressAlreadyAddedToSavedAddressesError) {
|
if (d.addressAlreadyAddedToSavedAddressesError) {
|
||||||
addressInput.errorMessageCmp.text = qsTr("This address is already saved")
|
addressInput.errorMessageCmp.text = qsTr("This address is already saved")
|
||||||
addressInput.errorMessageCmp.visible = true
|
addressInput.errorMessageCmp.visible = true
|
||||||
@ -589,12 +585,13 @@ StatusModal {
|
|||||||
id: networkSelector
|
id: networkSelector
|
||||||
|
|
||||||
objectName: "addSavedAddressNetworkSelector"
|
objectName: "addSavedAddressNetworkSelector"
|
||||||
title: "Network preference"
|
title: qsTr("Network preference")
|
||||||
implicitWidth: d.componentWidth
|
implicitWidth: d.componentWidth
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
enabled: d.addressInputValid && !d.addressInputIsENS
|
enabled: d.addressInputValid && !d.addressInputIsENS
|
||||||
defaultItemText: "Add networks"
|
visible: !(d.editMode && d.addressInputIsENS)
|
||||||
|
defaultItemText: qsTr("Add networks")
|
||||||
defaultItemImageSource: "add"
|
defaultItemImageSource: "add"
|
||||||
rightButtonVisible: true
|
rightButtonVisible: true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user