Skip to content

Commit 73a1c2b

Browse files
committed
Merge pull request element-hq#5 from matrix-org/user_settings
User settings
2 parents 139b92f + 5d9db52 commit 73a1c2b

17 files changed

Lines changed: 603 additions & 15 deletions

File tree

‎skins/base/css/common.css‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,31 @@ h2 {
3333
margin-top: 16px;
3434
margin-bottom: 16px;
3535
}
36+
37+
.mx_Dialog_Background {
38+
position: fixed;
39+
top: 0;
40+
left: 0;
41+
width: 100%;
42+
height: 100%;
43+
background-color: #ccc;
44+
opacity: 0.5;
45+
z-index: -200;
46+
}
47+
48+
.mx_Dialog_Wrapper {
49+
position: fixed;
50+
top: 0;
51+
left: 0;
52+
width: 100%;
53+
height: 100%;
54+
}
55+
56+
.mx_Dialog {
57+
background-color: #fff;
58+
margin: auto;
59+
max-width: 500px;
60+
z-index: -100;
61+
position: relative;
62+
top: 100px;
63+
}

‎skins/base/css/organisms/RoomView.css‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ limitations under the License.
2424
display: -webkit-flex;
2525
display: flex;
2626
width: 100%;
27+
height: 100%;
2728
flex-direction: column;
2829
-webkit-flex-direction: column;
2930
}
@@ -65,7 +66,7 @@ limitations under the License.
6566
margin-bottom: 60px;
6667
/* background-color: #ff0; */
6768

68-
overflow-y: scroll;
69+
overflow-y: scroll;
6970
}
7071

7172
.mx_RoomView_messageListWrapper {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2015 OpenMarket 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_UserSettings {
18+
max-width: 720px;
19+
margin: auto;
20+
}

‎skins/base/css/pages/MatrixChat.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ limitations under the License.
3838
height: 100%;
3939
}
4040

41-
.mx_MatrixChat .mx_RoomView {
41+
.mx_MatrixChat .mx_MatrixChat_MiddleView {
4242
-webkit-box-ordinal-group: 2;
4343
-moz-box-ordinal-group: 2;
4444
-ms-flex-order: 2;
@@ -47,7 +47,7 @@ limitations under the License.
4747

4848
background-color: #f3f8fa;
4949
width: 100%;
50-
height: 100%;
50+
height: 100%;
5151
}
5252

5353
.mx_MatrixChat .mx_RightPanel {
@@ -60,5 +60,5 @@ limitations under the License.
6060
background-color: #f3f8fa;
6161
-webkit-flex: 0 0 230px;
6262
flex: 0 0 230px;
63-
height: 100%;
63+
height: 100%;
6464
}

‎skins/base/views/atoms/EditableText.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,22 @@ module.exports = React.createClass({
4343
},
4444

4545
onFinish: function(ev) {
46-
this.setValue(ev.target.value);
46+
if (ev.target.value) {
47+
this.setValue(ev.target.value);
48+
} else {
49+
this.cancelEdit();
50+
}
4751
},
4852

4953
render: function() {
5054
var editable_el;
5155

5256
if (this.state.phase == this.Phases.Display) {
53-
editable_el = <div ref="display_div" onClick={this.onClickDiv}>{this.state.value}</div>;
57+
if (this.state.value) {
58+
editable_el = <div ref="display_div" onClick={this.onClickDiv}>{this.state.value}</div>;
59+
} else {
60+
editable_el = <div ref="display_div" onClick={this.onClickDiv}><i>{this.props.placeHolder}</i></div>;
61+
}
5462
} else if (this.state.phase == this.Phases.Edit) {
5563
editable_el = (
5664
<div>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright 2015 OpenMarket 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+
'use strict';
18+
19+
var React = require('react');
20+
21+
var ChangeAvatarController = require("../../../../src/controllers/molecules/ChangeAvatar");
22+
23+
24+
module.exports = React.createClass({
25+
displayName: 'ChangeAvatar',
26+
mixins: [ChangeAvatarController],
27+
28+
render: function() {
29+
switch (this.state.phase) {
30+
case this.Phases.Display:
31+
case this.Phases.Error:
32+
return (
33+
<div>
34+
<img src={this.state.avatarUrl} />
35+
<div>
36+
<button>Upload new</button>
37+
<button onClick={this.props.onFinished}>Cancel</button>
38+
</div>
39+
</div>
40+
);
41+
case this.Phases.Uploading:
42+
return (
43+
<Loader />
44+
);
45+
}
46+
}
47+
});
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
Copyright 2015 OpenMarket 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+
'use strict';
18+
19+
var React = require('react');
20+
21+
var ChangePasswordController = require("../../../../src/controllers/molecules/ChangePassword");
22+
var Loader = require("react-loader");
23+
24+
25+
module.exports = React.createClass({
26+
displayName: 'ChangePassword',
27+
mixins: [ChangePasswordController],
28+
29+
onClickChange: function() {
30+
var old_password = this.refs.old_input.getDOMNode().value;
31+
var new_password = this.refs.new_input.getDOMNode().value;
32+
var confirm_password = this.refs.confirm_input.getDOMNode().value;
33+
if (new_password != confirm_password) {
34+
this.setState({
35+
state: this.Phases.Error,
36+
errorString: "Passwords don't match"
37+
});
38+
} else if (new_password == '' || old_password == '') {
39+
this.setState({
40+
state: this.Phases.Error,
41+
errorString: "Passwords can't be empty"
42+
});
43+
} else {
44+
this.changePassword(old_password, new_password);
45+
}
46+
},
47+
48+
render: function() {
49+
switch (this.state.phase) {
50+
case this.Phases.Edit:
51+
case this.Phases.Error:
52+
return (
53+
<div>
54+
<div>{this.state.errorString}</div>
55+
<label>Old password <input type="password" ref="old_input"/></label>
56+
<label>New password <input type="password" ref="new_input"/></label>
57+
<label>Confirm password <input type="password" ref="confirm_input"/></label>
58+
<div>
59+
<button onClick={this.onClickChange}>Change Password</button>
60+
<button onClick={this.props.onFinished}>Cancel</button>
61+
</div>
62+
</div>
63+
);
64+
case this.Phases.Uploading:
65+
return (
66+
<Loader />
67+
);
68+
case this.Phases.Success:
69+
return (
70+
<div>
71+
Success!
72+
<button onClick={this.props.onFinished}>Ok</button>
73+
</div>
74+
)
75+
}
76+
}
77+
});

‎skins/base/views/molecules/DirectoryMenu.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ limitations under the License.
1919
var React = require('react');
2020
var classNames = require('classnames');
2121

22+
var dis = require("../../../../src/dispatcher");
23+
2224
//var DirectoryMenuController = require("../../../../src/controllers/molecules/DirectoryMenuController");
2325

2426
var MatrixClientPeg = require("../../../../src/MatrixClientPeg");
2527

2628
module.exports = React.createClass({
2729
displayName: 'DirectoryMenu',
2830
// mixins: [DirectoryMenuController],
31+
32+
onSettingsClick: function() {
33+
dis.dispatch({action: 'view_user_settings'});
34+
},
35+
2936
render: function() {
3037
return (
3138
<div className="mx_DirectoryMenu">
@@ -42,7 +49,7 @@ module.exports = React.createClass({
4249
</div>
4350
<div className="mx_RoomTile_name">Directory</div>
4451
</div>
45-
<div className="mx_RoomTile">
52+
<div className="mx_RoomTile" onClick={this.onSettingsClick}>
4653
<div className="mx_RoomTile_avatar">
4754
<img src="img/settings-big.png" width="42" height="42"/>
4855
</div>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
'use strict';
15+
16+
var React = require('react');
17+
var ComponentBroker = require('../../../../src/ComponentBroker');
18+
var MatrixClientPeg = require("../../../../src/MatrixClientPeg");
19+
20+
var UserSettingsController = require("../../../../src/controllers/organisms/UserSettings");
21+
22+
var EditableText = ComponentBroker.get('atoms/EditableText');
23+
var ChangeAvatar = ComponentBroker.get('molecules/ChangeAvatar');
24+
var ChangePassword = ComponentBroker.get('molecules/ChangePassword');
25+
var Loader = require("react-loader");
26+
27+
var Modal = require("../../../../src/Modal")
28+
29+
module.exports = React.createClass({
30+
displayName: 'UserSettings',
31+
mixins: [UserSettingsController],
32+
33+
editAvatar: function() {
34+
var url = MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl);
35+
Modal.createDialog(ChangeAvatar, {initialAvatarUrl: url});
36+
},
37+
38+
addEmail: function() {
39+
40+
},
41+
42+
editDisplayName: function() {
43+
this.refs.displayname.edit();
44+
},
45+
46+
changePassword: function() {
47+
Modal.createDialog(ChangePassword);
48+
},
49+
50+
render: function() {
51+
switch (this.state.phase) {
52+
case this.Phases.Loading:
53+
return <Loader />
54+
case this.Phases.Display:
55+
return (
56+
<div className="mx_UserSettings">
57+
<div className="mx_UserSettings_User">
58+
<h1>User Settings</h1>
59+
<hr/>
60+
<div className="mx_UserSettings_User_Inner">
61+
<div className="mx_UserSettings_Avatar">
62+
<div className="mx_UserSettings_Avatar_Text">Profile Photo</div>
63+
<div className="mx_UserSettings_Avatar_Edit" onClick={this.editAvatar}>Edit</div>
64+
</div>
65+
66+
<div className="mx_UserSettings_DisplayName">
67+
<EditableText ref="displayname" initalValue={this.state.displayName} placeHolder="Click to set display name." onValueChanged={this.changeDisplayname}/>
68+
<div className="mx_UserSettings_DisplayName_Edit" onClick={this.editDisplayName}>Edit</div>
69+
</div>
70+
71+
<div className="mx_UserSettings_3pids">
72+
{this.state.threepids.map(function(val) {
73+
return <div>{val.address}</div>;
74+
})}
75+
</div>
76+
77+
<div className="mx_UserSettings_Add3pid" onClick={this.addEmail}>Add email</div>
78+
</div>
79+
</div>
80+
81+
<div className="mx_UserSettings_Global">
82+
<h1>Global Settings</h1>
83+
<hr/>
84+
<div className="mx_UserSettings_Global_Inner">
85+
<div className="mx_UserSettings_ChangePassword" onClick={this.changePassword}>
86+
Change Password
87+
</div>
88+
<div className="mx_UserSettings_ClientVersion">
89+
Version {this.state.clientVersion}
90+
</div>
91+
</div>
92+
</div>
93+
</div>
94+
);
95+
}
96+
}
97+
});

0 commit comments

Comments
 (0)