-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add key storage delete confirm screen
- Loading branch information
Showing
4 changed files
with
103 additions
and
8 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
src/components/views/settings/encryption/DeleteKeyStoragePanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { Breadcrumb, Button, VisualList, VisualListItem } from "@vector-im/compound-web"; | ||
import CrossIcon from "@vector-im/compound-design-tokens/assets/web/icons/close"; | ||
import ErrorIcon from "@vector-im/compound-design-tokens/assets/web/icons/error"; | ||
import React, { useCallback, useState } from "react"; | ||
|
||
import { _t } from "../../../../languageHandler"; | ||
import { EncryptionCard } from "./EncryptionCard"; | ||
import { useKeyStoragePanelViewModel } from "../../../viewmodels/settings/encryption/KeyStoragePanelViewModel"; | ||
|
||
interface ResetIdentityPanelProps { | ||
onFinish: () => void; | ||
} | ||
|
||
/** | ||
* Confirms that the user really wants to turn off and delete their key storage | ||
*/ | ||
export function DeleteKeyStoragePanel({ onFinish }: ResetIdentityPanelProps): JSX.Element { | ||
const { setEnabled } = useKeyStoragePanelViewModel(); | ||
const [busy, setBusy] = useState(false); | ||
|
||
const onDeleteClick = useCallback(async () => { | ||
setBusy(true); | ||
try { | ||
await setEnabled(false); | ||
} finally { | ||
setBusy(false); | ||
} | ||
onFinish(); | ||
}, [setEnabled, onFinish]); | ||
|
||
return ( | ||
<> | ||
<Breadcrumb | ||
backLabel={_t("action|back")} | ||
onBackClick={onFinish} | ||
pages={[_t("settings|encryption|title"), _t("settings|encryption|delete_key_storage|breadcrumb_page")]} | ||
onPageClick={onFinish} | ||
/> | ||
<EncryptionCard | ||
Icon={ErrorIcon} | ||
destructive={true} | ||
title={_t("settings|encryption|delete_key_storage|title")} | ||
className="mx_ResetIdentityPanel" | ||
> | ||
<div className="mx_ResetIdentityPanel_content"> | ||
{_t("settings|encryption|delete_key_storage|description")} | ||
<VisualList> | ||
<VisualListItem Icon={CrossIcon} destructive={true}> | ||
{_t("settings|encryption|delete_key_storage|list_first")} | ||
</VisualListItem> | ||
<VisualListItem Icon={CrossIcon} destructive={true}> | ||
{_t("settings|encryption|delete_key_storage|list_second")} | ||
</VisualListItem> | ||
</VisualList> | ||
</div> | ||
<div className="mx_ResetIdentityPanel_footer"> | ||
<Button destructive={true} onClick={onDeleteClick} disabled={busy}> | ||
{_t("settings|encryption|delete_key_storage|confirm")} | ||
</Button> | ||
<Button kind="tertiary" onClick={onFinish}> | ||
{_t("action|cancel")} | ||
</Button> | ||
</div> | ||
</EncryptionCard> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters