diff --git a/src/components/views/dialogs/ConfirmUserActionDialog.js b/src/components/views/dialogs/ConfirmUserActionDialog.js
index fbe719710b..4bd9cb669c 100644
--- a/src/components/views/dialogs/ConfirmUserActionDialog.js
+++ b/src/components/views/dialogs/ConfirmUserActionDialog.js
@@ -31,22 +31,40 @@ export default React.createClass({
propTypes: {
member: React.PropTypes.object.isRequired, // matrix-js-sdk member object
action: React.PropTypes.string.isRequired, // eg. 'Ban'
+
+ // Whether to display a text field for a reason
+ // If true, the second argument to onFinished will
+ // be the string entered.
+ askReason: React.PropTypes.bool,
danger: React.PropTypes.bool,
onFinished: React.PropTypes.func.isRequired,
},
defaultProps: {
danger: false,
+ askReason: false,
+ },
+
+ componentWillMount: function() {
+ this._reasonField = null;
},
onOk: function() {
- this.props.onFinished(true);
+ let reason;
+ if (this._reasonField) {
+ reason = this._reasonField.value;
+ }
+ this.props.onFinished(true, reason);
},
onCancel: function() {
this.props.onFinished(false);
},
+ _collectReasonField: function(e) {
+ this._reasonField = e;
+ },
+
render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar");
@@ -56,8 +74,24 @@ export default React.createClass({
'mx_Dialog_primary': true,
'danger': this.props.danger,
});
+
+ let reasonBox;
+ if (this.props.askReason) {
+ reasonBox = (
+
+
+
+ );
+ }
+
return (
-
@@ -68,8 +102,11 @@ export default React.createClass({
{this.props.member.name}
{this.props.member.userId}
+ {reasonBox}
-