@@ -17,7 +17,42 @@ limitations under the License.
1717import React from 'react' ;
1818import sdk from 'matrix-react-sdk' ;
1919import { _t } from 'matrix-react-sdk/lib/languageHandler' ;
20+ import Modal from 'matrix-react-sdk/lib/Modal' ;
2021
22+ const WarmFuzzy = function ( props ) {
23+ const BaseDialog = sdk . getComponent ( 'views.dialogs.BaseDialog' ) ;
24+ let title = _t ( 'You have successfully set a password!' ) ;
25+ if ( props . didSetEmail ) {
26+ title = _t ( 'You have successfully set a password and an email address!' ) ;
27+ }
28+ const advice = _t ( 'You can now return to your account after signing out, and sign in on other devices.' ) ;
29+ let extraAdvice = null ;
30+ if ( ! props . didSetEmail ) {
31+ extraAdvice = _t ( 'Remember, you can always set an email address in user settings if you change your mind.' ) ;
32+ }
33+
34+ return < BaseDialog className = "mx_SetPasswordDialog"
35+ onFinished = { props . onFinished }
36+ title = { title }
37+ >
38+ < div className = "mx_Dialog_content" >
39+ < p >
40+ { advice }
41+ </ p >
42+ < p >
43+ { extraAdvice }
44+ </ p >
45+ </ div >
46+ < div className = "mx_Dialog_buttons" >
47+ < button
48+ className = "mx_Dialog_primary"
49+ autoFocus = { true }
50+ onClick = { props . onFinished } >
51+ { _t ( 'Continue' ) }
52+ </ button >
53+ </ div >
54+ </ BaseDialog > ;
55+ } ;
2156
2257/**
2358 * Prompt the user to set a password
@@ -33,13 +68,19 @@ export default React.createClass({
3368 getInitialState : function ( ) {
3469 return {
3570 error : null ,
36- success : false ,
3771 } ;
3872 } ,
3973
40- _onPasswordChanged : function ( ) {
41- this . setState ( {
42- success : true ,
74+ componentWillMount : function ( ) {
75+ console . info ( 'SetPasswordDialog component will mount' ) ;
76+ } ,
77+
78+ _onPasswordChanged : function ( res ) {
79+ Modal . createDialog ( WarmFuzzy , {
80+ didSetEmail : res . didSetEmail ,
81+ onFinished : ( ) => {
82+ this . _onContinueClicked ( ) ;
83+ } ,
4384 } ) ;
4485 } ,
4586
@@ -66,29 +107,6 @@ export default React.createClass({
66107 const BaseDialog = sdk . getComponent ( 'views.dialogs.BaseDialog' ) ;
67108 const ChangePassword = sdk . getComponent ( 'views.settings.ChangePassword' ) ;
68109
69- if ( this . state . success ) {
70- return (
71- < BaseDialog className = "mx_SetPasswordDialog"
72- onFinished = { this . props . onFinished }
73- title = { _t ( 'You have successfully set a password!' ) }
74- >
75- < div className = "mx_Dialog_content" >
76- < p >
77- { _t ( 'You can now return to your account after signing out, and sign in on other devices.' ) }
78- </ p >
79- </ div >
80- < div className = "mx_Dialog_buttons" >
81- < button
82- className = "mx_Dialog_primary"
83- autoFocus = { true }
84- onClick = { this . _onContinueClicked } >
85- { _t ( 'Continue' ) }
86- </ button >
87- </ div >
88- </ BaseDialog >
89- ) ;
90- }
91-
92110 return (
93111 < BaseDialog className = "mx_SetPasswordDialog"
94112 onFinished = { this . props . onFinished }
@@ -106,6 +124,7 @@ export default React.createClass({
106124 buttonClassName = "mx_Dialog_primary mx_SetPasswordDialog_change_password_button"
107125 confirm = { false }
108126 autoFocusNewPasswordInput = { true }
127+ shouldAskForEmail = { true }
109128 onError = { this . _onPasswordChangeError }
110129 onFinished = { this . _onPasswordChanged } />
111130 < div className = "error" >
0 commit comments