From 47bd790b7b657fedf268dd7109cb0584cca752ac Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 31 Jan 2022 14:56:12 -0300 Subject: [PATCH] fix: #7164 --- packages/anastasis-webui/package.json | 4 +-- .../taler-wallet-webextension/src/cta/Pay.tsx | 2 +- .../src/popup/TalerActionFound.tsx | 28 +++++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/anastasis-webui/package.json b/packages/anastasis-webui/package.json index 71793550e..96ff60b41 100644 --- a/packages/anastasis-webui/package.json +++ b/packages/anastasis-webui/package.json @@ -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" } -} +} \ No newline at end of file diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 427a3a715..806338c4d 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -357,7 +357,7 @@ export function PaymentRequestView({ kind="neutral" /> )} - {contractTerms.products && ( + {contractTerms.products && contractTerms.products.length > 0 && ( )} diff --git a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx index 45c4203e8..5de457614 100644 --- a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx +++ b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx @@ -29,6 +29,24 @@ export interface Props { onDismiss: () => void; } +async function getCurrentTab(): Promise { + let queryOptions = { active: true, currentWindow: true }; + const tab = await new Promise((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) {

This page has pay action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open pay page @@ -52,7 +70,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a withdrawal action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open withdraw page @@ -64,7 +82,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a tip action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open tip page @@ -76,7 +94,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a notify reserve action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Notify @@ -88,7 +106,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a refund action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open refund page