2015-09-21 19:23:51 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2015-09-21 19:23:51 +03: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 18:54:05 +03:00
|
|
|
import React from 'react';
|
|
|
|
import sdk from '../../../index';
|
2015-09-21 19:23:51 +03:00
|
|
|
|
2017-01-24 18:54:05 +03:00
|
|
|
export default React.createClass({
|
2015-11-30 17:11:04 +03:00
|
|
|
displayName: 'QuestionDialog',
|
2015-09-21 19:23:51 +03:00
|
|
|
propTypes: {
|
|
|
|
title: React.PropTypes.string,
|
2017-03-16 17:18:18 +03:00
|
|
|
description: React.PropTypes.node,
|
|
|
|
extraButtons: React.PropTypes.node,
|
2015-09-21 19:23:51 +03:00
|
|
|
button: React.PropTypes.string,
|
|
|
|
focus: React.PropTypes.bool,
|
|
|
|
onFinished: React.PropTypes.func.isRequired,
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps: function() {
|
|
|
|
return {
|
|
|
|
title: "",
|
|
|
|
description: "",
|
2017-03-16 17:18:18 +03:00
|
|
|
extraButtons: null,
|
2015-09-21 19:23:51 +03:00
|
|
|
focus: true,
|
2017-03-01 18:41:13 +03:00
|
|
|
hasCancelButton: true,
|
2015-09-21 19:23:51 +03:00
|
|
|
};
|
|
|
|
},
|
2015-11-30 17:11:04 +03:00
|
|
|
|
|
|
|
onOk: function() {
|
|
|
|
this.props.onFinished(true);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCancel: function() {
|
|
|
|
this.props.onFinished(false);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2017-01-24 18:54:05 +03:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
2017-03-01 18:41:13 +03:00
|
|
|
const cancelButton = this.props.hasCancelButton ? (
|
|
|
|
<button onClick={this.onCancel}>
|
|
|
|
Cancel
|
|
|
|
</button>
|
|
|
|
) : null;
|
2015-11-30 17:11:04 +03:00
|
|
|
return (
|
2017-01-24 18:54:05 +03:00
|
|
|
<BaseDialog className="mx_QuestionDialog" onFinished={this.props.onFinished}
|
|
|
|
onEnterPressed={ this.onOk }
|
|
|
|
title={this.props.title}
|
|
|
|
>
|
2015-11-30 17:11:04 +03:00
|
|
|
<div className="mx_Dialog_content">
|
|
|
|
{this.props.description}
|
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_buttons">
|
2017-05-16 18:11:01 +03:00
|
|
|
<button className="mx_Dialog_primary" onClick={this.onOk} autoFocus={this.props.focus}>
|
2015-11-30 17:11:04 +03:00
|
|
|
{this.props.button}
|
|
|
|
</button>
|
2017-03-16 17:18:18 +03:00
|
|
|
{this.props.extraButtons}
|
2017-03-01 18:41:13 +03:00
|
|
|
{cancelButton}
|
2015-11-30 17:11:04 +03:00
|
|
|
</div>
|
2017-01-24 18:54:05 +03:00
|
|
|
</BaseDialog>
|
2015-11-30 17:11:04 +03:00
|
|
|
);
|
2017-01-24 18:54:05 +03:00
|
|
|
},
|
2015-11-30 17:11:04 +03:00
|
|
|
});
|