-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix pending details missing - Closes #1269 #1273
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
25396f9
:bug: Fix pending details missing
michaeltomasik 1f59471
:recycle: Refactor of fix pending details missing
michaeltomasik 87d5a06
:recycle: Fix tests on transactionDetailView with pendingTransactions
michaeltomasik d3ff75f
:recycle: Fix broken e2e explorer tests
michaeltomasik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,7 @@ class TransactionsDetailView extends React.Component { | |
constructor(props) { | ||
super(props); | ||
|
||
const { search } = this.props.location || window.location; | ||
const params = new URLSearchParams(search); | ||
const transactionId = params.get('id'); | ||
const transactionId = this.getTransactionIdFromURL(); | ||
|
||
if (props.peers.data && transactionId) { | ||
this.props.loadTransaction({ | ||
|
@@ -34,6 +32,25 @@ class TransactionsDetailView extends React.Component { | |
|
||
componentWillReceiveProps(nextProps) { | ||
if (nextProps.location && !nextProps.location.search) this.props.prevStep(); | ||
|
||
// It rerenders component when pending status changed to confirmed | ||
if (nextProps.pendingTransactions && | ||
nextProps.pendingTransactions.length === 0 && typeof nextProps.transaction === 'string') { | ||
const transactionId = this.getTransactionIdFromURL(); | ||
|
||
if (this.props.peers.data && transactionId) { | ||
this.props.loadTransaction({ | ||
id: transactionId, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
getTransactionIdFromURL() { | ||
const { search } = this.props.location || window.location; | ||
const params = new URLSearchParams(search); | ||
|
||
return params.get('id'); | ||
} | ||
|
||
getVoters(dataName) { | ||
|
@@ -66,40 +83,50 @@ class TransactionsDetailView extends React.Component { | |
} | ||
|
||
getFirstRow() { | ||
const isSendTransaction = this.props.transaction.type === transactions.send; | ||
const transactionId = this.getTransactionIdFromURL(); | ||
const isTransactionEmpty = (typeof this.props.transaction === 'object' && | ||
Object.keys(this.props.transaction).length !== 0); | ||
|
||
const transaction = isTransactionEmpty || (isTransactionEmpty && | ||
this.props.pendingTransactions.find(tx => tx.id === transactionId)) ? | ||
this.props.transaction : | ||
(this.props.pendingTransactions.find(tx => tx.id === transactionId) || {}); | ||
|
||
const isSendTransaction = this.props.transaction.type === transactions.send | ||
|| (this.props.pendingTransactions && this.props.pendingTransactions.length > 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what is the goal, but logic here seems wrong. if there are some pending transactions, it doesn't mean that they are of "send" type. |
||
|
||
return ( | ||
<TransactionDetailViewRow> | ||
<TransactionDetailViewField | ||
label={this.props.t('Sender')} | ||
value={ | ||
<Link className={`${styles.addressLink} ${styles.clickable}`} id='sender-address' | ||
to={`${routes.explorer.path}${routes.accounts.path}/${this.props.transaction.senderId}`}> | ||
{this.props.transaction.senderId} | ||
to={`${routes.explorer.path}${routes.accounts.path}/${transaction.senderId}`}> | ||
{transaction.senderId} | ||
</Link> | ||
} | ||
column> | ||
{this.props.transaction.senderId ? | ||
{transaction.senderId ? | ||
<figure className={styles.accountVisual}> | ||
<AccountVisual address={this.props.transaction.senderId} size={43} /> | ||
<AccountVisual address={transaction.senderId} size={43} /> | ||
</figure> : null} | ||
</TransactionDetailViewField> | ||
|
||
{!isSendTransaction ? this.getDateField() : | ||
<TransactionDetailViewField | ||
shouldShow={this.props.transaction.recipientId} | ||
shouldShow={transaction.recipientId} | ||
label={this.props.t('Recipient')} | ||
style={styles.sender} | ||
value={ | ||
<Link className={`${styles.addressLink} ${styles.clickable}`} id='receiver-address' | ||
to={`${routes.explorer.path}${routes.accounts.path}/${this.props.transaction.recipientId}`}> | ||
{this.props.transaction.recipientId} | ||
to={`${routes.explorer.path}${routes.accounts.path}/${transaction.recipientId}`}> | ||
{transaction.recipientId} | ||
</Link> | ||
} | ||
column> | ||
{this.props.transaction.recipientId ? | ||
{transaction.recipientId ? | ||
<figure className={styles.accountVisual}> | ||
<AccountVisual address={this.props.transaction.recipientId} size={43} /> | ||
<AccountVisual address={transaction.recipientId} size={43} /> | ||
</figure> : null | ||
} | ||
</TransactionDetailViewField> | ||
|
@@ -109,6 +136,15 @@ class TransactionsDetailView extends React.Component { | |
} | ||
|
||
render() { | ||
const transactionId = this.getTransactionIdFromURL(); | ||
const isTransactionEmpty = (typeof this.props.transaction === 'object' && | ||
Object.keys(this.props.transaction).length !== 0); | ||
|
||
const transaction = isTransactionEmpty || (isTransactionEmpty && | ||
this.props.pendingTransactions.find(tx => tx.id === transactionId)) ? | ||
this.props.transaction : | ||
(this.props.pendingTransactions.find(tx => tx.id === transactionId) || {}); | ||
|
||
return ( | ||
<div className={`${styles.details}`}> | ||
{ | ||
|
@@ -129,8 +165,8 @@ class TransactionsDetailView extends React.Component { | |
<header> | ||
<h2 className={styles.title}> | ||
<TransactionType | ||
{...this.props.transaction} | ||
address={this.props.transaction.senderId} | ||
{...transaction} | ||
address={transaction.senderId} | ||
showTransaction /> | ||
</h2> | ||
</header> | ||
|
@@ -139,20 +175,20 @@ class TransactionsDetailView extends React.Component { | |
|
||
{this.getFirstRow()} | ||
|
||
<TransactionDetailViewRow shouldShow={this.props.transaction.type === 0}> | ||
<TransactionDetailViewRow shouldShow={transaction.type === 0}> | ||
{this.getDateField()} | ||
<TransactionDetailViewField | ||
label={this.props.t('Amount (LSK)')} | ||
value={ | ||
<Amount | ||
value={this.props.transaction} | ||
value={transaction} | ||
address={this.props.address}> | ||
</Amount> | ||
} | ||
style={styles.amount} /> | ||
</TransactionDetailViewRow> | ||
|
||
<TransactionDetailViewRow shouldShow={this.props.transaction.type === transactions.vote}> | ||
<TransactionDetailViewRow shouldShow={transaction.type === transactions.vote}> | ||
<TransactionDetailViewField | ||
label={this.props.t('Added votes')} | ||
value={this.getVoters('added')} /> | ||
|
@@ -164,10 +200,10 @@ class TransactionsDetailView extends React.Component { | |
<TransactionDetailViewRow> | ||
<TransactionDetailViewField | ||
label={this.props.t('Additional fee')} | ||
value={<LiskAmount val={this.props.transaction.fee} />} /> | ||
value={<LiskAmount val={transaction.fee} />} /> | ||
<TransactionDetailViewField | ||
label={this.props.t('Confirmations')} | ||
value={<span>{this.props.transaction.confirmations}</span>} /> | ||
value={<span>{transaction.confirmations}</span>} /> | ||
</TransactionDetailViewRow> | ||
|
||
<TransactionDetailViewRow> | ||
|
@@ -176,15 +212,15 @@ class TransactionsDetailView extends React.Component { | |
label={this.props.t('Transaction ID')} | ||
value={ | ||
<CopyToClipboard | ||
value={this.props.transaction.id} | ||
text={this.props.transaction.id} | ||
value={transaction.id} | ||
text={transaction.id} | ||
copyClassName={`${styles.copy}`} /> | ||
} /> | ||
} | ||
<TransactionDetailViewField | ||
shouldShow={this.props.transaction.asset && this.props.transaction.asset.data} | ||
shouldShow={transaction.asset && transaction.asset.data} | ||
label={this.props.t('Reference')} | ||
value={(this.props.transaction.asset && this.props.transaction.asset.data) || '-'} /> | ||
value={(transaction.asset && transaction.asset.data) || '-'} /> | ||
</TransactionDetailViewRow> | ||
</div> | ||
<footer> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same 4 lines again on line 143. Would be worth a helper function.