From db9788b4cc2dab3a1aba3ccff5619b84f5b54366 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Thu, 19 Sep 2019 16:34:20 +0400 Subject: [PATCH] remove SafeList route because the list moved to sidebar --- .../Header/component/SafeListHeader/index.jsx | 2 +- src/components/Sidebar/index.jsx | 2 +- src/routes/index.js | 6 +-- src/routes/safe/store/actions/addSafe.js | 2 +- .../safe/store/middleware/safeStorage.js | 2 +- src/routes/safe/store/selectors/index.js | 22 +++++++++- src/routes/safeList/components/Layout.jsx | 25 ----------- .../safeList/components/Layout.stories.js | 13 ------ src/routes/safeList/components/SafeTable.jsx | 44 ------------------- src/routes/safeList/container/index.jsx | 21 --------- src/routes/safeList/container/selector.js | 9 ---- src/routes/safeList/store/selectors/index.js | 25 ----------- 12 files changed, 26 insertions(+), 147 deletions(-) delete mode 100644 src/routes/safeList/components/Layout.jsx delete mode 100644 src/routes/safeList/components/Layout.stories.js delete mode 100644 src/routes/safeList/components/SafeTable.jsx delete mode 100644 src/routes/safeList/container/index.jsx delete mode 100644 src/routes/safeList/container/selector.js delete mode 100644 src/routes/safeList/store/selectors/index.js diff --git a/src/components/Header/component/SafeListHeader/index.jsx b/src/components/Header/component/SafeListHeader/index.jsx index c7df187b..18abbb86 100644 --- a/src/components/Header/component/SafeListHeader/index.jsx +++ b/src/components/Header/component/SafeListHeader/index.jsx @@ -10,7 +10,7 @@ import Col from '~/components/layout/Col' import { xs, sm, md, border, } from '~/theme/variables' -import { safesCountSelector } from '~/routes/safeList/store/selectors' +import { safesCountSelector } from '~/routes/safe/store/selectors' import { SidebarContext } from '~/components/Sidebar' const useStyles = makeStyles({ diff --git a/src/components/Sidebar/index.jsx b/src/components/Sidebar/index.jsx index 61d617ce..2f90d538 100644 --- a/src/components/Sidebar/index.jsx +++ b/src/components/Sidebar/index.jsx @@ -13,7 +13,7 @@ import Spacer from '~/components/Spacer' import Hairline from '~/components/layout/Hairline' import Row from '~/components/layout/Row' 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 useSidebarStyles from './style' import SafeList from './SafeList' diff --git a/src/routes/index.js b/src/routes/index.js index 57ec5ea3..c238ef8f 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -4,7 +4,7 @@ import { connect } from 'react-redux' import { Switch, Redirect, Route, withRouter, } from 'react-router-dom' -import { defaultSafeSelector } from '~/routes/safeList/store/selectors' +import { defaultSafeSelector } from '~/routes/safe/store/selectors' import Loader from '~/components/Loader' import Welcome from './welcome/container' import { @@ -18,8 +18,6 @@ import { const Safe = React.lazy(() => import('./safe/container')) -const SafeList = React.lazy(() => import('./safeList/container')) - const Open = React.lazy(() => import('./open/container/Open')) const Opening = React.lazy(() => import('./opening/container')) @@ -66,10 +64,10 @@ const Routes = ({ defaultSafe, location }: RoutesProps) => { /> - + ) } diff --git a/src/routes/safe/store/actions/addSafe.js b/src/routes/safe/store/actions/addSafe.js index 735b4f3f..5a6bbf1b 100644 --- a/src/routes/safe/store/actions/addSafe.js +++ b/src/routes/safe/store/actions/addSafe.js @@ -3,7 +3,7 @@ import { List } from 'immutable' import { createAction } from 'redux-actions' import type { Dispatch as ReduxDispatch, GetState } from 'redux' 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 { makeOwner } from '~/routes/safe/store/models/owner' import setDefaultSafe from '~/routes/safe/store/actions/setDefaultSafe' diff --git a/src/routes/safe/store/middleware/safeStorage.js b/src/routes/safe/store/middleware/safeStorage.js index 853d50fb..de7cb3dd 100644 --- a/src/routes/safe/store/middleware/safeStorage.js +++ b/src/routes/safe/store/middleware/safeStorage.js @@ -12,7 +12,7 @@ import { type GlobalState } from '~/store/' import { saveSafes, setOwners, removeOwners, saveDefaultSafe, } 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 { tokensSelector } from '~/logic/tokens/store/selectors' import type { Token } from '~/logic/tokens/store/model/token' diff --git a/src/routes/safe/store/selectors/index.js b/src/routes/safe/store/selectors/index.js index f194061c..46574d4b 100644 --- a/src/routes/safe/store/selectors/index.js +++ b/src/routes/safe/store/selectors/index.js @@ -5,11 +5,10 @@ import { createSelector, createStructuredSelector, type Selector } from 'reselec import { type GlobalState } from '~/store/index' import { SAFE_PARAM_ADDRESS } from '~/routes/routes' 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 Transaction } from '~/routes/safe/store/models/transaction' 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 = { match: Match, @@ -23,6 +22,25 @@ type TransactionProps = { transaction: Transaction, } +const safesStateSelector = (state: GlobalState): Map => state[SAFE_REDUCER_ID] + +export const safesMapSelector = (state: GlobalState): Map => state[SAFE_REDUCER_ID].get('safes') + +export const safesListSelector: Selector> = createSelector( + safesMapSelector, + (safes: Map): List => safes.toList(), +) + +export const safesCountSelector: Selector = createSelector( + safesMapSelector, + (safes: Map): number => safes.size, +) + +export const defaultSafeSelector: Selector = createSelector( + safesStateSelector, + (safeState: Map): string => safeState.get('defaultSafe'), +) + const transactionsSelector = (state: GlobalState): TransactionsState => state[TRANSACTIONS_REDUCER_ID] const oneTransactionSelector = (state: GlobalState, props: TransactionProps) => props.transaction diff --git a/src/routes/safeList/components/Layout.jsx b/src/routes/safeList/components/Layout.jsx deleted file mode 100644 index a7dde521..00000000 --- a/src/routes/safeList/components/Layout.jsx +++ /dev/null @@ -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, - provider: string, -} - -const SafeList = ({ safes, provider }: Props) => { - const safesAvailable = safes && safes.count() > 0 - - return ( - <> - { safesAvailable - ? - : } - - ) -} - -export default SafeList diff --git a/src/routes/safeList/components/Layout.stories.js b/src/routes/safeList/components/Layout.stories.js deleted file mode 100644 index 391b8de6..00000000 --- a/src/routes/safeList/components/Layout.stories.js +++ /dev/null @@ -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) =>
{story()}
- -storiesOf('Routes /safes', module) - .addDecorator(FrameDecorator) - .add('Safe List whithout safes and connected', () => ) - .add('Safe List whithout safes and NOT connected', () => ) diff --git a/src/routes/safeList/components/SafeTable.jsx b/src/routes/safeList/components/SafeTable.jsx deleted file mode 100644 index 78dc14d2..00000000 --- a/src/routes/safeList/components/SafeTable.jsx +++ /dev/null @@ -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 -} -const SafeTable = ({ safes }: Props) => ( - - - - Open - Name - Deployed Address - Confirmations - Number of owners - - - - {safes.map(safe => ( - - - - - - - {safe.get('name')} - {safe.get('address')} - {safe.get('threshold')} - {safe.get('owners').count()} - - ))} - -
-) - -export default SafeTable diff --git a/src/routes/safeList/container/index.jsx b/src/routes/safeList/container/index.jsx deleted file mode 100644 index 6eaf1bb7..00000000 --- a/src/routes/safeList/container/index.jsx +++ /dev/null @@ -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, - provider: string, -} - -const SafeList = ({ safes, provider }: Props) => ( - - - -) - -export default connect<*, *, *, *>(selector)(SafeList) diff --git a/src/routes/safeList/container/selector.js b/src/routes/safeList/container/selector.js deleted file mode 100644 index 9a301e0e..00000000 --- a/src/routes/safeList/container/selector.js +++ /dev/null @@ -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({ - safes: safesListSelector, - provider: providerNameSelector, -}) diff --git a/src/routes/safeList/store/selectors/index.js b/src/routes/safeList/store/selectors/index.js deleted file mode 100644 index f37f0afa..00000000 --- a/src/routes/safeList/store/selectors/index.js +++ /dev/null @@ -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 => state[SAFE_REDUCER_ID] - -export const safesMapSelector = (state: GlobalState): Map => state[SAFE_REDUCER_ID].get('safes') - -export const safesListSelector: Selector> = createSelector( - safesMapSelector, - (safes: Map): List => safes.toList(), -) - -export const safesCountSelector: Selector = createSelector( - safesMapSelector, - (safes: Map): number => safes.size, -) - -export const defaultSafeSelector: Selector = createSelector( - safesStateSelector, - (safeState: Map): string => safeState.get('defaultSafe'), -)