fix(@desktop/wallet): QR dialog (point 4)

Point 4 of #11968
This commit is contained in:
Sale Djenic 2023-08-22 13:22:27 +02:00 committed by saledjenic
parent f21e10f80d
commit 228de3715b
6 changed files with 26 additions and 12 deletions

View File

@ -58,6 +58,9 @@ method load*[T](self: Module[T], keyUid: string, mode: ImportKeypairModuleMode)
self.view.setCurrentState(newSelectKeypairState(nil))
else:
self.view.setSelectedKeypairItem(newKeyPairItem(keyUid = keyUid))
let keypair = self.controller.getKeypairByKeyUid(keyUid)
if not keypair.isNil:
self.view.getSelectedKeypair().setName(keypair.name)
if mode == ImportKeypairModuleMode.ExportKeypairQr:
self.view.setCurrentState(newExportKeypairState(nil))
self.controller.authenticateLoggedInUser()
@ -66,7 +69,6 @@ method load*[T](self: Module[T], keyUid: string, mode: ImportKeypairModuleMode)
self.view.setCurrentState(newImportQrState(nil))
self.delegate.onKeypairImportModuleLoaded()
return
let keypair = self.controller.getKeypairByKeyUid(keyUid)
if keypair.isNil:
error "ki_trying to import an unknown keypair"
self.closeKeypairImportPopup()

View File

@ -36,7 +36,7 @@ Item {
StatusBaseText {
width: parent.width
text: root.store.isAddAccountPopup? qsTr("Private key") : qsTr("Private key for %1 keypair").arg(root.store.selectedKeypair.name)
text: root.store.isAddAccountPopup? qsTr("Private key") : qsTr("Enter seed phrase for %1 keypair").arg(root.store.selectedKeypair.name)
font.pixelSize: Constants.addAccountPopup.labelFontSize1
elide: Text.ElideRight
}

View File

@ -27,7 +27,7 @@ Item {
StatusBaseText {
width: parent.width
text: root.store.isAddAccountPopup? qsTr("Enter seed phrase") : qsTr("Enter seed phrase for %1 keypair").arg(root.store.selectedKeypair.name)
text: root.store.isAddAccountPopup? qsTr("Enter seed phrase") : qsTr("Enter private key for %1 keypair").arg(root.store.selectedKeypair.name)
font.pixelSize: Constants.addAccountPopup.labelFontSize1
elide: Text.ElideRight
}

View File

@ -24,12 +24,13 @@ StatusModal {
switch (root.store.currentState.stateType) {
case Constants.keypairImportPopup.state.selectKeypair:
return qsTr("Import missing keypairs")
case Constants.keypairImportPopup.state.selectImportMethod:
return qsTr("Import %1 keypair").arg(root.store.selectedKeypair.name)
case Constants.keypairImportPopup.state.exportKeypair:
if (!!root.store.selectedKeypair.name) {
return qsTr("Encrypted QR for %1 keypair").arg(root.store.selectedKeypair.name)
}
return qsTr("Encrypted QR for keypairs on this device")
case Constants.keypairImportPopup.state.importQr:
return qsTr("Scan encrypted QR")
return qsTr("Scan encrypted keypair QR code")
case Constants.keypairImportPopup.state.displayInstructions:
return qsTr("How to generate the encrypted QR")
}
@ -163,9 +164,13 @@ StatusModal {
case Constants.keypairImportPopup.state.exportKeypair:
return qsTr("Done")
case Constants.keypairImportPopup.state.importQr:
if (root.store.syncViaQr) {
return qsTr("Done")
}
return qsTr("Import keypair")
case Constants.keypairImportPopup.state.importPrivateKey:
case Constants.keypairImportPopup.state.importSeedPhrase:
return qsTr("Import %1 keypair").arg(root.store.selectedKeypair.name)
return qsTr("Import keypair")
}
return ""
@ -174,7 +179,8 @@ StatusModal {
enabled: root.store.primaryPopupButtonEnabled
icon.name: {
if (root.store.currentState.stateType === Constants.keypairImportPopup.state.exportKeypair) {
if (root.store.currentState.stateType === Constants.keypairImportPopup.state.exportKeypair ||
root.store.currentState.stateType === Constants.keypairImportPopup.state.importQr && root.store.syncViaQr) {
return ""
}

View File

@ -23,8 +23,8 @@ Item {
secondTabName: qsTr("Enter encrypted key")
syncQrErrorMessage: qsTr("This does not look like the correct keypair QR code")
syncCodeErrorMessage: qsTr("This does not look like an encrypted keypair code")
firstInstructionButtonName: qsTr("How to generate the QR")
secondInstructionButtonName: qsTr("How to generate the key")
firstInstructionButtonName: qsTr("How to display the QR code on your other device")
secondInstructionButtonName: qsTr("How to copy the encrypted key from your other device")
syncCodeLabel: qsTr("Paste encrypted key")
validateConnectionString: function(connectionString) {
@ -32,6 +32,10 @@ Item {
return result === ""
}
onSyncViaQrChanged: {
root.store.syncViaQr = syncViaQr
}
onProceed: {
root.store.keypairImportModule.connectionString = connectionString
if (!syncViaQr) {

View File

@ -11,6 +11,7 @@ BasePopupStore {
property bool userProfileIsKeycardUser: userProfile.isKeycardUser
property bool userProfileUsingBiometricLogin: userProfile.usingBiometricLogin
property bool syncViaQr: true
// Module Properties
property var currentState: root.keypairImportModule.currentState
@ -19,7 +20,7 @@ BasePopupStore {
privateKeyAccAddress: root.keypairImportModule.privateKeyAccAddress
submitPopup: function(event) {
if (!root.primaryPopupButtonEnabled) {
if (!root.syncViaQr && !root.primaryPopupButtonEnabled) {
return
}
@ -51,7 +52,8 @@ BasePopupStore {
readonly property bool primaryPopupButtonEnabled: {
if (root.currentState.stateType === Constants.keypairImportPopup.state.importQr) {
return !!root.keypairImportModule.connectionString &&
return !root.syncViaQr &&
!!root.keypairImportModule.connectionString &&
!root.keypairImportModule.connectionStringError
}