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-12-20 04:19:56 +03:00
|
|
|
import * as sdk from '../../../index';
|
2017-05-25 20:20:48 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2021-03-09 05:59:41 +03:00
|
|
|
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
2015-09-18 20:39:16 +03:00
|
|
|
|
2021-06-14 23:55:47 +03:00
|
|
|
interface IProps {
|
|
|
|
onFinished: (success: boolean) => void;
|
|
|
|
title?: string;
|
|
|
|
description?: React.ReactNode;
|
|
|
|
button?: string;
|
|
|
|
focus?: boolean;
|
|
|
|
headerImage?: string;
|
|
|
|
}
|
2015-09-18 20:39:16 +03:00
|
|
|
|
2021-06-14 23:55:47 +03:00
|
|
|
interface IState {
|
|
|
|
onFinished: (success: boolean) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
@replaceableComponent("views.dialogs.ErrorDialog")
|
|
|
|
export default class ErrorDialog extends React.Component<IProps, IState> {
|
|
|
|
public static defaultProps = {
|
2020-08-29 14:14:16 +03:00
|
|
|
focus: true,
|
|
|
|
title: null,
|
|
|
|
description: null,
|
|
|
|
button: null,
|
|
|
|
};
|
2015-11-30 17:11:04 +03:00
|
|
|
|
2021-06-14 23:55:47 +03:00
|
|
|
private onClick = () => {
|
2021-02-01 19:25:50 +03:00
|
|
|
this.props.onFinished(true);
|
|
|
|
};
|
|
|
|
|
2021-06-14 23:55:47 +03:00
|
|
|
public render() {
|
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">
|
2021-02-01 19:25:50 +03:00
|
|
|
<button className="mx_Dialog_primary" onClick={this.onClick} 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
|
|
|
);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
|
|
|
}
|