1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Hide Copy Tx ID and block explorer link for txns w/o hash (#6928)

This commit is contained in:
Whymarrh Whitby 2019-07-29 22:12:29 -02:30 committed by GitHub
parent 948b6ca80b
commit 2761cc5a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 1 deletions

View File

@ -78,4 +78,73 @@ describe('TransactionListItemDetails Component', () => {
assert.ok(wrapper.hasClass('transaction-list-item-details'))
assert.equal(wrapper.find(Button).length, 3)
})
it('should disable the Copy Tx ID and View In Etherscan buttons when tx hash is missing', () => {
const transaction = {
history: [],
id: 1,
status: 'confirmed',
txParams: {
from: '0x1',
gas: '0x5208',
gasPrice: '0x3b9aca00',
nonce: '0xa4',
to: '0x2',
value: '0x2386f26fc10000',
},
}
const transactionGroup = {
transactions: [transaction],
primaryTransaction: transaction,
initialTransaction: transaction,
}
const wrapper = shallow(
<TransactionListItemDetails
transactionGroup={transactionGroup}
/>,
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
)
assert.ok(wrapper.hasClass('transaction-list-item-details'))
const buttons = wrapper.find(Button)
assert.strictEqual(buttons.at(0).prop('disabled'), true)
assert.strictEqual(buttons.at(1).prop('disabled'), true)
})
it('should render functional Copy Tx ID and View In Etherscan buttons when tx hash exists', () => {
const transaction = {
history: [],
id: 1,
status: 'confirmed',
hash: '0xaa',
txParams: {
from: '0x1',
gas: '0x5208',
gasPrice: '0x3b9aca00',
nonce: '0xa4',
to: '0x2',
value: '0x2386f26fc10000',
},
}
const transactionGroup = {
transactions: [transaction],
primaryTransaction: transaction,
initialTransaction: transaction,
}
const wrapper = shallow(
<TransactionListItemDetails
transactionGroup={transactionGroup}
/>,
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
)
assert.ok(wrapper.hasClass('transaction-list-item-details'))
const buttons = wrapper.find(Button)
assert.strictEqual(buttons.at(0).prop('disabled'), false)
assert.strictEqual(buttons.at(1).prop('disabled'), false)
})
})

View File

@ -128,7 +128,7 @@ export default class TransactionListItemDetails extends PureComponent {
rpcPrefs: { blockExplorerUrl } = {},
} = this.props
const { primaryTransaction: transaction } = transactionGroup
const { txParams: { to, from } = {} } = transaction
const { hash, txParams: { to, from } = {} } = transaction
return (
<div className="transaction-list-item-details">
@ -152,6 +152,7 @@ export default class TransactionListItemDetails extends PureComponent {
type="raised"
onClick={this.handleCopyTxId}
className="transaction-list-item-details__header-button"
disabled={!hash}
>
<img
className="transaction-list-item-details__header-button__copy-icon"
@ -164,6 +165,7 @@ export default class TransactionListItemDetails extends PureComponent {
type="raised"
onClick={this.handleEtherscanClick}
className="transaction-list-item-details__header-button"
disabled={!hash}
>
<img src="/images/arrow-popout.svg" />
</Button>