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
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/SafeListSidebar/SafeList/SafeListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/routes/LoadSafePage/LoadSafePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ describe('<LoadSafePage>', () => {

await waitFor(() => {
expect(historyPushSpy).toHaveBeenCalledWith(
generateSafeRoute(SAFE_ROUTES.ASSETS_BALANCES, {
generateSafeRoute(SAFE_ROUTES.DASHBOARD, {
shortName: getShortName(),
safeAddress: validSafeAddress,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/routes/LoadSafePage/LoadSafePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down
3 changes: 2 additions & 1 deletion src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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.

DiogoSoaress marked this conversation as resolved.
Show resolved Hide resolved

<Route component={Welcome} exact path={WELCOME_ROUTE} />

Expand Down
1 change: 1 addition & 0 deletions src/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down