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:
|
|
|
|
* Modal.createDialog(ErrorDialog, {
|
|
|
|
* 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';
|
|
|
|
import sdk from '../../../index';
|
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: {
|
|
|
|
title: React.PropTypes.string,
|
2016-03-18 19:20:00 +08:00
|
|
|
description: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.element,
|
|
|
|
React.PropTypes.string,
|
|
|
|
]),
|
2015-09-19 01:39:16 +08:00
|
|
|
button: React.PropTypes.string,
|
|
|
|
focus: React.PropTypes.bool,
|
|
|
|
onFinished: React.PropTypes.func.isRequired,
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps: function() {
|
|
|
|
return {
|
|
|
|
title: "Error",
|
|
|
|
description: "An error has occurred.",
|
|
|
|
button: "OK",
|
|
|
|
focus: true,
|
|
|
|
};
|
|
|
|
},
|
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}
|
|
|
|
title={this.props.title}>
|
2015-11-30 22:11:04 +08:00
|
|
|
<div className="mx_Dialog_content">
|
|
|
|
{this.props.description}
|
|
|
|
</div>
|
|
|
|
<div className="mx_Dialog_buttons">
|
2016-07-15 18:23:58 +08:00
|
|
|
<button className="mx_Dialog_primary" onClick={this.props.onFinished} autoFocus={this.props.focus}>
|
2015-11-30 22:11:04 +08:00
|
|
|
{this.props.button}
|
|
|
|
</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
|
|
|
});
|