wallet-core/packages/taler-wallet-webextension/src/components/Diagnostics.tsx

87 lines
2.5 KiB
TypeScript
Raw Normal View History

2021-09-13 18:33:13 +02:00
/*
This file is part of GNU Taler
2022-06-06 17:05:26 +02:00
(C) 2022 Taler Systems S.A.
2021-09-13 18:33:13 +02:00
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
import { WalletDiagnostics } from "@gnu-taler/taler-util";
2021-11-16 17:59:53 +01:00
import { Fragment, h, VNode } from "preact";
2022-03-29 04:41:07 +02:00
import { useTranslationContext } from "../context/translation.js";
2021-08-13 23:04:05 +02:00
interface Props {
timedOut: boolean;
2021-11-15 15:18:58 +01:00
diagnostics: WalletDiagnostics | undefined;
2021-08-13 23:04:05 +02:00
}
2021-11-16 17:59:53 +01:00
export function Diagnostics({ timedOut, diagnostics }: Props): VNode {
const { i18n } = useTranslationContext();
if (timedOut) {
2022-02-23 19:18:37 +01:00
return (
<p>
<i18n.Translate>
2022-02-23 19:18:37 +01:00
Diagnostics timed out. Could not talk to the wallet backend.
</i18n.Translate>
2022-02-23 19:18:37 +01:00
</p>
);
}
if (diagnostics) {
if (diagnostics.errors.length === 0) {
2021-11-16 17:59:53 +01:00
return <Fragment />;
}
2021-11-16 17:59:53 +01:00
return (
<div
style={{
borderLeft: "0.5em solid red",
paddingLeft: "1em",
paddingTop: "0.2em",
paddingBottom: "0.2em",
}}
>
2022-02-23 19:18:37 +01:00
<p>
<i18n.Translate>Problems detected:</i18n.Translate>
2022-02-23 19:18:37 +01:00
</p>
2021-11-16 17:59:53 +01:00
<ol>
{diagnostics.errors.map((errMsg) => (
<li key={errMsg}>{errMsg}</li>
))}
</ol>
{diagnostics.firefoxIdbProblem ? (
<p>
<i18n.Translate>
2022-02-23 19:18:37 +01:00
Please check in your <code>about:config</code> settings that you
have IndexedDB enabled (check the preference name{" "}
<code>dom.indexedDB.enabled</code>).
</i18n.Translate>
2021-11-16 17:59:53 +01:00
</p>
) : null}
{diagnostics.dbOutdated ? (
<p>
<i18n.Translate>
2022-02-23 19:18:37 +01:00
Your wallet database is outdated. Currently automatic migration is
not supported. Please go <i18n.Translate>here</i18n.Translate>
2022-02-23 19:18:37 +01:00
to reset the wallet database.
</i18n.Translate>
2021-11-16 17:59:53 +01:00
</p>
) : null}
</div>
);
}
2022-02-23 19:18:37 +01:00
return (
<p>
<i18n.Translate>Running diagnostics</i18n.Translate> ...
2022-02-23 19:18:37 +01:00
</p>
);
}