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