2015-09-21 19:23:51 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2017-08-21 21:18:32 +03:00
|
|
|
Copyright 2017 New Vector 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';
|
2017-12-26 04:03:18 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2017-01-24 18:54:05 +03:00
|
|
|
import sdk from '../../../index';
|
2017-05-25 20:20:48 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
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: {
|
2017-12-26 04:03:18 +03:00
|
|
|
title: PropTypes.string,
|
|
|
|
description: PropTypes.node,
|
|
|
|
extraButtons: PropTypes.node,
|
|
|
|
button: PropTypes.string,
|
|
|
|
danger: PropTypes.bool,
|
|
|
|
focus: PropTypes.bool,
|
|
|
|
onFinished: PropTypes.func.isRequired,
|
2015-09-21 19:23:51 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
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,
|
2017-08-21 21:18:32 +03:00
|
|
|
danger: false,
|
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-12-21 13:51:14 +03:00
|
|
|
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
|
|
|
|
let primaryButtonClass = "";
|
|
|
|
if (this.props.danger) {
|
|
|
|
primaryButtonClass = "danger";
|
|
|
|
}
|
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}
|
|
|
|
title={this.props.title}
|
2017-11-29 23:13:48 +03:00
|
|
|
contentId='mx_Dialog_content'
|
2017-01-24 18:54:05 +03:00
|
|
|
>
|
2017-11-30 10:32:18 +03:00
|
|
|
<div className="mx_Dialog_content" id='mx_Dialog_content'>
|
2017-09-28 13:21:06 +03:00
|
|
|
{ this.props.description }
|
2015-11-30 17:11:04 +03:00
|
|
|
</div>
|
2017-12-21 13:51:14 +03:00
|
|
|
<DialogButtons primaryButton={this.props.button || _t('OK')}
|
2018-06-14 20:58:38 +03:00
|
|
|
primaryButtonClass={primaryButtonClass}
|
2018-05-22 17:45:58 +03:00
|
|
|
cancelButton={this.props.cancelButton}
|
2018-06-14 20:58:38 +03:00
|
|
|
hasCancel={this.props.hasCancelButton}
|
2017-12-21 13:51:14 +03:00
|
|
|
onPrimaryButtonClick={this.onOk}
|
2018-01-12 13:52:51 +03:00
|
|
|
focus={this.props.focus}
|
2017-12-21 13:51:14 +03:00
|
|
|
onCancel={this.onCancel}
|
|
|
|
>
|
2017-09-28 13:21:06 +03:00
|
|
|
{ this.props.extraButtons }
|
2017-12-21 13:51:14 +03:00
|
|
|
</DialogButtons>
|
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
|
|
|
});
|