Fix local transactions without condition. (#5716)

This commit is contained in:
Tomasz Drwięga 2017-06-03 14:41:31 +02:00 committed by Gav Wood
parent 45d8cc706c
commit 5ec5d2fa0b

View File

@ -210,31 +210,36 @@ class TxRow extends Component {
if (!isCancelOpen && !isEditOpen) { if (!isCancelOpen && !isEditOpen) {
const pendingStatus = this.getCondition(); const pendingStatus = this.getCondition();
const isPending = pendingStatus === 'pending';
if (pendingStatus === 'submitting') {
return (
<div className={ styles.pending }>
<div />
<div className={ styles.uppercase }>
<FormattedMessage
id='ui.txList.txRow.submitting'
defaultMessage='Submitting'
/>
</div>
</div>
);
}
return ( return (
<div className={ styles.pending }> <div className={ styles.pending }>
<span> {
{ pendingStatus } isPending
</span> ? (
<div className={ styles.uppercase }> <div className={ styles.pending }>
<FormattedMessage <div />
id='ui.txList.txRow.scheduled' <div className={ styles.uppercase }>
defaultMessage='Scheduled' <FormattedMessage
/> id='ui.txList.txRow.submitting'
</div> defaultMessage='Pending'
/>
</div>
</div>
) : (
<div>
<span>
{ pendingStatus }
</span>
<div className={ styles.uppercase }>
<FormattedMessage
id='ui.txList.txRow.scheduled'
defaultMessage='Scheduled'
/>
</div>
</div>
)
}
<a onClick={ this.setEdit } className={ styles.uppercase }> <a onClick={ this.setEdit } className={ styles.uppercase }>
<FormattedMessage <FormattedMessage
id='ui.txList.txRow.edit' id='ui.txList.txRow.edit'
@ -248,6 +253,16 @@ class TxRow extends Component {
defaultMessage='Cancel' defaultMessage='Cancel'
/> />
</a> </a>
{ isPending
? (
<div>
<FormattedMessage
id='ui.txList.txRow.cancelWarning'
defaultMessage='Warning: Editing or Canceling the transaction may not succeed!'
/>
</div>
) : null
}
</div> </div>
); );
} }
@ -319,11 +334,10 @@ class TxRow extends Component {
getCondition = () => { getCondition = () => {
const { blockNumber, tx } = this.props; const { blockNumber, tx } = this.props;
let { time, block } = tx.condition || {}; let { time, block = 0 } = tx.condition || {};
if (time) { if (time) {
if ((time.getTime() - Date.now()) >= 0) { if ((time.getTime() - Date.now()) >= 0) {
// return `${dateDifference(new Date(), time, { compact: true })} left`;
return ( return (
<FormattedMessage <FormattedMessage
id='ui.txList.txRow.pendingStatus.time' id='ui.txList.txRow.pendingStatus.time'
@ -333,14 +347,11 @@ class TxRow extends Component {
} } } }
/> />
); );
} else {
return 'submitting';
} }
} else if (blockNumber && block) { }
if (blockNumber) {
block = blockNumber.minus(block); block = blockNumber.minus(block);
// return (block.toNumber() < 0)
// ? block.abs().toFormat(0) + ' blocks left'
// : 'submitting';
if (block.toNumber() < 0) { if (block.toNumber() < 0) {
return ( return (
<FormattedMessage <FormattedMessage
@ -351,10 +362,10 @@ class TxRow extends Component {
} } } }
/> />
); );
} else {
return 'submitting';
} }
} }
return 'pending';
} }
cancelTx = () => { cancelTx = () => {