mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-04 22:03:41 +00:00
fix displayButtonRow boolean expression
This commit is contained in:
parent
e4c10d2a48
commit
ea8a108bb0
@ -12,6 +12,7 @@ type Props = {
|
|||||||
onTxCancel: Function,
|
onTxCancel: Function,
|
||||||
classes: Object,
|
classes: Object,
|
||||||
showConfirmBtn: boolean,
|
showConfirmBtn: boolean,
|
||||||
|
showCancelBtn: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = () => ({
|
const styles = () => ({
|
||||||
@ -34,14 +35,16 @@ const styles = () => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const ButtonRow = ({
|
const ButtonRow = ({
|
||||||
classes, onTxCancel, onTxConfirm, showConfirmBtn,
|
classes, onTxCancel, onTxConfirm, showConfirmBtn, showCancelBtn,
|
||||||
}: Props) => (
|
}: Props) => (
|
||||||
<Row align="center" className={classes.buttonRow}>
|
<Row align="center" className={classes.buttonRow}>
|
||||||
<Button className={classes.button} variant="contained" minWidth={140} color="secondary" onClick={onTxCancel}>
|
{showCancelBtn && (
|
||||||
<BlockIcon className={classes.icon} />
|
<Button className={classes.button} variant="contained" minWidth={140} color="secondary" onClick={onTxCancel}>
|
||||||
{' '}
|
<BlockIcon className={classes.icon} />
|
||||||
|
{' '}
|
||||||
Cancel TX
|
Cancel TX
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
{showConfirmBtn && (
|
{showConfirmBtn && (
|
||||||
<Button className={classes.button} variant="contained" minWidth={140} color="primary" onClick={onTxConfirm}>
|
<Button className={classes.button} variant="contained" minWidth={140} color="primary" onClick={onTxConfirm}>
|
||||||
<EditIcon className={classes.icon} />
|
<EditIcon className={classes.icon} />
|
||||||
|
@ -16,6 +16,7 @@ import { type Transaction } from '~/routes/safe/store/models/transaction'
|
|||||||
import { type Owner } from '~/routes/safe/store/models/owner'
|
import { type Owner } from '~/routes/safe/store/models/owner'
|
||||||
import { getEtherScanLink, openTxInEtherScan, getWeb3 } from '~/logic/wallets/getWeb3'
|
import { getEtherScanLink, openTxInEtherScan, getWeb3 } from '~/logic/wallets/getWeb3'
|
||||||
import { shortVersionOf } from '~/logic/wallets/ethAddresses'
|
import { shortVersionOf } from '~/logic/wallets/ethAddresses'
|
||||||
|
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||||
import { secondary } from '~/theme/variables'
|
import { secondary } from '~/theme/variables'
|
||||||
import OwnersList from './OwnersList'
|
import OwnersList from './OwnersList'
|
||||||
import ButtonRow from './ButtonRow'
|
import ButtonRow from './ButtonRow'
|
||||||
@ -48,20 +49,29 @@ const openIconStyle = {
|
|||||||
const txStatusToLabel = {
|
const txStatusToLabel = {
|
||||||
success: 'Success',
|
success: 'Success',
|
||||||
awaiting_confirmations: 'Awaiting confirmations',
|
awaiting_confirmations: 'Awaiting confirmations',
|
||||||
|
cancelled: 'Cancelled',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isCancellationTransaction = (tx: Transaction, safeAddress: string) => !tx.value && tx.data === EMPTY_DATA && tx.recipient === safeAddress
|
||||||
|
|
||||||
const ExpandedTx = ({
|
const ExpandedTx = ({
|
||||||
classes, tx, threshold, owners, granted, userAddress, safeAddress, createTransaction,
|
classes,
|
||||||
|
tx,
|
||||||
|
threshold,
|
||||||
|
owners,
|
||||||
|
granted,
|
||||||
|
userAddress,
|
||||||
|
safeAddress,
|
||||||
|
createTransaction,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [tabIndex, setTabIndex] = useState<number>(0)
|
const [tabIndex, setTabIndex] = useState<number>(0)
|
||||||
const [openModal, setOpenModal] = useState<OpenModal>(null)
|
const [openModal, setOpenModal] = useState<OpenModal>(null)
|
||||||
const openApproveModal = () => setOpenModal('approveTx')
|
const openApproveModal = () => setOpenModal('approveTx')
|
||||||
const openCancelModal = () => setOpenModal('cancelTx')
|
const openCancelModal = () => setOpenModal('cancelTx')
|
||||||
const closeModal = () => setOpenModal(null)
|
const closeModal = () => setOpenModal(null)
|
||||||
|
const cancellationTx = isCancellationTransaction(tx, safeAddress)
|
||||||
const confirmedLabel = `Confirmed [${tx.confirmations.size}/${threshold}]`
|
const confirmedLabel = `Confirmed [${tx.confirmations.size}/${threshold}]`
|
||||||
const unconfirmedLabel = `Unconfirmed [${owners.size - tx.confirmations.size}]`
|
const unconfirmedLabel = `Unconfirmed [${owners.size - tx.confirmations.size}]`
|
||||||
const txStatus = tx.isExecuted ? 'success' : 'awaiting_confirmations'
|
|
||||||
|
|
||||||
const ownersWhoConfirmed = []
|
const ownersWhoConfirmed = []
|
||||||
const ownersUnconfirmed = []
|
const ownersUnconfirmed = []
|
||||||
@ -78,6 +88,7 @@ const ExpandedTx = ({
|
|||||||
ownersUnconfirmed.push(owner)
|
ownersUnconfirmed.push(owner)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const displayButtonRow = (!tx.isExecuted && tx.status !== 'cancelled' && !cancellationTx) || (cancellationTx && !currentUserAlreadyConfirmed)
|
||||||
|
|
||||||
const handleTabChange = (event, tabClicked) => {
|
const handleTabChange = (event, tabClicked) => {
|
||||||
setTabIndex(tabClicked)
|
setTabIndex(tabClicked)
|
||||||
@ -102,8 +113,8 @@ const ExpandedTx = ({
|
|||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph noMargin>
|
<Paragraph noMargin>
|
||||||
<Bold>TX status: </Bold>
|
<Bold>TX status: </Bold>
|
||||||
<Span className={classes[txStatus]} style={{ fontWeight: 'bold' }}>
|
<Span className={classes[tx.status]} style={{ fontWeight: 'bold' }}>
|
||||||
{txStatusToLabel[txStatus]}
|
{txStatusToLabel[tx.status]}
|
||||||
</Span>
|
</Span>
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph noMargin>
|
<Paragraph noMargin>
|
||||||
@ -147,18 +158,31 @@ to:
|
|||||||
</Row>
|
</Row>
|
||||||
<Row>{tabIndex === 0 && <OwnersList owners={ownersWhoConfirmed} />}</Row>
|
<Row>{tabIndex === 0 && <OwnersList owners={ownersWhoConfirmed} />}</Row>
|
||||||
<Row>{tabIndex === 1 && <OwnersList owners={ownersUnconfirmed} />}</Row>
|
<Row>{tabIndex === 1 && <OwnersList owners={ownersUnconfirmed} />}</Row>
|
||||||
{granted && (
|
{granted && displayButtonRow && (
|
||||||
<ButtonRow
|
<ButtonRow
|
||||||
onTxConfirm={openApproveModal}
|
onTxConfirm={openApproveModal}
|
||||||
onTxCancel={openCancelModal}
|
onTxCancel={openCancelModal}
|
||||||
showConfirmBtn={!currentUserAlreadyConfirmed}
|
showConfirmBtn={!currentUserAlreadyConfirmed}
|
||||||
|
showCancelBtn={!cancellationTx}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Block>
|
</Block>
|
||||||
<CancelTxModal isOpen={openModal === 'cancelTx'} createTransaction={createTransaction} onClose={closeModal} tx={tx} safeAddress={safeAddress} />
|
<CancelTxModal
|
||||||
<ApproveTxModal isOpen={openModal === 'approveTx'} createTransaction={createTransaction} onClose={closeModal} tx={tx} safeAddress={safeAddress} />
|
isOpen={openModal === 'cancelTx'}
|
||||||
|
createTransaction={createTransaction}
|
||||||
|
onClose={closeModal}
|
||||||
|
tx={tx}
|
||||||
|
safeAddress={safeAddress}
|
||||||
|
/>
|
||||||
|
<ApproveTxModal
|
||||||
|
isOpen={openModal === 'approveTx'}
|
||||||
|
createTransaction={createTransaction}
|
||||||
|
onClose={closeModal}
|
||||||
|
tx={tx}
|
||||||
|
safeAddress={safeAddress}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import { md, lg, connected } from '~/theme/variables'
|
import {
|
||||||
|
md, lg, connected, error,
|
||||||
|
} from '~/theme/variables'
|
||||||
|
|
||||||
export const styles = () => ({
|
export const styles = () => ({
|
||||||
txDataContainer: {
|
txDataContainer: {
|
||||||
@ -15,4 +17,7 @@ export const styles = () => ({
|
|||||||
success: {
|
success: {
|
||||||
color: connected,
|
color: connected,
|
||||||
},
|
},
|
||||||
|
cancelled: {
|
||||||
|
color: error,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user