Skip to content

Commit 9d42a81

Browse files
authored
Merge pull request element-hq#4301 from vector-im/luke/set-email-after-password-2
Ask for email address after setting password for the first time
2 parents 7af2a6c + 4f55f81 commit 9d42a81

3 files changed

Lines changed: 83 additions & 27 deletions

File tree

‎src/components/views/dialogs/SetPasswordDialog.js‎

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,42 @@ limitations under the License.
1717
import React from 'react';
1818
import sdk from 'matrix-react-sdk';
1919
import { _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">

‎src/skins/vector/css/_components.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
@import "./vector-web/views/context_menus/_MessageContextMenu.scss";
7272
@import "./vector-web/views/context_menus/_RoomTileContextMenu.scss";
7373
@import "./vector-web/views/dialogs/_ChangelogDialog.scss";
74+
@import "./vector-web/views/dialogs/_SetEmailDialog.scss";
7475
@import "./vector-web/views/dialogs/_SetPasswordDialog.scss";
7576
@import "./vector-web/views/directory/_NetworkDropdown.scss";
7677
@import "./vector-web/views/elements/_ImageView.scss";
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2017 Vector Creations Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_SetEmailDialog_email_input {
18+
border-radius: 3px;
19+
border: 1px solid $input-border-color;
20+
padding: 9px;
21+
color: $input-fg-color;
22+
background-color: $primary-bg-color;
23+
font-size: 15px;
24+
width: 100%;
25+
max-width: 280px;
26+
margin-bottom: 10px;
27+
}
28+
29+
.mx_SetEmailDialog_email_input:focus {
30+
outline: none;
31+
box-shadow: none;
32+
border: 1px solid $accent-color;
33+
}
34+
35+
.mx_SetEmailDialog_email_input_placeholder {
36+
}

0 commit comments

Comments
 (0)