|
| 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