From c659afa8db8e0dde59dd96ea43e927b54bf72a11 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 6 Dec 2024 10:26:26 +0000 Subject: [PATCH] Rename CreateCrossSigningDialog to InitialCryptoSetupDialog (#28658) * Rename CreateCrossSigningDialog to InitialCryptoSetup because it will soon encompass things other than just creating cross signing. * Fix name & tests * Fix import * Remove code creating key backup Because this was split out from my key backup by default PR * Fix comment * Convert to named export --- src/components/structures/auth/E2eSetup.tsx | 4 ++-- ...ialog.tsx => InitialCryptoSetupDialog.tsx} | 24 +++++++++++-------- ....tsx => InitialCryptoSetupDialog-test.tsx} | 14 +++++------ 3 files changed, 23 insertions(+), 19 deletions(-) rename src/components/views/dialogs/security/{CreateCrossSigningDialog.tsx => InitialCryptoSetupDialog.tsx} (83%) rename test/components/views/dialogs/security/{CreateCrossSigningDialog-test.tsx => InitialCryptoSetupDialog-test.tsx} (91%) diff --git a/src/components/structures/auth/E2eSetup.tsx b/src/components/structures/auth/E2eSetup.tsx index 80a135fe19f..265905db107 100644 --- a/src/components/structures/auth/E2eSetup.tsx +++ b/src/components/structures/auth/E2eSetup.tsx @@ -11,7 +11,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix"; import AuthPage from "../../views/auth/AuthPage"; import CompleteSecurityBody from "../../views/auth/CompleteSecurityBody"; -import CreateCrossSigningDialog from "../../views/dialogs/security/CreateCrossSigningDialog"; +import { InitialCryptoSetupDialog } from "../../views/dialogs/security/InitialCryptoSetupDialog"; interface IProps { matrixClient: MatrixClient; @@ -25,7 +25,7 @@ export default class E2eSetup extends React.Component { return ( - = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => { +export const InitialCryptoSetupDialog: React.FC = ({ + matrixClient, + accountPassword, + tokenLogin, + onFinished, +}) => { const [error, setError] = useState(false); - const bootstrapCrossSigning = useCallback(async () => { + const doSetup = useCallback(async () => { const cryptoApi = matrixClient.getCrypto(); if (!cryptoApi) return; @@ -40,6 +45,7 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo try { await createCrossSigning(matrixClient, tokenLogin, accountPassword); + onFinished(true); } catch (e) { if (tokenLogin) { @@ -58,8 +64,8 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo }, [onFinished]); useEffect(() => { - bootstrapCrossSigning(); - }, [bootstrapCrossSigning]); + doSetup(); + }, [doSetup]); let content; if (error) { @@ -69,7 +75,7 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo
@@ -95,5 +101,3 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo ); }; - -export default CreateCrossSigningDialog; diff --git a/test/components/views/dialogs/security/CreateCrossSigningDialog-test.tsx b/test/components/views/dialogs/security/InitialCryptoSetupDialog-test.tsx similarity index 91% rename from test/components/views/dialogs/security/CreateCrossSigningDialog-test.tsx rename to test/components/views/dialogs/security/InitialCryptoSetupDialog-test.tsx index 3e5dc4eb94e..4d3d495a38d 100644 --- a/test/components/views/dialogs/security/CreateCrossSigningDialog-test.tsx +++ b/test/components/views/dialogs/security/InitialCryptoSetupDialog-test.tsx @@ -12,14 +12,14 @@ import { mocked } from "jest-mock"; import { MatrixClient } from "matrix-js-sdk/src/matrix"; import { createCrossSigning } from "../../../../../src/CreateCrossSigning"; -import CreateCrossSigningDialog from "../../../../../src/components/views/dialogs/security/CreateCrossSigningDialog"; +import { InitialCryptoSetupDialog } from "../../../../../src/components/views/dialogs/security/InitialCryptoSetupDialog"; import { createTestClient } from "../../../../test-utils"; jest.mock("../../../../../src/CreateCrossSigning", () => ({ createCrossSigning: jest.fn(), })); -describe("CreateCrossSigningDialog", () => { +describe("InitialCryptoSetupDialog", () => { let client: MatrixClient; let createCrossSigningResolve: () => void; let createCrossSigningReject: (e: Error) => void; @@ -43,7 +43,7 @@ describe("CreateCrossSigningDialog", () => { const onFinished = jest.fn(); render( - { it("should display an error if createCrossSigning fails", async () => { render( - { const onFinished = jest.fn(); render( - { const onFinished = jest.fn(); render( - { it("should retry when the retry button is clicked", async () => { render( -