From 5da6fd5ab18812929cbf790527a3029fd8d7123c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 26 May 2016 14:32:45 -0700 Subject: Add clicking txs in list shows tx conf screen --- ui/app/account-detail.js | 3 +++ ui/app/actions.js | 9 +++++++++ ui/app/components/transaction-list-item.js | 9 ++++++++- ui/app/components/transaction-list.js | 6 ++++-- ui/app/reducers/app.js | 28 ++++++++++++++++++++++++++-- 5 files changed, 50 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 1dcce1d08..2f412c5be 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -201,6 +201,9 @@ AccountDetailScreen.prototype.transactionList = function() { network, unconfTxs, unconfMsgs, + viewPendingTx:(txId) => { + this.props.dispatch(actions.viewPendingTx(txId)) + } }) } diff --git a/ui/app/actions.js b/ui/app/actions.js index 5b058aaed..ae6125b20 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -76,6 +76,8 @@ var actions = { txError: txError, nextTx: nextTx, previousTx: previousTx, + viewPendingTx: viewPendingTx, + VIEW_PENDING_TX: 'VIEW_PENDING_TX', // app messages showAccountDetail: showAccountDetail, BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL', @@ -387,6 +389,13 @@ function nextTx() { } } +function viewPendingTx(txId) { + return { + type: actions.VIEW_PENDING_TX, + value: txId, + } +} + function previousTx() { return { type: actions.PREVIOUS_TX, diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js index cff9a47b2..ac74046f3 100644 --- a/ui/app/components/transaction-list-item.js +++ b/ui/app/components/transaction-list-item.js @@ -25,6 +25,7 @@ TransactionListItem.prototype.render = function() { var isMsg = ('msgParams' in transaction) var isTx = ('txParams' in transaction) + var isPending = transaction.status === 'unconfirmed' let txParams if (isTx) { @@ -33,10 +34,16 @@ TransactionListItem.prototype.render = function() { txParams = transaction.msgParams } + const isClickable = ('hash' in transaction) || isPending + return ( - h(`.transaction-list-item.flex-row.flex-space-between${transaction.hash ? '.pointer' : ''}`, { + h(`.transaction-list-item.flex-row.flex-space-between${isClickable ? '.pointer' : ''}`, { key: `tx-${transaction.id + i}`, onClick: (event) => { + if (isPending) { + this.props.showTx(transaction.id) + } + if (!transaction.hash) return var url = explorerLink(transaction.hash, parseInt(network)) chrome.tabs.create({ url }) diff --git a/ui/app/components/transaction-list.js b/ui/app/components/transaction-list.js index 3c778b19d..5ebb3e563 100644 --- a/ui/app/components/transaction-list.js +++ b/ui/app/components/transaction-list.js @@ -16,7 +16,6 @@ TransactionList.prototype.render = function() { const { txsToRender, network, unconfTxs, unconfMsgs } = this.props const transactions = txsToRender.concat(unconfMsgs) .sort((a, b) => b.time - a.time) - console.dir(transactions) return ( @@ -53,7 +52,10 @@ TransactionList.prototype.render = function() { transactions.length ? transactions.map((transaction, i) => { return h(TransactionListItem, { - transaction, i + transaction, i, + showTx:(txId) => { + this.props.viewPendingTx(txId) + }, }) }) : diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index a98b809d6..08c2268c1 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -12,10 +12,10 @@ function reduceApp(state, action) { const pendingTxs = hasPendingTxs(state) let name = 'accounts' if (selectedAccount) { - defaultView = 'accountDetail' + name = 'accountDetail' } if (pendingTxs) { - defaultView = 'confTx' + name = 'confTx' } var defaultView = { @@ -270,6 +270,17 @@ function reduceApp(state, action) { } }) + case actions.VIEW_PENDING_TX: + const context = indexForPending(state, action.value) + return extend(appState, { + transForward: true, + currentView: { + name: 'confTx', + context, + warning: null, + } + }) + case actions.PREVIOUS_TX: return extend(appState, { transForward: false, @@ -366,3 +377,16 @@ function hasPendingTxs (state) { var unconfTxList = txHelper(unconfTxs, unconfMsgs) return unconfTxList.length > 0 } + +function indexForPending(state, txId) { + var unconfTxs = state.metamask.unconfTxs + var unconfMsgs = state.metamask.unconfMsgs + var unconfTxList = txHelper(unconfTxs, unconfMsgs) + let idx + unconfTxList.forEach((tx, i) => { + if (tx.id === txId) { + idx = i + } + }) + return idx +} -- cgit