Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
4dfdc965
Commit
4dfdc965
authored
Aug 17, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep account pathname when switching between networks
parent
457e1f21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
networks.ts
lib/networks.ts
+6
-0
NetworkMenuLink.tsx
ui/navigation/networkMenu/NetworkMenuLink.tsx
+17
-4
NetworkMenuPopup.tsx
ui/navigation/networkMenu/NetworkMenuPopup.tsx
+1
-1
No files found.
data
/networks.ts
→
lib
/networks.ts
View file @
4dfdc965
...
@@ -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
);
}
ui/navigation/networkMenu/NetworkMenuLink.tsx
View file @
4dfdc965
...
@@ -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
});
...
...
ui/navigation/networkMenu/NetworkMenuPopup.tsx
View file @
4dfdc965
...
@@ -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
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment