Prevent user from accidentally triggering multiple identity resets (#29388)
* prevent user from accidentally triggering multiple identity resets * apply changes from review and update to latest design * Use a CSS class and compound variable * update snapshot * Update test/unit-tests/components/views/settings/encryption/ResetIdentityPanel-test.tsx --------- Co-authored-by: Richard van der Hoff <richard@matrix.org> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
co-authored by
Richard van der Hoff
Richard van der Hoff
parent
9d8efacede
commit
56c7fc1948
@@ -5,11 +5,11 @@
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { Breadcrumb, Button, VisualList, VisualListItem } from "@vector-im/compound-web";
|
||||
import { Breadcrumb, Button, InlineSpinner, VisualList, VisualListItem } from "@vector-im/compound-web";
|
||||
import CheckIcon from "@vector-im/compound-design-tokens/assets/web/icons/check";
|
||||
import InfoIcon from "@vector-im/compound-design-tokens/assets/web/icons/info";
|
||||
import ErrorIcon from "@vector-im/compound-design-tokens/assets/web/icons/error-solid";
|
||||
import React, { type MouseEventHandler } from "react";
|
||||
import React, { useState, type MouseEventHandler } from "react";
|
||||
|
||||
import { _t } from "../../../../languageHandler";
|
||||
import { EncryptionCard } from "./EncryptionCard";
|
||||
@@ -44,6 +44,10 @@ interface ResetIdentityPanelProps {
|
||||
export function ResetIdentityPanel({ onCancelClick, onFinish, variant }: ResetIdentityPanelProps): JSX.Element {
|
||||
const matrixClient = useMatrixClientContext();
|
||||
|
||||
// After the user clicks "Continue", we disable the button so it can't be
|
||||
// clicked again, and warn the user not to close the window.
|
||||
const [inProgress, setInProgress] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Breadcrumb
|
||||
@@ -78,18 +82,34 @@ export function ResetIdentityPanel({ onCancelClick, onFinish, variant }: ResetId
|
||||
<EncryptionCardButtons>
|
||||
<Button
|
||||
destructive={true}
|
||||
disabled={inProgress}
|
||||
onClick={async (evt) => {
|
||||
setInProgress(true);
|
||||
await matrixClient
|
||||
.getCrypto()
|
||||
?.resetEncryption((makeRequest) => uiAuthCallback(matrixClient, makeRequest));
|
||||
onFinish(evt);
|
||||
}}
|
||||
>
|
||||
{_t("action|continue")}
|
||||
</Button>
|
||||
<Button kind="tertiary" onClick={onCancelClick}>
|
||||
{_t("action|cancel")}
|
||||
{inProgress ? (
|
||||
<>
|
||||
<InlineSpinner /> {_t("settings|encryption|advanced|reset_in_progress")}
|
||||
</>
|
||||
) : (
|
||||
_t("action|continue")
|
||||
)}
|
||||
</Button>
|
||||
{inProgress ? (
|
||||
<EncryptionCardEmphasisedContent>
|
||||
<span className="mx_ResetIdentityPanel_warning">
|
||||
{_t("settings|encryption|advanced|do_not_close_warning")}
|
||||
</span>
|
||||
</EncryptionCardEmphasisedContent>
|
||||
) : (
|
||||
<Button kind="tertiary" onClick={onCancelClick}>
|
||||
{_t("action|cancel")}
|
||||
</Button>
|
||||
)}
|
||||
</EncryptionCardButtons>
|
||||
</EncryptionCard>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user