-
- Change Password
-
-
- Version {this.state.clientVersion}
-
-
-
-
-
-
+
Account
+
+
+
+
+
+
+
+
Notifications
+
+
+
+
+
+
+
+
+
+
+
+
Advanced
+
+
+
+ Logged in as {this._me}
+
+
+ Version {this.state.clientVersion}
+
+
- );
- }
+ );
}
});
diff --git a/src/components/views/elements/EditableText.js b/src/components/views/elements/EditableText.js
index 0ed443fbae..ee88f1a853 100644
--- a/src/components/views/elements/EditableText.js
+++ b/src/components/views/elements/EditableText.js
@@ -113,6 +113,10 @@ module.exports = React.createClass({
}
},
+ onBlur: function() {
+ this.cancelEdit();
+ },
+
render: function() {
var editable_el;
@@ -125,7 +129,8 @@ module.exports = React.createClass({
} else if (this.state.phase == this.Phases.Edit) {
editable_el = (
-
+
);
}
diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js
index 10f3297b75..13959a16b9 100644
--- a/src/components/views/rooms/RoomHeader.js
+++ b/src/components/views/rooms/RoomHeader.js
@@ -73,10 +73,15 @@ module.exports = React.createClass({
var header;
if (this.props.simpleHeader) {
+ var cancel;
+ if (this.props.onCancelClick) {
+ cancel =

+ }
header =
{ this.props.simpleHeader }
+ { cancel }
}
diff --git a/src/components/views/settings/ChangeAvatar.js b/src/components/views/settings/ChangeAvatar.js
index 2ae50a0cae..ee2b5ad5e1 100644
--- a/src/components/views/settings/ChangeAvatar.js
+++ b/src/components/views/settings/ChangeAvatar.js
@@ -23,6 +23,9 @@ module.exports = React.createClass({
propTypes: {
initialAvatarUrl: React.PropTypes.string,
room: React.PropTypes.object,
+ // if false, you need to call changeAvatar.onFileSelected yourself.
+ showUploadSection: React.PropTypes.bool,
+ className: React.PropTypes.string
},
Phases: {
@@ -31,6 +34,13 @@ module.exports = React.createClass({
Error: "error",
},
+ getDefaultProps: function() {
+ return {
+ showUploadSection: true,
+ className: "mx_Dialog_content" // FIXME - shouldn't be this by default
+ };
+ },
+
getInitialState: function() {
return {
avatarUrl: this.props.initialAvatarUrl,
@@ -55,7 +65,7 @@ module.exports = React.createClass({
phase: this.Phases.Uploading
});
var self = this;
- MatrixClientPeg.get().uploadContent(file).then(function(url) {
+ var httpPromise = MatrixClientPeg.get().uploadContent(file).then(function(url) {
newUrl = url;
if (self.props.room) {
return MatrixClientPeg.get().sendStateEvent(
@@ -67,7 +77,9 @@ module.exports = React.createClass({
} else {
return MatrixClientPeg.get().setAvatarUrl(url);
}
- }).done(function() {
+ });
+
+ httpPromise.done(function() {
self.setState({
phase: self.Phases.Display,
avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(newUrl)
@@ -78,11 +90,13 @@ module.exports = React.createClass({
});
self.onError(error);
});
+
+ return httpPromise;
},
onFileSelected: function(ev) {
this.avatarSet = true;
- this.setAvatarFromFile(ev.target.files[0]);
+ return this.setAvatarFromFile(ev.target.files[0]);
},
onError: function(error) {
@@ -106,19 +120,26 @@ module.exports = React.createClass({
avatarImg =

;
}
+ var uploadSection;
+ if (this.props.showUploadSection) {
+ uploadSection = (
+
+ Upload new:
+
+ {this.state.errorText}
+
+ );
+ }
+
switch (this.state.phase) {
case this.Phases.Display:
case this.Phases.Error:
return (
-
+
{avatarImg}
-
- Upload new:
-
- {this.state.errorText}
-
+ {uploadSection}
);
case this.Phases.Uploading:
diff --git a/src/components/views/settings/ChangeDisplayName.js b/src/components/views/settings/ChangeDisplayName.js
index 4af413cfbe..9410b02290 100644
--- a/src/components/views/settings/ChangeDisplayName.js
+++ b/src/components/views/settings/ChangeDisplayName.js
@@ -98,7 +98,9 @@ module.exports = React.createClass({
} else {
var EditableText = sdk.getComponent('elements.EditableText');
return (
-
+
);
}
}
diff --git a/src/components/views/settings/ChangePassword.js b/src/components/views/settings/ChangePassword.js
index a6666b7ed1..219ad10714 100644
--- a/src/components/views/settings/ChangePassword.js
+++ b/src/components/views/settings/ChangePassword.js
@@ -18,30 +18,47 @@ limitations under the License.
var React = require('react');
var MatrixClientPeg = require("../../../MatrixClientPeg");
+var sdk = require("../../../index");
module.exports = React.createClass({
displayName: 'ChangePassword',
propTypes: {
onFinished: React.PropTypes.func,
+ onError: React.PropTypes.func,
+ onCheckPassword: React.PropTypes.func,
+ rowClassName: React.PropTypes.string,
+ rowLabelClassName: React.PropTypes.string,
+ rowInputClassName: React.PropTypes.string,
+ buttonClassName: React.PropTypes.string
},
Phases: {
Edit: "edit",
Uploading: "uploading",
- Error: "error",
- Success: "Success"
+ Error: "error"
},
getDefaultProps: function() {
return {
onFinished: function() {},
+ onError: function() {},
+ onCheckPassword: function(oldPass, newPass, confirmPass) {
+ if (newPass !== confirmPass) {
+ return {
+ error: "New passwords don't match."
+ };
+ } else if (!newPass || newPass.length === 0) {
+ return {
+ error: "Passwords can't be empty"
+ };
+ }
+ }
};
},
getInitialState: function() {
return {
- phase: this.Phases.Edit,
- errorString: ''
+ phase: this.Phases.Edit
}
},
@@ -55,60 +72,72 @@ module.exports = React.createClass({
};
this.setState({
- phase: this.Phases.Uploading,
- errorString: '',
- })
-
- var d = cli.setPassword(authDict, new_password);
+ phase: this.Phases.Uploading
+ });
var self = this;
- d.then(function() {
- self.setState({
- phase: self.Phases.Success,
- errorString: '',
- })
+ cli.setPassword(authDict, new_password).then(function() {
+ self.props.onFinished();
}, function(err) {
+ self.props.onError(err);
+ }).finally(function() {
self.setState({
- phase: self.Phases.Error,
- errorString: err.toString()
- })
- });
+ phase: self.Phases.Edit
+ });
+ }).done();
},
onClickChange: function() {
var old_password = this.refs.old_input.value;
var new_password = this.refs.new_input.value;
var confirm_password = this.refs.confirm_input.value;
- if (new_password != confirm_password) {
- this.setState({
- state: this.Phases.Error,
- errorString: "Passwords don't match"
- });
- } else if (new_password == '' || old_password == '') {
- this.setState({
- state: this.Phases.Error,
- errorString: "Passwords can't be empty"
- });
- } else {
+ var err = this.props.onCheckPassword(
+ old_password, new_password, confirm_password
+ );
+ if (err) {
+ this.props.onError(err);
+ }
+ else {
this.changePassword(old_password, new_password);
}
},
render: function() {
+ var rowClassName = this.props.rowClassName;
+ var rowLabelClassName = this.props.rowLabelClassName;
+ var rowInputClassName = this.props.rowInputClassName
+ var buttonClassName = this.props.buttonClassName;
+
switch (this.state.phase) {
case this.Phases.Edit:
- case this.Phases.Error:
return (
-
-
-
{this.state.errorString}
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Change Password
);
@@ -119,17 +148,6 @@ module.exports = React.createClass({
);
- case this.Phases.Success:
- return (
-
-
- Success!
-
-
-
-
-
- )
}
}
});