remove SafeList route because the list moved to sidebar

This commit is contained in:
Mikhail Mikheev 2019-09-19 16:34:20 +04:00
parent 14b946abc2
commit db9788b4cc
12 changed files with 26 additions and 147 deletions

View File

@ -10,7 +10,7 @@ import Col from '~/components/layout/Col'
import { import {
xs, sm, md, border, xs, sm, md, border,
} from '~/theme/variables' } from '~/theme/variables'
import { safesCountSelector } from '~/routes/safeList/store/selectors' import { safesCountSelector } from '~/routes/safe/store/selectors'
import { SidebarContext } from '~/components/Sidebar' import { SidebarContext } from '~/components/Sidebar'
const useStyles = makeStyles({ const useStyles = makeStyles({

View File

@ -13,7 +13,7 @@ import Spacer from '~/components/Spacer'
import Hairline from '~/components/layout/Hairline' import Hairline from '~/components/layout/Hairline'
import Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import { type Safe } from '~/routes/safe/store/models/safe' import { type Safe } from '~/routes/safe/store/models/safe'
import { safesListSelector, defaultSafeSelector } from '~/routes/safeList/store/selectors' import { safesListSelector, defaultSafeSelector } from '~/routes/safe/store/selectors'
import setDefaultSafe from '~/routes/safe/store/actions/setDefaultSafe' import setDefaultSafe from '~/routes/safe/store/actions/setDefaultSafe'
import useSidebarStyles from './style' import useSidebarStyles from './style'
import SafeList from './SafeList' import SafeList from './SafeList'

View File

@ -4,7 +4,7 @@ import { connect } from 'react-redux'
import { import {
Switch, Redirect, Route, withRouter, Switch, Redirect, Route, withRouter,
} from 'react-router-dom' } from 'react-router-dom'
import { defaultSafeSelector } from '~/routes/safeList/store/selectors' import { defaultSafeSelector } from '~/routes/safe/store/selectors'
import Loader from '~/components/Loader' import Loader from '~/components/Loader'
import Welcome from './welcome/container' import Welcome from './welcome/container'
import { import {
@ -18,8 +18,6 @@ import {
const Safe = React.lazy(() => import('./safe/container')) const Safe = React.lazy(() => import('./safe/container'))
const SafeList = React.lazy(() => import('./safeList/container'))
const Open = React.lazy(() => import('./open/container/Open')) const Open = React.lazy(() => import('./open/container/Open'))
const Opening = React.lazy(() => import('./opening/container')) const Opening = React.lazy(() => import('./opening/container'))
@ -66,10 +64,10 @@ const Routes = ({ defaultSafe, location }: RoutesProps) => {
/> />
<Route exact path={WELCOME_ADDRESS} component={Welcome} /> <Route exact path={WELCOME_ADDRESS} component={Welcome} />
<Route exact path={OPEN_ADDRESS} component={Open} /> <Route exact path={OPEN_ADDRESS} component={Open} />
<Route exact path={SAFELIST_ADDRESS} component={SafeList} />
<Route exact path={SAFE_ADDRESS} component={Safe} /> <Route exact path={SAFE_ADDRESS} component={Safe} />
<Route exact path={OPENING_ADDRESS} component={Opening} /> <Route exact path={OPENING_ADDRESS} component={Opening} />
<Route exact path={LOAD_ADDRESS} component={Load} /> <Route exact path={LOAD_ADDRESS} component={Load} />
<Redirect to="/" />
</Switch> </Switch>
) )
} }

View File

@ -3,7 +3,7 @@ import { List } from 'immutable'
import { createAction } from 'redux-actions' import { createAction } from 'redux-actions'
import type { Dispatch as ReduxDispatch, GetState } from 'redux' import type { Dispatch as ReduxDispatch, GetState } from 'redux'
import { type GlobalState } from '~/store' import { type GlobalState } from '~/store'
import { safesListSelector } from '~/routes/safeList/store/selectors' import { safesListSelector } from '~/routes/safe/store/selectors'
import { type Safe } from '~/routes/safe/store/models/safe' import { type Safe } from '~/routes/safe/store/models/safe'
import { makeOwner } from '~/routes/safe/store/models/owner' import { makeOwner } from '~/routes/safe/store/models/owner'
import setDefaultSafe from '~/routes/safe/store/actions/setDefaultSafe' import setDefaultSafe from '~/routes/safe/store/actions/setDefaultSafe'

View File

@ -12,7 +12,7 @@ import { type GlobalState } from '~/store/'
import { import {
saveSafes, setOwners, removeOwners, saveDefaultSafe, saveSafes, setOwners, removeOwners, saveDefaultSafe,
} from '~/logic/safe/utils' } from '~/logic/safe/utils'
import { safesMapSelector } from '~/routes/safeList/store/selectors' import { safesMapSelector } from '~/routes/safe/store/selectors'
import { getActiveTokensAddressesForAllSafes } from '~/routes/safe/store/selectors' import { getActiveTokensAddressesForAllSafes } from '~/routes/safe/store/selectors'
import { tokensSelector } from '~/logic/tokens/store/selectors' import { tokensSelector } from '~/logic/tokens/store/selectors'
import type { Token } from '~/logic/tokens/store/model/token' import type { Token } from '~/logic/tokens/store/model/token'

View File

@ -5,11 +5,10 @@ import { createSelector, createStructuredSelector, type Selector } from 'reselec
import { type GlobalState } from '~/store/index' import { type GlobalState } from '~/store/index'
import { SAFE_PARAM_ADDRESS } from '~/routes/routes' import { SAFE_PARAM_ADDRESS } from '~/routes/routes'
import { type Safe } from '~/routes/safe/store/models/safe' import { type Safe } from '~/routes/safe/store/models/safe'
import { safesMapSelector } from '~/routes/safeList/store/selectors'
import { type State as TransactionsState, TRANSACTIONS_REDUCER_ID } from '~/routes/safe/store/reducer/transactions' import { type State as TransactionsState, TRANSACTIONS_REDUCER_ID } from '~/routes/safe/store/reducer/transactions'
import { type Transaction } from '~/routes/safe/store/models/transaction' import { type Transaction } from '~/routes/safe/store/models/transaction'
import { type Confirmation } from '~/routes/safe/store/models/confirmation' import { type Confirmation } from '~/routes/safe/store/models/confirmation'
import { safesListSelector } from '~/routes/safeList/store/selectors/' import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe'
export type RouterProps = { export type RouterProps = {
match: Match, match: Match,
@ -23,6 +22,25 @@ type TransactionProps = {
transaction: Transaction, transaction: Transaction,
} }
const safesStateSelector = (state: GlobalState): Map<string, *> => state[SAFE_REDUCER_ID]
export const safesMapSelector = (state: GlobalState): Map<string, Safe> => state[SAFE_REDUCER_ID].get('safes')
export const safesListSelector: Selector<GlobalState, {}, List<Safe>> = createSelector(
safesMapSelector,
(safes: Map<string, Safe>): List<Safe> => safes.toList(),
)
export const safesCountSelector: Selector<GlobalState, {}, number> = createSelector(
safesMapSelector,
(safes: Map<string, Safe>): number => safes.size,
)
export const defaultSafeSelector: Selector<GlobalState, {}, string> = createSelector(
safesStateSelector,
(safeState: Map<string, *>): string => safeState.get('defaultSafe'),
)
const transactionsSelector = (state: GlobalState): TransactionsState => state[TRANSACTIONS_REDUCER_ID] const transactionsSelector = (state: GlobalState): TransactionsState => state[TRANSACTIONS_REDUCER_ID]
const oneTransactionSelector = (state: GlobalState, props: TransactionProps) => props.transaction const oneTransactionSelector = (state: GlobalState, props: TransactionProps) => props.transaction

View File

@ -1,25 +0,0 @@
// @flow
import { List } from 'immutable'
import * as React from 'react'
import NoSafe from '~/components/NoSafe'
import { type Safe } from '~/routes/safe/store/models/safe'
import SafeTable from '~/routes/safeList/components/SafeTable'
type Props = {
safes: List<Safe>,
provider: string,
}
const SafeList = ({ safes, provider }: Props) => {
const safesAvailable = safes && safes.count() > 0
return (
<>
{ safesAvailable
? <SafeTable safes={safes} />
: <NoSafe provider={provider} text="No safes created, please create a new one" />}
</>
)
}
export default SafeList

View File

@ -1,13 +0,0 @@
// @flow
import { storiesOf } from '@storybook/react'
import { List } from 'immutable'
import * as React from 'react'
import styles from '~/components/layout/PageFrame/index.scss'
import Component from './Layout'
const FrameDecorator = (story) => <div className={styles.frame}>{story()}</div>
storiesOf('Routes /safes', module)
.addDecorator(FrameDecorator)
.add('Safe List whithout safes and connected', () => <Component provider="METAMASK" safes={List([])} />)
.add('Safe List whithout safes and NOT connected', () => <Component provider="" safes={List([])} />)

View File

@ -1,44 +0,0 @@
// @flow
import { List } from 'immutable'
import * as React from 'react'
import Button from '~/components/layout/Button'
import Link from '~/components/layout/Link'
import Table, {
TableBody, TableCell, TableHead, TableRow,
} from '~/components/layout/Table'
import { type Safe } from '~/routes/safe/store/models/safe'
import { SAFELIST_ADDRESS } from '~/routes/routes'
type Props = {
safes: List<Safe>
}
const SafeTable = ({ safes }: Props) => (
<Table size={900}>
<TableHead>
<TableRow>
<TableCell>Open</TableCell>
<TableCell>Name</TableCell>
<TableCell>Deployed Address</TableCell>
<TableCell align="right">Confirmations</TableCell>
<TableCell align="right">Number of owners</TableCell>
</TableRow>
</TableHead>
<TableBody>
{safes.map(safe => (
<TableRow key={safe.address}>
<TableCell>
<Link to={`${SAFELIST_ADDRESS}/${safe.address}`}>
<Button variant="contained" size="small" color="primary">Open</Button>
</Link>
</TableCell>
<TableCell padding="none">{safe.get('name')}</TableCell>
<TableCell padding="none">{safe.get('address')}</TableCell>
<TableCell padding="none" align="right">{safe.get('threshold')}</TableCell>
<TableCell padding="none" align="right">{safe.get('owners').count()}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
export default SafeTable

View File

@ -1,21 +0,0 @@
// @flow
import { List } from 'immutable'
import * as React from 'react'
import { connect } from 'react-redux'
import Page from '~/components/layout/Page'
import { type Safe } from '~/routes/safe/store/models/safe'
import Layout from '../components/Layout'
import selector from './selector'
type Props = {
safes: List<Safe>,
provider: string,
}
const SafeList = ({ safes, provider }: Props) => (
<Page>
<Layout safes={safes} provider={provider} />
</Page>
)
export default connect<*, *, *, *>(selector)(SafeList)

View File

@ -1,9 +0,0 @@
// @flow
import { createStructuredSelector } from 'reselect'
import { safesListSelector } from '~/routes/safeList/store/selectors'
import { providerNameSelector } from '~/logic/wallets/store/selectors'
export default createStructuredSelector<Object, *>({
safes: safesListSelector,
provider: providerNameSelector,
})

View File

@ -1,25 +0,0 @@
// @flow
import { List, Map } from 'immutable'
import { createSelector, type Selector } from 'reselect'
import { type GlobalState } from '~/store/index'
import { type Safe } from '~/routes/safe/store/models/safe'
import { SAFE_REDUCER_ID } from '~/routes/safe/store/reducer/safe'
const safesStateSelector = (state: GlobalState): Map<string, *> => state[SAFE_REDUCER_ID]
export const safesMapSelector = (state: GlobalState): Map<string, Safe> => state[SAFE_REDUCER_ID].get('safes')
export const safesListSelector: Selector<GlobalState, {}, List<Safe>> = createSelector(
safesMapSelector,
(safes: Map<string, Safe>): List<Safe> => safes.toList(),
)
export const safesCountSelector: Selector<GlobalState, {}, number> = createSelector(
safesMapSelector,
(safes: Map<string, Safe>): number => safes.size,
)
export const defaultSafeSelector: Selector<GlobalState, {}, string> = createSelector(
safesStateSelector,
(safeState: Map<string, *>): string => safeState.get('defaultSafe'),
)