This commit is contained in:
Sebastian 2022-01-31 14:56:12 -03:00
parent c47311b4a7
commit 47bd790b7b
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 26 additions and 8 deletions

View File

@ -8,7 +8,7 @@
"serve": "sirv build --port ${PORT:=8080} --cors --single",
"dev": "preact watch --port ${PORT:=8080} --no-sw --no-esm",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
"test": "jest ./tests",
"test": "echo no tests",
"build-storybook": "build-storybook",
"build-single": "preact build --no-sw --no-esm -c preact.single-config.js --dest single && sh remove-link-stylesheet.sh",
"serve-single": "sirv single --port ${PORT:=8080} --cors --single",
@ -61,4 +61,4 @@
"sirv-cli": "^1.0.14",
"typescript": "^4.5.4"
}
}
}

View File

@ -357,7 +357,7 @@ export function PaymentRequestView({
kind="neutral"
/>
)}
{contractTerms.products && (
{contractTerms.products && contractTerms.products.length > 0 && (
<ProductList products={contractTerms.products} />
)}
</section>

View File

@ -29,6 +29,24 @@ export interface Props {
onDismiss: () => void;
}
async function getCurrentTab(): Promise<chrome.tabs.Tab> {
let queryOptions = { active: true, currentWindow: true };
const tab = await new Promise<chrome.tabs.Tab>((res, rej) => {
chrome.tabs.query(queryOptions, (tabs) => {
res(tabs[0]);
});
});
return tab;
}
async function navigateTo(url?: string) {
if (!url) return;
const tab = await getCurrentTab();
if (!tab.id) return;
await chrome.tabs.update(tab.id, { url });
window.close();
}
export function TalerActionFound({ url, onDismiss }: Props) {
const uriType = classifyTalerUri(url);
return (
@ -40,7 +58,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {
<p>This page has pay action.</p>
<ButtonSuccess
onClick={() => {
chrome.tabs.create({ url: actionForTalerUri(uriType, url) });
navigateTo(actionForTalerUri(uriType, url));
}}
>
Open pay page
@ -52,7 +70,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {
<p>This page has a withdrawal action.</p>
<ButtonSuccess
onClick={() => {
chrome.tabs.create({ url: actionForTalerUri(uriType, url) });
navigateTo(actionForTalerUri(uriType, url));
}}
>
Open withdraw page
@ -64,7 +82,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {
<p>This page has a tip action.</p>
<ButtonSuccess
onClick={() => {
chrome.tabs.create({ url: actionForTalerUri(uriType, url) });
navigateTo(actionForTalerUri(uriType, url));
}}
>
Open tip page
@ -76,7 +94,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {
<p>This page has a notify reserve action.</p>
<ButtonSuccess
onClick={() => {
chrome.tabs.create({ url: actionForTalerUri(uriType, url) });
navigateTo(actionForTalerUri(uriType, url));
}}
>
Notify
@ -88,7 +106,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {
<p>This page has a refund action.</p>
<ButtonSuccess
onClick={() => {
chrome.tabs.create({ url: actionForTalerUri(uriType, url) });
navigateTo(actionForTalerUri(uriType, url));
}}
>
Open refund page