From cbf06fda5b97199e5b556e9462194be9bbc99116 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Fri, 10 Jan 2025 16:08:35 +0100 Subject: [PATCH] Use new labels when changing the recovery key --- .../settings/encryption/ChangeRecoveryKey.tsx | 45 +++++++++++++++---- src/i18n/strings/en_EN.json | 11 +++-- .../ChangeRecoveryKey-test.tsx.snap | 2 +- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/components/views/settings/encryption/ChangeRecoveryKey.tsx b/src/components/views/settings/encryption/ChangeRecoveryKey.tsx index 630f7ac8a9d..511acc32233 100644 --- a/src/components/views/settings/encryption/ChangeRecoveryKey.tsx +++ b/src/components/views/settings/encryption/ChangeRecoveryKey.tsx @@ -32,9 +32,15 @@ import { withSecretStorageKeyCache } from "../../../../SecurityManager"; * - `inform_user`: The user is informed about the recovery key. * - `save_key_setup_flow`: The user is asked to save the new recovery key during the setup flow. * - `save_key_change_flow`: The user is asked to save the new recovery key during the change key flow. - * - `confirm`: The user is asked to confirm the new recovery key. + * - `confirm_key_setup_flow`: The user is asked to confirm the new recovery key during the set up flow. + * - `confirm_key_change_flow`: The user is asked to confirm the new recovery key during the change key flow. */ -type State = "inform_user" | "save_key_setup_flow" | "save_key_change_flow" | "confirm"; +type State = + | "inform_user" + | "save_key_setup_flow" + | "save_key_change_flow" + | "confirm_key_setup_flow" + | "confirm_key_change_flow"; interface ChangeRecoveryKeyProps { /** @@ -89,12 +95,19 @@ export function ChangeRecoveryKey({ setState("confirm")} + onConfirmClick={() => + setState((currentState) => + currentState === "save_key_change_flow" + ? "confirm_key_change_flow" + : "confirm_key_setup_flow", + ) + } onCancelClick={onCancelClick} /> ); break; - case "confirm": + case "confirm_key_setup_flow": + case "confirm_key_change_flow": // Ask the user to enter the recovery key they just save to confirm it. content = ( ); } @@ -181,10 +199,15 @@ function getLabels(state: State): Labels { title: _t("settings|encryption|recovery|change_recovery_key_title"), description: _t("settings|encryption|recovery|change_recovery_key_description"), }; - case "confirm": + case "confirm_key_setup_flow": return { - title: _t("settings|encryption|recovery|confirm_title"), - description: _t("settings|encryption|recovery|confirm_description"), + title: _t("settings|encryption|recovery|set_up_recovery_confirm_title"), + description: _t("settings|encryption|recovery|set_up_recovery_confirm_description"), + }; + case "confirm_key_change_flow": + return { + title: _t("settings|encryption|recovery|change_recovery_confirm_title"), + description: _t("settings|encryption|recovery|change_recovery_confirm_description"), }; } } @@ -279,6 +302,10 @@ interface KeyFormProps { * The recovery key to confirm. */ recoveryKey: string; + /** + * The label for the submit button. + */ + submitButtonLabel: string; } /** @@ -286,7 +313,7 @@ interface KeyFormProps { * The finish button is disabled until the key is filled and valid. * The entered key is valid if it matches the recovery key. */ -function KeyForm({ onCancelClick, onSubmit, recoveryKey }: KeyFormProps): JSX.Element { +function KeyForm({ onCancelClick, onSubmit, recoveryKey, submitButtonLabel }: KeyFormProps): JSX.Element { // Undefined by default, as the key is not filled yet const [isKeyValid, setIsKeyValid] = useState(); const isKeyInvalidAndFilled = isKeyValid === false; @@ -316,7 +343,7 @@ function KeyForm({ onCancelClick, onSubmit, recoveryKey }: KeyFormProps): JSX.El )}
- + diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 13001ee9704..81241c771f0 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2472,12 +2472,12 @@ "device_not_verified_title": "Device not verified", "dialog_title": "Settings: Encryption", "recovery": { + "change_recovery_confirm_button": "Confirm new recovery key", + "change_recovery_confirm_description": "Enter your new recovery key below to finish. Your old one will no longer work.", + "change_recovery_confirm_title": "Enter your new recovery key", "change_recovery_key": "Change recovery key", - "change_recovery_key_description": "Get a new recovery key if you've lost your existing one. After changing your recovery key, your old one will no longer work.", + "change_recovery_key_description": "Write down this new recovery key somewhere safe. Then click Continue to confirm the change.", "change_recovery_key_title": "Change recovery key?", - "confirm_description": "Enter the recovery key shown on the previous screen to finish setting up recovery.", - "confirm_finish": "Finish set up", - "confirm_title": "Enter your recovery key to confirm", "description": "Recover your cryptographic identity and message history with a recovery key if you’ve lost all your existing devices.", "enter_key_error": "The recovery key you entered is not correct.", "enter_recovery_key": "Enter recovery key", @@ -2485,6 +2485,9 @@ "save_key_description": "Do not share this with anyone!", "save_key_title": "Recovery key", "set_up_recovery": "Set up recovery", + "set_up_recovery_confirm_button": "Finish set up", + "set_up_recovery_confirm_description": "Enter the recovery key shown on the previous screen to finish setting up recovery.", + "set_up_recovery_confirm_title": "Enter your recovery key to confirm", "set_up_recovery_description": "Your key storage is protected by a recovery key. If you need a new recovery key after setup, you can recreate it by selecting ‘%(changeRecoveryKeyButton)s’.", "set_up_recovery_save_key_description": "Write down this recovery key somewhere safe, like a password manager, encrypted note, or a physical safe.", "set_up_recovery_save_key_title": "Save your recovery key somewhere safe", diff --git a/test/unit-tests/components/views/settings/encryption/__snapshots__/ChangeRecoveryKey-test.tsx.snap b/test/unit-tests/components/views/settings/encryption/__snapshots__/ChangeRecoveryKey-test.tsx.snap index ee18396e448..0719c6cc531 100644 --- a/test/unit-tests/components/views/settings/encryption/__snapshots__/ChangeRecoveryKey-test.tsx.snap +++ b/test/unit-tests/components/views/settings/encryption/__snapshots__/ChangeRecoveryKey-test.tsx.snap @@ -82,7 +82,7 @@ exports[` flow to change the recovery key should display th Change recovery key? - Get a new recovery key if you've lost your existing one. After changing your recovery key, your old one will no longer work. + Write down this new recovery key somewhere safe. Then click Continue to confirm the change.