fixed width for popup, fixed url redirect on manual taler link lookup, fixed uncontrolled checkbox handling
This commit is contained in:
parent
bb10e038c9
commit
f0ab1449c5
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
AmountJson,
|
AmountJson,
|
||||||
Amounts,
|
Amounts,
|
||||||
BalancesResponse,
|
BalancesResponse,
|
||||||
@ -66,7 +66,6 @@ function Tab(props: TabProps): JSX.Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function WalletNavBar({ current }: { current?: string }) {
|
function WalletNavBar({ current }: { current?: string }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="nav" id="header">
|
<div className="nav" id="header">
|
||||||
<Tab target="/popup/balance" current={current}>{i18n.str`Balance`}</Tab>
|
<Tab target="/popup/balance" current={current}>{i18n.str`Balance`}</Tab>
|
||||||
@ -502,19 +501,19 @@ function actionForTalerUri(talerUri: string): string | undefined {
|
|||||||
const uriType = classifyTalerUri(talerUri);
|
const uriType = classifyTalerUri(talerUri);
|
||||||
switch (uriType) {
|
switch (uriType) {
|
||||||
case TalerUriType.TalerWithdraw:
|
case TalerUriType.TalerWithdraw:
|
||||||
return makeExtensionUrlWithParams("static/withdraw.html", {
|
return makeExtensionUrlWithParams("static/popup.html#/withdraw", {
|
||||||
talerWithdrawUri: talerUri,
|
talerWithdrawUri: talerUri,
|
||||||
});
|
});
|
||||||
case TalerUriType.TalerPay:
|
case TalerUriType.TalerPay:
|
||||||
return makeExtensionUrlWithParams("static/pay.html", {
|
return makeExtensionUrlWithParams("static/popup.html#/pay", {
|
||||||
talerPayUri: talerUri,
|
talerPayUri: talerUri,
|
||||||
});
|
});
|
||||||
case TalerUriType.TalerTip:
|
case TalerUriType.TalerTip:
|
||||||
return makeExtensionUrlWithParams("static/tip.html", {
|
return makeExtensionUrlWithParams("static/popup.html#/tip", {
|
||||||
talerTipUri: talerUri,
|
talerTipUri: talerUri,
|
||||||
});
|
});
|
||||||
case TalerUriType.TalerRefund:
|
case TalerUriType.TalerRefund:
|
||||||
return makeExtensionUrlWithParams("static/refund.html", {
|
return makeExtensionUrlWithParams("static/popup.html#/refund", {
|
||||||
talerRefundUri: talerUri,
|
talerRefundUri: talerUri,
|
||||||
});
|
});
|
||||||
case TalerUriType.TalerNotifyReserve:
|
case TalerUriType.TalerNotifyReserve:
|
||||||
@ -535,7 +534,7 @@ async function findTalerUriInActiveTab(): Promise<string | undefined> {
|
|||||||
{
|
{
|
||||||
code: `
|
code: `
|
||||||
(() => {
|
(() => {
|
||||||
let x = document.querySelector("a[href^='taler://'");
|
let x = document.querySelector("a[href^='taler://'") || document.querySelector("a[href^='taler+http://'");
|
||||||
return x ? x.href.toString() : null;
|
return x ? x.href.toString() : null;
|
||||||
})();
|
})();
|
||||||
`,
|
`,
|
||||||
@ -568,10 +567,10 @@ export function WalletPopup(): JSX.Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
check();
|
check();
|
||||||
});
|
}, []);
|
||||||
if (talerActionUrl && !dismissed) {
|
if (talerActionUrl && !dismissed) {
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: "1em" }}>
|
<div style={{ padding: "1em", width: 400 }}>
|
||||||
<h1>Taler Action</h1>
|
<h1>Taler Action</h1>
|
||||||
<p>This page has a Taler action. </p>
|
<p>This page has a Taler action. </p>
|
||||||
<p>
|
<p>
|
||||||
@ -592,7 +591,7 @@ export function WalletPopup(): JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Match>{({ path }: any) => <WalletNavBar current={path} />}</Match>
|
<Match>{({ path }: any) => <WalletNavBar current={path} />}</Match>
|
||||||
<div style={{ margin: "1em" }}>
|
<div style={{ margin: "1em", width: 400 }}>
|
||||||
<Router>
|
<Router>
|
||||||
<Route path={Pages.balance} component={WalletBalanceView} />
|
<Route path={Pages.balance} component={WalletBalanceView} />
|
||||||
<Route path={Pages.settings} component={WalletSettings} />
|
<Route path={Pages.settings} component={WalletSettings} />
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useState, useEffect } from "preact/hooks";
|
import { useState, useEffect, useMemo, useCallback } from "preact/hooks";
|
||||||
import { getDiagnostics } from "../wxApi";
|
import { getDiagnostics } from "../wxApi";
|
||||||
import { PageLink } from "../renderHtml";
|
import { PageLink } from "../renderHtml";
|
||||||
import * as wxApi from "../wxApi";
|
import * as wxApi from "../wxApi";
|
||||||
import { getPermissionsApi } from "../compat";
|
import { getPermissionsApi } from "../compat";
|
||||||
import { extendedPermissions } from "../permissions";
|
import { extendedPermissions } from "../permissions";
|
||||||
import { WalletDiagnostics } from "@gnu-taler/taler-util";
|
import { WalletDiagnostics } from "@gnu-taler/taler-util";
|
||||||
import { JSX } from "preact/jsx-runtime";
|
import { Fragment, JSX } from "preact/jsx-runtime";
|
||||||
|
|
||||||
function Diagnostics(): JSX.Element | null {
|
function Diagnostics(): JSX.Element | null {
|
||||||
const [timedOut, setTimedOut] = useState(false);
|
const [timedOut, setTimedOut] = useState(false);
|
||||||
@ -100,7 +100,7 @@ function Diagnostics(): JSX.Element | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function handleExtendedPerm(isEnabled: boolean, setEnable: (v:boolean) => void): Promise<void> {
|
async function handleExtendedPerm(isEnabled: boolean): Promise<boolean> {
|
||||||
let nextVal: boolean | undefined;
|
let nextVal: boolean | undefined;
|
||||||
|
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
@ -124,26 +124,33 @@ async function handleExtendedPerm(isEnabled: boolean, setEnable: (v:boolean) =>
|
|||||||
const res = await wxApi.setExtendedPermissions(false);
|
const res = await wxApi.setExtendedPermissions(false);
|
||||||
nextVal = res.newValue;
|
nextVal = res.newValue;
|
||||||
}
|
}
|
||||||
console.log("new permissions applied:", nextVal);
|
console.log("new permissions applied:", nextVal ?? false);
|
||||||
setEnable(nextVal ?? false);
|
return nextVal ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PermissionsCheckbox(): JSX.Element {
|
export function PermissionsCheckbox(): JSX.Element {
|
||||||
const [extendedPermissionsEnabled, setExtendedPermissionsEnabled] = useState(false);
|
const [extendedPermissionsEnabled, setExtendedPermissionsEnabled] = useState(false);
|
||||||
|
|
||||||
|
const togglePermission = () => {
|
||||||
|
setExtendedPermissionsEnabled(v => !v)
|
||||||
|
handleExtendedPerm(extendedPermissionsEnabled).then( result => {
|
||||||
|
setExtendedPermissionsEnabled(result)
|
||||||
|
} )
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getExtendedPermValue(): Promise<void> {
|
async function getExtendedPermValue(): Promise<void> {
|
||||||
const res = await wxApi.getExtendedPermissions();
|
const res = await wxApi.getExtendedPermissions();
|
||||||
setExtendedPermissionsEnabled(res.newValue);
|
setExtendedPermissionsEnabled(res.newValue);
|
||||||
}
|
}
|
||||||
getExtendedPermValue();
|
getExtendedPermValue();
|
||||||
});
|
},[]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
checked={extendedPermissionsEnabled}
|
checked={extendedPermissionsEnabled}
|
||||||
onChange={() => handleExtendedPerm(extendedPermissionsEnabled, setExtendedPermissionsEnabled) }
|
onClick={togglePermission}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="checkbox-perm"
|
id="checkbox-perm"
|
||||||
style={{ width: "1.5em", height: "1.5em", verticalAlign: "middle" }}
|
style={{ width: "1.5em", height: "1.5em", verticalAlign: "middle" }}
|
||||||
|
Loading…
Reference in New Issue
Block a user