status-desktop/ui/app/AppLayouts/Onboarding/views/SeedPhraseInputView.qml
Alex Jbanca 8a69f3bc63
fix(SeedPhrase): Fixing seed phrase validation (#13496)
* fix(SeedPhrase): Fixing seed phrase validation

1. Validate each word after the editing is finished
2. Fixing the seed phrase suggestions where the suggestions box was hidden behind other ui elements
3. Propagate editingFinished signal in StatusBaseInput, StatusInput, StatusSeedPhraseInput
4. Fixing undefined `mnemonicIndex` errors

* fix: Refactoring of SeedPhraseInputView

Remove duplicated code and use EnterSeedPhrase component

+ Added storybook page

* fix(Onboarding): Fixing seed phrase validation on windows

The seed phrase validation fails on windows due to the dictionary line endings

* chore(squish): Update e2e tests to the new enter seed phrase panel construction

* fix: Load english dictionary from local file using StringUtils
2024-02-14 15:50:14 +02:00

91 lines
3.3 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import AppLayouts.Onboarding.controls 1.0
import AppLayouts.Onboarding.stores 1.0
import utils 1.0
import shared.panels 1.0
import shared.stores 1.0
import shared.controls 1.0
Item {
id: root
property StartupStore startupStore
QtObject {
id: d
property bool wrongSeedPhrase: root.startupStore.startupModuleInst.keycardData & Constants.predefinedKeycardData.wrongSeedPhrase
onWrongSeedPhraseChanged: {
if (wrongSeedPhrase) {
if (root.startupStore.startupModuleInst.flowType === Constants.startupFlow.firstRunOldUserImportSeedPhrase) {
seedPhraseView.setWrongSeedPhraseMessage(qsTr("Profile keypair for the inserted seed phrase is already set up"))
return
}
seedPhraseView.setWrongSeedPhraseMessage(qsTr("Seed phrase doesnt match the profile of an existing Keycard user on this device"))
}
else {
seedPhraseView.setWrongSeedPhraseMessage("")
}
}
}
ColumnLayout {
width: 565
implicitHeight: contentItem.implicitHeight
anchors.centerIn: parent
spacing: 24
StatusBaseText {
id: headlineText
font.pixelSize: 22
font.weight: Font.Bold
color: Theme.palette.directColor1
Layout.alignment: Qt.AlignHCenter
text: qsTr("Enter seed phrase")
}
EnterSeedPhrase {
id: seedPhraseView
isSeedPhraseValid: root.startupStore.validMnemonic
Layout.alignment: Qt.AlignHCenter
}
StatusButton {
id: submitButton
objectName: "seedPhraseViewSubmitButton"
Layout.alignment: Qt.AlignHCenter
enabled: seedPhraseView.seedPhraseIsValid
text: {
if (root.startupStore.currentStartupState.flowType === Constants.startupFlow.firstRunNewUserImportSeedPhrase) {
return qsTr("Import")
}
else if (root.startupStore.currentStartupState.flowType === Constants.startupFlow.firstRunOldUserImportSeedPhrase) {
return qsTr("Restore Status Profile")
}
else if (root.startupStore.currentStartupState.flowType === Constants.startupFlow.firstRunOldUserKeycardImport ||
root.startupStore.currentStartupState.flowType === Constants.startupFlow.appLogin) {
return qsTr("Recover Keycard")
}
else if (root.startupStore.currentStartupState.flowType === Constants.startupFlow.firstRunNewUserImportSeedPhraseIntoKeycard ||
root.startupStore.currentStartupState.flowType === Constants.startupFlow.lostKeycardReplacement ||
root.startupStore.currentStartupState.flowType === Constants.startupFlow.lostKeycardConvertToRegularAccount) {
return qsTr("Next")
}
return ""
}
onClicked: root.startupStore.doPrimaryAction()
}
}
}