Use DialogButtons in ConfirmUserActionDialog

Use DialogButtons to eliminate duplicate button code.
This commit is contained in:
Aidan Gauland 2017-12-23 16:15:53 +13:00
parent 7a761dbf6b
commit 93b789438b

View file

@ -76,13 +76,11 @@ export default React.createClass({
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar"); const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar");
const BaseAvatar = sdk.getComponent("views.avatars.BaseAvatar"); const BaseAvatar = sdk.getComponent("views.avatars.BaseAvatar");
const confirmButtonClass = classnames({ const confirmButtonClass = this.props.danger ? 'danger' : '';
'mx_Dialog_primary': true,
'danger': this.props.danger,
});
let reasonBox; let reasonBox;
if (this.props.askReason) { if (this.props.askReason) {
@ -127,17 +125,11 @@ export default React.createClass({
<div className="mx_ConfirmUserActionDialog_userId">{ userId }</div> <div className="mx_ConfirmUserActionDialog_userId">{ userId }</div>
</div> </div>
{ reasonBox } { reasonBox }
<div className="mx_Dialog_buttons"> <DialogButtons primaryButton={this.props.action}
<button className={confirmButtonClass} onPrimaryButtonClick={this.onOk}
onClick={this.onOk} autoFocus={!this.props.askReason} primaryButtonClass={confirmButtonClass}
> focus={!this.props.askReason}
{ this.props.action } onCancel={this.onCancel} />
</button>
<button onClick={this.onCancel}>
{ _t("Cancel") }
</button>
</div>
</BaseDialog> </BaseDialog>
); );
}, },