fix displaying threshold in replacing owner modal, eslint fixes

This commit is contained in:
Mikhail Mikheev 2019-06-27 17:26:19 +04:00
parent 80fb0760b3
commit 7c389ca49a
3 changed files with 54 additions and 36 deletions

View File

@ -1,15 +1,14 @@
// @flow // @flow
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { List } from 'immutable' import { List } from 'immutable'
import { withStyles } from '@material-ui/core/styles'
import { SharedSnackbarConsumer } from '~/components/SharedSnackBar' import { SharedSnackbarConsumer } from '~/components/SharedSnackBar'
import Modal from '~/components/Modal' import Modal from '~/components/Modal'
import { type Safe } from '~/routes/safe/store/models/safe'
import { type Owner, makeOwner } from '~/routes/safe/store/models/owner' import { type Owner, makeOwner } from '~/routes/safe/store/models/owner'
import { setOwners } from '~/logic/safe/utils' import { setOwners } from '~/logic/safe/utils'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import OwnerForm from './screens/OwnerForm' import OwnerForm from './screens/OwnerForm'
import ReviewReplaceOwner from './screens/Review' import ReviewReplaceOwner from './screens/Review'
import { withStyles } from '@material-ui/core/styles'
const styles = () => ({ const styles = () => ({
biggerModalWindow: { biggerModalWindow: {
@ -29,10 +28,10 @@ type Props = {
ownerName: string, ownerName: string,
owners: List<Owner>, owners: List<Owner>,
network: string, network: string,
userAddress: string, threshold: string,
createTransaction: Function, createTransaction: Function,
} }
type ActiveScreen = 'ownerForm' | 'reviewReplaceOwner' type ActiveScreen = 'checkOwner' | 'reviewReplaceOwner'
const SENTINEL_ADDRESS = '0x0000000000000000000000000000000000000001' const SENTINEL_ADDRESS = '0x0000000000000000000000000000000000000001'
@ -49,11 +48,15 @@ export const sendReplaceOwner = async (
const storedOwners = await gnosisSafe.getOwners() const storedOwners = await gnosisSafe.getOwners()
const index = storedOwners.findIndex(ownerAddress => ownerAddress === ownerAddressToRemove) const index = storedOwners.findIndex(ownerAddress => ownerAddress === ownerAddressToRemove)
const prevAddress = index === 0 ? SENTINEL_ADDRESS : storedOwners[index - 1] const prevAddress = index === 0 ? SENTINEL_ADDRESS : storedOwners[index - 1]
const txData = gnosisSafe.contract.methods.swapOwner(prevAddress, ownerAddressToRemove, values.ownerAddress).encodeABI() const txData = gnosisSafe.contract.methods
const text = `Replace Owner ${ownerNameToRemove} (${ownerAddressToRemove}) with ${values.ownerName} (${values.ownerAddress})` .swapOwner(prevAddress, ownerAddressToRemove, values.ownerAddress)
.encodeABI()
// const text = `Replace Owner ${ownerNameToRemove} (${ownerAddressToRemove}) with ${values.ownerName} (${values.ownerAddress})`
const ownersWithoutOldOwner = owners.filter(o => o.address !== ownerAddressToRemove) const ownersWithoutOldOwner = owners.filter(o => o.address !== ownerAddressToRemove)
const ownersWithNewOwner = ownersWithoutOldOwner.push(makeOwner({ name: values.ownerName, address: values.ownerAddress })) const ownersWithNewOwner = ownersWithoutOldOwner.push(
makeOwner({ name: values.ownerName, address: values.ownerAddress }),
)
const txHash = createTransaction(safeAddress, safeAddress, 0, txData, openSnackbar) const txHash = createTransaction(safeAddress, safeAddress, 0, txData, openSnackbar)
if (txHash) { if (txHash) {
@ -71,7 +74,7 @@ const ReplaceOwner = ({
ownerName, ownerName,
owners, owners,
network, network,
userAddress, threshold,
createTransaction, createTransaction,
}: Props) => { }: Props) => {
const [activeScreen, setActiveScreen] = useState<ActiveScreen>('checkOwner') const [activeScreen, setActiveScreen] = useState<ActiveScreen>('checkOwner')
@ -137,6 +140,7 @@ const ReplaceOwner = ({
ownerName={ownerName} ownerName={ownerName}
onClickBack={onClickBack} onClickBack={onClickBack}
onSubmit={onReplaceOwner} onSubmit={onReplaceOwner}
threshold={threshold}
/> />
)} )}
</React.Fragment> </React.Fragment>

View File

@ -10,13 +10,10 @@ import Identicon from '~/components/Identicon'
import Link from '~/components/layout/Link' import Link from '~/components/layout/Link'
import Paragraph from '~/components/layout/Paragraph' import Paragraph from '~/components/layout/Paragraph'
import Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import GnoForm from '~/components/forms/GnoForm'
import Col from '~/components/layout/Col' import Col from '~/components/layout/Col'
import Button from '~/components/layout/Button' import Button from '~/components/layout/Button'
import Block from '~/components/layout/Block' import Block from '~/components/layout/Block'
import Hairline from '~/components/layout/Hairline' import Hairline from '~/components/layout/Hairline'
import Field from '~/components/forms/Field'
import TextField from '~/components/forms/TextField'
import type { Owner } from '~/routes/safe/store/models/owner' import type { Owner } from '~/routes/safe/store/models/owner'
import { getEtherScanLink } from '~/logic/wallets/getWeb3' import { getEtherScanLink } from '~/logic/wallets/getWeb3'
import { secondary } from '~/theme/variables' import { secondary } from '~/theme/variables'
@ -38,6 +35,7 @@ type Props = {
ownerName: string, ownerName: string,
onClickBack: Function, onClickBack: Function,
onSubmit: Function, onSubmit: Function,
threshold: string,
} }
const ReviewRemoveOwner = ({ const ReviewRemoveOwner = ({
@ -50,6 +48,7 @@ const ReviewRemoveOwner = ({
ownerAddress, ownerAddress,
ownerName, ownerName,
onClickBack, onClickBack,
threshold,
onSubmit, onSubmit,
}: Props) => { }: Props) => {
const handleSubmit = () => { const handleSubmit = () => {
@ -90,7 +89,13 @@ const ReviewRemoveOwner = ({
Any transaction requires the confirmation of: Any transaction requires the confirmation of:
</Paragraph> </Paragraph>
<Paragraph size="lg" color="primary" noMargin weight="bolder" className={classes.name}> <Paragraph size="lg" color="primary" noMargin weight="bolder" className={classes.name}>
{values.threshold} out of {owners.size} owner(s) {threshold}
{' '}
out of
{' '}
{owners.size}
{' '}
owner(s)
</Paragraph> </Paragraph>
</Block> </Block>
</Block> </Block>
@ -98,11 +103,14 @@ const ReviewRemoveOwner = ({
<Col xs={8} layout="column" className={classes.owners}> <Col xs={8} layout="column" className={classes.owners}>
<Row className={classes.ownersTitle}> <Row className={classes.ownersTitle}>
<Paragraph size="lg" color="primary" noMargin> <Paragraph size="lg" color="primary" noMargin>
{owners.size} Safe owner(s) {owners.size}
{' '}
Safe owner(s)
</Paragraph> </Paragraph>
</Row> </Row>
<Hairline /> <Hairline />
{owners.map(owner => owner.get('address') != ownerAddress && ( {owners.map(
owner => owner.address !== ownerAddress && (
<React.Fragment key={owner.get('address')}> <React.Fragment key={owner.get('address')}>
<Row className={classes.owner}> <Row className={classes.owner}>
<Col xs={1} align="center"> <Col xs={1} align="center">
@ -117,7 +125,11 @@ const ReviewRemoveOwner = ({
<Paragraph size="md" color="disabled" noMargin> <Paragraph size="md" color="disabled" noMargin>
{owner.get('address')} {owner.get('address')}
</Paragraph> </Paragraph>
<Link className={classes.open} to={getEtherScanLink(owner.get('address'), network)} target="_blank"> <Link
className={classes.open}
to={getEtherScanLink(owner.get('address'), network)}
target="_blank"
>
<OpenInNew style={openIconStyle} /> <OpenInNew style={openIconStyle} />
</Link> </Link>
</Block> </Block>
@ -126,7 +138,8 @@ const ReviewRemoveOwner = ({
</Row> </Row>
<Hairline /> <Hairline />
</React.Fragment> </React.Fragment>
))} ),
)}
<Row className={classes.info} align="center"> <Row className={classes.info} align="center">
<Paragraph weight="bolder" noMargin color="primary" size="md"> <Paragraph weight="bolder" noMargin color="primary" size="md">
REMOVING OWNER &darr; REMOVING OWNER &darr;

View File

@ -204,6 +204,7 @@ class ManageOwners extends React.Component<Props, State> {
ownerName={selectedOwnerName} ownerName={selectedOwnerName}
owners={owners} owners={owners}
network={network} network={network}
threshold={threshold}
userAddress={userAddress} userAddress={userAddress}
createTransaction={createTransaction} createTransaction={createTransaction}
/> />