From 42a0076f5951d303635b2e544aa66112cdb9abfe Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Mon, 1 Feb 2016 15:10:20 +0100
Subject: new fulfillment protocol

---
 extension/popup/popup.tsx | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

(limited to 'extension/popup/popup.tsx')

diff --git a/extension/popup/popup.tsx b/extension/popup/popup.tsx
index 258292df9..a9579f18c 100644
--- a/extension/popup/popup.tsx
+++ b/extension/popup/popup.tsx
@@ -20,6 +20,8 @@
 
 "use strict";
 
+import {substituteFulfillmentUrl} from "../lib/web-common";
+
 declare var m: any;
 declare var i18n: any;
 
@@ -106,11 +108,22 @@ function formatAmount(amount) {
   return `${v.toFixed(2)} ${amount.currency}`;
 }
 
+
 function abbrevKey(s: string) {
   return m("span.abbrev", {title: s}, (s.slice(0, 5) + ".."))
 }
 
 
+function retryPayment(url, contractHash) {
+  return function() {
+    chrome.tabs.create({
+                         "url": substituteFulfillmentUrl(url,
+                                                         {H_contract: contractHash})
+                       });
+  }
+}
+
+
 function formatHistoryItem(historyItem) {
   const d = historyItem.detail;
   const t = historyItem.timestamp;
@@ -124,10 +137,14 @@ function formatHistoryItem(historyItem) {
       return m("p",
                i18n`Withdraw at ${formatTimestamp(t)}`);
     case "pay":
+      let url = substituteFulfillmentUrl(d.fulfillmentUrl,
+                                         {H_contract: d.contractHash});
       return m("p",
                [
                  i18n`Payment for ${formatAmount(d.amount)} to merchant ${d.merchantName}. `,
-                 m("a[href=javascript:;]", "Retry")
+                 m(`a`,
+                   {href: url, onclick: openTab(url)},
+                   "Retry")
                ]);
     default:
       return m("p", i18n`Unknown event (${historyItem.type})`);
@@ -204,3 +221,12 @@ function openExtensionPage(page) {
   }
 }
 
+
+function openTab(page) {
+  return function() {
+    chrome.tabs.create({
+                         "url": page
+                       });
+  }
+}
+
-- 
cgit v1.2.3

