5
5
* Please see LICENSE files in the repository root for full details.
6
6
*/
7
7
8
- import { Breadcrumb , Button , InlineSpinner , VisualList , VisualListItem } from "@vector-im/compound-web" ;
9
- import CheckIcon from "@vector-im/compound-design-tokens/assets/web/icons/check" ;
10
- import InfoIcon from "@vector-im/compound-design-tokens/assets/web/icons/info" ;
11
- import ErrorIcon from "@vector-im/compound-design-tokens/assets/web/icons/error-solid" ;
12
- import React , { type JSX , useState , type MouseEventHandler } from "react" ;
8
+ import { Breadcrumb } from "@vector-im/compound-web" ;
9
+ import React , { type JSX , type MouseEventHandler } from "react" ;
13
10
14
11
import { _t } from "../../../../languageHandler" ;
15
- import { EncryptionCard } from "./EncryptionCard" ;
16
- import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext" ;
17
- import { uiAuthCallback } from "../../../../CreateCrossSigning" ;
18
- import { EncryptionCardButtons } from "./EncryptionCardButtons" ;
19
- import { EncryptionCardEmphasisedContent } from "./EncryptionCardEmphasisedContent" ;
12
+ import { ResetIdentityBody , type ResetIdentityBodyVariant } from "./ResetIdentityBody" ;
20
13
21
14
interface ResetIdentityPanelProps {
22
15
/**
@@ -29,33 +22,17 @@ interface ResetIdentityPanelProps {
29
22
onCancelClick : ( ) => void ;
30
23
31
24
/**
32
- * The variant of the panel to show. We show more warnings in the 'compromised' variant (no use in showing a user
33
- * this warning if they have to reset because they no longer have their key)
25
+ * Which variant of this panel to show.
34
26
*/
35
- variant : ResetIdentityPanelVariant ;
27
+ variant : ResetIdentityBodyVariant ;
36
28
}
37
29
38
30
/**
39
- * "compromised" is shown when the user chooses 'reset' explicitly in settings, usually because they believe their
40
- * identity has been compromised.
31
+ * The Encryption Settings panel for resetting the identity of the current user.
41
32
*
42
- * "sync_failed" is shown when the user tried to recover their identity but the process failed, probably because
43
- * the required information is missing from recovery.
44
- *
45
- * "forgot" is shown when the user has just forgotten their passphrase.
46
- */
47
- export type ResetIdentityPanelVariant = "compromised" | "forgot" | "sync_failed" ;
48
-
49
- /**
50
- * The panel for resetting the identity of the current user.
33
+ * A thin wrapper around {@link ResetIdentityBody}, just adding breadcrumbs.
51
34
*/
52
35
export function ResetIdentityPanel ( { onCancelClick, onFinish, variant } : ResetIdentityPanelProps ) : JSX . Element {
53
- const matrixClient = useMatrixClientContext ( ) ;
54
-
55
- // After the user clicks "Continue", we disable the button so it can't be
56
- // clicked again, and warn the user not to close the window.
57
- const [ inProgress , setInProgress ] = useState ( false ) ;
58
-
59
36
return (
60
37
< >
61
38
< Breadcrumb
@@ -64,67 +41,7 @@ export function ResetIdentityPanel({ onCancelClick, onFinish, variant }: ResetId
64
41
pages = { [ _t ( "settings|encryption|title" ) , _t ( "settings|encryption|advanced|breadcrumb_page" ) ] }
65
42
onPageClick = { onCancelClick }
66
43
/>
67
- < EncryptionCard Icon = { ErrorIcon } destructive = { true } title = { titleForVariant ( variant ) } >
68
- < EncryptionCardEmphasisedContent >
69
- < VisualList >
70
- < VisualListItem Icon = { CheckIcon } success = { true } >
71
- { _t ( "settings|encryption|advanced|breadcrumb_first_description" ) }
72
- </ VisualListItem >
73
- < VisualListItem Icon = { InfoIcon } >
74
- { _t ( "settings|encryption|advanced|breadcrumb_second_description" ) }
75
- </ VisualListItem >
76
- < VisualListItem Icon = { InfoIcon } >
77
- { _t ( "settings|encryption|advanced|breadcrumb_third_description" ) }
78
- </ VisualListItem >
79
- </ VisualList >
80
- { variant === "compromised" && < span > { _t ( "settings|encryption|advanced|breadcrumb_warning" ) } </ span > }
81
- </ EncryptionCardEmphasisedContent >
82
- < EncryptionCardButtons >
83
- < Button
84
- destructive = { true }
85
- disabled = { inProgress }
86
- onClick = { async ( evt ) => {
87
- setInProgress ( true ) ;
88
- await matrixClient
89
- . getCrypto ( )
90
- ?. resetEncryption ( ( makeRequest ) => uiAuthCallback ( matrixClient , makeRequest ) ) ;
91
- onFinish ( evt ) ;
92
- } }
93
- >
94
- { inProgress ? (
95
- < >
96
- < InlineSpinner /> { _t ( "settings|encryption|advanced|reset_in_progress" ) }
97
- </ >
98
- ) : (
99
- _t ( "action|continue" )
100
- ) }
101
- </ Button >
102
- { inProgress ? (
103
- < EncryptionCardEmphasisedContent >
104
- < span className = "mx_ResetIdentityPanel_warning" >
105
- { _t ( "settings|encryption|advanced|do_not_close_warning" ) }
106
- </ span >
107
- </ EncryptionCardEmphasisedContent >
108
- ) : (
109
- < Button kind = "tertiary" onClick = { onCancelClick } >
110
- { _t ( "action|cancel" ) }
111
- </ Button >
112
- ) }
113
- </ EncryptionCardButtons >
114
- </ EncryptionCard >
44
+ < ResetIdentityBody onFinish = { onFinish } onCancelClick = { onCancelClick } variant = { variant } />
115
45
</ >
116
46
) ;
117
47
}
118
-
119
- function titleForVariant ( variant : ResetIdentityPanelVariant ) : string {
120
- switch ( variant ) {
121
- case "compromised" :
122
- return _t ( "settings|encryption|advanced|breadcrumb_title" ) ;
123
- case "sync_failed" :
124
- return _t ( "settings|encryption|advanced|breadcrumb_title_sync_failed" ) ;
125
-
126
- default :
127
- case "forgot" :
128
- return _t ( "settings|encryption|advanced|breadcrumb_title_forgot" ) ;
129
- }
130
- }
0 commit comments