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,22 +210,24 @@ 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 ( return (
<div className={ styles.pending }>
{
isPending
? (
<div className={ styles.pending }> <div className={ styles.pending }>
<div /> <div />
<div className={ styles.uppercase }> <div className={ styles.uppercase }>
<FormattedMessage <FormattedMessage
id='ui.txList.txRow.submitting' id='ui.txList.txRow.submitting'
defaultMessage='Submitting' defaultMessage='Pending'
/> />
</div> </div>
</div> </div>
); ) : (
} <div>
return (
<div className={ styles.pending }>
<span> <span>
{ pendingStatus } { pendingStatus }
</span> </span>
@ -235,6 +237,9 @@ class TxRow extends Component {
defaultMessage='Scheduled' defaultMessage='Scheduled'
/> />
</div> </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 = () => {