Merge pull request #285 from gnosis/feature/208-pending-transactions
Feature #208: Show pending state for newly created transactions
This commit is contained in:
commit
1021790f8d
|
@ -1,6 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
|
import CircularProgress from '@material-ui/core/CircularProgress'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import Paragraph from '~/components/layout/Paragraph/'
|
import Paragraph from '~/components/layout/Paragraph/'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
|
@ -20,6 +21,7 @@ const statusToIcon = {
|
||||||
cancelled: ErrorIcon,
|
cancelled: ErrorIcon,
|
||||||
awaiting_confirmations: AwaitingIcon,
|
awaiting_confirmations: AwaitingIcon,
|
||||||
awaiting_execution: AwaitingIcon,
|
awaiting_execution: AwaitingIcon,
|
||||||
|
pending: <CircularProgress size={14} />,
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusToLabel = {
|
const statusToLabel = {
|
||||||
|
@ -27,6 +29,7 @@ const statusToLabel = {
|
||||||
cancelled: 'Cancelled',
|
cancelled: 'Cancelled',
|
||||||
awaiting_confirmations: 'Awaiting',
|
awaiting_confirmations: 'Awaiting',
|
||||||
awaiting_execution: 'Awaiting',
|
awaiting_execution: 'Awaiting',
|
||||||
|
pending: 'Pending',
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusIconStyle = {
|
const statusIconStyle = {
|
||||||
|
@ -34,11 +37,21 @@ const statusIconStyle = {
|
||||||
width: '14px',
|
width: '14px',
|
||||||
}
|
}
|
||||||
|
|
||||||
const Status = ({ classes, status }: Props) => (
|
const Status = ({ classes, status }: Props) => {
|
||||||
|
const Icon = statusToIcon[status]
|
||||||
|
|
||||||
|
return (
|
||||||
<Block className={`${classes.container} ${classes[status]}`}>
|
<Block className={`${classes.container} ${classes[status]}`}>
|
||||||
<Img src={statusToIcon[status]} alt="OK Icon" style={statusIconStyle} />
|
{typeof Icon === 'object' ? (
|
||||||
<Paragraph noMargin className={classes.statusText}>{statusToLabel[status]}</Paragraph>
|
Icon
|
||||||
|
) : (
|
||||||
|
<Img src={Icon} alt="OK Icon" style={statusIconStyle} />
|
||||||
|
)}
|
||||||
|
<Paragraph noMargin className={classes.statusText}>
|
||||||
|
{statusToLabel[status]}
|
||||||
|
</Paragraph>
|
||||||
</Block>
|
</Block>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default withStyles(styles)(Status)
|
export default withStyles(styles)(Status)
|
||||||
|
|
|
@ -29,6 +29,10 @@ export const styles = () => ({
|
||||||
backgroundColor: '#dfebff',
|
backgroundColor: '#dfebff',
|
||||||
color: disabled,
|
color: disabled,
|
||||||
},
|
},
|
||||||
|
pending: {
|
||||||
|
backgroundColor: '#fff3e2',
|
||||||
|
color: '#e8673c',
|
||||||
|
},
|
||||||
statusText: {
|
statusText: {
|
||||||
marginLeft: 'auto',
|
marginLeft: 'auto',
|
||||||
textTransform: 'uppercase',
|
textTransform: 'uppercase',
|
||||||
|
|
|
@ -41,6 +41,8 @@ const getTxStatus = (tx: Transaction, safe: Safe): TransactionStatus => {
|
||||||
txStatus = 'cancelled'
|
txStatus = 'cancelled'
|
||||||
} else if (tx.confirmations.size === safe.threshold) {
|
} else if (tx.confirmations.size === safe.threshold) {
|
||||||
txStatus = 'awaiting_execution'
|
txStatus = 'awaiting_execution'
|
||||||
|
} else if (!tx.confirmations.size) {
|
||||||
|
txStatus = 'pending'
|
||||||
}
|
}
|
||||||
|
|
||||||
return txStatus
|
return txStatus
|
||||||
|
|
|
@ -85,6 +85,7 @@ const createTransaction = (
|
||||||
from,
|
from,
|
||||||
isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
||||||
)
|
)
|
||||||
|
dispatch(fetchTransactions(safeAddress))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ const processTransaction = (
|
||||||
from,
|
from,
|
||||||
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
||||||
)
|
)
|
||||||
|
dispatch(fetchTransactions(safeAddress))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,9 @@ import { List, Record } from 'immutable'
|
||||||
import type { RecordFactory, RecordOf } from 'immutable'
|
import type { RecordFactory, RecordOf } from 'immutable'
|
||||||
import { type Confirmation } from '~/routes/safe/store/models/confirmation'
|
import { type Confirmation } from '~/routes/safe/store/models/confirmation'
|
||||||
|
|
||||||
export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution'
|
export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution' | 'pending'
|
||||||
|
|
||||||
export type TransactionProps = {
|
export type TransactionProps = {
|
||||||
name: string,
|
|
||||||
nonce: number,
|
nonce: number,
|
||||||
value: string,
|
value: string,
|
||||||
confirmations: List<Confirmation>,
|
confirmations: List<Confirmation>,
|
||||||
|
@ -29,7 +28,6 @@ export type TransactionProps = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
||||||
name: '',
|
|
||||||
nonce: 0,
|
nonce: 0,
|
||||||
value: 0,
|
value: 0,
|
||||||
confirmations: List([]),
|
confirmations: List([]),
|
||||||
|
|
Loading…
Reference in New Issue