Convert SessionRestoreErrorDialog to TS

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-09-05 16:40:46 +02:00
parent 4ca2ab11fb
commit 0285bb555f
No known key found for this signature in database
GPG Key ID: 55C211A1226CB17D
1 changed files with 18 additions and 20 deletions

View File

@ -17,27 +17,27 @@ limitations under the License.
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import * as sdk from '../../../index';
import SdkConfig from '../../../SdkConfig'; import SdkConfig from '../../../SdkConfig';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import QuestionDialog from "./QuestionDialog";
import BugReportDialog from "./BugReportDialog";
import BaseDialog from "./BaseDialog";
import DialogButtons from "../elements/DialogButtons";
interface IProps {
error: string;
onFinished: () => void;
}
@replaceableComponent("views.dialogs.SessionRestoreErrorDialog") @replaceableComponent("views.dialogs.SessionRestoreErrorDialog")
export default class SessionRestoreErrorDialog extends React.Component { export default class SessionRestoreErrorDialog extends React.Component<IProps> {
static propTypes = { private sendBugReport = (): void => {
error: PropTypes.string.isRequired,
onFinished: PropTypes.func.isRequired,
};
_sendBugReport = () => {
const BugReportDialog = sdk.getComponent("dialogs.BugReportDialog");
Modal.createTrackedDialog('Session Restore Error', 'Send Bug Report Dialog', BugReportDialog, {}); Modal.createTrackedDialog('Session Restore Error', 'Send Bug Report Dialog', BugReportDialog, {});
}; };
_onClearStorageClick = () => { private onClearStorageClick = (): void => {
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createTrackedDialog('Session Restore Confirm Logout', '', QuestionDialog, { Modal.createTrackedDialog('Session Restore Confirm Logout', '', QuestionDialog, {
title: _t("Sign out"), title: _t("Sign out"),
description: description:
@ -48,19 +48,17 @@ export default class SessionRestoreErrorDialog extends React.Component {
}); });
}; };
_onRefreshClick = () => { private onRefreshClick = (): void => {
// Is this likely to help? Probably not, but giving only one button // Is this likely to help? Probably not, but giving only one button
// that clears your storage seems awful. // that clears your storage seems awful.
window.location.reload(true); window.location.reload();
}; };
render() { public render(): JSX.Element {
const brand = SdkConfig.get().brand; const brand = SdkConfig.get().brand;
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
const clearStorageButton = ( const clearStorageButton = (
<button onClick={this._onClearStorageClick} className="danger"> <button onClick={this.onClearStorageClick} className="danger">
{ _t("Clear Storage and Sign Out") } { _t("Clear Storage and Sign Out") }
</button> </button>
); );
@ -68,7 +66,7 @@ export default class SessionRestoreErrorDialog extends React.Component {
let dialogButtons; let dialogButtons;
if (SdkConfig.get().bug_report_endpoint_url) { if (SdkConfig.get().bug_report_endpoint_url) {
dialogButtons = <DialogButtons primaryButton={_t("Send Logs")} dialogButtons = <DialogButtons primaryButton={_t("Send Logs")}
onPrimaryButtonClick={this._sendBugReport} onPrimaryButtonClick={this.sendBugReport}
focus={true} focus={true}
hasCancel={false} hasCancel={false}
> >
@ -76,7 +74,7 @@ export default class SessionRestoreErrorDialog extends React.Component {
</DialogButtons>; </DialogButtons>;
} else { } else {
dialogButtons = <DialogButtons primaryButton={_t("Refresh")} dialogButtons = <DialogButtons primaryButton={_t("Refresh")}
onPrimaryButtonClick={this._onRefreshClick} onPrimaryButtonClick={this.onRefreshClick}
focus={true} focus={true}
hasCancel={false} hasCancel={false}
> >