parent
fd51ab1229
commit
5beb34aa52
After Width: | Height: | Size: 795 B |
@ -0,0 +1 @@ |
||||
export { default } from './transaction-list-item-details.component' |
@ -0,0 +1,49 @@ |
||||
.transaction-list-item-details { |
||||
&__header { |
||||
margin-bottom: 8px; |
||||
display: flex; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
} |
||||
|
||||
&__header-buttons { |
||||
display: flex; |
||||
flex-direction: row; |
||||
} |
||||
|
||||
&__header-button { |
||||
font-size: .625rem; |
||||
|
||||
&:not(:last-child) { |
||||
margin-right: 8px; |
||||
} |
||||
} |
||||
|
||||
&__sender-to-recipient-container { |
||||
margin-bottom: 8px; |
||||
} |
||||
|
||||
&__cards-container { |
||||
display: flex; |
||||
flex-direction: row; |
||||
|
||||
@media screen and (max-width: $break-small) { |
||||
flex-direction: column; |
||||
} |
||||
} |
||||
|
||||
&__transaction-breakdown { |
||||
flex: 1; |
||||
margin-right: 8px; |
||||
min-width: 0; |
||||
|
||||
@media screen and (max-width: $break-small) { |
||||
margin: 0 0 8px 0; |
||||
} |
||||
} |
||||
|
||||
&__transaction-activity-log { |
||||
flex: 2; |
||||
min-width: 0; |
||||
} |
||||
} |
@ -0,0 +1,66 @@ |
||||
import React from 'react' |
||||
import assert from 'assert' |
||||
import { shallow } from 'enzyme' |
||||
import TransactionListItemDetails from '../transaction-list-item-details.component' |
||||
import Button from '../../button' |
||||
import SenderToRecipient from '../../sender-to-recipient' |
||||
import TransactionBreakdown from '../../transaction-breakdown' |
||||
import TransactionActivityLog from '../../transaction-activity-log' |
||||
|
||||
describe('TransactionListItemDetails Component', () => { |
||||
it('should render properly', () => { |
||||
const transaction = { |
||||
history: [], |
||||
id: 1, |
||||
status: 'confirmed', |
||||
txParams: { |
||||
from: '0x1', |
||||
gas: '0x5208', |
||||
gasPrice: '0x3b9aca00', |
||||
nonce: '0xa4', |
||||
to: '0x2', |
||||
value: '0x2386f26fc10000', |
||||
}, |
||||
} |
||||
|
||||
const wrapper = shallow( |
||||
<TransactionListItemDetails |
||||
transaction={transaction} |
||||
/>, |
||||
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } } |
||||
) |
||||
|
||||
assert.ok(wrapper.hasClass('transaction-list-item-details')) |
||||
assert.equal(wrapper.find(Button).length, 1) |
||||
assert.equal(wrapper.find(SenderToRecipient).length, 1) |
||||
assert.equal(wrapper.find(TransactionBreakdown).length, 1) |
||||
assert.equal(wrapper.find(TransactionActivityLog).length, 1) |
||||
}) |
||||
|
||||
it('should render a retry button', () => { |
||||
const transaction = { |
||||
history: [], |
||||
id: 1, |
||||
status: 'confirmed', |
||||
txParams: { |
||||
from: '0x1', |
||||
gas: '0x5208', |
||||
gasPrice: '0x3b9aca00', |
||||
nonce: '0xa4', |
||||
to: '0x2', |
||||
value: '0x2386f26fc10000', |
||||
}, |
||||
} |
||||
|
||||
const wrapper = shallow( |
||||
<TransactionListItemDetails |
||||
transaction={transaction} |
||||
showRetry={true} |
||||
/>, |
||||
{ context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } } |
||||
) |
||||
|
||||
assert.ok(wrapper.hasClass('transaction-list-item-details')) |
||||
assert.equal(wrapper.find(Button).length, 2) |
||||
}) |
||||
}) |
@ -0,0 +1,80 @@ |
||||
import React, { PureComponent } from 'react' |
||||
import PropTypes from 'prop-types' |
||||
import SenderToRecipient from '../sender-to-recipient' |
||||
import { CARDS_VARIANT } from '../sender-to-recipient/sender-to-recipient.constants' |
||||
import TransactionActivityLog from '../transaction-activity-log' |
||||
import TransactionBreakdown from '../transaction-breakdown' |
||||
import Button from '../button' |
||||
import prefixForNetwork from '../../../lib/etherscan-prefix-for-network' |
||||
|
||||
export default class TransactionListItemDetails extends PureComponent { |
||||
static contextTypes = { |
||||
t: PropTypes.func, |
||||
} |
||||
|
||||
static propTypes = { |
||||
transaction: PropTypes.object, |
||||
showRetry: PropTypes.bool, |
||||
} |
||||
|
||||
handleEtherscanClick = () => { |
||||
const { hash, metamaskNetworkId } = this.props.transaction |
||||
|
||||
const prefix = prefixForNetwork(metamaskNetworkId) |
||||
const etherscanUrl = `https://${prefix}etherscan.io/tx/${hash}` |
||||
global.platform.openWindow({ url: etherscanUrl }) |
||||
this.setState({ showTransactionDetails: true }) |
||||
} |
||||
|
||||
render () { |
||||
const { t } = this.context |
||||
const { transaction, showRetry } = this.props |
||||
const { txParams: { to, from } = {} } = transaction |
||||
|
||||
return ( |
||||
<div className="transaction-list-item-details"> |
||||
<div className="transaction-list-item-details__header"> |
||||
<div>Details</div> |
||||
<div className="transaction-list-item-details__header-buttons"> |
||||
{ |
||||
showRetry && ( |
||||
<Button |
||||
type="raised" |
||||
onClick={this.handleEtherscanClick} |
||||
className="transaction-list-item-details__header-button" |
||||
> |
||||
{ t('speedUp') } |
||||
</Button> |
||||
) |
||||
} |
||||
<Button |
||||
type="raised" |
||||
onClick={this.handleEtherscanClick} |
||||
className="transaction-list-item-details__header-button" |
||||
> |
||||
<img src="/images/arrow-popout.svg" /> |
||||
</Button> |
||||
</div> |
||||
</div> |
||||
<div className="transaction-list-item-details__sender-to-recipient-container"> |
||||
<SenderToRecipient |
||||
variant={CARDS_VARIANT} |
||||
addressOnly |
||||
recipientAddress={to} |
||||
senderAddress={from} |
||||
/> |
||||
</div> |
||||
<div className="transaction-list-item-details__cards-container"> |
||||
<TransactionBreakdown |
||||
transaction={transaction} |
||||
className="transaction-list-item-details__transaction-breakdown" |
||||
/> |
||||
<TransactionActivityLog |
||||
transaction={transaction} |
||||
className="transaction-list-item-details__transaction-activity-log" |
||||
/> |
||||
</div> |
||||
</div> |
||||
) |
||||
} |
||||
} |
Loading…
Reference in new issue