some changes

using transaction context from web utils
alertContext.safely api change (easier to integrate)
using lang and localstorage from web utils
removing auto permission, from UI
adding settings
This commit is contained in:
Sebastian 2023-04-14 14:16:08 -03:00
parent 5ea22a325c
commit 6e060da237
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069
86 changed files with 200 additions and 424 deletions

View File

@ -33,12 +33,12 @@ import {
SvgIcon, SvgIcon,
} from "./components/styled/index.js"; } from "./components/styled/index.js";
import { useBackendContext } from "./context/backend.js"; import { useBackendContext } from "./context/backend.js";
import { useTranslationContext } from "./context/translation.js";
import { useAsyncAsHook } from "./hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "./hooks/useAsyncAsHook.js";
import qrIcon from "./svg/qr_code_24px.svg"; import qrIcon from "./svg/qr_code_24px.svg";
import settingsIcon from "./svg/settings_black_24dp.svg"; import settingsIcon from "./svg/settings_black_24dp.svg";
import warningIcon from "./svg/warning_24px.svg"; import warningIcon from "./svg/warning_24px.svg";
import { parseTalerUri, TalerUriAction } from "@gnu-taler/taler-util"; import { parseTalerUri, TalerUriAction } from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
/** /**
* List of pages used by the wallet * List of pages used by the wallet

View File

@ -22,7 +22,7 @@
import { AmountJson, Amounts } from "@gnu-taler/taler-util"; import { AmountJson, Amounts } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { AmountFieldHandler, nullFunction, withSafe } from "../mui/handlers.js"; import { AmountFieldHandler, nullFunction, withSafe } from "../mui/handlers.js";
import { AmountField } from "./AmountField.js"; import { AmountField } from "./AmountField.js";

View File

@ -25,7 +25,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { AmountFieldHandler } from "../mui/handlers.js"; import { AmountFieldHandler } from "../mui/handlers.js";
import { TextField } from "../mui/TextField.js"; import { TextField } from "../mui/TextField.js";

View File

@ -23,7 +23,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useEffect, useRef, useState } from "preact/hooks"; import { useEffect, useRef, useState } from "preact/hooks";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { CopiedIcon, CopyIcon } from "../svg/index.js"; import { CopiedIcon, CopyIcon } from "../svg/index.js";
import { Amount } from "./Amount.js"; import { Amount } from "./Amount.js";
import { ButtonBox, TooltipLeft } from "./styled/index.js"; import { ButtonBox, TooltipLeft } from "./styled/index.js";

View File

@ -16,12 +16,12 @@
import { ComponentChildren, Fragment, h, VNode } from "preact"; import { ComponentChildren, Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { useTranslationContext } from "../../../web-util/src/index.browser.js";
import { import {
Alert as AlertNotification, Alert as AlertNotification,
useAlertContext, useAlertContext,
} from "../context/alert.js"; } from "../context/alert.js";
import { Alert } from "../mui/Alert.js"; import { Alert } from "../mui/Alert.js";
import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
/** /**
* *

View File

@ -16,7 +16,7 @@
import { WalletDiagnostics } from "@gnu-taler/taler-util"; import { WalletDiagnostics } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
interface Props { interface Props {
timedOut: boolean; timedOut: boolean;

View File

@ -16,7 +16,7 @@
import { h, VNode } from "preact"; import { h, VNode } from "preact";
import { useRef, useState } from "preact/hooks"; import { useRef, useState } from "preact/hooks";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
interface Props { interface Props {
value: string; value: string;

View File

@ -16,7 +16,7 @@
import { css } from "@linaria/core"; import { css } from "@linaria/core";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useEffect, useState } from "preact/hooks"; import { useEffect, useState } from "preact/hooks";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import ProgressIcon from "../svg/progress.svg"; import ProgressIcon from "../svg/progress.svg";
import { CenteredText } from "./styled/index.js"; import { CenteredText } from "./styled/index.js";

View File

@ -97,7 +97,7 @@ const CollasibleBox = styled.div`
} }
`; `;
import arrowDown from "../svg/chevron-down.svg"; import arrowDown from "../svg/chevron-down.svg";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
export function PartCollapsible({ text, title, big, showSign }: Props): VNode { export function PartCollapsible({ text, title, big, showSign }: Props): VNode {
const Text = big ? ExtraLargeText : LargeText; const Text = big ? ExtraLargeText : LargeText;

View File

@ -28,7 +28,7 @@ import { Amount } from "./Amount.js";
import { Part } from "./Part.js"; import { Part } from "./Part.js";
import { QR } from "./QR.js"; import { QR } from "./QR.js";
import { LinkSuccess, WarningBox } from "./styled/index.js"; import { LinkSuccess, WarningBox } from "./styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { ButtonHandler } from "../mui/handlers.js"; import { ButtonHandler } from "../mui/handlers.js";
import { assertUnreachable } from "../utils/index.js"; import { assertUnreachable } from "../utils/index.js";

View File

@ -24,7 +24,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { Fragment, h, JSX, VNode } from "preact"; import { Fragment, h, JSX, VNode } from "preact";
import { useEffect } from "preact/hooks"; import { useEffect } from "preact/hooks";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Avatar } from "../mui/Avatar.js"; import { Avatar } from "../mui/Avatar.js";
import { Grid } from "../mui/Grid.js"; import { Grid } from "../mui/Grid.js";

View File

@ -17,7 +17,7 @@
import { Amounts, Product } from "@gnu-taler/taler-util"; import { Amounts, Product } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { SmallLightText } from "./styled/index.js"; import { SmallLightText } from "./styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
export function ProductList({ products }: { products: Product[] }): VNode { export function ProductList({ products }: { products: Product[] }): VNode {
const { i18n } = useTranslationContext(); const { i18n } = useTranslationContext();

View File

@ -16,7 +16,7 @@
import { TranslatedString } from "@gnu-taler/taler-util"; import { TranslatedString } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { NiceSelect } from "./styled/index.js"; import { NiceSelect } from "./styled/index.js";
interface Props { interface Props {

View File

@ -26,7 +26,7 @@ import { Modal } from "../components/Modal.js";
import { Time } from "../components/Time.js"; import { Time } from "../components/Time.js";
import { alertFromError, useAlertContext } from "../context/alert.js"; import { alertFromError, useAlertContext } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { ButtonHandler } from "../mui/handlers.js"; import { ButtonHandler } from "../mui/handlers.js";
import { compose, StateViewMap } from "../utils/index.js"; import { compose, StateViewMap } from "../utils/index.js";

View File

@ -15,10 +15,10 @@
*/ */
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";
import { buildTermsOfServiceState } from "./utils.js"; import { buildTermsOfServiceState } from "./utils.js";

View File

@ -24,7 +24,7 @@ import {
WarningBox, WarningBox,
WarningText, WarningText,
} from "../../components/styled/index.js"; } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -25,7 +25,7 @@ import {
ExtendedStatus, ExtendedStatus,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { h, VNode } from "preact"; import { h, VNode } from "preact";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Avatar } from "../mui/Avatar.js"; import { Avatar } from "../mui/Avatar.js";
import { Pages } from "../NavigationBar.js"; import { Pages } from "../NavigationBar.js";
import { assertUnreachable } from "../utils/index.js"; import { assertUnreachable } from "../utils/index.js";

View File

@ -25,6 +25,7 @@ import { useContext, useState } from "preact/hooks";
import { HookError } from "../hooks/useAsyncAsHook.js"; import { HookError } from "../hooks/useAsyncAsHook.js";
import { SafeHandler, withSafe } from "../mui/handlers.js"; import { SafeHandler, withSafe } from "../mui/handlers.js";
import { BackgroundError } from "../wxApi.js"; import { BackgroundError } from "../wxApi.js";
import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
export type AlertType = "info" | "warning" | "error" | "success"; export type AlertType = "info" | "warning" | "error" | "success";
@ -55,10 +56,7 @@ type Type = {
* @deprecated use safely * @deprecated use safely
*/ */
pushAlertOnError: <T>(h: (p: T) => Promise<void>) => SafeHandler<T>; pushAlertOnError: <T>(h: (p: T) => Promise<void>) => SafeHandler<T>;
safely: <T>( safely: <T>(name: string, h: (p: T) => Promise<void>) => SafeHandler<T>;
h: (p: T) => Promise<void>,
error: TranslatedString,
) => SafeHandler<T>;
}; };
const initial: Type = { const initial: Type = {
@ -113,10 +111,13 @@ export const AlertProvider = ({ children }: Props): VNode => {
}); });
} }
const { i18n } = useTranslationContext();
function safely<T>( function safely<T>(
name: string,
handler: (p: T) => Promise<void>, handler: (p: T) => Promise<void>,
message: TranslatedString,
): SafeHandler<T> { ): SafeHandler<T> {
const message = i18n.str`Error was thrown trying to: "${name}"`;
return withSafe(handler, (e) => { return withSafe(handler, (e) => {
const a = alertFromError(message, e); const a = alertFromError(message, e);
pushAlert(a); pushAlert(a);

View File

@ -1,92 +0,0 @@
/*
This file is part of GNU Taler
(C) 2022 Taler Systems S.A.
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/>
*/
/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
import { i18n, setupI18n } from "@gnu-taler/taler-util";
import { createContext, h, VNode } from "preact";
import { useContext, useEffect } from "preact/hooks";
import { useLang } from "../hooks/useLang.js";
import { strings } from "../i18n/strings.js";
interface Type {
lang: string;
supportedLang: { [id in keyof typeof supportedLang]: string };
changeLanguage: (l: string) => void;
i18n: typeof i18n;
isSaved: boolean;
}
const supportedLang = {
es: "Español [es]",
ja: "日本語 [ja]",
en: "English [en]",
fr: "Français [fr]",
de: "Deutsch [de]",
sv: "Svenska [sv]",
it: "Italiano [it]",
// ko: "한국어 [ko]",
// ru: "Ру́сский язы́к [ru]",
tr: "Türk [tr]",
navigator: "Defined by navigator",
};
const initial = {
lang: "en",
supportedLang,
changeLanguage: () => {
// do not change anything
},
i18n,
isSaved: false,
};
const Context = createContext<Type>(initial);
interface Props {
initial?: string;
children: any;
forceLang?: string;
}
export const TranslationProvider = ({
initial,
children,
forceLang,
}: Props): VNode => {
const [lang, changeLanguage, isSaved] = useLang(initial);
useEffect(() => {
if (forceLang) {
changeLanguage(forceLang);
}
});
useEffect(() => {
setupI18n(lang, strings);
}, [lang]);
if (forceLang) {
setupI18n(forceLang, strings);
} else {
setupI18n(lang, strings);
}
return h(Context.Provider, {
value: { lang, changeLanguage, supportedLang, i18n, isSaved },
children,
});
};
export const useTranslationContext = (): Type => useContext(Context);

View File

@ -18,7 +18,7 @@ import { Amounts } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -20,7 +20,7 @@ import { Amount } from "../../components/Amount.js";
import { LogoHeader } from "../../components/LogoHeader.js"; import { LogoHeader } from "../../components/LogoHeader.js";
import { Part } from "../../components/Part.js"; import { Part } from "../../components/Part.js";
import { SubTitle, WalletAction } from "../../components/styled/index.js"; import { SubTitle, WalletAction } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -21,7 +21,7 @@ import { isFuture, parse } from "date-fns";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { useSelectedExchange } from "../../hooks/useSelectedExchange.js"; import { useSelectedExchange } from "../../hooks/useSelectedExchange.js";
import { RecursiveState } from "../../utils/index.js"; import { RecursiveState } from "../../utils/index.js";

View File

@ -24,7 +24,7 @@ import {
SvgIcon, SvgIcon,
WalletAction, WalletAction,
} from "../../components/styled/index.js"; } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { TextField } from "../../mui/TextField.js"; import { TextField } from "../../mui/TextField.js";
import editIcon from "../../svg/edit_24px.svg"; import editIcon from "../../svg/edit_24px.svg";

View File

@ -26,7 +26,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useEffect } from "preact/hooks"; import { useEffect } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -21,7 +21,7 @@ import { Part } from "../../components/Part.js";
import { PaymentButtons } from "../../components/PaymentButtons.js"; import { PaymentButtons } from "../../components/PaymentButtons.js";
import { SubTitle, WalletAction } from "../../components/styled/index.js"; import { SubTitle, WalletAction } from "../../components/styled/index.js";
import { Time } from "../../components/Time.js"; import { Time } from "../../components/Time.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { getAmountWithFee, InvoiceDetails } from "../../wallet/Transaction.js"; import { getAmountWithFee, InvoiceDetails } from "../../wallet/Transaction.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -24,7 +24,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useEffect } from "preact/hooks"; import { useEffect } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { ButtonHandler } from "../../mui/handlers.js"; import { ButtonHandler } from "../../mui/handlers.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -31,7 +31,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { ErrorAlert, useAlertContext } from "../../context/alert.js"; import { ErrorAlert, useAlertContext } from "../../context/alert.js";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";

View File

@ -26,7 +26,7 @@ import { Part } from "../../components/Part.js";
import { PaymentButtons } from "../../components/PaymentButtons.js"; import { PaymentButtons } from "../../components/PaymentButtons.js";
import { SuccessBox, WarningBox } from "../../components/styled/index.js"; import { SuccessBox, WarningBox } from "../../components/styled/index.js";
import { Time } from "../../components/Time.js"; import { Time } from "../../components/Time.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { import {
getAmountWithFee, getAmountWithFee,
MerchantDetails, MerchantDetails,

View File

@ -19,7 +19,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { AmountFieldHandler, TextFieldHandler } from "../../mui/handlers.js"; import { AmountFieldHandler, TextFieldHandler } from "../../mui/handlers.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";
@ -157,7 +157,7 @@ export function useComponentState({
onCreate: { onCreate: {
onClick: errors onClick: errors
? undefined ? undefined
: safely(createOrder, i18n.str`Could not create order`), : safely("create order for pay template", createOrder),
}, },
}; };
} }

View File

@ -20,7 +20,7 @@
*/ */
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";
import { useComponentState } from "./state.js"; import { useComponentState } from "./state.js";

View File

@ -17,7 +17,7 @@
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { AmountField } from "../../components/AmountField.js"; import { AmountField } from "../../components/AmountField.js";
import { Part } from "../../components/Part.js"; import { Part } from "../../components/Part.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { TextField } from "../../mui/TextField.js"; import { TextField } from "../../mui/TextField.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -18,7 +18,7 @@ import { parseRestoreUri } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useAlertContext } from "../../context/alert.js"; import { useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";
export function useComponentState({ export function useComponentState({

View File

@ -17,7 +17,7 @@
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { LogoHeader } from "../../components/LogoHeader.js"; import { LogoHeader } from "../../components/LogoHeader.js";
import { SubTitle, WalletAction } from "../../components/styled/index.js"; import { SubTitle, WalletAction } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -19,7 +19,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useEffect, useState } from "preact/hooks"; import { useEffect, useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -26,7 +26,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";
import { useComponentState } from "./state.js"; import { useComponentState } from "./state.js";

View File

@ -21,7 +21,7 @@ import { LogoHeader } from "../../components/LogoHeader.js";
import { Part } from "../../components/Part.js"; import { Part } from "../../components/Part.js";
import { ProductList } from "../../components/ProductList.js"; import { ProductList } from "../../components/ProductList.js";
import { Link, SubTitle, WalletAction } from "../../components/styled/index.js"; import { Link, SubTitle, WalletAction } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -18,7 +18,7 @@ import { Amounts } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -22,7 +22,7 @@
import { Amounts } from "@gnu-taler/taler-util"; import { Amounts } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";
import { Props } from "./index.js"; import { Props } from "./index.js";

View File

@ -20,7 +20,7 @@ import { Amount } from "../../components/Amount.js";
import { LogoHeader } from "../../components/LogoHeader.js"; import { LogoHeader } from "../../components/LogoHeader.js";
import { Part } from "../../components/Part.js"; import { Part } from "../../components/Part.js";
import { Link, SubTitle, WalletAction } from "../../components/styled/index.js"; import { Link, SubTitle, WalletAction } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -20,7 +20,7 @@ import { isFuture, parse } from "date-fns";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -21,7 +21,7 @@ import { ErrorTalerOperation } from "../../components/ErrorTalerOperation.js";
import { LogoHeader } from "../../components/LogoHeader.js"; import { LogoHeader } from "../../components/LogoHeader.js";
import { Part } from "../../components/Part.js"; import { Part } from "../../components/Part.js";
import { Link, SubTitle, WalletAction } from "../../components/styled/index.js"; import { Link, SubTitle, WalletAction } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { TextField } from "../../mui/TextField.js"; import { TextField } from "../../mui/TextField.js";
import { getAmountWithFee, TransferDetails } from "../../wallet/Transaction.js"; import { getAmountWithFee, TransferDetails } from "../../wallet/Transaction.js";

View File

@ -22,7 +22,7 @@ import {
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -21,7 +21,7 @@ import { LogoHeader } from "../../components/LogoHeader.js";
import { Part } from "../../components/Part.js"; import { Part } from "../../components/Part.js";
import { Link, SubTitle, WalletAction } from "../../components/styled/index.js"; import { Link, SubTitle, WalletAction } from "../../components/styled/index.js";
import { Time } from "../../components/Time.js"; import { Time } from "../../components/Time.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { getAmountWithFee, TransferDetails } from "../../wallet/Transaction.js"; import { getAmountWithFee, TransferDetails } from "../../wallet/Transaction.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -26,7 +26,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { useSelectedExchange } from "../../hooks/useSelectedExchange.js"; import { useSelectedExchange } from "../../hooks/useSelectedExchange.js";
import { RecursiveState } from "../../utils/index.js"; import { RecursiveState } from "../../utils/index.js";

View File

@ -27,7 +27,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";
import { useComponentStateFromURI } from "./state.js"; import { useComponentStateFromURI } from "./state.js";

View File

@ -23,7 +23,7 @@ import { QR } from "../../components/QR.js";
import { SelectList } from "../../components/SelectList.js"; import { SelectList } from "../../components/SelectList.js";
import { Input, LinkSuccess, SvgIcon } from "../../components/styled/index.js"; import { Input, LinkSuccess, SvgIcon } from "../../components/styled/index.js";
import { TermsOfService } from "../../components/TermsOfService/index.js"; import { TermsOfService } from "../../components/TermsOfService/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import editIcon from "../../svg/edit_24px.svg"; import editIcon from "../../svg/edit_24px.svg";
import { import {

View File

@ -1,70 +0,0 @@
/*
This file is part of GNU Taler
(C) 2022 Taler Systems S.A.
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 { useEffect, useState } from "preact/hooks";
import { useAlertContext } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js";
import { ToggleHandler } from "../mui/handlers.js";
import { platform } from "../platform/foreground.js";
export function useAutoOpenPermissions(): ToggleHandler {
const api = useBackendContext();
const { pushAlertOnError } = useAlertContext();
const [enabled, setEnabled] = useState(false);
async function handleAutoOpenPerm(): Promise<void> {
if (!enabled) {
// We set permissions here, since apparently FF wants this to be done
// as the result of an input event ...
let granted: boolean;
try {
granted = await platform.getPermissionsApi().requestHostPermissions();
} catch (lastError) {
setEnabled(false);
throw lastError;
}
const res = await api.background.call("toggleHeaderListener", granted);
setEnabled(res.newValue);
} else {
try {
await api.background
.call("toggleHeaderListener", false)
.then((r) => setEnabled(r.newValue));
} catch (e) {
console.log(e);
}
}
return;
}
useEffect(() => {
async function getValue(): Promise<void> {
const res = await api.background.call(
"containsHeaderListener",
undefined,
);
setEnabled(res.newValue);
}
getValue();
}, []);
return {
value: enabled,
button: {
onClick: pushAlertOnError(handleAutoOpenPerm),
},
};
}

View File

@ -1,31 +0,0 @@
/*
This file is part of GNU Taler
(C) 2022 Taler Systems S.A.
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 { useNotNullLocalStorage } from "./useLocalStorage.js";
function getBrowserLang(): string | undefined {
if (typeof window === "undefined") return undefined;
if (window.navigator.languages) return window.navigator.languages[0];
if (window.navigator.language) return window.navigator.language;
return undefined;
}
export function useLang(
initial?: string,
): [string, (s: string) => void, boolean] {
const defaultLang = (getBrowserLang() || initial || "en").substring(0, 2);
return useNotNullLocalStorage("lang-preference", defaultLang);
}

View File

@ -1,83 +0,0 @@
/*
This file is part of GNU Taler
(C) 2022 Taler Systems S.A.
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/>
*/
/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
import { StateUpdater, useState } from "preact/hooks";
export function useLocalStorage(
key: string,
initialValue?: string,
): [string | undefined, StateUpdater<string | undefined>] {
const [storedValue, setStoredValue] = useState<string | undefined>(
(): string | undefined => {
return typeof window !== "undefined"
? window.localStorage.getItem(key) || initialValue
: initialValue;
},
);
const setValue = (
value?: string | ((val?: string) => string | undefined),
): void => {
setStoredValue((p) => {
const toStore = value instanceof Function ? value(p) : value;
if (typeof window !== "undefined") {
if (!toStore) {
window.localStorage.removeItem(key);
} else {
window.localStorage.setItem(key, toStore);
}
}
return toStore;
});
};
return [storedValue, setValue];
}
//TODO: merge with the above function
export function useNotNullLocalStorage(
key: string,
initialValue: string,
): [string, StateUpdater<string>, boolean] {
const [storedValue, setStoredValue] = useState<string>((): string => {
return typeof window !== "undefined"
? window.localStorage.getItem(key) || initialValue
: initialValue;
});
const setValue = (value: string | ((val: string) => string)): void => {
const valueToStore = value instanceof Function ? value(storedValue) : value;
setStoredValue(valueToStore);
if (typeof window !== "undefined") {
if (!valueToStore) {
window.localStorage.removeItem(key);
} else {
window.localStorage.setItem(key, valueToStore);
}
}
};
const isSaved =
typeof window === "undefined"
? false
: window.localStorage.getItem(key) !== null;
return [storedValue, setValue, isSaved];
}

View File

@ -0,0 +1,51 @@
/*
This file is part of GNU Taler
(C) 2022 Taler Systems S.A.
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 { useLocalStorage } from "@gnu-taler/web-util/lib/index.browser";
interface Settings {
injectTalerSupport: boolean;
}
const defaultSettings: Settings = {
injectTalerSupport: false,
};
function parse_json_or_undefined<T>(str: string | undefined): T | undefined {
if (str === undefined) return undefined;
try {
return JSON.parse(str);
} catch {
return undefined;
}
}
export function useSettings(): [
Readonly<Settings>,
<T extends keyof Settings>(key: T, value: Settings[T]) => void,
] {
const { value, update } = useLocalStorage("wallet-settings");
const parsed: Settings = parse_json_or_undefined(value) ?? defaultSettings;
function updateField<T extends keyof Settings>(k: T, v: Settings[T]) {
const newValue = { ...parsed, [k]: v };
console.log("should update", k, v, parsed, newValue);
const json = JSON.stringify(newValue);
console.log(json);
update(json);
}
return [parsed, updateField];
}

View File

@ -15,7 +15,7 @@
*/ */
import { css } from "@linaria/core"; import { css } from "@linaria/core";
import { ComponentChildren, h, VNode } from "preact"; import { ComponentChildren, h, VNode } from "preact";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
// eslint-disable-next-line import/extensions // eslint-disable-next-line import/extensions
import { theme } from "./style.js"; import { theme } from "./style.js";

View File

@ -32,7 +32,7 @@ import { IoCProviderForRuntime } from "../context/iocContext.js";
import { import {
TranslationProvider, TranslationProvider,
useTranslationContext, useTranslationContext,
} from "../context/translation.js"; } from "@gnu-taler/web-util/lib/index.browser";
import { useTalerActionURL } from "../hooks/useTalerActionURL.js"; import { useTalerActionURL } from "../hooks/useTalerActionURL.js";
import { Pages, PopupNavBar, PopupNavBarOptions } from "../NavigationBar.js"; import { Pages, PopupNavBar, PopupNavBarOptions } from "../NavigationBar.js";
import { platform } from "../platform/foreground.js"; import { platform } from "../platform/foreground.js";
@ -40,10 +40,11 @@ import { BackupPage } from "../wallet/BackupPage.js";
import { ProviderDetailPage } from "../wallet/ProviderDetailPage.js"; import { ProviderDetailPage } from "../wallet/ProviderDetailPage.js";
import { BalancePage } from "./BalancePage.js"; import { BalancePage } from "./BalancePage.js";
import { TalerActionFound } from "./TalerActionFound.js"; import { TalerActionFound } from "./TalerActionFound.js";
import { strings } from "../i18n/strings.js";
export function Application(): VNode { export function Application(): VNode {
return ( return (
<TranslationProvider> <TranslationProvider source={strings}>
<DevContextProvider> <DevContextProvider>
<IoCProviderForRuntime> <IoCProviderForRuntime>
<ApplicationView /> <ApplicationView />

View File

@ -28,7 +28,7 @@ import {
useAlertContext, useAlertContext,
} from "../context/alert.js"; } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { ButtonHandler } from "../mui/handlers.js"; import { ButtonHandler } from "../mui/handlers.js";

View File

@ -15,7 +15,7 @@
*/ */
import { css } from "@linaria/core"; import { css } from "@linaria/core";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Alert } from "../mui/Alert.js"; import { Alert } from "../mui/Alert.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { ButtonHandler } from "../mui/handlers.js"; import { ButtonHandler } from "../mui/handlers.js";

View File

@ -22,7 +22,7 @@
import { classifyTalerUri, TalerUriType } from "@gnu-taler/taler-util"; import { classifyTalerUri, TalerUriType } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { Title } from "../components/styled/index.js"; import { Title } from "../components/styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { platform } from "../platform/foreground.js"; import { platform } from "../platform/foreground.js";

View File

@ -25,17 +25,18 @@ import {
ComponentChildren, ComponentChildren,
Fragment, Fragment,
FunctionalComponent, FunctionalComponent,
VNode,
h as create, h as create,
options, options,
render as renderIntoDom, render as renderIntoDom,
VNode,
} from "preact"; } from "preact";
import { render as renderToString } from "preact-render-to-string"; import { render as renderToString } from "preact-render-to-string";
import { AlertProvider } from "./context/alert.js"; import { AlertProvider } from "./context/alert.js";
import { BackendProvider } from "./context/backend.js"; import { BackendProvider } from "./context/backend.js";
import { TranslationProvider } from "./context/translation.js";
import { nullFunction } from "./mui/handlers.js"; import { nullFunction } from "./mui/handlers.js";
import { BackgroundApiClient, wxApi } from "./wxApi.js"; import { BackgroundApiClient, wxApi } from "./wxApi.js";
import { TranslationProvider } from "@gnu-taler/web-util/lib/index.browser";
import { strings } from "./i18n/strings.js";
// When doing tests we want the requestAnimationFrame to be as fast as possible. // When doing tests we want the requestAnimationFrame to be as fast as possible.
// without this option the RAF will timeout after 100ms making the tests slower // without this option the RAF will timeout after 100ms making the tests slower
@ -368,7 +369,11 @@ export function createWalletApiMock(): {
}): VNode { }): VNode {
let children = _cs; let children = _cs;
children = create(AlertProvider, { children }, children); children = create(AlertProvider, { children }, children);
children = create(TranslationProvider, { children }, children); children = create(
TranslationProvider,
{ children, source: strings, initial: "en", forceLang: "en" },
children,
);
return create( return create(
BackendProvider, BackendProvider,
{ {

View File

@ -20,7 +20,7 @@
*/ */
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";
import { Props } from "./index.js"; import { Props } from "./index.js";

View File

@ -23,7 +23,7 @@ import {
SubTitle, SubTitle,
Title, Title,
} from "../../components/styled/index.js"; } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { TextField } from "../../mui/TextField.js"; import { TextField } from "../../mui/TextField.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -18,7 +18,7 @@ import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { platform } from "../platform/foreground.js"; import { platform } from "../platform/foreground.js";
import { InputWithLabel } from "../components/styled/index.js"; import { InputWithLabel } from "../components/styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
export interface Props { export interface Props {

View File

@ -44,7 +44,7 @@ import { IoCProviderForRuntime } from "../context/iocContext.js";
import { import {
TranslationProvider, TranslationProvider,
useTranslationContext, useTranslationContext,
} from "../context/translation.js"; } from "@gnu-taler/web-util/lib/index.browser";
import { DepositPage as DepositPageCTA } from "../cta/Deposit/index.js"; import { DepositPage as DepositPageCTA } from "../cta/Deposit/index.js";
import { InvoiceCreatePage } from "../cta/InvoiceCreate/index.js"; import { InvoiceCreatePage } from "../cta/InvoiceCreate/index.js";
import { InvoicePayPage } from "../cta/InvoicePay/index.js"; import { InvoicePayPage } from "../cta/InvoicePay/index.js";
@ -80,6 +80,7 @@ import { QrReaderPage } from "./QrReader.js";
import { SettingsPage } from "./Settings.js"; import { SettingsPage } from "./Settings.js";
import { TransactionPage } from "./Transaction.js"; import { TransactionPage } from "./Transaction.js";
import { WelcomePage } from "./Welcome.js"; import { WelcomePage } from "./Welcome.js";
import { strings } from "../i18n/strings.js";
export function Application(): VNode { export function Application(): VNode {
const { i18n } = useTranslationContext(); const { i18n } = useTranslationContext();
@ -89,7 +90,7 @@ export function Application(): VNode {
redirectTo(Pages.balanceTransaction({ tid })); redirectTo(Pages.balanceTransaction({ tid }));
} }
return ( return (
<TranslationProvider> <TranslationProvider source={strings}>
<DevContextProvider> <DevContextProvider>
<IoCProviderForRuntime> <IoCProviderForRuntime>
<Router history={hash_history}> <Router history={hash_history}>

View File

@ -48,7 +48,7 @@ import {
} from "../components/styled/index.js"; } from "../components/styled/index.js";
import { alertFromError } from "../context/alert.js"; import { alertFromError } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { Pages } from "../NavigationBar.js"; import { Pages } from "../NavigationBar.js";

View File

@ -27,7 +27,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { RecursiveState } from "../../utils/index.js"; import { RecursiveState } from "../../utils/index.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -29,7 +29,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";

View File

@ -20,7 +20,7 @@ import { AmountField } from "../../components/AmountField.js";
import { ErrorMessage } from "../../components/ErrorMessage.js"; import { ErrorMessage } from "../../components/ErrorMessage.js";
import { SelectList } from "../../components/SelectList.js"; import { SelectList } from "../../components/SelectList.js";
import { Input, SubTitle, WarningBox } from "../../components/styled/index.js"; import { Input, SubTitle, WarningBox } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { Grid } from "../../mui/Grid.js"; import { Grid } from "../../mui/Grid.js";
import { State } from "./index.js"; import { State } from "./index.js";

View File

@ -19,7 +19,7 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { assertUnreachable, RecursiveState } from "../../utils/index.js"; import { assertUnreachable, RecursiveState } from "../../utils/index.js";
import { Contact, Props, State } from "./index.js"; import { Contact, Props, State } from "./index.js";

View File

@ -27,7 +27,7 @@ import {
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai"; import { expect } from "chai";
import { tests } from "../../../../web-util/src/index.browser.js"; import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { nullFunction } from "../../mui/handlers.js"; import { nullFunction } from "../../mui/handlers.js";
import { createWalletApiMock } from "../../test-utils.js"; import { createWalletApiMock } from "../../test-utils.js";
import { useComponentState } from "./state.js"; import { useComponentState } from "./state.js";

View File

@ -25,7 +25,7 @@ import {
LinkPrimary, LinkPrimary,
SvgIcon, SvgIcon,
} from "../../components/styled/index.js"; } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { Grid } from "../../mui/Grid.js"; import { Grid } from "../../mui/Grid.js";
import { Paper } from "../../mui/Paper.js"; import { Paper } from "../../mui/Paper.js";

View File

@ -34,7 +34,7 @@ import { SelectList } from "../components/SelectList.js";
import { NotifyUpdateFadeOut } from "../components/styled/index.js"; import { NotifyUpdateFadeOut } from "../components/styled/index.js";
import { Time } from "../components/Time.js"; import { Time } from "../components/Time.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { useDiagnostics } from "../hooks/useDiagnostics.js"; import { useDiagnostics } from "../hooks/useDiagnostics.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";

View File

@ -15,7 +15,7 @@
*/ */
import { h, VNode } from "preact"; import { h, VNode } from "preact";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { State } from "./index.js"; import { State } from "./index.js";
export function ReadyView({ error }: State.Ready): VNode { export function ReadyView({ error }: State.Ready): VNode {

View File

@ -17,7 +17,7 @@ import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { Title } from "../components/styled/index.js"; import { Title } from "../components/styled/index.js";
import { TermsOfService } from "../components/TermsOfService/index.js"; import { TermsOfService } from "../components/TermsOfService/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
export interface Props { export interface Props {

View File

@ -22,7 +22,7 @@ import {
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -25,7 +25,7 @@ import { SelectList } from "../../components/SelectList.js";
import { Input, SvgIcon } from "../../components/styled/index.js"; import { Input, SvgIcon } from "../../components/styled/index.js";
import { TermsOfService } from "../../components/TermsOfService/index.js"; import { TermsOfService } from "../../components/TermsOfService/index.js";
import { Time } from "../../components/Time.js"; import { Time } from "../../components/Time.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { State as SelectExchangeState } from "../../hooks/useSelectedExchange.js"; import { State as SelectExchangeState } from "../../hooks/useSelectedExchange.js";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import arrowDown from "../../svg/chevron-down.svg"; import arrowDown from "../../svg/chevron-down.svg";

View File

@ -27,7 +27,7 @@ import {
Title, Title,
WarningBox, WarningBox,
} from "../components/styled/index.js"; } from "../components/styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
export interface Props { export interface Props {

View File

@ -35,7 +35,7 @@ import { Time } from "../components/Time.js";
import { TransactionItem } from "../components/TransactionItem.js"; import { TransactionItem } from "../components/TransactionItem.js";
import { alertFromError, useAlertContext } from "../context/alert.js"; import { alertFromError, useAlertContext } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { NoBalanceHelp } from "../popup/NoBalanceHelp.js"; import { NoBalanceHelp } from "../popup/NoBalanceHelp.js";

View File

@ -24,7 +24,7 @@ import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js"; import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useDevContext } from "../../context/devContext.js"; import { useDevContext } from "../../context/devContext.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { AccountByType, Props, State } from "./index.js"; import { AccountByType, Props, State } from "./index.js";

View File

@ -29,7 +29,7 @@ import { useState } from "preact/hooks";
import { ErrorMessage } from "../../components/ErrorMessage.js"; import { ErrorMessage } from "../../components/ErrorMessage.js";
import { SelectList } from "../../components/SelectList.js"; import { SelectList } from "../../components/SelectList.js";
import { Input, SubTitle, SvgIcon } from "../../components/styled/index.js"; import { Input, SubTitle, SvgIcon } from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { TextFieldHandler } from "../../mui/handlers.js"; import { TextFieldHandler } from "../../mui/handlers.js";
import { TextField } from "../../mui/TextField.js"; import { TextField } from "../../mui/TextField.js";

View File

@ -17,7 +17,7 @@
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { alertFromError } from "../../context/alert.js"; import { alertFromError } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js"; import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js"; import { Props, State } from "./index.js";

View File

@ -28,7 +28,7 @@ import {
SmallLightText, SmallLightText,
} from "../../components/styled/index.js"; } from "../../components/styled/index.js";
import { Time } from "../../components/Time.js"; import { Time } from "../../components/Time.js";
import { useTranslationContext } from "../../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Avatar } from "../../mui/Avatar.js"; import { Avatar } from "../../mui/Avatar.js";
import { Button } from "../../mui/Button.js"; import { Button } from "../../mui/Button.js";
import { Grid } from "../../mui/Grid.js"; import { Grid } from "../../mui/Grid.js";

View File

@ -32,7 +32,7 @@ import {
Title, Title,
} from "../components/styled/index.js"; } from "../components/styled/index.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { queryToSlashConfig } from "../utils/index.js"; import { queryToSlashConfig } from "../utils/index.js";

View File

@ -30,7 +30,7 @@ import { PaymentStatus, SmallLightText } from "../components/styled/index.js";
import { Time } from "../components/Time.js"; import { Time } from "../components/Time.js";
import { alertFromError } from "../context/alert.js"; import { alertFromError } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";

View File

@ -23,7 +23,7 @@ import { styled } from "@linaria/react";
import { css } from "@linaria/core"; import { css } from "@linaria/core";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { Ref, useEffect, useMemo, useRef, useState } from "preact/hooks"; import { Ref, useEffect, useMemo, useRef, useState } from "preact/hooks";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Alert } from "../mui/Alert.js"; import { Alert } from "../mui/Alert.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { TextField } from "../mui/TextField.js"; import { TextField } from "../mui/TextField.js";

View File

@ -21,7 +21,7 @@ import { CopyButton } from "../components/CopyButton.js";
import { ErrorMessage } from "../components/ErrorMessage.js"; import { ErrorMessage } from "../components/ErrorMessage.js";
import { QR } from "../components/QR.js"; import { QR } from "../components/QR.js";
import { Title, WarningBox } from "../components/styled/index.js"; import { Title, WarningBox } from "../components/styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
export interface Props { export interface Props {
reservePub: string; reservePub: string;

View File

@ -36,9 +36,9 @@ import {
import { useAlertContext } from "../context/alert.js"; import { useAlertContext } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useDevContext } from "../context/devContext.js"; import { useDevContext } from "../context/devContext.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { useAutoOpenPermissions } from "../hooks/useAutoOpenPermissions.js"; import { useSettings } from "../hooks/useSettings.js";
import { useBackupDeviceName } from "../hooks/useBackupDeviceName.js"; import { useBackupDeviceName } from "../hooks/useBackupDeviceName.js";
import { useClipboardPermissions } from "../hooks/useClipboardPermissions.js"; import { useClipboardPermissions } from "../hooks/useClipboardPermissions.js";
import { ToggleHandler } from "../mui/handlers.js"; import { ToggleHandler } from "../mui/handlers.js";
@ -48,9 +48,10 @@ import { platform } from "../platform/foreground.js";
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
export function SettingsPage(): VNode { export function SettingsPage(): VNode {
const autoOpenToggle = useAutoOpenPermissions(); const [settings, updateSettings] = useSettings();
const clipboardToggle = useClipboardPermissions(); const clipboardToggle = useClipboardPermissions();
const { devMode, toggle } = useDevContext(); const { devMode, toggle } = useDevContext();
const { safely } = useAlertContext();
const { name, update } = useBackupDeviceName(); const { name, update } = useBackupDeviceName();
const { pushAlertOnError } = useAlertContext(); const { pushAlertOnError } = useAlertContext();
const webex = platform.getWalletWebExVersion(); const webex = platform.getWalletWebExVersion();
@ -71,7 +72,15 @@ export function SettingsPage(): VNode {
knownExchanges={exchanges} knownExchanges={exchanges}
deviceName={name} deviceName={name}
setDeviceName={update} setDeviceName={update}
autoOpenToggle={autoOpenToggle} autoOpenToggle={{
value: settings.injectTalerSupport,
button: {
onClick: safely("update support injection", async () => {
console.log("click", settings.injectTalerSupport);
updateSettings("injectTalerSupport", !settings.injectTalerSupport);
}),
},
}}
clipboardToggle={clipboardToggle} clipboardToggle={clipboardToggle}
devModeToggle={{ devModeToggle={{
value: devMode, value: devMode,
@ -115,21 +124,6 @@ export function SettingsView({
return ( return (
<Fragment> <Fragment>
<section> <section>
{/* <Checkbox
label={
i18n.str`Automatically check clipboard for Taler URI`
}
name="clipboard"
description={
<i18n.Translate>
Enabling this option below will make using the wallet faster, but
requires more permissions from your browser.
</i18n.Translate>
}
enabled={clipboardToggle.value!}
onToggle={clipboardToggle.button.onClick!}
/> */}
<SubTitle> <SubTitle>
<i18n.Translate>Trust</i18n.Translate> <i18n.Translate>Trust</i18n.Translate>
</SubTitle> </SubTitle>
@ -273,23 +267,22 @@ export function SettingsView({
enabled={devModeToggle.value!} enabled={devModeToggle.value!}
onToggle={devModeToggle.button.onClick!} onToggle={devModeToggle.button.onClick!}
/> />
<JustInDevMode> <SubTitle>
<SubTitle> <i18n.Translate>Navigator</i18n.Translate>
<i18n.Translate>Navigator</i18n.Translate> </SubTitle>
</SubTitle> <Checkbox
<Checkbox label={i18n.str`Automatically inject Taler API in all pages`}
label={i18n.str`Automatically open wallet based on page content`} name="inject"
name="autoOpen" description={
description={ <i18n.Translate>
<i18n.Translate> Disabling this option will make some web application not able to
Enabling this option below will make using the wallet faster, trigger the wallet when clicking links but you will be able to
but requires more permissions from your browser. open the wallet using the keyboard shortcut
</i18n.Translate> </i18n.Translate>
} }
enabled={autoOpenToggle.value!} enabled={autoOpenToggle.value!}
onToggle={autoOpenToggle.button.onClick!} onToggle={autoOpenToggle.button.onClick!}
/> />
</JustInDevMode>
</section> </section>
</Fragment> </Fragment>
); );

View File

@ -61,7 +61,7 @@ import {
import { Time } from "../components/Time.js"; import { Time } from "../components/Time.js";
import { alertFromError, useAlertContext } from "../context/alert.js"; import { alertFromError, useAlertContext } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js"; import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Button } from "../mui/Button.js"; import { Button } from "../mui/Button.js";
import { SafeHandler } from "../mui/handlers.js"; import { SafeHandler } from "../mui/handlers.js";
@ -283,10 +283,7 @@ function TransactionTemplate({
<Button <Button
variant="contained" variant="contained"
color="error" color="error"
onClick={safely( onClick={safely("delete transaction", onDelete)}
onDelete,
i18n.str`Could not forget transaction`,
)}
> >
<i18n.Translate>Confirm</i18n.Translate> <i18n.Translate>Confirm</i18n.Translate>
</Button> </Button>
@ -322,10 +319,7 @@ function TransactionTemplate({
<Button <Button
variant="contained" variant="contained"
color="error" color="error"
onClick={safely( onClick={safely("cancel active transaction", onCancel)}
onCancel,
i18n.str`Could not cancel the active transaction`,
)}
> >
<i18n.Translate>Yes</i18n.Translate> <i18n.Translate>Yes</i18n.Translate>
</Button> </Button>
@ -340,7 +334,7 @@ function TransactionTemplate({
{showSend ? ( {showSend ? (
<Button <Button
variant="contained" variant="contained"
onClick={safely(onSend, i18n.str`Could not send`)} onClick={safely("send transaction", onSend)}
> >
<i18n.Translate>Send</i18n.Translate> <i18n.Translate>Send</i18n.Translate>
</Button> </Button>
@ -350,7 +344,7 @@ function TransactionTemplate({
{showRetry ? ( {showRetry ? (
<Button <Button
variant="contained" variant="contained"
onClick={safely(onRetry, i18n.str`Could not retry`)} onClick={safely("retry transaction", onRetry)}
> >
<i18n.Translate>Retry</i18n.Translate> <i18n.Translate>Retry</i18n.Translate>
</Button> </Button>
@ -627,9 +621,8 @@ export function TransactionView({
<div> <div>
<Button <Button
variant="contained" variant="contained"
onClick={safely( onClick={safely("refund transaction", () =>
() => onRefund(transaction.proposalId), onRefund(transaction.proposalId),
i18n.str`Could not refund`,
)} )}
> >
<i18n.Translate>Accept</i18n.Translate> <i18n.Translate>Accept</i18n.Translate>

View File

@ -24,18 +24,27 @@ import { WalletDiagnostics } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
import { Checkbox } from "../components/Checkbox.js"; import { Checkbox } from "../components/Checkbox.js";
import { SubTitle, Title } from "../components/styled/index.js"; import { SubTitle, Title } from "../components/styled/index.js";
import { useTranslationContext } from "../context/translation.js"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { useDiagnostics } from "../hooks/useDiagnostics.js"; import { useDiagnostics } from "../hooks/useDiagnostics.js";
import { useAutoOpenPermissions } from "../hooks/useAutoOpenPermissions.js"; import { useSettings } from "../hooks/useSettings.js";
import { ToggleHandler } from "../mui/handlers.js"; import { ToggleHandler } from "../mui/handlers.js";
import { platform } from "../platform/foreground.js"; import { platform } from "../platform/foreground.js";
import { useAlertContext } from "../context/alert.js";
export function WelcomePage(): VNode { export function WelcomePage(): VNode {
const permissionToggle = useAutoOpenPermissions(); const [settings, updateSettings] = useSettings();
const { safely } = useAlertContext();
const [diagnostics, timedOut] = useDiagnostics(); const [diagnostics, timedOut] = useDiagnostics();
return ( return (
<View <View
permissionToggle={permissionToggle} permissionToggle={{
value: settings.injectTalerSupport,
button: {
onClick: safely("update support injection", async () =>
updateSettings("injectTalerSupport", !settings.injectTalerSupport),
),
},
}}
diagnostics={diagnostics} diagnostics={diagnostics}
timedOut={timedOut} timedOut={timedOut}
/> />
@ -88,15 +97,16 @@ export function View({
</Fragment> </Fragment>
)} )}
<SubTitle> <SubTitle>
<i18n.Translate>Permissions</i18n.Translate> <i18n.Translate>Navigator</i18n.Translate>
</SubTitle> </SubTitle>
<Checkbox <Checkbox
label={i18n.str`Automatically open wallet based on page content`} label={i18n.str`Automatically inject Taler API in all pages`}
name="perm" name="inject"
description={ description={
<i18n.Translate> <i18n.Translate>
(Enabling this option below will make using the wallet faster, but Disabling this option will make some web application not able to
requires more permissions from your browser.) trigger the wallet when clicking links but you will be able to
open the wallet using the keyboard shortcut
</i18n.Translate> </i18n.Translate>
} }
enabled={permissionToggle.value!} enabled={permissionToggle.value!}

View File

@ -31,9 +31,6 @@
{ {
"path": "../taler-wallet-core/" "path": "../taler-wallet-core/"
}, },
{
"path": "../web-util/"
},
{ {
"path": "../taler-util/" "path": "../taler-util/"
} }