commit aacf7d4424d5d79b0f47882180603acd42e135f5
parent 4002f124f2bfe26e5084012ed6d1cda56ddee37a
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Fri, 7 Nov 2025 21:50:32 +0100
make forward to contact a proper button
Diffstat:
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -25,6 +25,7 @@ import {
ScopeInfo,
TalerUri,
TalerUriAction,
+ TransactionIdStr,
TranslatedString,
parsePaytoUri,
parseScopeInfoShort,
@@ -437,6 +438,9 @@ export function Application(): VNode {
}),
)
}
+ onForwardToContact={(tid: TransactionIdStr) =>
+ redirectTo(Pages.contacts({tid}))
+ }
/>
</WalletTemplate>
)}
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -80,9 +80,14 @@ import refreshIcon from "../svg/refresh_24px.inline.svg";
interface Props {
tid: string;
goToWalletHistory: (scope?: ScopeInfo) => Promise<void>;
+ onForwardToContact?: (id: TransactionIdStr) => Promise<void>;
}
-export function TransactionPage({ tid, goToWalletHistory }: Props): VNode {
+export function TransactionPage({
+ tid,
+ goToWalletHistory,
+ onForwardToContact,
+}: Props): VNode {
const transactionId = tid as TransactionIdStr; //FIXME: validate
const { i18n } = useTranslationContext();
const api = useBackendContext();
@@ -166,6 +171,7 @@ export function TransactionPage({ tid, goToWalletHistory }: Props): VNode {
});
}}
onBack={() => goToWalletHistory(txScope)}
+ onForwardToContact={onForwardToContact}
/>
);
}
@@ -180,6 +186,7 @@ export interface WalletTransactionProps {
onRetry: () => Promise<void>;
onRefund: (id: TransactionIdStr) => Promise<void>;
onBack: () => Promise<void>;
+ onForwardToContact?: (id: TransactionIdStr) => Promise<void>;
}
const PurchaseDetailsTable = styled.table`
@@ -488,6 +495,7 @@ export function TransactionView({
onRetry,
onRefund,
onCancel,
+ onForwardToContact,
}: WalletTransactionProps): VNode {
const { i18n } = useTranslationContext();
const { safely } = useAlertContext();
@@ -963,7 +971,7 @@ export function TransactionView({
!transaction.error && (
<Part
title={i18n.str`URI`}
- text={<ShowQrWithCopy text={transaction.talerUri} startOpen />}
+ text={<ShowQrWithCopy text={transaction.talerUri} startOpen onForwardToContact={() => { onForwardToContact && onForwardToContact(transaction.transactionId)} }/>}
kind="neutral"
/>
)}
@@ -987,16 +995,6 @@ export function TransactionView({
/>
}
/>
- <EnabledBySettings name="p2p_aliases">
- <Part
- title={i18n.str`Social`}
- text={
- <a href={`#${Pages.contacts({tid: transaction.transactionId})}`} >
- <i18n.Translate>Forward request to a contact</i18n.Translate>
- </a>
- }
- />
- </EnabledBySettings>
</TransactionTemplate>
);
}
@@ -1069,7 +1067,7 @@ export function TransactionView({
{transaction.talerUri && (
<Part
title={i18n.str`URI`}
- text={<ShowQrWithCopy text={transaction.talerUri} startOpen />}
+ text={<ShowQrWithCopy text={transaction.talerUri} startOpen onForwardToContact={() => { onForwardToContact && onForwardToContact(transaction.transactionId)} } />}
kind="neutral"
/>
)}
@@ -1093,16 +1091,6 @@ export function TransactionView({
/>
}
/>
- <EnabledBySettings name="p2p_aliases">
- <Part
- title={i18n.str`Social`}
- text={
- <a href={`#${Pages.contacts({tid: transaction.transactionId})}`} >
- <i18n.Translate>Forward request to a contact</i18n.Translate>
- </a>
- }
- />
- </EnabledBySettings>
</TransactionTemplate>
);
}
@@ -2013,9 +2001,11 @@ function NicePayto({ payto }: { payto: PaytoUri }): VNode {
function ShowQrWithCopy({
text,
startOpen,
+ onForwardToContact,
}: {
text: string;
startOpen?: boolean;
+ onForwardToContact?: () => void;
}): VNode {
const [showing, setShowing] = useState(startOpen);
const { i18n } = useTranslationContext();
@@ -2035,6 +2025,12 @@ function ShowQrWithCopy({
<Button onClick={toggle as SafeHandler<void>}>
<i18n.Translate>hide qr</i18n.Translate>
</Button>
+ <EnabledBySettings name="p2p_aliases">
+ {(onForwardToContact) && (
+ <Button onClick={onForwardToContact as SafeHandler<void>}>
+ <i18n.Translate>forward to contact</i18n.Translate>
+ </Button>)}
+ </EnabledBySettings>
</div>
);
}
@@ -2047,6 +2043,12 @@ function ShowQrWithCopy({
<Button onClick={toggle as SafeHandler<void>}>
<i18n.Translate>show qr</i18n.Translate>
</Button>
+ <EnabledBySettings name="p2p_aliases">
+ {(onForwardToContact) && (
+ <Button onClick={onForwardToContact as SafeHandler<void>}>
+ <i18n.Translate>forward to contact</i18n.Translate>
+ </Button>)}
+ </EnabledBySettings>
</div>
);
}