2015-09-21 16:23:51 +00:00
|
|
|
/*
|
2016-01-07 04:06:39 +00:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2017-08-21 18:18:32 +00:00
|
|
|
Copyright 2017 New Vector Ltd.
|
2015-09-21 16:23:51 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-01-24 15:54:05 +00:00
|
|
|
import React from 'react';
|
|
|
|
import sdk from '../../../index';
|
2017-05-25 17:20:48 +00:00
|
|
|
import { _t } from '../../../languageHandler';
|
2017-08-21 18:18:32 +00:00
|
|
|
import classnames from 'classnames';
|
2015-09-21 16:23:51 +00:00
|
|
|
|
2017-01-24 15:54:05 +00:00
|
|
|
export default React.createClass({
|
2015-11-30 14:11:04 +00:00
|
|
|
displayName: 'QuestionDialog',
|
2015-09-21 16:23:51 +00:00
|
|
|
propTypes: {
|
|
|
|
title: React.PropTypes.string,
|
2017-03-16 14:18:18 +00:00
|
|
|
description: React.PropTypes.node,
|
|
|
|
extraButtons: React.PropTypes.node,
|
2015-09-21 16:23:51 +00:00
|
|
|
button: React.PropTypes.string,
|
2017-08-21 18:18:32 +00:00
|
|
|
danger: React.PropTypes.bool,
|
2015-09-21 16:23:51 +00:00
|
|
|
focus: React.PropTypes.bool,
|
|
|
|
onFinished: React.PropTypes.func.isRequired,
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps: function() {
|
|
|
|
return {
|
|
|
|
title: "",
|
|
|
|
description: "",
|
2017-03-16 14:18:18 +00:00
|
|
|
extraButtons: null,
|
2015-09-21 16:23:51 +00:00
|
|
|
focus: true,
|
2017-03-01 15:41:13 +00:00
|
|
|
hasCancelButton: true,
|
2017-08-21 18:18:32 +00:00
|
|
|
danger: false,
|
2015-09-21 16:23:51 +00:00
|
|
|
};
|
|
|
|
},
|
2015-11-30 14:11:04 +00:00
|
|
|
|
|
|
|
onOk: function() {
|
|
|
|
this.props.onFinished(true);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCancel: function() {
|
|
|
|
this.props.onFinished(false);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2017-01-24 15:54:05 +00:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
2017-03-01 15:41:13 +00:00
|
|
|
const cancelButton = this.props.hasCancelButton ? (
|
|
|
|
<button onClick={this.onCancel}>
|
2017-09-28 10:21:06 +00:00
|
|
|
{ _t("Cancel") }
|
2017-03-01 15:41:13 +00:00
|
|
|
</button>
|
|
|
|
) : null;
|
2017-08-21 18:18:32 +00:00
|
|
|
const buttonClasses = classnames({
|
|
|
|
mx_Dialog_primary: true,
|
|
|
|
danger: this.props.danger,
|
|
|
|
});
|
2015-11-30 14:11:04 +00:00
|
|
|
return (
|
2017-01-24 15:54:05 +00:00
|
|
|
<BaseDialog className="mx_QuestionDialog" onFinished={this.props.onFinished}
|
2017-09-28 10:21:06 +00:00
|
|
|
onEnterPressed={this.onOk}
|
2017-01-24 15:54:05 +00:00
|
|
|
title={this.props.title}
|
2017-11-29 20:13:48 +00:00
|
|
|
contentId='mx_Dialog_content'
|
2017-01-24 15:54:05 +00:00
|
|
|
>
|
2015-11-30 14:11:04 +00:00
|
|
|
<div className="mx_Dialog_content">
|
2017-09-28 10:21:06 +00:00
|
|
|
{ this.props.description }
|
2015-11-30 14:11:04 +00:00
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_buttons">
|
2017-08-21 18:18:32 +00:00
|
|
|
<button className={buttonClasses} onClick={this.onOk} autoFocus={this.props.focus}>
|
2017-09-28 10:21:06 +00:00
|
|
|
{ this.props.button || _t('OK') }
|
2015-11-30 14:11:04 +00:00
|
|
|
</button>
|
2017-09-28 10:21:06 +00:00
|
|
|
{ this.props.extraButtons }
|
|
|
|
{ cancelButton }
|
2015-11-30 14:11:04 +00:00
|
|
|
</div>
|
2017-01-24 15:54:05 +00:00
|
|
|
</BaseDialog>
|
2015-11-30 14:11:04 +00:00
|
|
|
);
|
2017-01-24 15:54:05 +00:00
|
|
|
},
|
2015-11-30 14:11:04 +00:00
|
|
|
});
|