diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/popup')
-rw-r--r-- | packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx index 840398a44..ea87ba01f 100644 --- a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx @@ -18,7 +18,7 @@ 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 { useRef, useState } from "preact/hooks"; import { Diagnostics } from "../components/Diagnostics"; import { NotifyUpdateFadeOut } from "../components/styled"; import { Time } from "../components/Time"; @@ -83,11 +83,34 @@ export function View({ content, }); } + const fileRef = useRef<HTMLInputElement>(null); + async function onImportDatabase(str: string): Promise<void> { + return wxApi.importDB(JSON.parse(str)); + } return ( <div> <p>Debug tools:</p> <button onClick={confirmReset}>reset</button> <br /> + <button onClick={() => fileRef?.current?.click()}>import database</button> + <input + ref={fileRef} + style={{ display: "none" }} + type="file" + onChange={async (e) => { + const f: FileList | null = e.currentTarget.files; + if (!f || f.length != 1) { + return Promise.reject(); + } + const buf = await f[0].arrayBuffer(); + const str = new Uint8Array(buf).reduce( + (data, byte) => data + String.fromCharCode(byte), + "", + ); + return onImportDatabase(str); + }} + /> + <br /> <button onClick={onExportDatabase}>export database</button> {downloadedDatabase && ( <div> @@ -152,6 +175,8 @@ export function reload(): void { } } +function runIntegrationTest() {} + export async function confirmReset(): Promise<void> { if ( confirm( |