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';
|
2019-08-24 10:59:46 +00:00
|
|
|
import createReactClass from 'create-react-class';
|
2017-12-26 01:03:18 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-12-20 01:19:56 +00:00
|
|
|
import * as sdk from '../../../index';
|
2017-05-25 17:20:48 +00:00
|
|
|
import { _t } from '../../../languageHandler';
|
2015-09-21 16:23:51 +00:00
|
|
|
|
2019-08-24 10:59:46 +00:00
|
|
|
export default createReactClass({
|
2015-11-30 14:11:04 +00:00
|
|
|
displayName: 'QuestionDialog',
|
2015-09-21 16:23:51 +00:00
|
|
|
propTypes: {
|
2017-12-26 01:03:18 +00:00
|
|
|
title: PropTypes.string,
|
|
|
|
description: PropTypes.node,
|
|
|
|
extraButtons: PropTypes.node,
|
|
|
|
button: PropTypes.string,
|
|
|
|
danger: PropTypes.bool,
|
|
|
|
focus: PropTypes.bool,
|
|
|
|
onFinished: PropTypes.func.isRequired,
|
2020-01-31 16:03:10 +00:00
|
|
|
headerImage: PropTypes.string,
|
2020-02-26 21:54:45 +00:00
|
|
|
quitOnly: PropTypes.bool, // quitOnly doesn't show the cancel button just the quit [x].
|
2020-03-16 12:00:56 +00:00
|
|
|
fixedWidth: PropTypes.bool,
|
2015-09-21 16:23:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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,
|
2020-02-26 21:54:45 +00:00
|
|
|
quitOnly: 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-12-21 10:51:14 +00:00
|
|
|
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
|
|
|
|
let primaryButtonClass = "";
|
|
|
|
if (this.props.danger) {
|
|
|
|
primaryButtonClass = "danger";
|
|
|
|
}
|
2015-11-30 14:11:04 +00:00
|
|
|
return (
|
2020-03-16 12:00:56 +00:00
|
|
|
<BaseDialog
|
|
|
|
className="mx_QuestionDialog"
|
|
|
|
onFinished={this.props.onFinished}
|
2017-01-24 15:54:05 +00:00
|
|
|
title={this.props.title}
|
2017-11-29 20:13:48 +00:00
|
|
|
contentId='mx_Dialog_content'
|
2020-01-31 16:03:10 +00:00
|
|
|
headerImage={this.props.headerImage}
|
2018-10-10 16:07:17 +00:00
|
|
|
hasCancel={this.props.hasCancelButton}
|
2020-03-16 12:00:56 +00:00
|
|
|
fixedWidth={this.props.fixedWidth}
|
2017-01-24 15:54:05 +00:00
|
|
|
>
|
2017-11-30 07:32:18 +00:00
|
|
|
<div className="mx_Dialog_content" id='mx_Dialog_content'>
|
2017-09-28 10:21:06 +00:00
|
|
|
{ this.props.description }
|
2015-11-30 14:11:04 +00:00
|
|
|
</div>
|
2017-12-21 10:51:14 +00:00
|
|
|
<DialogButtons primaryButton={this.props.button || _t('OK')}
|
2018-06-14 17:58:38 +00:00
|
|
|
primaryButtonClass={primaryButtonClass}
|
2018-05-22 14:45:58 +00:00
|
|
|
cancelButton={this.props.cancelButton}
|
2020-02-26 21:54:45 +00:00
|
|
|
hasCancel={this.props.hasCancelButton && !this.props.quitOnly}
|
2017-12-21 10:51:14 +00:00
|
|
|
onPrimaryButtonClick={this.onOk}
|
2018-01-12 10:52:51 +00:00
|
|
|
focus={this.props.focus}
|
2017-12-21 10:51:14 +00:00
|
|
|
onCancel={this.onCancel}
|
|
|
|
>
|
2017-09-28 10:21:06 +00:00
|
|
|
{ this.props.extraButtons }
|
2017-12-21 10:51:14 +00:00
|
|
|
</DialogButtons>
|
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
|
|
|
});
|