mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Use DialogButtons in QuestionDialog
Use DialogButtons to eliminate duplicate button code.
This commit is contained in:
parent
45d86ea7ca
commit
3b2c61e456
1 changed files with 13 additions and 17 deletions
|
@ -18,7 +18,6 @@ limitations under the License.
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import classnames from 'classnames';
|
|
||||||
|
|
||||||
export default React.createClass({
|
export default React.createClass({
|
||||||
displayName: 'QuestionDialog',
|
displayName: 'QuestionDialog',
|
||||||
|
@ -53,30 +52,27 @@ export default React.createClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
||||||
const cancelButton = this.props.hasCancelButton ? (
|
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
|
||||||
<button onClick={this.onCancel}>
|
let primaryButtonClass = "";
|
||||||
{ _t("Cancel") }
|
if (this.props.danger) {
|
||||||
</button>
|
primaryButtonClass = "danger";
|
||||||
) : null;
|
}
|
||||||
const buttonClasses = classnames({
|
|
||||||
mx_Dialog_primary: true,
|
|
||||||
danger: this.props.danger,
|
|
||||||
});
|
|
||||||
return (
|
return (
|
||||||
<BaseDialog className="mx_QuestionDialog" onFinished={this.props.onFinished}
|
<BaseDialog className="mx_QuestionDialog" onFinished={this.props.onFinished}
|
||||||
onEnterPressed={this.onOk}
|
onEnterPressed={this.onOk}
|
||||||
title={this.props.title}
|
title={this.props.title}
|
||||||
|
focus={this.props.focus}
|
||||||
>
|
>
|
||||||
<div className="mx_Dialog_content">
|
<div className="mx_Dialog_content">
|
||||||
{ this.props.description }
|
{ this.props.description }
|
||||||
</div>
|
</div>.
|
||||||
<div className="mx_Dialog_buttons">
|
<DialogButtons primaryButton={this.props.button || _t('OK')}
|
||||||
<button className={buttonClasses} onClick={this.onOk} autoFocus={this.props.focus}>
|
onPrimaryButtonClick={this.onOk}
|
||||||
{ this.props.button || _t('OK') }
|
primaryButtonClass={primaryButtonClass}
|
||||||
</button>
|
onCancel={this.onCancel}
|
||||||
|
>
|
||||||
{ this.props.extraButtons }
|
{ this.props.extraButtons }
|
||||||
{ cancelButton }
|
</DialogButtons>
|
||||||
</div>
|
|
||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue