Commit 4dfdc965 authored by tom's avatar tom

keep account pathname when switching between networks

parent 457e1f21
...@@ -92,3 +92,9 @@ export const NETWORKS: Array<Network> = [ ...@@ -92,3 +92,9 @@ export const NETWORKS: Array<Network> = [
group: 'other', group: 'other',
}, },
]; ];
export const ACCOUNT_ROUTES = [ '/watchlist', 'private-tags', 'public-tags', 'api-keys', 'custom-abi' ];
export function isAccountRoute(route: string) {
return ACCOUNT_ROUTES.includes(route);
}
...@@ -6,6 +6,7 @@ import type { Network } from 'types/networks'; ...@@ -6,6 +6,7 @@ import type { Network } from 'types/networks';
import checkIcon from 'icons/check.svg'; import checkIcon from 'icons/check.svg';
import placeholderIcon from 'icons/networks/placeholder.svg'; import placeholderIcon from 'icons/networks/placeholder.svg';
import { isAccountRoute } from 'lib/networks';
import useColors from './useColors'; import useColors from './useColors';
...@@ -14,12 +15,24 @@ interface Props extends Network { ...@@ -14,12 +15,24 @@ interface Props extends Network {
routeName: string; routeName: string;
} }
const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName }: Props) => { const NetworkMenuLink = ({ name, type, subType, icon, isActive, routeName, isAccountSupported, isNewUiSupported }: Props) => {
const pathName = `/${ type }/${ subType }` + (routeName || ''); const isAccount = isAccountRoute(routeName);
const localPath = (() => {
if (isAccount && isAccountSupported) {
return routeName;
}
if (isAccount && !isAccountSupported) {
return '';
}
// will change when blocks&transaction is implemented
return routeName;
})();
const pathName = `/${ type }/${ subType }${ localPath }`;
// will fix later after we agree on CI/CD workflow // will fix later after we agree on CI/CD workflow
// const href = isNewUi ? pathname : 'https://blockscout.com' + pathname; const href = isNewUiSupported ? pathName : 'https://blockscout.com' + pathName;
const href = pathName;
const hasIcon = Boolean(icon); const hasIcon = Boolean(icon);
const colors = useColors({ hasIcon }); const colors = useColors({ hasIcon });
......
...@@ -4,7 +4,7 @@ import React from 'react'; ...@@ -4,7 +4,7 @@ import React from 'react';
import type { NetworkGroup } from 'types/networks'; import type { NetworkGroup } from 'types/networks';
import { NETWORKS } from 'data/networks'; import { NETWORKS } from 'lib/networks';
import NetworkMenuLink from './NetworkMenuLink'; import NetworkMenuLink from './NetworkMenuLink';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment