Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

feat: Add Safe route for dashboard #3759

Merged
merged 5 commits into from
Apr 5, 2022
Merged

Conversation

usame-algan
Copy link
Member

@usame-algan usame-algan commented Apr 5, 2022

What it solves

Part of #3693

How this PR fixes it

Changes the Safe dashboard route from /app/home to /app/<safe address>/home and loads the Dashboard component inside SafeContainer so that it has access to transaction data.

Navigates the user to the Dashboard if:

  1. A safe is selected from the Sidebar
  2. A safe is created
  3. A safe is loaded
  4. A safe is removed and there is an available safe
  5. ROOT is opened if last viewed Safe exists

How to test it

  1. Open the Safe App
  2. Select a Safe from the Sidebar
  3. Observe that the Dashboard is visible
  4. Create a new Safe
  5. Observe being navigated to the Dashboard
  6. Load an existing Safe
  7. Observe being navigated to the Dashboard
  8. Remove a safe while having another safe on the same network
  9. Observe being navigated to the Dashboard
  10. Open / while having a last viewed Safe
  11. Observe being navigated to the Dashboard
  12. Open / while in Inkognito mode
  13. Observe being navigated to Welcome page

@github-actions
Copy link

github-actions bot commented Apr 5, 2022

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Apr 5, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you done a global search for ASSETS_BALANCES? I think there could be a few other places where we open to the balances page.

@@ -88,7 +89,7 @@ const Routes = (): React.ReactElement => {
}}
/>

<Route component={Home} exact path={HOME_ROUTE} />
<Route component={Home} exact path={[HOME_ROUTE, SAFE_ROUTES.DASHBOARD]} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component will need to know whether it's on an 'addressed route'.

Do you think we should send a flag here or determine it within the component? Within the component we could just check for the existence of the param in the URL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the URL sounds like a good idea! We will need it for some of the render logic i.e. to display the Add Safe/Load Safe Widget. I suggest we do that in a future PR once we have some of the Widgets ready.

@usame-algan
Copy link
Member Author

Have you done a global search for ASSETS_BALANCES? I think there could be a few other places where we open to the balances page.

Good question! Currently, we navigate the user to the Balances view when a Safe is added, loaded or when they delete a safe (and are navigated to the next available safe). In those cases, we could also navigate to the Dashboard instead. What do you think?

@github-actions
Copy link

github-actions bot commented Apr 5, 2022

Deployment links

🟠 Rinkeby Mainnet 🟣 Polygon 🟡 BSC Arbitrum 🟢 Gnosis Chain

@iamacook
Copy link
Member

iamacook commented Apr 5, 2022

Good question! Currently, we navigate the user to the Balances view when a Safe is added, loaded or when they delete a safe (and are navigated to the next available safe). In those cases, we could also navigate to the Dashboard instead. What do you think?

I think the dashboard is the entry page for the Safe. We could later let the user to define this themselves.

@usame-algan
Copy link
Member Author

I think the dashboard is the entry page for the Safe. We could later let the user to define this themselves.

Agreed, I updated the places where the user was navigated to the Balances view to go to the Dashboard instead.

Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Copy link
Member

@DiogoSoaress DiogoSoaress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can still navigate to /app/home without being redirected to the SAFE_ROUTES.DASHBOARD

src/routes/index.tsx Outdated Show resolved Hide resolved
@usame-algan usame-algan changed the title feat: Add safe specific dashboard route feat: Add Safe route for dashboard Apr 5, 2022
Copy link
Member

@DiogoSoaress DiogoSoaress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -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'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Picky, but please remove React.. You've imported it purely for this lazy load.

@@ -87,6 +88,7 @@ const Container = (): React.ReactElement => {
return (
<>
<Switch>
<Route exact path={SAFE_ROUTES.DASHBOARD} render={() => wrapInSuspense(<Home />, null)} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapInSuspense has a default fallback of null already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Will remove it from the others as well.

@usame-algan usame-algan requested a review from iamacook April 5, 2022 13:38
@@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to import React.

@usame-algan usame-algan merged commit ece833b into epic-dashboard Apr 5, 2022
@usame-algan usame-algan deleted the dashboard-routes branch April 5, 2022 13:55
@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants