Show owner list when current address in not an owner

This commit is contained in:
Germán Martínez 2019-07-03 18:33:05 +02:00
parent 482da14439
commit b064b0fa9f
3 changed files with 63 additions and 59 deletions

View File

@ -9,7 +9,7 @@ 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 Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import Paragraph from '~/components/layout/Paragraph' import Heading from '~/components/layout/Heading'
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 Img from '~/components/layout/Img'
@ -22,7 +22,7 @@ import type { Owner } from '~/routes/safe/store/models/owner'
import { import {
getOwnerData, generateColumns, OWNERS_TABLE_NAME_ID, OWNERS_TABLE_ADDRESS_ID, type OwnerRow, getOwnerData, generateColumns, OWNERS_TABLE_NAME_ID, OWNERS_TABLE_ADDRESS_ID, type OwnerRow,
} from './dataFetcher' } from './dataFetcher'
import { sm, boldFont } from '~/theme/variables' import { lg, sm, boldFont } from '~/theme/variables'
import { styles } from './style' import { styles } from './style'
import ReplaceOwnerIcon from './assets/icons/replace-owner.svg' import ReplaceOwnerIcon from './assets/icons/replace-owner.svg'
import RenameOwnerIcon from './assets/icons/rename-owner.svg' import RenameOwnerIcon from './assets/icons/rename-owner.svg'
@ -43,6 +43,10 @@ const addOwnerButtonStyle = {
fontWeight: boldFont, fontWeight: boldFont,
} }
const title = {
padding: lg,
}
type Props = { type Props = {
classes: Object, classes: Object,
safeAddress: string, safeAddress: string,
@ -53,6 +57,7 @@ type Props = {
userAddress: string, userAddress: string,
createTransaction: Function, createTransaction: Function,
updateSafe: Function, updateSafe: Function,
granted: boolean,
} }
type State = { type State = {
@ -103,6 +108,7 @@ class ManageOwners extends React.Component<Props, State> {
userAddress, userAddress,
createTransaction, createTransaction,
updateSafe, updateSafe,
granted,
} = this.props } = this.props
const { const {
showAddOwner, showAddOwner,
@ -120,9 +126,7 @@ class ManageOwners extends React.Component<Props, State> {
return ( return (
<React.Fragment> <React.Fragment>
<Block className={classes.formContainer}> <Block className={classes.formContainer}>
<Paragraph noMargin className={classes.title} size="lg" weight="bolder"> <Heading tag="h3" style={title}>Manage Safe Owners</Heading>
Manage Safe Owners
</Paragraph>
<Table <Table
label="Owners" label="Owners"
defaultOrderBy={OWNERS_TABLE_NAME_ID} defaultOrderBy={OWNERS_TABLE_NAME_ID}
@ -144,6 +148,7 @@ class ManageOwners extends React.Component<Props, State> {
</TableCell> </TableCell>
))} ))}
<TableCell component="td"> <TableCell component="td">
{granted && (
<Row align="end" className={classes.actions}> <Row align="end" className={classes.actions}>
<Img <Img
alt="Edit owner" alt="Edit owner"
@ -158,6 +163,7 @@ class ManageOwners extends React.Component<Props, State> {
src={ReplaceOwnerIcon} src={ReplaceOwnerIcon}
onClick={this.onShow('ReplaceOwner', row)} onClick={this.onShow('ReplaceOwner', row)}
/> />
{ownerData.size > 1 && (
<Img <Img
alt="Remove owner" alt="Remove owner"
className={classes.removeOwnerIcon} className={classes.removeOwnerIcon}
@ -165,13 +171,17 @@ class ManageOwners extends React.Component<Props, State> {
onClick={this.onShow('RemoveOwner', row)} onClick={this.onShow('RemoveOwner', row)}
testId={REMOVE_OWNER_BTN_TESTID} testId={REMOVE_OWNER_BTN_TESTID}
/> />
)}
</Row> </Row>
)}
</TableCell> </TableCell>
</TableRow> </TableRow>
)) ))
} }
</Table> </Table>
</Block> </Block>
{granted && (
<React.Fragment>
<Hairline /> <Hairline />
<Row style={controlsStyle} align="end" grow> <Row style={controlsStyle} align="end" grow>
<Col end="xs"> <Col end="xs">
@ -187,6 +197,8 @@ class ManageOwners extends React.Component<Props, State> {
</Button> </Button>
</Col> </Col>
</Row> </Row>
</React.Fragment>
)}
<AddOwnerModal <AddOwnerModal
onClose={this.onHide('AddOwner')} onClose={this.onHide('AddOwner')}
isOpen={showAddOwner} isOpen={showAddOwner}

View File

@ -2,10 +2,6 @@
import { lg } from '~/theme/variables' import { lg } from '~/theme/variables'
export const styles = () => ({ export const styles = () => ({
title: {
padding: `${lg} 20px`,
fontSize: '16px',
},
formContainer: { formContainer: {
minHeight: '369px', minHeight: '369px',
}, },

View File

@ -20,8 +20,6 @@ import actions, { type Actions } from './actions'
import { styles } from './style' import { styles } from './style'
import RemoveSafeIcon from './assets/icons/bin.svg' import RemoveSafeIcon from './assets/icons/bin.svg'
export const OWNERS_SETTINGS_TAB_TEST_ID = 'owner-settings-tab'
type State = { type State = {
showRemoveSafe: boolean, showRemoveSafe: boolean,
menuOptionIndex: number, menuOptionIndex: number,
@ -111,18 +109,15 @@ class Settings extends React.Component<Props, State> {
Safe name Safe name
</Row> </Row>
<Hairline /> <Hairline />
{granted && (
<React.Fragment>
<Row <Row
className={cn(classes.menuOption, menuOptionIndex === 2 && classes.active)} className={cn(classes.menuOption, menuOptionIndex === 2 && classes.active)}
onClick={this.handleChange(2)} onClick={this.handleChange(2)}
testId={OWNERS_SETTINGS_TAB_TEST_ID}
> >
Owners ( Owners ({owners.size})
{owners.size}
)
</Row> </Row>
<Hairline /> <Hairline />
{granted && (
<React.Fragment>
<Row <Row
className={cn(classes.menuOption, menuOptionIndex === 3 && classes.active)} className={cn(classes.menuOption, menuOptionIndex === 3 && classes.active)}
onClick={this.handleChange(3)} onClick={this.handleChange(3)}
@ -139,7 +134,7 @@ class Settings extends React.Component<Props, State> {
{menuOptionIndex === 1 && ( {menuOptionIndex === 1 && (
<ChangeSafeName safeAddress={safeAddress} safeName={safeName} updateSafe={updateSafe} /> <ChangeSafeName safeAddress={safeAddress} safeName={safeName} updateSafe={updateSafe} />
)} )}
{granted && menuOptionIndex === 2 && ( {menuOptionIndex === 2 && (
<ManageOwners <ManageOwners
owners={owners} owners={owners}
threshold={threshold} threshold={threshold}
@ -149,6 +144,7 @@ class Settings extends React.Component<Props, State> {
createTransaction={createTransaction} createTransaction={createTransaction}
userAddress={userAddress} userAddress={userAddress}
updateSafe={updateSafe} updateSafe={updateSafe}
granted={granted}
/> />
)} )}
{granted && menuOptionIndex === 3 && ( {granted && menuOptionIndex === 3 && (