Skip to content

Commit bc93aeb

Browse files
committed
Flesh out the user_settings page
1 parent 1b43586 commit bc93aeb

8 files changed

Lines changed: 384 additions & 2 deletions

File tree

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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
23+
24+
module.exports = React.createClass({
25+
displayName: 'ChangePassword',
26+
mixins: [ChangePasswordController],
27+
28+
render: function() {
29+
switch (this.state.phase) {
30+
case this.Phases.Edit:
31+
case this.Phases.Error:
32+
return (
33+
<div>
34+
<label>Old password <input type="password" /></label>
35+
<label>New password <input type="password" /></label>
36+
<label>Confirm password <input type="password" /></label>
37+
<div>
38+
<button>Change Password</button>
39+
<button onClick={this.props.onFinished}>Cancel</button>
40+
</div>
41+
</div>
42+
);
43+
case this.Phases.Uploading:
44+
return (
45+
<Loader />
46+
);
47+
}
48+
}
49+
});
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" style={{maxWidth: "720px", margin: "auto"}}>
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+
});

‎src/ComponentBroker.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ require('../skins/base/views/organisms/Notifier');
8989
require('../skins/base/views/organisms/CreateRoom');
9090
require('../skins/base/views/molecules/UserSelector');
9191
require('../skins/base/views/organisms/UserSettings');
92+
require('../skins/base/views/molecules/ChangeAvatar');
93+
require('../skins/base/views/molecules/ChangePassword');
9294
// new for vector
9395
require('../skins/base/views/organisms/LeftPanel');
9496
require('../skins/base/views/organisms/RightPanel');

‎src/controllers/atoms/EditableText.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ module.exports = {
5353
this.setState({
5454
value: val,
5555
phase: this.Phases.Display,
56-
});
56+
}, this.onValueChanged);
57+
},
5758

58-
this.onValueChanged();
59+
edit: function() {
60+
this.setState({
61+
phase: this.Phases.Edit,
62+
});
5963
},
6064

6165
cancelEdit: function() {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
var MatrixClientPeg = require("../../MatrixClientPeg");
21+
22+
var dis = require("../../dispatcher");
23+
24+
module.exports = {
25+
propTypes: {
26+
onFinished: React.PropTypes.func,
27+
initialAvatarUrl: React.PropTypes.string.isRequired,
28+
},
29+
30+
Phases: {
31+
Display: "display",
32+
Uploading: "uploading",
33+
Error: "error",
34+
},
35+
36+
getDefaultProps: function() {
37+
return {
38+
onFinished: function() {},
39+
};
40+
},
41+
42+
getInitialState: function() {
43+
return {
44+
avatarUrl: this.props.initialAvatarUrl,
45+
phase: this.Phases.Display,
46+
}
47+
},
48+
49+
uploadNewAvatar: function() {
50+
51+
},
52+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
var MatrixClientPeg = require("../../MatrixClientPeg");
21+
22+
var dis = require("../../dispatcher");
23+
24+
module.exports = {
25+
propTypes: {
26+
onFinished: React.PropTypes.func,
27+
},
28+
29+
Phases: {
30+
Edit: "edit",
31+
Uploading: "uploading",
32+
Error: "error",
33+
},
34+
35+
getDefaultProps: function() {
36+
return {
37+
onFinished: function() {},
38+
};
39+
},
40+
41+
getInitialState: function() {
42+
return {
43+
phase: this.Phases.Edit,
44+
}
45+
},
46+
47+
changePassword: function(old_password, new_password) {
48+
// DO SOMETHING.
49+
},
50+
}

0 commit comments

Comments
 (0)