More random tweaks

- Make onBlur reset the EditText to show that it hasn't submitted it.
- Add the user ID of the logged in user to Advanced.
- Remove remnants of the Save/Cancel buttons.
This commit is contained in:
Kegan Dougal 2015-12-23 16:02:18 +00:00
parent 72b8cf1be2
commit 19bd39b066
3 changed files with 20 additions and 19 deletions

View File

@ -40,7 +40,7 @@ module.exports = React.createClass({
avatarUrl: null, avatarUrl: null,
threePids: [], threePids: [],
clientVersion: version, clientVersion: version,
phase: "UserSettings.LOADING", // LOADING, DISPLAY, SAVING phase: "UserSettings.LOADING", // LOADING, DISPLAY
}; };
}, },
@ -71,13 +71,15 @@ module.exports = React.createClass({
componentDidMount: function() { componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
this._me = MatrixClientPeg.get().credentials.userId;
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
dis.unregister(this.dispatcherRef); dis.unregister(this.dispatcherRef);
}, },
onSaveClicked: function(ev) { /*
onSaveClicked: function(ev) { // XXX unused
var self = this; var self = this;
var savePromises = []; var savePromises = [];
@ -116,7 +118,7 @@ module.exports = React.createClass({
description: error.toString() description: error.toString()
}); });
}); });
}, }, */
onAction: function(payload) { onAction: function(payload) {
if (payload.action === "notifier_enabled") { if (payload.action === "notifier_enabled") {
@ -189,14 +191,12 @@ module.exports = React.createClass({
}, },
render: function() { render: function() {
var Loader = sdk.getComponent("elements.Spinner");
var saving;
switch (this.state.phase) { switch (this.state.phase) {
case "UserSettings.LOADING": case "UserSettings.LOADING":
return <Loader /> var Loader = sdk.getComponent("elements.Spinner");
case "UserSettings.SAVING": return (
saving = <Loader /> <Loader />
// intentional fall through );
case "UserSettings.DISPLAY": case "UserSettings.DISPLAY":
break; // quit the switch to return the common state break; // quit the switch to return the common state
default: default:
@ -209,7 +209,7 @@ module.exports = React.createClass({
return ( return (
<div className="mx_UserSettings"> <div className="mx_UserSettings">
<RoomHeader simpleHeader="Settings" onCancelClick={ this.props.onClose } /> <RoomHeader simpleHeader="Settings" />
<h2>Profile</h2> <h2>Profile</h2>
@ -290,14 +290,10 @@ module.exports = React.createClass({
<div className="mx_UserSettings_section"> <div className="mx_UserSettings_section">
<div className="mx_UserSettings_advanced"> <div className="mx_UserSettings_advanced">
Version {this.state.clientVersion} Logged in as {this._me}
</div> </div>
</div> <div className="mx_UserSettings_advanced">
Version {this.state.clientVersion}
<div className="mx_UserSettings_save">
<div className="mx_UserSettings_spinner">{ saving }</div>
<div className="mx_UserSettings_button" onClick={this.onSaveClicked}>
Save and close
</div> </div>
</div> </div>
</div> </div>

View File

@ -113,6 +113,10 @@ module.exports = React.createClass({
} }
}, },
onBlur: function() {
this.cancelEdit();
},
render: function() { render: function() {
var editable_el; var editable_el;
@ -125,7 +129,8 @@ module.exports = React.createClass({
} else if (this.state.phase == this.Phases.Edit) { } else if (this.state.phase == this.Phases.Edit) {
editable_el = ( editable_el = (
<div> <div>
<input type="text" defaultValue={this.state.value} onKeyUp={this.onKeyUp} onFocus={this.onFocus} onBlur={this.onFinish} placeholder={this.props.placeHolder} autoFocus/> <input type="text" defaultValue={this.state.value}
onKeyUp={this.onKeyUp} onFocus={this.onFocus} onBlur={this.onBlur} placeholder={this.props.placeHolder} autoFocus/>
</div> </div>
); );
} }

View File

@ -117,7 +117,7 @@ module.exports = React.createClass({
<div className={this.props.className}> <div className={this.props.className}>
<div className={rowClassName}> <div className={rowClassName}>
<div className={rowLabelClassName}> <div className={rowLabelClassName}>
<label htmlFor="passwordold">Old password</label> <label htmlFor="passwordold">Current password</label>
</div> </div>
<div className={rowInputClassName}> <div className={rowInputClassName}>
<input id="passwordold" type="password" ref="old_input" /> <input id="passwordold" type="password" ref="old_input" />