From 9f980f1c07639dfe5e08766c0759092b50e6c491 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Tue, 5 Apr 2022 11:43:31 +0200 Subject: [PATCH 1/5] feat: Add safe specific dashboard route --- src/components/SafeListSidebar/SafeList/SafeListItem.tsx | 2 +- src/routes/index.tsx | 3 ++- src/routes/routes.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/SafeListSidebar/SafeList/SafeListItem.tsx b/src/components/SafeListSidebar/SafeList/SafeListItem.tsx index 10e043165e..f823c3f705 100644 --- a/src/components/SafeListSidebar/SafeList/SafeListItem.tsx +++ b/src/components/SafeListSidebar/SafeList/SafeListItem.tsx @@ -97,7 +97,7 @@ const SafeListItem = ({ const handleOpenSafe = (): void => { onSafeClick() onNetworkSwitch?.() - history.push(generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, routesSlug)) + history.push(generateSafeRoute(SAFE_ROUTES.DASHBOARD, routesSlug)) } const handleLoadSafe = (): void => { diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 13a232d2b0..5cd2d471d8 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -15,6 +15,7 @@ import { getNetworkRootRoutes, extractSafeAddress, HOME_ROUTE, + SAFE_ROUTES, } from './routes' import { setChainId } from 'src/logic/config/utils' import { setChainIdFromUrl } from 'src/utils/history' @@ -88,7 +89,7 @@ const Routes = (): React.ReactElement => { }} /> - + diff --git a/src/routes/routes.ts b/src/routes/routes.ts index b04a1d20da..18c8f328cc 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -48,6 +48,7 @@ export const LOAD_SAFE_ROUTE = generatePath(LOAD_SPECIFIC_SAFE_ROUTE) // By prov // [SAFE_SECTION_SLUG], [SAFE_SUBSECTION_SLUG] populated safe routes export const SAFE_ROUTES = { + DASHBOARD: `${ADDRESSED_ROUTE}/home`, ASSETS_BALANCES: `${ADDRESSED_ROUTE}/balances`, // [SAFE_SECTION_SLUG] === 'balances' ASSETS_BALANCES_COLLECTIBLES: `${ADDRESSED_ROUTE}/balances/collectibles`, // [SAFE_SUBSECTION_SLUG] === 'collectibles' TRANSACTIONS: `${ADDRESSED_ROUTE}/transactions`, From cf56450ebe0ac3b2ccf217f51879af19f8c0c1c6 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Tue, 5 Apr 2022 12:23:06 +0200 Subject: [PATCH 2/5] fix: Redirect user to Dashboard when adding/loading/removing a safe --- src/routes/CreateSafePage/components/SafeCreationProcess.tsx | 2 +- src/routes/LoadSafePage/LoadSafePage.test.tsx | 2 +- src/routes/LoadSafePage/LoadSafePage.tsx | 2 +- src/routes/safe/components/Settings/RemoveSafeModal/index.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/CreateSafePage/components/SafeCreationProcess.tsx b/src/routes/CreateSafePage/components/SafeCreationProcess.tsx index 20fb49612a..f975e2f5ec 100644 --- a/src/routes/CreateSafePage/components/SafeCreationProcess.tsx +++ b/src/routes/CreateSafePage/components/SafeCreationProcess.tsx @@ -274,7 +274,7 @@ function SafeCreationProcess(): ReactElement { const { safeName, safeCreationTxHash, safeAddress } = modalData history.push({ - pathname: generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, { + pathname: generateSafeRoute(SAFE_ROUTES.DASHBOARD, { shortName: getShortName(), safeAddress, }), diff --git a/src/routes/LoadSafePage/LoadSafePage.test.tsx b/src/routes/LoadSafePage/LoadSafePage.test.tsx index 70a84cc9db..3c071f8c07 100644 --- a/src/routes/LoadSafePage/LoadSafePage.test.tsx +++ b/src/routes/LoadSafePage/LoadSafePage.test.tsx @@ -614,7 +614,7 @@ describe('', () => { await waitFor(() => { expect(historyPushSpy).toHaveBeenCalledWith( - generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, { + generateSafeRoute(SAFE_ROUTES.DASHBOARD, { shortName: getShortName(), safeAddress: validSafeAddress, }), diff --git a/src/routes/LoadSafePage/LoadSafePage.tsx b/src/routes/LoadSafePage/LoadSafePage.tsx index 588895dc7f..f4fa7bf780 100644 --- a/src/routes/LoadSafePage/LoadSafePage.tsx +++ b/src/routes/LoadSafePage/LoadSafePage.tsx @@ -120,7 +120,7 @@ function Load(): ReactElement { // Go to the newly added Safe history.push( - generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, { + generateSafeRoute(SAFE_ROUTES.DASHBOARD, { shortName: getShortName(), safeAddress: checksummedAddress, }), diff --git a/src/routes/safe/components/Settings/RemoveSafeModal/index.tsx b/src/routes/safe/components/Settings/RemoveSafeModal/index.tsx index dc4cf56090..c79b470e81 100644 --- a/src/routes/safe/components/Settings/RemoveSafeModal/index.tsx +++ b/src/routes/safe/components/Settings/RemoveSafeModal/index.tsx @@ -43,7 +43,7 @@ function getDestinationRoute(nextAvailableSafe: SafeRecordProps | undefined) { shortName, safeAddress: nextAvailableSafe.address, } - return generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, routesSlug) + return generateSafeRoute(SAFE_ROUTES.DASHBOARD, routesSlug) } const RemoveSafeModal = ({ isOpen, onClose }: RemoveSafeModalProps): React.ReactElement => { From c71a125cb26816463e3fe6d9a40000b41a99933b Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Tue, 5 Apr 2022 15:15:19 +0200 Subject: [PATCH 3/5] fix: Remove old dashboard route --- src/routes/index.tsx | 14 +++++++++++--- src/routes/routes.ts | 1 - 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 5cd2d471d8..026d2b60ce 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -14,12 +14,13 @@ import { LOAD_SAFE_ROUTE, getNetworkRootRoutes, extractSafeAddress, - HOME_ROUTE, SAFE_ROUTES, + generateSafeRoute, } from './routes' import { setChainId } from 'src/logic/config/utils' import { setChainIdFromUrl } from 'src/utils/history' import { usePageTracking } from 'src/utils/googleTagManager' +import { getShortName } from 'src/config' const Home = React.lazy(() => import('./Home')) const Welcome = React.lazy(() => import('./welcome/Welcome')) @@ -82,14 +83,21 @@ const Routes = (): React.ReactElement => { } if (defaultSafe) { - return + return ( + + ) } return }} /> - + diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 18c8f328cc..33374e5fd8 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -41,7 +41,6 @@ export const LOAD_SPECIFIC_SAFE_ROUTE = `/load/:${SAFE_ADDRESS_SLUG}?` // ? = op // Routes independant of safe/network export const ROOT_ROUTE = '/' -export const HOME_ROUTE = '/home' export const WELCOME_ROUTE = '/welcome' export const OPEN_SAFE_ROUTE = '/open' export const LOAD_SAFE_ROUTE = generatePath(LOAD_SPECIFIC_SAFE_ROUTE) // By providing no slug, we get '/load' From 04851d6c71fd112d50711ce757f2c4817e3d420b Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Tue, 5 Apr 2022 15:22:33 +0200 Subject: [PATCH 4/5] fix: Move Dashboard component inside SafeContainer to access transactions --- src/routes/index.tsx | 3 --- src/routes/safe/container/index.tsx | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 026d2b60ce..f3969ca34d 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -22,7 +22,6 @@ import { setChainIdFromUrl } from 'src/utils/history' import { usePageTracking } from 'src/utils/googleTagManager' import { getShortName } from 'src/config' -const Home = React.lazy(() => import('./Home')) const Welcome = React.lazy(() => import('./welcome/Welcome')) const CreateSafePage = React.lazy(() => import('./CreateSafePage/CreateSafePage')) const LoadSafePage = React.lazy(() => import('./LoadSafePage/LoadSafePage')) @@ -97,8 +96,6 @@ const Routes = (): React.ReactElement => { }} /> - - diff --git a/src/routes/safe/container/index.tsx b/src/routes/safe/container/index.tsx index 2b23768343..2529e3ed41 100644 --- a/src/routes/safe/container/index.tsx +++ b/src/routes/safe/container/index.tsx @@ -1,5 +1,5 @@ import { GenericModal, Loader } from '@gnosis.pm/safe-react-components' -import { useState, lazy, useEffect } from 'react' +import React, { useState, lazy, useEffect } from 'react' import { useSelector } from 'react-redux' import { Redirect, Route, Switch } from 'react-router-dom' @@ -21,6 +21,7 @@ export const ADDRESS_BOOK_TAB_BTN_TEST_ID = 'address-book-tab-btn' export const SAFE_VIEW_NAME_HEADING_TEST_ID = 'safe-name-heading' export const TRANSACTIONS_TAB_NEW_BTN_TEST_ID = 'transactions-tab-new-btn' +const Home = React.lazy(() => import('src/routes/Home')) const Apps = lazy(() => import('src/routes/safe/components/Apps')) const Settings = lazy(() => import('src/routes/safe/components/Settings')) const Balances = lazy(() => import('src/routes/safe/components/Balances')) @@ -87,6 +88,7 @@ const Container = (): React.ReactElement => { return ( <> + wrapInSuspense(, null)} /> Date: Tue, 5 Apr 2022 15:38:24 +0200 Subject: [PATCH 5/5] fix: Remove null fallback for wrapInSuspense, remove unnecessary React reference --- src/routes/safe/container/index.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/routes/safe/container/index.tsx b/src/routes/safe/container/index.tsx index 2529e3ed41..849d89d347 100644 --- a/src/routes/safe/container/index.tsx +++ b/src/routes/safe/container/index.tsx @@ -1,5 +1,5 @@ import { GenericModal, Loader } from '@gnosis.pm/safe-react-components' -import React, { useState, lazy, useEffect } from 'react' +import { useState, lazy, useEffect } from 'react' import { useSelector } from 'react-redux' import { Redirect, Route, Switch } from 'react-router-dom' @@ -21,7 +21,7 @@ export const ADDRESS_BOOK_TAB_BTN_TEST_ID = 'address-book-tab-btn' export const SAFE_VIEW_NAME_HEADING_TEST_ID = 'safe-name-heading' export const TRANSACTIONS_TAB_NEW_BTN_TEST_ID = 'transactions-tab-new-btn' -const Home = React.lazy(() => import('src/routes/Home')) +const Home = lazy(() => import('src/routes/Home')) const Apps = lazy(() => import('src/routes/safe/components/Apps')) const Settings = lazy(() => import('src/routes/safe/components/Settings')) const Balances = lazy(() => import('src/routes/safe/components/Balances')) @@ -88,11 +88,11 @@ const Container = (): React.ReactElement => { return ( <> - wrapInSuspense(, null)} /> + wrapInSuspense()} /> wrapInSuspense(, null)} + render={() => wrapInSuspense()} /> { SAFE_ROUTES.TRANSACTIONS_QUEUE, SAFE_ROUTES.TRANSACTIONS_SINGULAR, ]} - render={() => wrapInSuspense(, null)} + render={() => wrapInSuspense()} /> - wrapInSuspense(, null)} /> + wrapInSuspense()} /> { if (!featuresEnabled.includes(FEATURES.SAFE_APPS)) { history.push(generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, extractPrefixedSafeAddress())) } - return wrapInSuspense(, null) + return wrapInSuspense() }} /> - wrapInSuspense(, null)} /> + wrapInSuspense()} /> {modal.isOpen && }