Safe view tabs as routes wip

This commit is contained in:
Mikhail Mikheev 2019-10-04 18:10:17 +04:00
parent b458aa44ba
commit 051b677651

View File

@ -1,6 +1,7 @@
// @flow // @flow
import * as React from 'react' import * as React from 'react'
import classNames from 'classnames/bind' import classNames from 'classnames/bind'
import { Switch, Redirect, Route } from 'react-router-dom'
import OpenInNew from '@material-ui/icons/OpenInNew' import OpenInNew from '@material-ui/icons/OpenInNew'
import Tabs from '@material-ui/core/Tabs' import Tabs from '@material-ui/core/Tabs'
import Tab from '@material-ui/core/Tab' import Tab from '@material-ui/core/Tab'
@ -21,9 +22,7 @@ import Receive from './Balances/Receive'
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 { getEtherScanLink } from '~/logic/wallets/getWeb3' import { getEtherScanLink } from '~/logic/wallets/getWeb3'
import { import { secondary, border } from '~/theme/variables'
secondary, border,
} from '~/theme/variables'
import { copyToClipboard } from '~/utils/clipboard' import { copyToClipboard } from '~/utils/clipboard'
import { type Actions } from '../container/actions' import { type Actions } from '../container/actions'
import Balances from './Balances' import Balances from './Balances'
@ -49,7 +48,7 @@ type Props = SelectorProps &
onShow: Function, onShow: Function,
onHide: Function, onHide: Function,
showSendFunds: Function, showSendFunds: Function,
hideSendFunds: Function hideSendFunds: Function,
} }
const openIconStyle = { const openIconStyle = {
@ -99,6 +98,7 @@ class Layout extends React.Component<Props, State> {
showSendFunds, showSendFunds,
hideSendFunds, hideSendFunds,
} = this.props } = this.props
console.log(this.props)
const { tabIndex } = this.state const { tabIndex } = this.state
if (!safe) { if (!safe) {
@ -139,7 +139,7 @@ class Layout extends React.Component<Props, State> {
disabled={!granted} disabled={!granted}
> >
<CallMade alt="Send Transaction" className={classNames(classes.leftIcon, classes.iconSmall)} /> <CallMade alt="Send Transaction" className={classNames(classes.leftIcon, classes.iconSmall)} />
Send Send
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@ -149,7 +149,7 @@ class Layout extends React.Component<Props, State> {
onClick={onShow('Receive')} onClick={onShow('Receive')}
> >
<CallReceived alt="Receive Transaction" className={classNames(classes.leftIcon, classes.iconSmall)} /> <CallReceived alt="Receive Transaction" className={classNames(classes.leftIcon, classes.iconSmall)} />
Receive Receive
</Button> </Button>
</Row> </Row>
</Block> </Block>
@ -162,46 +162,61 @@ class Layout extends React.Component<Props, State> {
</Tabs> </Tabs>
</Row> </Row>
<Hairline color={border} style={{ marginTop: '-2px' }} /> <Hairline color={border} style={{ marginTop: '-2px' }} />
{tabIndex === 0 && ( <Switch>
<Balances <Route
ethBalance={ethBalance} exact
tokens={tokens} path="balances"
activeTokens={activeTokens} render={() => (
granted={granted} <Balances
safeAddress={address} ethBalance={ethBalance}
safeName={name} tokens={tokens}
etherScanLink={etherScanLink} activeTokens={activeTokens}
createTransaction={createTransaction} granted={granted}
safeAddress={address}
safeName={name}
etherScanLink={etherScanLink}
createTransaction={createTransaction}
/>
)}
/> />
)} <Route
{tabIndex === 1 && ( exact
<Transactions path="transactions"
threshold={safe.threshold} render={() => (
owners={safe.owners} <Transactions
transactions={transactions} threshold={safe.threshold}
fetchTransactions={fetchTransactions} owners={safe.owners}
safeAddress={address} transactions={transactions}
userAddress={userAddress} fetchTransactions={fetchTransactions}
currentNetwork={network} safeAddress={address}
granted={granted} userAddress={userAddress}
createTransaction={createTransaction} currentNetwork={network}
processTransaction={processTransaction} granted={granted}
createTransaction={createTransaction}
processTransaction={processTransaction}
/>
)}
/> />
)} <Route
{tabIndex === 2 && ( exact
<Settings path="settings"
granted={granted} render={() => (
safeAddress={address} <Settings
safeName={name} granted={granted}
etherScanLink={etherScanLink} safeAddress={address}
updateSafe={updateSafe} safeName={name}
threshold={safe.threshold} etherScanLink={etherScanLink}
owners={safe.owners} updateSafe={updateSafe}
network={network} threshold={safe.threshold}
userAddress={userAddress} owners={safe.owners}
createTransaction={createTransaction} network={network}
userAddress={userAddress}
createTransaction={createTransaction}
/>
)}
/> />
)} <Redirect to="balances" />
</Switch>
<SendModal <SendModal
onClose={hideSendFunds} onClose={hideSendFunds}
isOpen={sendFunds.isOpen} isOpen={sendFunds.isOpen}
@ -221,12 +236,7 @@ class Layout extends React.Component<Props, State> {
open={showReceive} open={showReceive}
paperClassName={classes.receiveModal} paperClassName={classes.receiveModal}
> >
<Receive <Receive safeName={name} safeAddress={address} etherScanLink={etherScanLink} onClose={onHide('Receive')} />
safeName={name}
safeAddress={address}
etherScanLink={etherScanLink}
onClose={onHide('Receive')}
/>
</Modal> </Modal>
</> </>
) )