Skip to content

Commit

Permalink
feat(crypto settings): Add "Forgot recovery key?" button to encryptio…
Browse files Browse the repository at this point in the history
…n tab
  • Loading branch information
florianduros committed Feb 5, 2025
1 parent 4a381c2 commit 73e59df
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions res/css/_components.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
@import "./views/settings/encryption/_AdvancedPanel.pcss";
@import "./views/settings/encryption/_ChangeRecoveryKey.pcss";
@import "./views/settings/encryption/_EncryptionCard.pcss";
@import "./views/settings/encryption/_RecoveryPanelOutOfSync.pcss";
@import "./views/settings/encryption/_ResetIdentityPanel.pcss";
@import "./views/settings/tabs/_SettingsBanner.pcss";
@import "./views/settings/tabs/_SettingsIndent.pcss";
Expand Down
11 changes: 11 additions & 0 deletions res/css/views/settings/encryption/_RecoveryPanelOutOfSync.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/

.mx_RecoveryPanelOutOfSync {
display: flex;
gap: var(--cpd-space-2x);
}
33 changes: 21 additions & 12 deletions src/components/views/settings/encryption/RecoveryPanelOutOfSync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ interface RecoveryPanelOutOfSyncProps {
* Callback for when the user has finished entering their recovery key.
*/
onFinish: () => void;
/**
* Callback for when the user clicks on the "Forgot recovery key?" button.
*/
onForgotRecoveryKey: () => void;
}

/**
Expand All @@ -28,7 +32,7 @@ interface RecoveryPanelOutOfSyncProps {
* It prompts the user to enter their recovery key so that the secrets can be loaded from 4S into
* the client.
*/
export function RecoveryPanelOutOfSync({ onFinish }: RecoveryPanelOutOfSyncProps): JSX.Element {
export function RecoveryPanelOutOfSync({ onForgotRecoveryKey, onFinish }: RecoveryPanelOutOfSyncProps): JSX.Element {
return (
<SettingsSection
legacy={false}
Expand All @@ -42,17 +46,22 @@ export function RecoveryPanelOutOfSync({ onFinish }: RecoveryPanelOutOfSyncProps
}
data-testid="recoveryPanel"
>
<Button
size="sm"
kind="primary"
Icon={KeyIcon}
onClick={async () => {
await accessSecretStorage();
onFinish();
}}
>
{_t("settings|encryption|recovery|enter_recovery_key")}
</Button>
<div className="mx_RecoveryPanelOutOfSync">
<Button size="sm" kind="secondary" onClick={onForgotRecoveryKey}>
{_t("settings|encryption|recovery|forgot_recovery_key")}
</Button>
<Button
size="sm"
kind="primary"
Icon={KeyIcon}
onClick={async () => {
await accessSecretStorage();
onFinish();
}}
>
{_t("settings|encryption|recovery|enter_recovery_key")}
</Button>
</div>
</SettingsSection>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export function EncryptionUserSettingsTab({ initialState = "loading" }: Encrypti
content = <SetUpEncryptionPanel onFinish={checkEncryptionState} />;
break;
case "secrets_not_cached":
content = <RecoveryPanelOutOfSync onFinish={checkEncryptionState} />;
content = (
<RecoveryPanelOutOfSync
onFinish={checkEncryptionState}
onForgotRecoveryKey={() => setState("reset_identity_forgot")}
/>
);
break;
case "main":
content = (
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,7 @@
"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",
"forgot_recovery_key": "Forgot recovery key?",
"key_storage_warning": "Your key storage is out of sync. Click the button below to fix the problem.",
"save_key_description": "Do not share this with anyone!",
"save_key_title": "Recovery key",
Expand Down

0 comments on commit 73e59df

Please sign in to comment.