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
058a6dd7
Commit
058a6dd7
authored
Feb 15, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
account routes and home route
parent
b6626be8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
36 deletions
+29
-36
useNewTxsSocket.tsx
lib/hooks/useNewTxsSocket.tsx
+3
-4
isAccountRoute.ts
lib/link/isAccountRoute.ts
+0
-6
link.test.ts
lib/link/link.test.ts
+2
-2
routes.ts
lib/link/routes.ts
+19
-18
LatestTxs.pw.tsx
ui/home/LatestTxs.pw.tsx
+1
-2
AppError.tsx
ui/shared/AppError/AppError.tsx
+2
-2
NetworkLogo.tsx
ui/snippets/networkMenu/NetworkLogo.tsx
+2
-2
No files found.
lib/hooks/useNewTxsSocket.tsx
View file @
058a6dd7
...
@@ -3,14 +3,13 @@ import { useRouter } from 'next/router';
...
@@ -3,14 +3,13 @@ import { useRouter } from 'next/router';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
useGradualIncrement
from
'
lib/hooks/useGradualIncrement
'
;
import
useGradualIncrement
from
'
lib/hooks/useGradualIncrement
'
;
import
{
ROUTES
}
from
'
lib/link/routes
'
;
import
useSocketChannel
from
'
lib/socket/useSocketChannel
'
;
import
useSocketChannel
from
'
lib/socket/useSocketChannel
'
;
import
useSocketMessage
from
'
lib/socket/useSocketMessage
'
;
import
useSocketMessage
from
'
lib/socket/useSocketMessage
'
;
function
getSocketParams
(
router
:
NextRouter
)
{
function
getSocketParams
(
router
:
NextRouter
)
{
if
(
if
(
router
.
pathname
===
ROUTES
.
txs
.
pattern
&&
router
.
pathname
===
'
/txs
'
&&
(
router
.
query
.
tab
===
'
validated
'
||
router
.
query
.
tab
===
undefined
)
&&
(
router
.
query
.
tab
===
'
validated
'
||
router
.
query
.
tab
===
undefined
)
&&
!
router
.
query
.
block_number
&&
!
router
.
query
.
block_number
&&
!
router
.
query
.
page
!
router
.
query
.
page
...
@@ -18,12 +17,12 @@ function getSocketParams(router: NextRouter) {
...
@@ -18,12 +17,12 @@ function getSocketParams(router: NextRouter) {
return
{
topic
:
'
transactions:new_transaction
'
as
const
,
event
:
'
transaction
'
as
const
};
return
{
topic
:
'
transactions:new_transaction
'
as
const
,
event
:
'
transaction
'
as
const
};
}
}
if
(
router
.
pathname
===
ROUTES
.
network_index
.
pattern
)
{
if
(
router
.
pathname
===
'
/
'
)
{
return
{
topic
:
'
transactions:new_transaction
'
as
const
,
event
:
'
transaction
'
as
const
};
return
{
topic
:
'
transactions:new_transaction
'
as
const
,
event
:
'
transaction
'
as
const
};
}
}
if
(
if
(
router
.
pathname
===
ROUTES
.
txs
.
pattern
&&
router
.
pathname
===
'
/txs
'
&&
router
.
query
.
tab
===
'
pending
'
&&
router
.
query
.
tab
===
'
pending
'
&&
!
router
.
query
.
block_number
&&
!
router
.
query
.
block_number
&&
!
router
.
query
.
page
!
router
.
query
.
page
...
...
lib/link/isAccountRoute.ts
deleted
100644 → 0
View file @
b6626be8
export
const
ACCOUNT_ROUTES
:
Array
<
RouteName
>
=
[
'
watchlist
'
,
'
private_tags
'
,
'
public_tags
'
,
'
api_keys
'
,
'
custom_abi
'
];
import
type
{
RouteName
}
from
'
lib/link/routes
'
;
export
default
function
isAccountRoute
(
route
:
RouteName
)
{
return
ACCOUNT_ROUTES
.
includes
(
route
);
}
lib/link/link.test.ts
View file @
058a6dd7
import
link
from
'
./link
'
;
import
link
from
'
./link
'
;
it
(
'
makes correct link if there are no params in path
'
,
()
=>
{
it
(
'
makes correct link if there are no params in path
'
,
()
=>
{
const
result
=
link
(
'
api_key
s
'
);
const
result
=
link
(
'
stat
s
'
);
expect
(
result
).
toBe
(
'
https://blockscout.com/
account/api_key
'
);
expect
(
result
).
toBe
(
'
https://blockscout.com/
stats
'
);
});
});
it
(
'
makes correct link if there are params in path
'
,
()
=>
{
it
(
'
makes correct link if there are params in path
'
,
()
=>
{
...
...
lib/link/routes.ts
View file @
058a6dd7
...
@@ -11,30 +11,31 @@ export type RouteName = keyof typeof ROUTES;
...
@@ -11,30 +11,31 @@ export type RouteName = keyof typeof ROUTES;
export
const
ROUTES
=
{
export
const
ROUTES
=
{
// NETWORK MAIN PAGE
// NETWORK MAIN PAGE
// todo_tom need full url builder
network_index
:
{
network_index
:
{
pattern
:
PATHS
.
network_index
,
pattern
:
PATHS
.
network_index
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
// ACCOUNT
// ACCOUNT
watchlist
:
{
//
watchlist: {
pattern
:
PATHS
.
watchlist
,
//
pattern: PATHS.watchlist,
},
//
},
private_tags
:
{
//
private_tags: {
pattern
:
PATHS
.
private_tags
,
//
pattern: PATHS.private_tags,
},
//
},
public_tags
:
{
//
public_tags: {
pattern
:
PATHS
.
public_tags
,
//
pattern: PATHS.public_tags,
},
//
},
api_keys
:
{
//
api_keys: {
pattern
:
PATHS
.
api_keys
,
//
pattern: PATHS.api_keys,
},
//
},
custom_abi
:
{
//
custom_abi: {
pattern
:
PATHS
.
custom_abi
,
//
pattern: PATHS.custom_abi,
},
//
},
profile
:
{
//
profile: {
pattern
:
PATHS
.
profile
,
//
pattern: PATHS.profile,
},
//
},
// TRANSACTIONS
// TRANSACTIONS
txs
:
{
txs
:
{
...
...
ui/home/LatestTxs.pw.tsx
View file @
058a6dd7
import
{
test
as
base
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
{
test
as
base
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
ROUTES
}
from
'
lib/link/routes
'
;
import
*
as
statsMock
from
'
mocks/stats/index
'
;
import
*
as
statsMock
from
'
mocks/stats/index
'
;
import
*
as
txMock
from
'
mocks/txs/tx
'
;
import
*
as
txMock
from
'
mocks/txs/tx
'
;
import
*
as
socketServer
from
'
playwright/fixtures/socketServer
'
;
import
*
as
socketServer
from
'
playwright/fixtures/socketServer
'
;
...
@@ -42,7 +41,7 @@ test.describe('socket', () => {
...
@@ -42,7 +41,7 @@ test.describe('socket', () => {
const
hooksConfig
=
{
const
hooksConfig
=
{
router
:
{
router
:
{
pathname
:
ROUTES
.
network_index
.
pattern
,
pathname
:
'
/
'
,
query
:
{},
query
:
{},
},
},
};
};
...
...
ui/shared/AppError/AppError.tsx
View file @
058a6dd7
import
{
Box
,
Button
,
Heading
,
Icon
,
Text
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Button
,
Heading
,
Icon
,
Text
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
icon404
from
'
icons/error-pages/404.svg
'
;
import
icon404
from
'
icons/error-pages/404.svg
'
;
import
icon422
from
'
icons/error-pages/422.svg
'
;
import
icon422
from
'
icons/error-pages/422.svg
'
;
import
icon500
from
'
icons/error-pages/500.svg
'
;
import
icon500
from
'
icons/error-pages/500.svg
'
;
import
link
from
'
lib/link/link
'
;
interface
Props
{
interface
Props
{
statusCode
:
number
;
statusCode
:
number
;
...
@@ -42,7 +42,7 @@ const AppError = ({ statusCode, className }: Props) => {
...
@@ -42,7 +42,7 @@ const AppError = ({ statusCode, className }: Props) => {
size=
"lg"
size=
"lg"
variant=
"outline"
variant=
"outline"
as=
"a"
as=
"a"
href=
{
link
(
'
network_index
'
)
}
href=
{
route
({
pathname
:
'
/
'
}
)
}
>
>
Back to home
Back to home
</
Button
>
</
Button
>
...
...
ui/snippets/networkMenu/NetworkLogo.tsx
View file @
058a6dd7
import
{
Icon
,
Box
,
Image
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Icon
,
Box
,
Image
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
import
smallLogoPlaceholder
from
'
icons/networks/icons/placeholder.svg
'
;
import
smallLogoPlaceholder
from
'
icons/networks/icons/placeholder.svg
'
;
import
logoPlaceholder
from
'
icons/networks/logos/blockscout.svg
'
;
import
logoPlaceholder
from
'
icons/networks/logos/blockscout.svg
'
;
import
link
from
'
lib/link/link
'
;
import
ASSETS
from
'
lib/networks/networkAssets
'
;
import
ASSETS
from
'
lib/networks/networkAssets
'
;
interface
Props
{
interface
Props
{
...
@@ -14,7 +14,7 @@ interface Props {
...
@@ -14,7 +14,7 @@ interface Props {
const
NetworkLogo
=
({
isCollapsed
,
onClick
}:
Props
)
=>
{
const
NetworkLogo
=
({
isCollapsed
,
onClick
}:
Props
)
=>
{
const
logoColor
=
useColorModeValue
(
'
blue.600
'
,
'
white
'
);
const
logoColor
=
useColorModeValue
(
'
blue.600
'
,
'
white
'
);
const
href
=
link
(
'
network_index
'
);
const
href
=
route
({
pathname
:
'
/
'
}
);
const
[
isLogoError
,
setLogoError
]
=
React
.
useState
(
false
);
const
[
isLogoError
,
setLogoError
]
=
React
.
useState
(
false
);
const
[
isSmallLogoError
,
setSmallLogoError
]
=
React
.
useState
(
false
);
const
[
isSmallLogoError
,
setSmallLogoError
]
=
React
.
useState
(
false
);
...
...
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