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,49 +148,57 @@ class ManageOwners extends React.Component<Props, State> {
</TableCell> </TableCell>
))} ))}
<TableCell component="td"> <TableCell component="td">
<Row align="end" className={classes.actions}> {granted && (
<Img <Row align="end" className={classes.actions}>
alt="Edit owner" <Img
className={classes.editOwnerIcon} alt="Edit owner"
src={RenameOwnerIcon} className={classes.editOwnerIcon}
onClick={this.onShow('EditOwner', row)} src={RenameOwnerIcon}
testId={RENAME_OWNER_BTN_TESTID} onClick={this.onShow('EditOwner', row)}
/> testId={RENAME_OWNER_BTN_TESTID}
<Img />
alt="Replace owner" <Img
className={classes.replaceOwnerIcon} alt="Replace owner"
src={ReplaceOwnerIcon} className={classes.replaceOwnerIcon}
onClick={this.onShow('ReplaceOwner', row)} src={ReplaceOwnerIcon}
/> onClick={this.onShow('ReplaceOwner', row)}
<Img />
alt="Remove owner" {ownerData.size > 1 && (
className={classes.removeOwnerIcon} <Img
src={RemoveOwnerIcon} alt="Remove owner"
onClick={this.onShow('RemoveOwner', row)} className={classes.removeOwnerIcon}
testId={REMOVE_OWNER_BTN_TESTID} src={RemoveOwnerIcon}
/> onClick={this.onShow('RemoveOwner', row)}
</Row> testId={REMOVE_OWNER_BTN_TESTID}
/>
)}
</Row>
)}
</TableCell> </TableCell>
</TableRow> </TableRow>
)) ))
} }
</Table> </Table>
</Block> </Block>
<Hairline /> {granted && (
<Row style={controlsStyle} align="end" grow> <React.Fragment>
<Col end="xs"> <Hairline />
<Button <Row style={controlsStyle} align="end" grow>
style={addOwnerButtonStyle} <Col end="xs">
size="small" <Button
variant="contained" style={addOwnerButtonStyle}
color="primary" size="small"
onClick={this.onShow('AddOwner')} variant="contained"
testId={ADD_OWNER_BTN_TESTID} color="primary"
> onClick={this.onShow('AddOwner')}
Add new owner testId={ADD_OWNER_BTN_TESTID}
</Button> >
</Col> Add new owner
</Row> </Button>
</Col>
</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 />
<Row
className={cn(classes.menuOption, menuOptionIndex === 2 && classes.active)}
onClick={this.handleChange(2)}
>
Owners ({owners.size})
</Row>
<Hairline />
{granted && ( {granted && (
<React.Fragment> <React.Fragment>
<Row
className={cn(classes.menuOption, menuOptionIndex === 2 && classes.active)}
onClick={this.handleChange(2)}
testId={OWNERS_SETTINGS_TAB_TEST_ID}
>
Owners (
{owners.size}
)
</Row>
<Hairline />
<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 && (