diff --git a/packages/taler-wallet-webextension/src/popup/DeveloperPage.stories.tsx b/packages/taler-wallet-webextension/src/popup/DeveloperPage.stories.tsx index 1239a03e9..ea8a3537a 100644 --- a/packages/taler-wallet-webextension/src/popup/DeveloperPage.stories.tsx +++ b/packages/taler-wallet-webextension/src/popup/DeveloperPage.stories.tsx @@ -32,6 +32,7 @@ export default { }; export const AllOff = createExample(TestedComponent, { + onDownloadDatabase: async () => "this is the content of the database", operations: [ { type: PendingTaskType.ExchangeUpdate, diff --git a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx index 494f8ecbf..8d24545d5 100644 --- a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx @@ -16,15 +16,19 @@ import { NotificationType } from "@gnu-taler/taler-util"; import { PendingTaskInfo } from "@gnu-taler/taler-wallet-core"; +import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; +import { useState } from "preact/hooks"; import { Diagnostics } from "../components/Diagnostics"; import { NotifyUpdateFadeOut } from "../components/styled/index"; +import { Time } from "../components/Time"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { useDiagnostics } from "../hooks/useDiagnostics"; import * as wxApi from "../wxApi"; export function DeveloperPage(): VNode { const [status, timedOut] = useDiagnostics(); + const listenAllEvents = Array.from({ length: 1 }); listenAllEvents.includes = () => true; // includes every event const operationsResponse = useAsyncAsHook( @@ -39,19 +43,33 @@ export function DeveloperPage(): VNode { ? [] : operationsResponse.response.pendingOperations; - return ; + return "content"} + />; } + export interface Props { status: any; timedOut: boolean; operations: PendingTaskInfo[]; + onDownloadDatabase: () => Promise; } function hashObjectId(o: any): string { return JSON.stringify(o); } -export function View({ status, timedOut, operations }: Props): VNode { +export function View({ status, timedOut, operations, onDownloadDatabase }: Props): VNode { + const [downloadedDatabase, setDownloadedDatabase] = useState<{time: Date; content: string}|undefined>(undefined) + async function onExportDatabase(): Promise { + const content = await onDownloadDatabase() + setDownloadedDatabase({ + time: new Date(), + content + }) + } return (

Debug tools:

@@ -61,6 +79,11 @@ export function View({ status, timedOut, operations }: Props): VNode {
+ + {downloadedDatabase &&
+ Database exported at
} +
{operations && operations.length > 0 && (