Implement readonly on safe overview

This commit is contained in:
apanizo 2018-10-24 13:05:48 +02:00
parent deac8528fc
commit 76c7907acc
3 changed files with 42 additions and 32 deletions

View File

@ -76,6 +76,7 @@ const styles = theme => ({
type Props = { type Props = {
classes: Object, classes: Object,
granted: boolean,
} }
type Action = 'Token' | 'Send' | 'Receive' type Action = 'Token' | 'Send' | 'Receive'
@ -106,7 +107,7 @@ class Balances extends React.Component<Props, State> {
const { const {
hideZero, showToken, showReceive, showSend, hideZero, showToken, showReceive, showSend,
} = this.state } = this.state
const { classes } = this.props const { classes, granted } = this.props
const columns = generateColumns() const columns = generateColumns()
const autoColumns = columns.filter(c => !c.custom) const autoColumns = columns.filter(c => !c.custom)
@ -160,10 +161,12 @@ class Balances extends React.Component<Props, State> {
)) } )) }
<TableCell component="th" scope="row"> <TableCell component="th" scope="row">
<Row align="end" className={classes.actions}> <Row align="end" className={classes.actions}>
{ granted &&
<Button variant="contained" size="small" color="secondary" className={classes.send} onClick={this.onShow('Send')}> <Button variant="contained" size="small" color="secondary" className={classes.send} onClick={this.onShow('Send')}>
<CallMade className={classNames(classes.leftIcon, classes.iconSmall)} /> <CallMade className={classNames(classes.leftIcon, classes.iconSmall)} />
Send Send
</Button> </Button>
}
<Button variant="contained" size="small" color="secondary" className={classes.receive} onClick={this.onShow('Receive')}> <Button variant="contained" size="small" color="secondary" className={classes.receive} onClick={this.onShow('Receive')}>
<CallReceived className={classNames(classes.leftIcon, classes.iconSmall)} /> <CallReceived className={classNames(classes.leftIcon, classes.iconSmall)} />
Receive Receive
@ -173,20 +176,10 @@ class Balances extends React.Component<Props, State> {
</TableRow> </TableRow>
))} ))}
</Table> </Table>
<Modal <Modal title="Send Tokens" description="Send Tokens Form" handleClose={this.onHide('Send')} open={showSend}>
title="Send Tokens"
description="Send Tokens Form"
handleClose={this.onHide('Send')}
open={showSend}
>
<Send onClose={this.onHide('Send')} /> <Send onClose={this.onHide('Send')} />
</Modal> </Modal>
<Modal <Modal title="Receive Tokens" description="Receive Tokens Form" handleClose={this.onHide('Receive')} open={showReceive}>
title="Receive Tokens"
description="Receive Tokens Form"
handleClose={this.onHide('Receive')}
open={showReceive}
>
<Receive onClose={this.onHide('Receive')} /> <Receive onClose={this.onHide('Receive')} />
</Modal> </Modal>
</React.Fragment> </React.Fragment>

View File

@ -13,11 +13,12 @@ import Paragraph from '~/components/layout/Paragraph'
import NoSafe from '~/components/NoSafe' import NoSafe from '~/components/NoSafe'
import { type SelectorProps } from '~/routes/safe/container/selector' import { type SelectorProps } from '~/routes/safe/container/selector'
import { openAddressInEtherScan } from '~/logic/wallets/getWeb3' import { openAddressInEtherScan } from '~/logic/wallets/getWeb3'
import { sm, secondary } from '~/theme/variables' import { sm, xs, secondary, smallFontSize } from '~/theme/variables'
import Balances from './Balances' import Balances from './Balances'
type Props = SelectorProps & { type Props = SelectorProps & {
classes: Object, classes: Object,
granted: boolean,
} }
type State = { type State = {
@ -50,6 +51,18 @@ const styles = () => ({
cursor: 'pointer', cursor: 'pointer',
}, },
}, },
readonly: {
fontSize: smallFontSize,
letterSpacing: '0.5px',
color: '#ffffff',
backgroundColor: '#a2a8ba',
fontFamily: 'Roboto Mono, monospace',
textTransform: 'uppercase',
padding: `0 ${sm}`,
marginLeft: sm,
borderRadius: xs,
lineHeight: '28px',
},
}) })
class Layout extends React.Component<Props, State> { class Layout extends React.Component<Props, State> {
@ -63,7 +76,7 @@ class Layout extends React.Component<Props, State> {
render() { render() {
const { const {
safe, provider, network, classes, safe, provider, network, classes, granted,
} = this.props } = this.props
const { value } = this.state const { value } = this.state
@ -78,7 +91,14 @@ class Layout extends React.Component<Props, State> {
<Block className={classes.container} margin="xl"> <Block className={classes.container} margin="xl">
<Identicon address={address} diameter={50} /> <Identicon address={address} diameter={50} />
<Block className={classes.name}> <Block className={classes.name}>
<Row>
<Heading tag="h2" color="secondary">{safe.get('name')}</Heading> <Heading tag="h2" color="secondary">{safe.get('name')}</Heading>
{ !granted &&
<Block className={classes.readonly} >
Read Only
</Block>
}
</Row>
<Block align="center" className={classes.user}> <Block align="center" className={classes.user}>
<Paragraph size="md" color="disabled" noMargin>{address}</Paragraph> <Paragraph size="md" color="disabled" noMargin>{address}</Paragraph>
<OpenInNew <OpenInNew
@ -102,7 +122,7 @@ class Layout extends React.Component<Props, State> {
</Tabs> </Tabs>
</Row> </Row>
<Hairline color="#c8ced4" /> <Hairline color="#c8ced4" />
{value === 0 && <Balances />} {value === 0 && <Balances granted={granted} />}
</React.Fragment> </React.Fragment>
) )
} }

View File

@ -3,7 +3,6 @@ import * as React from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import Page from '~/components/layout/Page' import Page from '~/components/layout/Page'
import Layout from '~/routes/safe/component/Layout' import Layout from '~/routes/safe/component/Layout'
import NoRights from '~/routes/safe/component/NoRights'
import selector, { type SelectorProps } from './selector' import selector, { type SelectorProps } from './selector'
import actions, { type Actions } from './actions' import actions, { type Actions } from './actions'
@ -52,16 +51,14 @@ class SafeView extends React.PureComponent<Props> {
return ( return (
<Page> <Page>
{ granted <Layout
? <Layout
activeTokens={activeTokens} activeTokens={activeTokens}
provider={provider} provider={provider}
safe={safe} safe={safe}
userAddress={userAddress} userAddress={userAddress}
network={network} network={network}
granted={granted}
/> />
: <NoRights />
}
</Page> </Page>
) )
} }