diff --git a/app/ledger.js b/app/ledger.js index 8ac9dfc9cc5..a80cb5d6ad0 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -53,6 +53,7 @@ const appStore = require('../js/stores/appStore') const eventStore = require('../js/stores/eventStore') const rulesolver = require('./extensions/brave/content/scripts/pageInformation.js') const ledgerUtil = require('./common/lib/ledgerUtil') +const base64Encode = require('../js/lib/base64').encode // TBD: remove these post beta [MTR] const logPath = 'ledger-log.json' @@ -286,6 +287,18 @@ if (ipc) { if (balanceTimeoutId) clearTimeout(balanceTimeoutId) balanceTimeoutId = setTimeout(getBalance, 5 * msecs.second) }) + + ipc.on(messages.OPEN_LEDGER_TRANSACTION_CSV, (event, viewingIds, csvFilename) => { + if (client) { + let txCsvText = client.getTransactionCSVText(viewingIds) + let txCsvTextDataURI = 'data:text/csv;base64,' + base64Encode(txCsvText) + + const win = electron.BrowserWindow.getFocusedWindow() + if (win && win.webContents) { + win.webContents.downloadURL(txCsvTextDataURI) + } + } + }) } /* diff --git a/js/about/aboutActions.js b/js/about/aboutActions.js index cde4175a0be..91647ebded9 100644 --- a/js/about/aboutActions.js +++ b/js/about/aboutActions.js @@ -176,6 +176,10 @@ const AboutActions = { ipc.send(messages.LEDGER_CREATE_WALLET) }, + receiptLinkClick: function (viewingId, receiptFileName) { + ipc.send(messages.OPEN_LEDGER_TRANSACTION_CSV, viewingId, receiptFileName) + }, + setLedgerEnabled: function (enabled) { ipc.send(messages.LEDGER_ENABLE, enabled) }, diff --git a/js/about/preferences.js b/js/about/preferences.js index 31b96301a5d..ccd3ca32073 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -471,6 +471,7 @@ class PaymentHistory extends ImmutableComponent { + @@ -520,13 +521,26 @@ class PaymentHistoryRow extends ImmutableComponent { return (fiatAmount && typeof fiatAmount === 'number' ? fiatAmount.toFixed(2) : '0.00') } + get viewingId () { + return this.transaction.get('viewingId') + } + + get receiptFileName () { + return `brave_ledger${this.numericDateStr}.csv` + } + + onReceiptLinkClick () { + aboutActions.receiptLinkClick(this.viewingId, this.receiptFileName) + } + render () { var date = this.formattedDate var totalAmountStr = `${this.totalAmount} ${this.currency}` return - {date} - {totalAmountStr} + {date} + {totalAmountStr} + {this.receiptFileName} } } diff --git a/js/constants/messages.js b/js/constants/messages.js index 20bc5b1607a..0a5e95692ee 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -152,6 +152,7 @@ const messages = { LEDGER_PUBLISHER: _, LEDGER_UPDATED: _, LEDGER_CREATE_WALLET: _, + OPEN_LEDGER_TRANSACTION_CSV: _, CHECK_BITCOIN_HANDLER: _, ADD_FUNDS_CLOSED: _ } diff --git a/less/about/preferences.less b/less/about/preferences.less index 10a511a7de1..ca9dabdcbd3 100644 --- a/less/about/preferences.less +++ b/less/about/preferences.less @@ -580,7 +580,6 @@ div.nextPaymentSubmission { .modal .dialog.paymentHistory { padding: 0px; - width: 450px; .dialog-header { background-color: #EEE; @@ -684,7 +683,7 @@ div.nextPaymentSubmission { font-weight: 500; border-bottom: 2px solid @lightGray; text-align: left; - width: 25%; + width: 18%; } td { text-align: left; diff --git a/package.json b/package.json index ea768c50000..af4ada6c520 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "keytar": "^3.0.0", "l20n": "^3.5.1", "ledger-balance": "^0.8.60", - "ledger-client": "^0.8.77", + "ledger-client": "^0.8.78", "ledger-geoip": "^0.8.71", "ledger-publisher": "^0.8.69", "lru_cache": "^1.0.0",