diff options
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx | 7 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx | 187 |
2 files changed, 92 insertions, 102 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx index 2ca5305f5..c2c794e89 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx @@ -19,10 +19,9 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { PendingTaskType, TaskId } from "@gnu-taler/taler-wallet-core"; +import { AbsoluteTime } from "@gnu-taler/taler-util"; import * as tests from "@gnu-taler/web-util/testing"; import { View as TestedComponent } from "./DeveloperPage.js"; -import { AbsoluteTime, PendingIdStr } from "@gnu-taler/taler-util"; export default { title: "developer", @@ -36,8 +35,8 @@ export const AllOff = tests.createExample(TestedComponent, { onDownloadDatabase: async () => "this is the content of the database", operations: [ { - id: " " as TaskId, - type: PendingTaskType.ExchangeUpdate, + id: " ", + type: "exchange-update", exchangeBaseUrl: "http://exchange.url.", givesLifeness: false, lastError: undefined, diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index 5230d830f..0db7a07eb 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -23,26 +23,23 @@ import { LogLevel, NotificationType, } from "@gnu-taler/taler-util"; -import { - PendingTaskInfo, - WalletApiOperation, -} from "@gnu-taler/taler-wallet-core"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, VNode, h } from "preact"; import { useEffect, useRef, useState } from "preact/hooks"; +import { Checkbox } from "../components/Checkbox.js"; import { SelectList } from "../components/SelectList.js"; import { Time } from "../components/Time.js"; import { NotifyUpdateFadeOut } from "../components/styled/index.js"; +import { useAlertContext } from "../context/alert.js"; import { useBackendContext } from "../context/backend.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { useSettings } from "../hooks/useSettings.js"; import { Button } from "../mui/Button.js"; import { Grid } from "../mui/Grid.js"; import { Paper } from "../mui/Paper.js"; import { TextField } from "../mui/TextField.js"; -import { Checkbox } from "../components/Checkbox.js"; -import { useSettings } from "../hooks/useSettings.js"; -import { useAlertContext } from "../context/alert.js"; export function DeveloperPage(): VNode { const listenAllEvents = Array.from<NotificationType>({ length: 1 }); @@ -105,7 +102,8 @@ type SplitedCoinInfo = { }; export interface Props { - operations: PendingTaskInfo[]; + // FIXME: Pending operations don't exist anymore. + operations: any[]; coins: CoinsInfo; exchanges: ExchangeListItem[]; onDownloadDatabase: () => Promise<string>; @@ -351,8 +349,8 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { name="inject" description={ <i18n.Translate> - Enabling this option will make `window.taler` be available - in all sites + Enabling this option will make `window.taler` be available in all + sites </i18n.Translate> } enabled={settings.injectTalerSupport!} @@ -361,7 +359,6 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { })} /> - <Paper style={{ padding: 10, margin: 10 }}> <h3>Logging</h3> <div> @@ -414,8 +411,8 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { <Button variant="contained" onClick={async () => { - const resp = await fetch(new URL("/keys", exchangeURL).href) - const j = await resp.json() + const resp = await fetch(new URL("/keys", exchangeURL).href); + const j = await resp.json(); api.wallet.call(WalletApiOperation.AddGlobalCurrencyExchange, { currency: j.currency, exchangeBaseUrl: j.base_url, @@ -426,98 +423,92 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { Set exchange as Global </Button> </Paper> - { - downloadedDatabase && ( - <div> - <i18n.Translate> - Database exported at{" "} - <Time - timestamp={AbsoluteTime.fromMilliseconds( - downloadedDatabase.time.getTime(), - )} - format="yyyy/MM/dd HH:mm:ss" - />{" "} - <a - href={`data:text/plain;charset=utf-8;base64,${toBase64( - downloadedDatabase.content, - )}`} - download={`taler-wallet-database-${format( - downloadedDatabase.time, - "yyyy/MM/dd_HH:mm", - )}.json`} - > - <i18n.Translate>click here</i18n.Translate> - </a>{" "} - to download - </i18n.Translate> - </div> - ) - } + {downloadedDatabase && ( + <div> + <i18n.Translate> + Database exported at{" "} + <Time + timestamp={AbsoluteTime.fromMilliseconds( + downloadedDatabase.time.getTime(), + )} + format="yyyy/MM/dd HH:mm:ss" + />{" "} + <a + href={`data:text/plain;charset=utf-8;base64,${toBase64( + downloadedDatabase.content, + )}`} + download={`taler-wallet-database-${format( + downloadedDatabase.time, + "yyyy/MM/dd_HH:mm", + )}.json`} + > + <i18n.Translate>click here</i18n.Translate> + </a>{" "} + to download + </i18n.Translate> + </div> + )} <br /> <p> <i18n.Translate>Coins</i18n.Translate>: </p> - { - Object.keys(money_by_exchange).map((ex, idx) => { - const allcoins = money_by_exchange[ex]; - allcoins.sort((a, b) => { - if (b.denom_value !== a.denom_value) { - return b.denom_value - a.denom_value; - } - return b.denom_fraction - a.denom_fraction; - }); + {Object.keys(money_by_exchange).map((ex, idx) => { + const allcoins = money_by_exchange[ex]; + allcoins.sort((a, b) => { + if (b.denom_value !== a.denom_value) { + return b.denom_value - a.denom_value; + } + return b.denom_fraction - a.denom_fraction; + }); - const coins = allcoins.reduce( - (prev, cur) => { - if (cur.status === CoinStatus.Fresh) prev.usable.push(cur); - if (cur.status === CoinStatus.Dormant) prev.spent.push(cur); - return prev; - }, - { - spent: [], - usable: [], - } as SplitedCoinInfo, - ); + const coins = allcoins.reduce( + (prev, cur) => { + if (cur.status === CoinStatus.Fresh) prev.usable.push(cur); + if (cur.status === CoinStatus.Dormant) prev.spent.push(cur); + return prev; + }, + { + spent: [], + usable: [], + } as SplitedCoinInfo, + ); - return ( - <ShowAllCoins - key={idx} - coins={coins} - ex={ex} - currencies={currencies} - /> - ); - }) - } + return ( + <ShowAllCoins + key={idx} + coins={coins} + ex={ex} + currencies={currencies} + /> + ); + })} <br /> - { - operations && operations.length > 0 && ( - <Fragment> - <p> - <i18n.Translate>Pending operations</i18n.Translate> - </p> - <dl> - {operations.reverse().map((o) => { - return ( - <NotifyUpdateFadeOut key={hashObjectId(o)}> - <dt> - {o.type}{" "} - <Time - timestamp={o.timestampDue} - format="yy/MM/dd HH:mm:ss" - /> - </dt> - <dd> - <pre>{JSON.stringify(o, undefined, 2)}</pre> - </dd> - </NotifyUpdateFadeOut> - ); - })} - </dl> - </Fragment> - ) - } - </div > + {operations && operations.length > 0 && ( + <Fragment> + <p> + <i18n.Translate>Pending operations</i18n.Translate> + </p> + <dl> + {operations.reverse().map((o) => { + return ( + <NotifyUpdateFadeOut key={hashObjectId(o)}> + <dt> + {o.type}{" "} + <Time + timestamp={o.timestampDue} + format="yy/MM/dd HH:mm:ss" + /> + </dt> + <dd> + <pre>{JSON.stringify(o, undefined, 2)}</pre> + </dd> + </NotifyUpdateFadeOut> + ); + })} + </dl> + </Fragment> + )} + </div> ); } |