Merge commit 'b1a6575' into rav/roomview_works

This commit is contained in:
Richard van der Hoff 2016-02-23 11:56:51 +00:00
commit 8161a18efd
4 changed files with 41 additions and 18 deletions

View file

@ -175,7 +175,7 @@ module.exports = React.createClass({
guest: true guest: true
}); });
}, function(err) { }, function(err) {
console.error(err.data); console.error("Failed to register as guest: " + err + " " + err.data);
self._setAutoRegisterAsGuest(false); self._setAutoRegisterAsGuest(false);
}); });
}, },
@ -970,7 +970,9 @@ module.exports = React.createClass({
onRegisterClick={this.onRegisterClick} onRegisterClick={this.onRegisterClick}
homeserverUrl={this.props.config.default_hs_url} homeserverUrl={this.props.config.default_hs_url}
identityServerUrl={this.props.config.default_is_url} identityServerUrl={this.props.config.default_is_url}
onForgotPasswordClick={this.onForgotPasswordClick} /> onForgotPasswordClick={this.onForgotPasswordClick}
onLoginAsGuestClick={this.props.enableGuest && this.props.config && this.props.config.default_hs_url ? this._registerAsGuest: undefined}
/>
); );
} }
} }

View file

@ -840,11 +840,19 @@ module.exports = React.createClass({
self.setState({ self.setState({
rejecting: false rejecting: false
}); });
}, function(err) { }, function(error) {
console.error("Failed to reject invite: %s", err); console.error("Failed to reject invite: %s", error);
var msg = error.message ? error.message : JSON.stringify(error);
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
title: "Failed to reject invite",
description: msg
});
self.setState({ self.setState({
rejecting: false, rejecting: false,
rejectError: err rejectError: error
}); });
}); });
}, },
@ -1028,7 +1036,6 @@ module.exports = React.createClass({
); );
} }
else { else {
var joinErrorText = this.state.joinError ? "Failed to join room!" : "";
return ( return (
<div className="mx_RoomView"> <div className="mx_RoomView">
<RoomHeader ref="header" room={this.state.room} simpleHeader="Join room"/> <RoomHeader ref="header" room={this.state.room} simpleHeader="Join room"/>
@ -1037,7 +1044,6 @@ module.exports = React.createClass({
canJoin={ true } canPreview={ false } canJoin={ true } canPreview={ false }
spinner={this.state.joining} spinner={this.state.joining}
/> />
<div className="error">{joinErrorText}</div>
</div> </div>
<div className="mx_RoomView_messagePanel"></div> <div className="mx_RoomView_messagePanel"></div>
</div> </div>
@ -1063,10 +1069,6 @@ module.exports = React.createClass({
} else { } else {
var inviteEvent = myMember.events.member; var inviteEvent = myMember.events.member;
var inviterName = inviteEvent.sender ? inviteEvent.sender.name : inviteEvent.getSender(); var inviterName = inviteEvent.sender ? inviteEvent.sender.name : inviteEvent.getSender();
// XXX: Leaving this intentionally basic for now because invites are about to change totally
// FIXME: This comment is now outdated - what do we need to fix? ^
var joinErrorText = this.state.joinError ? "Failed to join room!" : "";
var rejectErrorText = this.state.rejectError ? "Failed to reject invite!" : "";
// We deliberately don't try to peek into invites, even if we have permission to peek // We deliberately don't try to peek into invites, even if we have permission to peek
// as they could be a spam vector. // as they could be a spam vector.
@ -1082,8 +1084,6 @@ module.exports = React.createClass({
canJoin={ true } canPreview={ false } canJoin={ true } canPreview={ false }
spinner={this.state.joining} spinner={this.state.joining}
/> />
<div className="error">{joinErrorText}</div>
<div className="error">{rejectErrorText}</div>
</div> </div>
<div className="mx_RoomView_messagePanel"></div> <div className="mx_RoomView_messagePanel"></div>
</div> </div>

View file

@ -35,7 +35,8 @@ module.exports = React.createClass({displayName: 'Login',
// login shouldn't know or care how registration is done. // login shouldn't know or care how registration is done.
onRegisterClick: React.PropTypes.func.isRequired, onRegisterClick: React.PropTypes.func.isRequired,
// login shouldn't care how password recovery is done. // login shouldn't care how password recovery is done.
onForgotPasswordClick: React.PropTypes.func onForgotPasswordClick: React.PropTypes.func,
onLoginAsGuestClick: React.PropTypes.func,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -167,6 +168,13 @@ module.exports = React.createClass({displayName: 'Login',
var LoginFooter = sdk.getComponent("login.LoginFooter"); var LoginFooter = sdk.getComponent("login.LoginFooter");
var loader = this.state.busy ? <div className="mx_Login_loader"><Loader /></div> : null; var loader = this.state.busy ? <div className="mx_Login_loader"><Loader /></div> : null;
var loginAsGuestJsx;
if (this.props.onLoginAsGuestClick) {
loginAsGuestJsx =
<a className="mx_Login_create" onClick={this.props.onLoginAsGuestClick} href="#">
Login as guest
</a>
}
return ( return (
<div className="mx_Login"> <div className="mx_Login">
<div className="mx_Login_box"> <div className="mx_Login_box">
@ -188,6 +196,7 @@ module.exports = React.createClass({displayName: 'Login',
<a className="mx_Login_create" onClick={this.props.onRegisterClick} href="#"> <a className="mx_Login_create" onClick={this.props.onRegisterClick} href="#">
Create a new account Create a new account
</a> </a>
{ loginAsGuestJsx }
<br/> <br/>
<LoginFooter /> <LoginFooter />
</div> </div>

View file

@ -26,9 +26,20 @@ module.exports = React.createClass({
}, },
getInitialState: function() { getInitialState: function() {
return { if (this.props.currentDisplayName) {
value: this.props.currentDisplayName || "Guest "+MatrixClientPeg.get().getUserIdLocalpart(), return { value: this.props.currentDisplayName };
} }
if (MatrixClientPeg.get().isGuest()) {
return { value : "Guest " + MatrixClientPeg.get().getUserIdLocalpart() };
}
else {
return { value : MatrixClientPeg.get().getUserIdLocalpart() };
}
},
componentDidMount: function() {
this.refs.input_value.select();
}, },
getValue: function() { getValue: function() {
@ -54,11 +65,12 @@ module.exports = React.createClass({
Set a Display Name Set a Display Name
</div> </div>
<div className="mx_Dialog_content"> <div className="mx_Dialog_content">
Your display name is how you'll appear to others when you speak in rooms. What would you like it to be? Your display name is how you'll appear to others when you speak in rooms.<br/>
What would you like it to be?
</div> </div>
<form onSubmit={this.onFormSubmit}> <form onSubmit={this.onFormSubmit}>
<div className="mx_Dialog_content"> <div className="mx_Dialog_content">
<input type="text" value={this.state.value} <input type="text" ref="input_value" value={this.state.value}
autoFocus={true} onChange={this.onValueChange} size="30" autoFocus={true} onChange={this.onValueChange} size="30"
className="mx_SetDisplayNameDialog_input" className="mx_SetDisplayNameDialog_input"
/> />