From a81e2f02e5df3790e728d592708faa33ba2d1d33 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Fri, 10 Jul 2020 12:40:20 +0200 Subject: [PATCH] feat: reword storage upgrade migration --- app/assets/javascripts/strings.ts | 5 ++ .../views/challenge_modal/challenge-modal.pug | 11 ++-- .../views/challenge_modal/challenge_modal.ts | 54 +++++++++++++++---- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index 98a31cb53..0ce2880ca 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -46,6 +46,11 @@ export const STRING_INVALID_IMPORT_FILE = "Unable to open file. Ensure it is a p export function StringImportError(errorCount: number) { return `Import complete. ${errorCount} items were not imported because there was an error decrypting them. Make sure the password is correct and try again.`; } +export const STRING_ENTER_ACCOUNT_PASSCODE = 'Enter your application passcode'; +export const STRING_ENTER_ACCOUNT_PASSWORD = 'Enter your account password'; +export const STRING_ENTER_PASSCODE_FOR_MIGRATION = 'Your application passcode is required to perform an upgrade of your local data storage structure.'; +export const STRING_STORAGE_UPDATE = 'Storage Update'; +export const STRING_AUTHENTICATION_REQUIRED = 'Authentication Required'; /** @password_change */ export const STRING_FAILED_PASSWORD_CHANGE = "There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup."; diff --git a/app/assets/javascripts/views/challenge_modal/challenge-modal.pug b/app/assets/javascripts/views/challenge_modal/challenge-modal.pug index 9e1fcef49..9ad61505e 100644 --- a/app/assets/javascripts/views/challenge_modal/challenge-modal.pug +++ b/app/assets/javascripts/views/challenge_modal/challenge-modal.pug @@ -3,11 +3,7 @@ .sn-component .sk-panel .sk-panel-header - .sk-panel-header-title Authentication Required - a.close-button.info( - ng-if="ctrl.cancelable" - ng-click="ctrl.cancel()" - ) Cancel + .sk-panel-header-title {{ctrl.title}} .sk-panel-content .sk-panel-section div(ng-repeat="type in ctrl.state.types") @@ -33,6 +29,11 @@ ng-disabled="ctrl.state.processing" ) .sk-label {{ctrl.state.processing ? 'Generating Keys...' : 'Submit'}} + .sk-panel-row(ng-if="ctrl.cancelable") + a.sk-panel-row.sk-a.info.centered( + ng-if="ctrl.cancelable" + ng-click="ctrl.cancel()" + ) Cancel .sk-panel-footer(ng-if="ctrl.state.showForgotPasscodeLink") a.sk-panel-row.sk-a.info.centered( diff --git a/app/assets/javascripts/views/challenge_modal/challenge_modal.ts b/app/assets/javascripts/views/challenge_modal/challenge_modal.ts index 2c372776c..d054414bf 100644 --- a/app/assets/javascripts/views/challenge_modal/challenge_modal.ts +++ b/app/assets/javascripts/views/challenge_modal/challenge_modal.ts @@ -10,7 +10,14 @@ import { import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; import { WebDirective } from '@/types'; import { confirmDialog } from '@/services/alertService'; -import { STRING_SIGN_OUT_CONFIRMATION } from '@/strings'; +import { + STRING_SIGN_OUT_CONFIRMATION, + STRING_ENTER_ACCOUNT_PASSCODE, + STRING_ENTER_ACCOUNT_PASSWORD, + STRING_ENTER_PASSCODE_FOR_MIGRATION, + STRING_STORAGE_UPDATE, + STRING_AUTHENTICATION_REQUIRED +} from '@/strings'; type InputValue = { value: string @@ -57,7 +64,25 @@ class ChallengeModalCtrl extends PureViewCtrl { invalid: false }; } - const showForgotPasscodeLink = this.challenge.reason === ChallengeReason.ApplicationUnlock + let showForgotPasscodeLink: boolean; + switch (this.challenge.reason) { + case ChallengeReason.ApplicationUnlock: + showForgotPasscodeLink = true; + this.cancelable = false; + break; + case ChallengeReason.Migration: + showForgotPasscodeLink = true; + this.cancelable = false; + break; + case ChallengeReason.ProtocolUpgrade: + showForgotPasscodeLink = false; + this.cancelable = true; + break; + case ChallengeReason.ResaveRootKey: + showForgotPasscodeLink = false; + this.cancelable = true; + break; + } this.cancelable = !showForgotPasscodeLink this.setState({ types, @@ -97,11 +122,22 @@ class ChallengeModalCtrl extends PureViewCtrl { }); } - promptForChallenge(challenge: ChallengeType) { - if (challenge === ChallengeType.LocalPasscode) { - return 'Enter your application passcode'; + get title(): string { + if (this.challenge.reason === ChallengeReason.Migration) { + return STRING_STORAGE_UPDATE; } else { - return 'Enter your account password'; + return STRING_AUTHENTICATION_REQUIRED; + } + } + + promptForChallenge(challenge: ChallengeType): string { + if (challenge === ChallengeType.LocalPasscode) { + if (this.challenge.reason === ChallengeReason.Migration) { + return STRING_ENTER_PASSCODE_FOR_MIGRATION; + } + return STRING_ENTER_ACCOUNT_PASSCODE; + } else { + return STRING_ENTER_ACCOUNT_PASSWORD; } } @@ -116,10 +152,10 @@ class ChallengeModalCtrl extends PureViewCtrl { } cancel() { - if (!this.cancelable) { - return; + if (this.cancelable) { + this.application!.cancelChallenge(this.challenge); + this.dismiss(); } - this.dismiss(); } onForgotPasscodeClick() {