Files
ThreadNet-Web/src/components/views/dialogs/SessionRestoreErrorDialog.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

103 lines
3.3 KiB
TypeScript
Raw Normal View History

/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
2020-07-10 19:07:11 +01:00
Copyright 2020 The Matrix.org Foundation C.I.C.
2024-09-09 14:57:16 +01:00
Copyright 2018 New Vector Ltd
Copyright 2017 Vector Creations Ltd
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
2024-09-09 14:57:16 +01:00
Please see LICENSE files in the repository root for full details.
*/
import React from "react";
2021-10-22 17:23:32 -05:00
import SdkConfig from "../../../SdkConfig";
import Modal from "../../../Modal";
2017-11-13 20:19:33 +01:00
import { _t } from "../../../languageHandler";
2021-09-05 16:40:46 +02:00
import QuestionDialog from "./QuestionDialog";
import BugReportDialog from "./BugReportDialog";
import BaseDialog from "./BaseDialog";
import DialogButtons from "../elements/DialogButtons";
interface IProps {
error: unknown;
onFinished(clear?: boolean): void;
2021-09-05 16:40:46 +02:00
}
2021-09-05 16:40:46 +02:00
export default class SessionRestoreErrorDialog extends React.Component<IProps> {
private sendBugReport = (): void => {
2022-06-14 17:51:51 +01:00
Modal.createDialog(BugReportDialog, {
2021-10-29 09:34:25 +01:00
error: this.props.error,
});
2020-08-29 12:14:16 +01:00
};
2021-09-05 16:40:46 +02:00
private onClearStorageClick = (): void => {
const { finished } = Modal.createDialog(QuestionDialog, {
title: _t("action|sign_out"),
description: <div>{_t("error|session_restore|clear_storage_description")}</div>,
button: _t("action|sign_out"),
2018-04-27 12:38:49 +01:00
danger: true,
});
finished.then(([ok]) => this.props.onFinished(ok));
2020-08-29 12:14:16 +01:00
};
2021-09-05 16:40:46 +02:00
private onRefreshClick = (): void => {
2018-04-27 12:38:49 +01:00
// Is this likely to help? Probably not, but giving only one button
// that clears your storage seems awful.
2021-09-05 16:40:46 +02:00
window.location.reload();
2020-08-29 12:14:16 +01:00
};
2018-04-26 17:07:58 +01:00
public render(): React.ReactNode {
2020-07-10 19:07:11 +01:00
const brand = SdkConfig.get().brand;
2018-04-30 14:22:18 +01:00
const clearStorageButton = (
2021-09-05 16:40:46 +02:00
<button onClick={this.onClearStorageClick} className="danger">
{_t("error|session_restore|clear_storage_button")}
2018-04-30 14:22:18 +01:00
</button>
);
2018-04-27 12:38:49 +01:00
let dialogButtons;
if (SdkConfig.get().bug_report_endpoint_url) {
2018-04-27 12:38:49 +01:00
dialogButtons = (
<DialogButtons
primaryButton={_t("bug_reporting|send_logs")}
2021-09-05 16:40:46 +02:00
onPrimaryButtonClick={this.sendBugReport}
2018-04-27 12:38:49 +01:00
focus={true}
hasCancel={false}
>
2018-04-30 14:34:14 +01:00
{clearStorageButton}
2018-04-27 15:56:28 +01:00
</DialogButtons>
);
2018-04-27 12:38:49 +01:00
} else {
dialogButtons = (
<DialogButtons
primaryButton={_t("action|refresh")}
2021-09-05 16:40:46 +02:00
onPrimaryButtonClick={this.onRefreshClick}
2018-04-27 12:38:49 +01:00
focus={true}
hasCancel={false}
>
2018-04-30 14:34:14 +01:00
{clearStorageButton}
2018-04-27 15:56:28 +01:00
</DialogButtons>
);
}
return (
2021-07-23 10:23:45 +01:00
<BaseDialog
className="mx_ErrorDialog"
onFinished={this.props.onFinished}
title={_t("error|session_restore|title")}
contentId="mx_Dialog_content"
2018-04-27 12:38:49 +01:00
hasCancel={false}
>
<div className="mx_Dialog_content" id="mx_Dialog_content">
<p>{_t("error|session_restore|description_1")}</p>
<p>{_t("error|session_restore|description_2", { brand })}</p>
<p>{_t("error|session_restore|description_3")}</p>
</div>
2018-04-27 12:38:49 +01:00
{dialogButtons}
</BaseDialog>
);
2020-08-29 12:14:16 +01:00
}
}