Little bit performance improvement for SafeOwnersForm in safe creation, still has to be improved
This commit is contained in:
parent
9001c52524
commit
f03fde5ffe
|
@ -2,12 +2,12 @@
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import { List } from 'immutable'
|
import { List } from 'immutable'
|
||||||
import Row from '~/components/layout/Row'
|
|
||||||
import Table from '@material-ui/core/Table'
|
import Table from '@material-ui/core/Table'
|
||||||
import TableBody from '@material-ui/core/TableBody'
|
import TableBody from '@material-ui/core/TableBody'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
import CircularProgress from '@material-ui/core/CircularProgress'
|
import CircularProgress from '@material-ui/core/CircularProgress'
|
||||||
import TablePagination from '@material-ui/core/TablePagination'
|
import TablePagination from '@material-ui/core/TablePagination'
|
||||||
|
import Row from '~/components/layout/Row'
|
||||||
import { type Order, stableSort, getSorting } from '~/components/Table/sorting'
|
import { type Order, stableSort, getSorting } from '~/components/Table/sorting'
|
||||||
import TableHead, { type Column } from '~/components/Table/TableHead'
|
import TableHead, { type Column } from '~/components/Table/TableHead'
|
||||||
import { xl } from '~/theme/variables'
|
import { xl } from '~/theme/variables'
|
||||||
|
@ -31,7 +31,6 @@ type State = {
|
||||||
orderProp: boolean,
|
orderProp: boolean,
|
||||||
rowsPerPage: number,
|
rowsPerPage: number,
|
||||||
fixed?: boolean,
|
fixed?: boolean,
|
||||||
noBorder: boolean,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
|
@ -134,13 +133,16 @@ class GnoTable<K> extends React.Component<Props<K>, State> {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{!isEmpty && (
|
{!isEmpty && (
|
||||||
<Table aria-labelledby={label} className={!noBorder && classes.root}>
|
<Table aria-labelledby={label} className={noBorder ? '' : classes.root}>
|
||||||
<TableHead columns={columns} order={order} orderBy={orderByParam} onSort={this.onSort} />
|
<TableHead columns={columns} order={order} orderBy={orderByParam} onSort={this.onSort} />
|
||||||
<TableBody>{children(sortedData)}</TableBody>
|
<TableBody>{children(sortedData)}</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
)}
|
)}
|
||||||
{isEmpty && (
|
{isEmpty && (
|
||||||
<Row className={classNames(classes.loader, !noBorder && classes.root)} style={this.getEmptyStyle(emptyRows + 1)}>
|
<Row
|
||||||
|
className={classNames(classes.loader, !noBorder && classes.root)}
|
||||||
|
style={this.getEmptyStyle(emptyRows + 1)}
|
||||||
|
>
|
||||||
<CircularProgress size={60} />
|
<CircularProgress size={60} />
|
||||||
</Row>
|
</Row>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// @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 InputAdornment from '@material-ui/core/InputAdornment'
|
||||||
|
import CheckCircle from '@material-ui/icons/CheckCircle'
|
||||||
import Field from '~/components/forms/Field'
|
import Field from '~/components/forms/Field'
|
||||||
import TextField from '~/components/forms/TextField'
|
import TextField from '~/components/forms/TextField'
|
||||||
import {
|
import {
|
||||||
|
@ -15,8 +17,6 @@ import Button from '~/components/layout/Button'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
import Col from '~/components/layout/Col'
|
import Col from '~/components/layout/Col'
|
||||||
import InputAdornment from '@material-ui/core/InputAdornment'
|
|
||||||
import CheckCircle from '@material-ui/icons/CheckCircle'
|
|
||||||
import { getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields'
|
import { getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import OpenPaper from '~/components/Stepper/OpenPaper'
|
import OpenPaper from '~/components/Stepper/OpenPaper'
|
||||||
|
@ -74,8 +74,11 @@ const styles = () => ({
|
||||||
})
|
})
|
||||||
|
|
||||||
const getAddressValidators = (addresses: string[], position: number) => {
|
const getAddressValidators = (addresses: string[], position: number) => {
|
||||||
|
// thanks Rich Harris
|
||||||
|
// https://twitter.com/Rich_Harris/status/1125850391155965952
|
||||||
const copy = addresses.slice()
|
const copy = addresses.slice()
|
||||||
copy.splice(position, 1)
|
copy[position] = copy[copy.length - 1]
|
||||||
|
copy.pop()
|
||||||
|
|
||||||
return composeValidators(required, mustBeEthereumAddress, uniqueAddress(copy))
|
return composeValidators(required, mustBeEthereumAddress, uniqueAddress(copy))
|
||||||
}
|
}
|
||||||
|
@ -97,7 +100,7 @@ export const calculateValuesAfterRemoving = (index: number, notRemovedOwners: nu
|
||||||
return initialValues
|
return initialValues
|
||||||
}
|
}
|
||||||
|
|
||||||
class SafeOwners extends React.Component<Props, State> {
|
class SafeOwners extends React.PureComponent<Props, State> {
|
||||||
state = {
|
state = {
|
||||||
numOwners: 1,
|
numOwners: 1,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,17 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { List } from 'immutable'
|
import { List } from 'immutable'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
|
import TableRow from '@material-ui/core/TableRow'
|
||||||
|
import TableCell from '@material-ui/core/TableCell'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import Col from '~/components/layout/Col'
|
import Col from '~/components/layout/Col'
|
||||||
import Table from '~/components/Table'
|
import Table from '~/components/Table'
|
||||||
import { type Column, cellWidth } from '~/components/Table/TableHead'
|
import { type Column, cellWidth } from '~/components/Table/TableHead'
|
||||||
import TableRow from '@material-ui/core/TableRow'
|
|
||||||
import TableCell from '@material-ui/core/TableCell'
|
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import Hairline from '~/components/layout/Hairline'
|
import Hairline from '~/components/layout/Hairline'
|
||||||
import Button from '~/components/layout/Button'
|
import Button from '~/components/layout/Button'
|
||||||
|
import Img from '~/components/layout/Img'
|
||||||
import AddOwnerModal from './AddOwnerModal'
|
import AddOwnerModal from './AddOwnerModal'
|
||||||
import RemoveOwnerModal from './RemoveOwnerModal'
|
import RemoveOwnerModal from './RemoveOwnerModal'
|
||||||
import ReplaceOwnerModal from './ReplaceOwnerModal'
|
import ReplaceOwnerModal from './ReplaceOwnerModal'
|
||||||
|
@ -48,6 +49,15 @@ type Props = {
|
||||||
createTransaction: Function,
|
createTransaction: Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type State = {
|
||||||
|
selectedOwnerAddress?: string,
|
||||||
|
selectedOwnerName?: string,
|
||||||
|
showAddOwner: boolean,
|
||||||
|
showRemoveOwner: boolean,
|
||||||
|
showReplaceOwner: boolean,
|
||||||
|
showEditOwner: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
type Action = 'AddOwner' | 'EditOwner' | 'ReplaceOwner' | 'RemoveOwner'
|
type Action = 'AddOwner' | 'EditOwner' | 'ReplaceOwner' | 'RemoveOwner'
|
||||||
|
|
||||||
class ManageOwners extends React.Component<Props, State> {
|
class ManageOwners extends React.Component<Props, State> {
|
||||||
|
@ -78,14 +88,7 @@ class ManageOwners extends React.Component<Props, State> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
classes,
|
classes, safeAddress, safeName, owners, threshold, network, userAddress, createTransaction,
|
||||||
safeAddress,
|
|
||||||
safeName,
|
|
||||||
owners,
|
|
||||||
threshold,
|
|
||||||
network,
|
|
||||||
userAddress,
|
|
||||||
createTransaction,
|
|
||||||
} = this.props
|
} = this.props
|
||||||
const {
|
const {
|
||||||
showAddOwner,
|
showAddOwner,
|
||||||
|
@ -106,36 +109,33 @@ class ManageOwners extends React.Component<Props, State> {
|
||||||
<Paragraph noMargin className={classes.title} size="lg" weight="bolder">
|
<Paragraph noMargin className={classes.title} size="lg" weight="bolder">
|
||||||
Manage Safe Owners
|
Manage Safe Owners
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Table
|
<Table label="owners" columns={columns} data={ownerData} size={ownerData.size} defaultFixed noBorder>
|
||||||
label="owners"
|
|
||||||
columns={columns}
|
|
||||||
data={ownerData}
|
|
||||||
size={ownerData.size}
|
|
||||||
defaultFixed
|
|
||||||
noBorder
|
|
||||||
>
|
|
||||||
{(sortedData: Array<OwnerRow>) => sortedData.map((row: any, index: number) => (
|
{(sortedData: Array<OwnerRow>) => sortedData.map((row: any, index: number) => (
|
||||||
<TableRow tabIndex={-1} key={index} className={classes.hide}>
|
<TableRow tabIndex={-1} key={index} className={classes.hide}>
|
||||||
{autoColumns.map((column: Column) => (
|
{autoColumns.map((column: Column) => (
|
||||||
<TableCell key={column.id} style={cellWidth(column.width)} align={column.align} component="td">
|
<TableCell key={column.id} style={cellWidth(column.width)} align={column.align} component="td">
|
||||||
{column.id === OWNERS_TABLE_ADDRESS_ID ? <OwnerAddressTableCell address={row[column.id]} /> : row[column.id]}
|
{column.id === OWNERS_TABLE_ADDRESS_ID ? (
|
||||||
|
<OwnerAddressTableCell address={row[column.id]} />
|
||||||
|
) : (
|
||||||
|
row[column.id]
|
||||||
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
))}
|
))}
|
||||||
<TableCell component="td">
|
<TableCell component="td">
|
||||||
<Row align="end" className={classes.actions}>
|
<Row align="end" className={classes.actions}>
|
||||||
<img
|
<Img
|
||||||
alt="Edit owner"
|
alt="Edit owner"
|
||||||
className={classes.editOwnerIcon}
|
className={classes.editOwnerIcon}
|
||||||
src={RenameOwnerIcon}
|
src={RenameOwnerIcon}
|
||||||
onClick={this.onShow('EditOwner', row)}
|
onClick={this.onShow('EditOwner', row)}
|
||||||
/>
|
/>
|
||||||
<img
|
<Img
|
||||||
alt="Replace owner"
|
alt="Replace owner"
|
||||||
className={classes.replaceOwnerIcon}
|
className={classes.replaceOwnerIcon}
|
||||||
src={ReplaceOwnerIcon}
|
src={ReplaceOwnerIcon}
|
||||||
onClick={this.onShow('ReplaceOwner', row)}
|
onClick={this.onShow('ReplaceOwner', row)}
|
||||||
/>
|
/>
|
||||||
<img
|
<Img
|
||||||
alt="Remove owner"
|
alt="Remove owner"
|
||||||
className={classes.removeOwnerIcon}
|
className={classes.removeOwnerIcon}
|
||||||
src={RemoveOwnerIcon}
|
src={RemoveOwnerIcon}
|
||||||
|
@ -144,7 +144,8 @@ class ManageOwners extends React.Component<Props, State> {
|
||||||
</Row>
|
</Row>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))
|
||||||
|
}
|
||||||
</Table>
|
</Table>
|
||||||
</Block>
|
</Block>
|
||||||
<Hairline />
|
<Hairline />
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import {
|
import { lg } from '~/theme/variables'
|
||||||
sm, xs, md, lg, border,
|
|
||||||
} from '~/theme/variables'
|
|
||||||
|
|
||||||
export const styles = () => ({
|
export const styles = () => ({
|
||||||
title: {
|
title: {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import { withStyles } from '@material-ui/core/styles'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import Col from '~/components/layout/Col'
|
import Col from '~/components/layout/Col'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
|
import Span from '~/components/layout/Span'
|
||||||
|
import Img from '~/components/layout/Img'
|
||||||
import RemoveSafeModal from './RemoveSafeModal'
|
import RemoveSafeModal from './RemoveSafeModal'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import Hairline from '~/components/layout/Hairline'
|
import Hairline from '~/components/layout/Hairline'
|
||||||
|
@ -83,10 +85,10 @@ class Settings extends React.Component<Props, State> {
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={6} end="sm">
|
<Col xs={6} end="sm">
|
||||||
<Paragraph noMargin size="md" color="error" onClick={this.onShow('RemoveSafe')}>
|
<Paragraph noMargin size="md" color="error" onClick={this.onShow('RemoveSafe')}>
|
||||||
<Paragraph noMargin className={cn(classes.links, classes.removeSafeText)}>
|
<Span className={cn(classes.links, classes.removeSafeText)}>
|
||||||
Remove Safe
|
Remove Safe
|
||||||
</Paragraph>
|
</Span>
|
||||||
<img alt="Trash Icon" className={classes.removeSafeIcon} src={RemoveSafeIcon} />
|
<Img alt="Trash Icon" className={classes.removeSafeIcon} src={RemoveSafeIcon} />
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<RemoveSafeModal
|
<RemoveSafeModal
|
||||||
onClose={this.onHide('RemoveSafe')}
|
onClose={this.onHide('RemoveSafe')}
|
||||||
|
|
Loading…
Reference in New Issue