Move and merge QuestionDialog and ErrorDialog
This commit is contained in:
parent
78cfaeb5c3
commit
fcb6db684b
8 changed files with 80 additions and 19 deletions
|
@ -115,7 +115,7 @@ function _setCallListeners(call) {
|
||||||
_setCallState(call, call.roomId, "busy");
|
_setCallState(call, call.roomId, "busy");
|
||||||
pause("ringbackAudio");
|
pause("ringbackAudio");
|
||||||
play("busyAudio");
|
play("busyAudio");
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Call Timeout",
|
title: "Call Timeout",
|
||||||
description: "The remote side failed to pick up."
|
description: "The remote side failed to pick up."
|
||||||
|
@ -173,7 +173,7 @@ function _onAction(payload) {
|
||||||
console.error("Unknown conf call type: %s", payload.type);
|
console.error("Unknown conf call type: %s", payload.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'place_call':
|
case 'place_call':
|
||||||
|
@ -202,7 +202,7 @@ function _onAction(payload) {
|
||||||
|
|
||||||
var members = room.getJoinedMembers();
|
var members = room.getJoinedMembers();
|
||||||
if (members.length <= 1) {
|
if (members.length <= 1) {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
description: "You cannot place a call with yourself."
|
description: "You cannot place a call with yourself."
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,9 +14,21 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Usage:
|
||||||
|
* Modal.createDialog(ErrorDialog, {
|
||||||
|
* title: "some text", (default: "Error")
|
||||||
|
* description: "some more text",
|
||||||
|
* button: "Button Text",
|
||||||
|
* onClose: someFunction,
|
||||||
|
* focus: true|false (default: true)
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
|
||||||
var React = require("react");
|
var React = require("react");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = React.createClass({
|
||||||
|
displayName: 'ErrorDialog',
|
||||||
propTypes: {
|
propTypes: {
|
||||||
title: React.PropTypes.string,
|
title: React.PropTypes.string,
|
||||||
button: React.PropTypes.string,
|
button: React.PropTypes.string,
|
||||||
|
@ -32,4 +44,22 @@ module.exports = {
|
||||||
focus: true,
|
focus: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
|
||||||
|
render: function() {
|
||||||
|
return (
|
||||||
|
<div className="mx_ErrorDialog">
|
||||||
|
<div className="mx_ErrorDialogTitle">
|
||||||
|
{this.props.title}
|
||||||
|
</div>
|
||||||
|
<div className="mx_Dialog_content">
|
||||||
|
{this.props.description}
|
||||||
|
</div>
|
||||||
|
<div className="mx_Dialog_buttons">
|
||||||
|
<button onClick={this.props.onFinished} autoFocus={this.props.focus}>
|
||||||
|
{this.props.button}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
|
@ -16,7 +16,8 @@ limitations under the License.
|
||||||
|
|
||||||
var React = require("react");
|
var React = require("react");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = React.createClass({
|
||||||
|
displayName: 'QuestionDialog',
|
||||||
propTypes: {
|
propTypes: {
|
||||||
title: React.PropTypes.string,
|
title: React.PropTypes.string,
|
||||||
description: React.PropTypes.string,
|
description: React.PropTypes.string,
|
||||||
|
@ -33,4 +34,34 @@ module.exports = {
|
||||||
focus: true,
|
focus: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
|
||||||
|
onOk: function() {
|
||||||
|
this.props.onFinished(true);
|
||||||
|
},
|
||||||
|
|
||||||
|
onCancel: function() {
|
||||||
|
this.props.onFinished(false);
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return (
|
||||||
|
<div className="mx_QuestionDialog">
|
||||||
|
<div className="mx_QuestionDialogTitle">
|
||||||
|
{this.props.title}
|
||||||
|
</div>
|
||||||
|
<div className="mx_Dialog_content">
|
||||||
|
{this.props.description}
|
||||||
|
</div>
|
||||||
|
<div className="mx_Dialog_buttons">
|
||||||
|
<button onClick={this.onOk} autoFocus={this.props.focus}>
|
||||||
|
{this.props.button}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button onClick={this.onCancel}>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
|
@ -272,7 +272,7 @@ module.exports = React.createClass({
|
||||||
this.markdownEnabled = false;
|
this.markdownEnabled = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Unknown command",
|
title: "Unknown command",
|
||||||
description: "Usage: /markdown on|off"
|
description: "Usage: /markdown on|off"
|
||||||
|
@ -292,7 +292,7 @@ module.exports = React.createClass({
|
||||||
console.log("Command success.");
|
console.log("Command success.");
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
console.error("Command failure: %s", err);
|
console.error("Command failure: %s", err);
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Server error",
|
title: "Server error",
|
||||||
description: err.message
|
description: err.message
|
||||||
|
@ -301,7 +301,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
else if (cmd.error) {
|
else if (cmd.error) {
|
||||||
console.error(cmd.error);
|
console.error(cmd.error);
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Command error",
|
title: "Command error",
|
||||||
description: cmd.error
|
description: cmd.error
|
||||||
|
|
|
@ -43,7 +43,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onKick: function() {
|
onKick: function() {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var roomId = this.props.member.roomId;
|
var roomId = this.props.member.roomId;
|
||||||
var target = this.props.member.userId;
|
var target = this.props.member.userId;
|
||||||
MatrixClientPeg.get().kick(roomId, target).done(function() {
|
MatrixClientPeg.get().kick(roomId, target).done(function() {
|
||||||
|
@ -60,7 +60,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onBan: function() {
|
onBan: function() {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var roomId = this.props.member.roomId;
|
var roomId = this.props.member.roomId;
|
||||||
var target = this.props.member.userId;
|
var target = this.props.member.userId;
|
||||||
MatrixClientPeg.get().ban(roomId, target).done(function() {
|
MatrixClientPeg.get().ban(roomId, target).done(function() {
|
||||||
|
@ -77,7 +77,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onMuteToggle: function() {
|
onMuteToggle: function() {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var roomId = this.props.member.roomId;
|
var roomId = this.props.member.roomId;
|
||||||
var target = this.props.member.userId;
|
var target = this.props.member.userId;
|
||||||
var room = MatrixClientPeg.get().getRoom(roomId);
|
var room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
|
@ -121,7 +121,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onModToggle: function() {
|
onModToggle: function() {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var roomId = this.props.member.roomId;
|
var roomId = this.props.member.roomId;
|
||||||
var target = this.props.member.userId;
|
var target = this.props.member.userId;
|
||||||
var room = MatrixClientPeg.get().getRoom(roomId);
|
var room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
|
@ -218,8 +218,8 @@ module.exports = React.createClass({
|
||||||
// FIXME: this is horribly duplicated with MemberTile's onLeaveClick.
|
// FIXME: this is horribly duplicated with MemberTile's onLeaveClick.
|
||||||
// Not sure what the right solution to this is.
|
// Not sure what the right solution to this is.
|
||||||
onLeaveClick: function() {
|
onLeaveClick: function() {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var QuestionDialog = sdk.getComponent("organisms.QuestionDialog");
|
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
|
|
||||||
var roomId = this.props.member.roomId;
|
var roomId = this.props.member.roomId;
|
||||||
Modal.createDialog(QuestionDialog, {
|
Modal.createDialog(QuestionDialog, {
|
||||||
|
|
|
@ -31,7 +31,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onLeaveClick: function() {
|
onLeaveClick: function() {
|
||||||
var QuestionDialog = sdk.getComponent("organisms.QuestionDialog");
|
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
|
|
||||||
var roomId = this.props.member.roomId;
|
var roomId = this.props.member.roomId;
|
||||||
Modal.createDialog(QuestionDialog, {
|
Modal.createDialog(QuestionDialog, {
|
||||||
|
|
|
@ -113,7 +113,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onInvite: function(inputText) {
|
onInvite: function(inputText) {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
var self = this;
|
var self = this;
|
||||||
inputText = inputText.trim(); // react requires es5-shim so we know trim() exists
|
inputText = inputText.trim(); // react requires es5-shim so we know trim() exists
|
||||||
var isEmailAddress = /^\S+@\S+\.\S+$/.test(inputText);
|
var isEmailAddress = /^\S+@\S+\.\S+$/.test(inputText);
|
||||||
|
|
|
@ -435,7 +435,7 @@ module.exports = {
|
||||||
if (deferreds.length) {
|
if (deferreds.length) {
|
||||||
var self = this;
|
var self = this;
|
||||||
q.all(deferreds).fail(function(err) {
|
q.all(deferreds).fail(function(err) {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Failed to set state",
|
title: "Failed to set state",
|
||||||
description: err.toString()
|
description: err.toString()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue