Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove word button #336

Merged
merged 4 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/actions/wallet-backup-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export default class WalletBackupActions {
restartWalletBackup: Action<any> = new Action();
cancelWalletBackup: Action<any> = new Action();
finishWalletBackup: Action<any> = new Action();
removeOneMnemonicWord: Action<any> = new Action();
}
12 changes: 6 additions & 6 deletions app/components/wallet/WalletBackupDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Props = {
isPrivacyNoticeAccepted: boolean,
countdownRemaining: number,
isTermDeviceAccepted: boolean,
canFinishBackup: boolean,
isTermRecoveryAccepted: boolean,
isValid: boolean,
isSubmitting: boolean,
Expand All @@ -26,8 +25,9 @@ type Props = {
onAcceptTermRecovery: Function,
onAddWord: Function,
onClear: Function,
onFinishBackup: Function,
onRestartBackup: Function,
removeWord: Function,
hasWord: Function
};

@observer
Expand All @@ -40,10 +40,10 @@ export default class WalletBackupDialog extends Component<Props> {
countdownRemaining, onAcceptPrivacyNotice,
onContinue, recoveryPhrase,
onStartWalletBackup, isTermDeviceAccepted,
enteredPhrase, canFinishBackup,
enteredPhrase, removeWord, hasWord,
isTermRecoveryAccepted, isValid, isSubmitting,
onAcceptTermDevice, onAcceptTermRecovery,
onAddWord, onClear, onFinishBackup,
onAddWord, onClear,
onRestartBackup, recoveryPhraseSorted,
} = this.props;

Expand Down Expand Up @@ -75,7 +75,6 @@ export default class WalletBackupDialog extends Component<Props> {
<WalletRecoveryPhraseEntryDialog
isTermDeviceAccepted={isTermDeviceAccepted}
enteredPhrase={enteredPhrase}
canFinishBackup={canFinishBackup}
isTermRecoveryAccepted={isTermRecoveryAccepted}
isValid={isValid}
isSubmitting={isSubmitting}
Expand All @@ -84,9 +83,10 @@ export default class WalletBackupDialog extends Component<Props> {
onAddWord={onAddWord}
onCancelBackup={onCancelBackup}
onClear={onClear}
onFinishBackup={onFinishBackup}
onRestartBackup={onRestartBackup}
recoveryPhraseSorted={recoveryPhraseSorted}
removeWord={removeWord}
hasWord={hasWord}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const messages = defineMessages({
defaultMessage: '!!!Tap each word in the correct order to verify your recovery phrase',
description: 'Instructions for verifying wallet recovery phrase on dialog for entering wallet recovery phrase.'
},
buttonLabelConfirm: {
id: 'wallet.recovery.phrase.show.entry.dialog.button.labelConfirm',
defaultMessage: '!!!Confirm',
description: 'Label for button "Confirm" on wallet backup dialog'
buttonLabelRemoveLast: {
id: 'wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast',
defaultMessage: '!!!Remove last',
description: 'Label for button "Remove Last" on wallet backup dialog'
},
buttonLabelClear: {
id: 'wallet.recovery.phrase.show.entry.dialog.button.labelClear',
Expand Down Expand Up @@ -51,13 +51,13 @@ type Props = {
isTermRecoveryAccepted: boolean,
isSubmitting: boolean,
onAddWord: Function,
canFinishBackup: boolean,
onClear: Function,
onAcceptTermDevice: Function,
onAcceptTermRecovery: Function,
onRestartBackup: Function,
onCancelBackup: Function,
onFinishBackup: Function,
removeWord: Function,
hasWord: Function
};

@observer
Expand All @@ -80,10 +80,10 @@ export default class WalletRecoveryPhraseEntryDialog extends Component<Props> {
onClear,
onAcceptTermDevice,
onAcceptTermRecovery,
canFinishBackup,
removeWord,
onRestartBackup,
onCancelBackup,
onFinishBackup
hasWord
} = this.props;
const dialogClasses = classnames([
styles.component,
Expand All @@ -95,10 +95,9 @@ export default class WalletRecoveryPhraseEntryDialog extends Component<Props> {
const actions = [];

actions.push({
className: isSubmitting ? styles.isSubmitting : null,
label: intl.formatMessage(messages.buttonLabelConfirm),
onClick: onFinishBackup,
disabled: !canFinishBackup,
label: intl.formatMessage(messages.buttonLabelRemoveLast),
ASUKA1006 marked this conversation as resolved.
Show resolved Hide resolved
onClick: removeWord,
disabled: !hasWord,
primary: true
});

Expand All @@ -107,6 +106,7 @@ export default class WalletRecoveryPhraseEntryDialog extends Component<Props> {
actions.unshift({
label: intl.formatMessage(messages.buttonLabelClear),
onClick: onClear,
primary: true
});
}

Expand Down
8 changes: 4 additions & 4 deletions app/containers/wallet/dialogs/WalletBackupDialogContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class WalletBackupDialogContainer extends Component<Props> {
acceptWalletBackupTermDevice,
acceptWalletBackupTermRecovery,
restartWalletBackup,
finishWalletBackup,
removeOneMnemonicWord,
acceptPrivacyNoticeForWalletBackup,
continueToRecoveryPhraseForWalletBackup
} = actions.walletBackup;
Expand All @@ -57,16 +57,16 @@ export default class WalletBackupDialogContainer extends Component<Props> {
// Props for WalletRecoveryPhraseEntryDialog
isTermDeviceAccepted={isTermDeviceAccepted}
enteredPhrase={enteredPhrase}
canFinishBackup={isRecoveryPhraseValid && isTermDeviceAccepted && isTermRecoveryAccepted}
hasWord={() => recoveryPhraseWords.length > 0}
isTermRecoveryAccepted={isTermRecoveryAccepted}
isValid={isRecoveryPhraseValid}
isSubmitting={createWalletRequest.isExecuting}
onAcceptTermDevice={acceptWalletBackupTermDevice.trigger}
onAcceptTermRecovery={acceptWalletBackupTermRecovery.trigger}
onAddWord={addWordToWalletBackupVerification.trigger}
onClear={clearEnteredRecoveryPhrase.trigger}
onFinishBackup={() => {
finishWalletBackup.trigger();
removeWord={() => {
removeOneMnemonicWord.trigger();
}}
onRestartBackup={restartWalletBackup.trigger}
recoveryPhraseSorted={recoveryPhraseSorted}
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "Ihre Wallet-Adresse",
"wallet.receive.page.walletReceiveInstructions": "Teile diese Wallet-Adresse mit, um Zahlungen zu erhalten. Um ihre Privatsphäre zu schützen, werden jedes Mal neue Adressen erzeugt, sobald sie genutzt worden sind.",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "Löschen",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "Bestätigen",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "do not translate",
"wallet.redeem.choices.tab.title.paperVended": "do not translate",
"wallet.redeem.choices.tab.title.recoveryForceVended": "do not translate",
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "Your wallet address",
"wallet.receive.page.walletReceiveInstructions": "Share this wallet address to receive payments. To protect your privacy, new addresses are generated automatically once you use them.",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "Clear",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "Confirm",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "Remove last",
"wallet.redeem.choices.tab.title.forceVended": "Force vended",
"wallet.redeem.choices.tab.title.paperVended": "Paper vended",
"wallet.redeem.choices.tab.title.recoveryForceVended": "Recovery - force vended",
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "Votre adresse de wallet",
"wallet.receive.page.walletReceiveInstructions": "Partagez cette adresse du wallet pour recevoir des paiements. Afin d'assurer votre sécurité, de nouvelles adresses sont générées à chaque utilisation.",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "Effacer",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "Confirmer",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "do not translate",
"wallet.redeem.choices.tab.title.paperVended": "do not translate",
"wallet.redeem.choices.tab.title.recoveryForceVended": "do not translate",
Expand Down
4 changes: 2 additions & 2 deletions app/i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "あなたのウォレットのアドレス",
"wallet.receive.page.walletReceiveInstructions": "上記アドレスを送信元に共有し、ADAの送金を依頼してください。セキュリティーの観点から、一度使用したアドレスを再度使用することはできません。新たなアドレスが自動的に生成されます。",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "クリア",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "確認",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "強制ヴェンド",
"wallet.redeem.choices.tab.title.paperVended": "紙ヴェンド",
"wallet.redeem.choices.tab.title.recoveryForceVended": "リカバリー:強制ヴェンド",
Expand Down Expand Up @@ -352,4 +352,4 @@
"wallet.trezor.error.101": "Trezor.ioへの接続に失敗しました。インターネット接続を確認して再試行してください。",
"wallet.trezor.error.102": "アクセス許可が得られませんでした。再試行してください。",
"wallet.trezor.error.103": "キャンセルされました。再試行してください。"
}
}
2 changes: 1 addition & 1 deletion app/i18n/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "내 지갑 주소",
"wallet.receive.page.walletReceiveInstructions": "돈을 받으려면 이 지갑 주소를 공유하십시오. 개인정보를 보호하기 위해 새 주소를 사용하면 새 주소가 자동으로 생성됩니다.",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "지우기",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "확인",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "강제 벤드",
"wallet.redeem.choices.tab.title.paperVended": "페이퍼 벤드",
"wallet.redeem.choices.tab.title.recoveryForceVended": "복구 - 강제 벤드",
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "Адрес Вашего кошелька",
"wallet.receive.page.walletReceiveInstructions": "Поделитесь данным адресом кошелька для получения платежей. Для защиты Вашей конфиденциальности, новые адреса генерируются автоматически после того, как Вы их использовали.",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "Очистить",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "Подтвердить",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "Форсированная продажа",
"wallet.redeem.choices.tab.title.paperVended": "Продажа документа",
"wallet.redeem.choices.tab.title.recoveryForceVended": "Восстановление - форсированная продажа",
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "您的钱包地址",
"wallet.receive.page.walletReceiveInstructions": "共享此钱包地址以接收付款。为保护您的隐私,在您使用地址后会自动生成新地址。",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "清除",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "确认",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "强行执行",
"wallet.redeem.choices.tab.title.paperVended": "Paper執行",
"wallet.redeem.choices.tab.title.recoveryForceVended": "强行恢复",
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"wallet.receive.page.walletAddressLabel": "您的錢包地址",
"wallet.receive.page.walletReceiveInstructions": "分享此錢包地址,以接收付款。為保護您的隱私,一旦使用,就會自動產生新地址。",
"wallet.recovery.phrase.show.entry.dialog.button.labelClear": "清除",
"wallet.recovery.phrase.show.entry.dialog.button.labelConfirm": "確認",
"wallet.recovery.phrase.show.entry.dialog.button.labelRemoveLast": "!!!Remove last",
"wallet.redeem.choices.tab.title.forceVended": "強行執行",
"wallet.redeem.choices.tab.title.paperVended": "Paper執行",
"wallet.redeem.choices.tab.title.recoveryForceVended": "強行恢復",
Expand Down
11 changes: 10 additions & 1 deletion app/stores/toplevel/WalletBackupStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WalletBackupStore extends Store {
a.restartWalletBackup.listen(this._restartWalletBackup);
a.cancelWalletBackup.listen(this._cancelWalletBackup);
a.finishWalletBackup.listen(this._finishWalletBackup);
a.removeOneMnemonicWord.listen(this._removeOneWord);
}

@action _initiateWalletBackup = (params: { recoveryPhrase: Array<string> }) => {
Expand Down Expand Up @@ -86,7 +87,7 @@ class WalletBackupStore extends Store {

@action _addWordToWalletBackupVerification = (params: { word: string, index: number }) => {
const { word, index } = params;
this.enteredPhrase.push({ word });
this.enteredPhrase.push({ word, index });
const pickedWord = this.recoveryPhraseSorted[index];
if (pickedWord && pickedWord.word === word) pickedWord.isActive = false;
};
Expand All @@ -98,6 +99,14 @@ class WalletBackupStore extends Store {
);
};

@action _removeOneWord = () => {
if (!this.enteredPhrase) {
return;
}
const poppedWord = this.enteredPhrase.pop();
this.recoveryPhraseSorted[poppedWord.index].isActive = true;
};

@computed get isRecoveryPhraseValid(): boolean {
return (
this.recoveryPhraseWords.reduce((words, { word }) => words + word, '') ===
Expand Down