2015-09-18 20:39:16 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2015-09-18 20:39:16 +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.
|
|
|
|
*/
|
|
|
|
|
2015-11-30 17:11:04 +03:00
|
|
|
/*
|
|
|
|
* Usage:
|
2017-08-10 15:49:11 +03:00
|
|
|
* Modal.createTrackedDialog('An Identifier', 'some detail', ErrorDialog, {
|
2015-11-30 17:11:04 +03:00
|
|
|
* title: "some text", (default: "Error")
|
|
|
|
* description: "some more text",
|
|
|
|
* button: "Button Text",
|
2016-03-22 20:20:22 +03:00
|
|
|
* onFinished: someFunction,
|
2015-11-30 17:11:04 +03:00
|
|
|
* focus: true|false (default: true)
|
|
|
|
* });
|
|
|
|
*/
|
|
|
|
|
2017-01-24 18:54:05 +03:00
|
|
|
import React from 'react';
|
2019-08-24 13:59:46 +03:00
|
|
|
import createReactClass from 'create-react-class';
|
2017-12-26 04:03:18 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2019-12-20 04:19:56 +03:00
|
|
|
import * as sdk from '../../../index';
|
2017-05-25 20:20:48 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2015-09-18 20:39:16 +03:00
|
|
|
|
2019-08-24 13:59:46 +03:00
|
|
|
export default createReactClass({
|
2015-11-30 17:11:04 +03:00
|
|
|
displayName: 'ErrorDialog',
|
2015-09-18 20:39:16 +03:00
|
|
|
propTypes: {
|
2017-12-26 04:03:18 +03:00
|
|
|
title: PropTypes.string,
|
|
|
|
description: PropTypes.oneOfType([
|
|
|
|
PropTypes.element,
|
|
|
|
PropTypes.string,
|
2016-03-18 14:20:00 +03:00
|
|
|
]),
|
2017-12-26 04:03:18 +03:00
|
|
|
button: PropTypes.string,
|
|
|
|
focus: PropTypes.bool,
|
|
|
|
onFinished: PropTypes.func.isRequired,
|
2020-01-28 14:13:09 +03:00
|
|
|
headerImage: PropTypes.string,
|
2015-09-18 20:39:16 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps: function() {
|
|
|
|
return {
|
|
|
|
focus: true,
|
2017-05-25 20:20:48 +03:00
|
|
|
title: null,
|
|
|
|
description: null,
|
|
|
|
button: null,
|
2015-09-18 20:39:16 +03:00
|
|
|
};
|
|
|
|
},
|
2015-11-30 17:11:04 +03:00
|
|
|
|
|
|
|
render: function() {
|
2017-01-24 18:54:05 +03:00
|
|
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
2015-11-30 17:11:04 +03:00
|
|
|
return (
|
2020-01-28 14:13:09 +03:00
|
|
|
<BaseDialog
|
|
|
|
className="mx_ErrorDialog"
|
|
|
|
onFinished={this.props.onFinished}
|
|
|
|
title={this.props.title || _t('Error')}
|
|
|
|
headerImage={this.props.headerImage}
|
|
|
|
contentId='mx_Dialog_content'
|
2017-12-05 15:52:20 +03:00
|
|
|
>
|
|
|
|
<div className="mx_Dialog_content" id='mx_Dialog_content'>
|
2017-09-28 13:21:06 +03:00
|
|
|
{ this.props.description || _t('An error has occurred.') }
|
2015-11-30 17:11:04 +03:00
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_buttons">
|
2017-12-05 15:52:20 +03:00
|
|
|
<button className="mx_Dialog_primary" onClick={this.props.onFinished} autoFocus={this.props.focus}>
|
2017-09-28 13:21:06 +03:00
|
|
|
{ this.props.button || _t('OK') }
|
2015-11-30 17:11:04 +03:00
|
|
|
</button>
|
|
|
|
</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
|
|
|
});
|