taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 7f9e128ca97d9f457d8ecac11d4b5cf8d0d7fe95
parent 05980dc52c57681bc1dc7dbe1a4cb46129ce82da
Author: Sebastian <sebasjm@taler-systems.com>
Date:   Thu, 12 Feb 2026 11:39:56 -0300

developer mode only for the current session, (same as others spa)

Diffstat:
Mpackages/merchant-backoffice-ui/src/components/form/FormProvider.tsx | 6+++---
Mpackages/merchant-backoffice-ui/src/components/modal/index.tsx | 5+++--
Mpackages/merchant-backoffice-ui/src/hooks/preference.ts | 3---
Mpackages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx | 30+++++++++++++++---------------
Mpackages/merchant-backoffice-ui/src/paths/login/index.tsx | 6+++---
Mpackages/merchant-backoffice-ui/src/paths/settings/index.tsx | 8++++----
Mpackages/web-util/src/components/NotificationBanner.tsx | 10++--------
7 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/packages/merchant-backoffice-ui/src/components/form/FormProvider.tsx b/packages/merchant-backoffice-ui/src/components/form/FormProvider.tsx @@ -28,6 +28,7 @@ import { import { ComponentChildren, createContext, h, VNode } from "preact"; import { useContext, useMemo } from "preact/hooks"; import { usePreference } from "../../hooks/preference.js"; +import { useCommonPreferences } from "@gnu-taler/web-util/browser"; type Updater<S> = (value: (prevState: S) => S) => void; @@ -61,12 +62,11 @@ export function FormProvider<T>({ }), [errors, object, valueHandler], ); - const [{ developer }] = usePreference(); - + const [{ showDebugInfo }] = useCommonPreferences(); return ( <FormContext.Provider value={value}> <form>{children}</form> - {developer ? <pre>{JSON.stringify(value.object, undefined, 2)}</pre> : undefined} + {showDebugInfo ? <pre>{JSON.stringify(value.object, undefined, 2)}</pre> : undefined} </FormContext.Provider> ); } diff --git a/packages/merchant-backoffice-ui/src/components/modal/index.tsx b/packages/merchant-backoffice-ui/src/components/modal/index.tsx @@ -28,6 +28,7 @@ import { import { ButtonBetterBulma, SafeHandlerTemplate, + useCommonPreferences, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { ComponentChildren, Fragment, h, VNode } from "preact"; @@ -433,7 +434,7 @@ export function ValidBankAccount({ const qrs = getQrCodesForPayto(Paytos.toFullString(payto)); const strPayto = Paytos.toFullString(payto); - const [{ developer }] = usePreference(); + const [{ showDebugInfo }] = useCommonPreferences(); return ( <ConfirmModal label={i18n.str`OK`} @@ -442,7 +443,7 @@ export function ValidBankAccount({ onCancel={onCancel} // onConfirm={onConfirm} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto, payto }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> diff --git a/packages/merchant-backoffice-ui/src/hooks/preference.ts b/packages/merchant-backoffice-ui/src/hooks/preference.ts @@ -65,7 +65,6 @@ export interface Preferences { hideMissingAccountUntil: AbsoluteTime; dateFormat: "ymd" | "dmy" | "mdy"; persona?: MerchantPersona; - developer: boolean; } const defaultSettings: Preferences = { @@ -73,14 +72,12 @@ const defaultSettings: Preferences = { hideMissingAccountUntil: AbsoluteTime.never(), dateFormat: "ymd", persona: undefined, - developer: false, }; export const codecForPreferences = (): Codec<Preferences> => buildCodecForObject<Preferences>() .property("hideKycUntil", codecForAbsoluteTime) - .property("developer", codecOptionalDefault(codecForBoolean(), false)) .property("hideMissingAccountUntil", codecForAbsoluteTime) .property( "dateFormat", diff --git a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx @@ -26,7 +26,7 @@ import { TalerMerchantApi, assertUnreachable, } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; +import { useCommonPreferences, useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; @@ -113,7 +113,7 @@ function ShowInstructionForKycRedirect({ onCancel: () => void; }): VNode { const { i18n } = useTranslationContext(); - const [{ developer }] = usePreference(); + const [{ showDebugInfo }] = useCommonPreferences(); switch (e.status) { case TalerMerchantApi.MerchantAccountKycStatus.KYC_WIRE_REQUIRED: const uri = Paytos.fromString(e.payto_uri); @@ -125,7 +125,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre> {JSON.stringify({ strPayto: e.payto_uri, uri }, undefined, 2)} </pre> @@ -160,7 +160,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -180,7 +180,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -203,7 +203,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -241,7 +241,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -261,7 +261,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -281,7 +281,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -301,7 +301,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -321,7 +321,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -341,7 +341,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -362,7 +362,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -382,7 +382,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre>{JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)}</pre> )} <p style={{ paddingTop: 0 }}> @@ -402,7 +402,7 @@ function ShowInstructionForKycRedirect({ active onCancel={onCancel} > - {!developer ? undefined : ( + {!showDebugInfo ? undefined : ( <pre> {JSON.stringify({ strPayto: e.payto_uri }, undefined, 2)} </pre> diff --git a/packages/merchant-backoffice-ui/src/paths/login/index.tsx b/packages/merchant-backoffice-ui/src/paths/login/index.tsx @@ -77,7 +77,7 @@ export function LoginPage({ showCreateAccount, focus }: Props): VNode { const mfa = useChallengeHandler(); const login = safeFunctionHandler( - i18n.str`create access token`, + i18n.str`login`, (usr: string, pwd: string, challengeIds: string[]) => { const api = getInstanceForUsername(usr); return api.createAccessToken( @@ -98,9 +98,9 @@ export function LoginPage({ showCreateAccount, focus }: Props): VNode { mfa.onChallengeRequired(fail.body); return undefined; case HttpStatusCode.Unauthorized: - return i18n.str`Unauthorized`; + return i18n.str`Wrong password.`; case HttpStatusCode.NotFound: - return i18n.str`Not found`; + return i18n.str`The account doesn't exist.`; default: assertUnreachable(fail); } diff --git a/packages/merchant-backoffice-ui/src/paths/settings/index.tsx b/packages/merchant-backoffice-ui/src/paths/settings/index.tsx @@ -39,7 +39,7 @@ import { InputBoolean } from "../../components/form/InputBoolean.js"; const TALER_SCREEN_ID = 83; -type FormType = Preferences; +type FormType = Preferences & {developer: boolean}; export function Settings({ onClose }: { onClose?: () => void }): VNode { const { i18n } = useTranslationContext(); const { config } = useSessionContext(); @@ -47,9 +47,10 @@ export function Settings({ onClose }: { onClose?: () => void }): VNode { const [{ showDebugInfo }, updateCommonPref] = useCommonPreferences(); const errors: FormErrors<FormType> = {}; - const formValue: typeof value = { + const formValue: FormType = { ...value, persona: value.persona ?? config.default_persona, + developer: showDebugInfo }; function valueHandler(s: (d: Partial<FormType>) => Partial<FormType>): void { @@ -60,7 +61,6 @@ export function Settings({ onClose }: { onClose?: () => void }): VNode { hideKycUntil: next.hideKycUntil ?? AbsoluteTime.never(), dateFormat: next.dateFormat ?? "ymd", persona: next.persona ?? config.default_persona, - developer: next.developer ?? false }; const isDeveloper = next.developer === true; @@ -177,7 +177,7 @@ export function Settings({ onClose }: { onClose?: () => void }): VNode { }} /> ) : undefined} - {value.developer ? ( + {formValue.developer === true ? ( <NotificationCardBulma notification={{ message: i18n.str`Developer mode`, diff --git a/packages/web-util/src/components/NotificationBanner.tsx b/packages/web-util/src/components/NotificationBanner.tsx @@ -119,14 +119,8 @@ export function LocalNotificationBannerBulma({ ) : ( <div>{msg.description[0]}</div> )} - {moreInfo ? ( - <a - onClick={() => setMoreInfo(false)} - type="button" - style={{ justifySelf: "right", color: "gray" }} - > - <i18n.Translate>show less info</i18n.Translate> - </a> + {moreInfo || msg.description.length === 1 ? ( + undefined ) : ( <a onClick={() => setMoreInfo(true)}