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
b06bc511
Unverified
Commit
b06bc511
authored
Jul 17, 2023
by
Igor Stuev
Committed by
GitHub
Jul 17, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1021 from blockscout/ind-status
int txs indexing status
parents
9d6a512c
d2dcb7a5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
137 additions
and
41 deletions
+137
-41
IndexingAlertBlocks.tsx
ui/home/IndexingAlertBlocks.tsx
+6
-37
IndexingAlertIntTxs.tsx
ui/home/IndexingAlertIntTxs.tsx
+102
-0
PageContent.tsx
ui/shared/Page/PageContent.tsx
+2
-2
Footer.pw.tsx
ui/snippets/footer/Footer.pw.tsx
+23
-0
Footer.tsx
ui/snippets/footer/Footer.tsx
+2
-0
Footer.pw.tsx_dark-color-mode_without-custom-links-with-indexing-alert-dark-mode-mobile-1.png
...t-custom-links-with-indexing-alert-dark-mode-mobile-1.png
+0
-0
Footer.pw.tsx_default_without-custom-links-with-indexing-alert-dark-mode-mobile-1.png
...t-custom-links-with-indexing-alert-dark-mode-mobile-1.png
+0
-0
Footer.pw.tsx_mobile_without-custom-links-with-indexing-alert-dark-mode-mobile-1.png
...t-custom-links-with-indexing-alert-dark-mode-mobile-1.png
+0
-0
Header.tsx
ui/snippets/header/Header.tsx
+2
-2
No files found.
ui/home/IndexingAlert.tsx
→
ui/home/IndexingAlert
Blocks
.tsx
View file @
b06bc511
...
@@ -13,7 +13,7 @@ import { nbsp, ndash } from 'lib/html-entities';
...
@@ -13,7 +13,7 @@ import { nbsp, ndash } from 'lib/html-entities';
import
useSocketChannel
from
'
lib/socket/useSocketChannel
'
;
import
useSocketChannel
from
'
lib/socket/useSocketChannel
'
;
import
useSocketMessage
from
'
lib/socket/useSocketMessage
'
;
import
useSocketMessage
from
'
lib/socket/useSocketMessage
'
;
const
IndexingAlert
=
({
className
}:
{
className
?:
string
})
=>
{
const
IndexingAlert
Blocks
=
({
className
}:
{
className
?:
string
})
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
appProps
=
useAppContext
();
const
appProps
=
useAppContext
();
...
@@ -24,7 +24,7 @@ const IndexingAlert = ({ className }: { className?: string }) => {
...
@@ -24,7 +24,7 @@ const IndexingAlert = ({ className }: { className?: string }) => {
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
!
isLoading
&&
!
isError
)
{
if
(
!
isLoading
&&
!
isError
)
{
cookies
.
set
(
cookies
.
NAMES
.
INDEXING_ALERT
,
data
.
finished_indexing
&&
data
.
finished_indexing
_blocks
?
'
false
'
:
'
true
'
);
cookies
.
set
(
cookies
.
NAMES
.
INDEXING_ALERT
,
data
.
finished_indexing_blocks
?
'
false
'
:
'
true
'
);
}
}
},
[
data
,
isError
,
isLoading
]);
},
[
data
,
isError
,
isLoading
]);
...
@@ -52,28 +52,6 @@ const IndexingAlert = ({ className }: { className?: string }) => {
...
@@ -52,28 +52,6 @@ const IndexingAlert = ({ className }: { className?: string }) => {
handler
:
handleBlocksIndexStatus
,
handler
:
handleBlocksIndexStatus
,
});
});
const
handleInternalTxsIndexStatus
:
SocketMessage
.
InternalTxsIndexStatus
[
'
handler
'
]
=
React
.
useCallback
((
payload
)
=>
{
queryClient
.
setQueryData
(
getResourceKey
(
'
homepage_indexing_status
'
),
(
prevData
:
IndexingStatus
|
undefined
)
=>
{
const
newData
=
prevData
?
{
...
prevData
}
:
{}
as
IndexingStatus
;
newData
.
finished_indexing
=
payload
.
finished
;
newData
.
indexed_internal_transactions_ratio
=
payload
.
ratio
;
return
newData
;
});
},
[
queryClient
]);
const
internalTxsIndexingChannel
=
useSocketChannel
({
topic
:
'
blocks:indexing_internal_transactions
'
,
isDisabled
:
!
data
||
data
.
finished_indexing
,
});
useSocketMessage
({
channel
:
internalTxsIndexingChannel
,
event
:
'
internal_txs_index_status
'
,
handler
:
handleInternalTxsIndexStatus
,
});
if
(
isError
)
{
if
(
isError
)
{
return
null
;
return
null
;
}
}
...
@@ -82,17 +60,7 @@ const IndexingAlert = ({ className }: { className?: string }) => {
...
@@ -82,17 +60,7 @@ const IndexingAlert = ({ className }: { className?: string }) => {
return
hasAlertCookie
?
<
Skeleton
h=
{
{
base
:
'
96px
'
,
lg
:
'
48px
'
}
}
mb=
{
6
}
w=
"100%"
className=
{
className
}
/>
:
null
;
return
hasAlertCookie
?
<
Skeleton
h=
{
{
base
:
'
96px
'
,
lg
:
'
48px
'
}
}
mb=
{
6
}
w=
"100%"
className=
{
className
}
/>
:
null
;
}
}
let
content
;
if
(
data
.
finished_indexing_blocks
!==
false
)
{
if
(
data
.
finished_indexing_blocks
===
false
)
{
content
=
`
${
data
.
indexed_blocks_ratio
&&
`
${
Math
.
floor
(
Number
(
data
.
indexed_blocks_ratio
)
*
100
)
}
% Blocks Indexed
${
nbsp
}${
ndash
}
`
}
We're indexing this chain right now. Some of the counts may be inaccurate.`
;
}
else
if
(
data
.
finished_indexing
===
false
)
{
content
=
`
${
data
.
indexed_internal_transactions_ratio
&&
`
${
Math
.
floor
(
Number
(
data
.
indexed_internal_transactions_ratio
)
*
100
)
}
% Blocks With Internal Transactions Indexed
${
nbsp
}${
ndash
}
`
}
We're indexing this chain right now. Some of the counts may be inaccurate.`
;
}
if
(
!
content
)
{
return
null
;
return
null
;
}
}
...
@@ -100,10 +68,11 @@ const IndexingAlert = ({ className }: { className?: string }) => {
...
@@ -100,10 +68,11 @@ const IndexingAlert = ({ className }: { className?: string }) => {
<
Alert
status=
"info"
colorScheme=
"gray"
py=
{
3
}
borderRadius=
"12px"
mb=
{
6
}
className=
{
className
}
>
<
Alert
status=
"info"
colorScheme=
"gray"
py=
{
3
}
borderRadius=
"12px"
mb=
{
6
}
className=
{
className
}
>
{
!
isMobile
&&
<
AlertIcon
/>
}
{
!
isMobile
&&
<
AlertIcon
/>
}
<
AlertTitle
>
<
AlertTitle
>
{
content
}
{
`${ data.indexed_blocks_ratio && `
$
{
Math
.
floor
(
Number
(
data
.
indexed_blocks_ratio
)
*
100
)
}
%
Blocks
Indexed$
{
nbsp
}
$
{
ndash
}
` }
We're indexing this chain right now. Some of the counts may be inaccurate.`
}
</
AlertTitle
>
</
AlertTitle
>
</
Alert
>
</
Alert
>
);
);
};
};
export
default
chakra
(
IndexingAlert
);
export
default
chakra
(
IndexingAlert
Blocks
);
ui/home/IndexingAlertIntTxs.tsx
0 → 100644
View file @
b06bc511
import
{
IconButton
,
Icon
,
Popover
,
PopoverTrigger
,
PopoverContent
,
PopoverBody
,
Flex
,
Text
,
useColorModeValue
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
SocketMessage
}
from
'
lib/socket/types
'
;
import
type
{
IndexingStatus
}
from
'
types/api/indexingStatus
'
;
import
infoIcon
from
'
icons/info.svg
'
;
import
useApiQuery
,
{
getResourceKey
}
from
'
lib/api/useApiQuery
'
;
import
{
apos
,
nbsp
,
ndash
}
from
'
lib/html-entities
'
;
import
useSocketChannel
from
'
lib/socket/useSocketChannel
'
;
import
useSocketMessage
from
'
lib/socket/useSocketMessage
'
;
const
IndexingAlertIntTxs
=
({
className
}:
{
className
?:
string
})
=>
{
const
{
data
,
isError
,
isLoading
}
=
useApiQuery
(
'
homepage_indexing_status
'
);
const
bgColor
=
useColorModeValue
(
'
blackAlpha.100
'
,
'
whiteAlpha.100
'
);
const
hintTextcolor
=
useColorModeValue
(
'
black
'
,
'
white
'
);
const
queryClient
=
useQueryClient
();
const
handleInternalTxsIndexStatus
:
SocketMessage
.
InternalTxsIndexStatus
[
'
handler
'
]
=
React
.
useCallback
((
payload
)
=>
{
queryClient
.
setQueryData
(
getResourceKey
(
'
homepage_indexing_status
'
),
(
prevData
:
IndexingStatus
|
undefined
)
=>
{
const
newData
=
prevData
?
{
...
prevData
}
:
{}
as
IndexingStatus
;
newData
.
finished_indexing
=
payload
.
finished
;
newData
.
indexed_internal_transactions_ratio
=
payload
.
ratio
;
return
newData
;
});
},
[
queryClient
]);
const
internalTxsIndexingChannel
=
useSocketChannel
({
topic
:
'
blocks:indexing_internal_transactions
'
,
isDisabled
:
!
data
||
data
.
finished_indexing
,
});
useSocketMessage
({
channel
:
internalTxsIndexingChannel
,
event
:
'
internal_txs_index_status
'
,
handler
:
handleInternalTxsIndexStatus
,
});
if
(
isError
||
isLoading
)
{
return
null
;
}
if
(
data
.
finished_indexing
!==
false
)
{
return
null
;
}
const
hint
=
(
<
Text
fontSize=
"xs"
color=
{
hintTextcolor
}
>
{
data
.
indexed_internal_transactions_ratio
&&
`${ Math.floor(Number(data.indexed_internal_transactions_ratio) * 100) }% Blocks With Internal Transactions Indexed${ nbsp }${ ndash } `
}
We
{
apos
}
re indexing this chain right now. Some of the counts may be inaccurate.`
</
Text
>
);
const
trigger
=
(
<
Flex
px=
{
2
}
py=
{
1
}
bg=
{
bgColor
}
borderRadius=
"base"
alignItems=
"center"
justifyContent=
"center"
className=
{
className
}
color=
"green.400"
_hover=
{
{
color
:
'
blue.400
'
}
}
>
<
IconButton
colorScheme=
"none"
aria
-
label=
"hint"
icon=
{
<
Icon
as=
{
infoIcon
}
boxSize=
{
5
}
/>
}
boxSize=
{
6
}
variant=
"simple"
/>
{
data
.
indexed_internal_transactions_ratio
&&
(
<
Text
fontWeight=
{
600
}
fontSize=
"xs"
color=
"inherit"
>
{
Math
.
floor
(
Number
(
data
.
indexed_internal_transactions_ratio
)
*
100
)
+
'
%
'
}
</
Text
>
)
}
</
Flex
>
);
return
(
<
Popover
placement=
"bottom-start"
isLazy
trigger=
"hover"
>
<
PopoverTrigger
>
{
trigger
}
</
PopoverTrigger
>
<
PopoverContent
maxH=
"450px"
overflowY=
"scroll"
w=
"240px"
>
<
PopoverBody
p=
{
4
}
bgColor=
{
bgColor
}
boxShadow=
"2xl"
>
{
hint
}
</
PopoverBody
>
</
PopoverContent
>
</
Popover
>
);
};
export
default
chakra
(
IndexingAlertIntTxs
);
ui/shared/Page/PageContent.tsx
View file @
b06bc511
...
@@ -2,7 +2,7 @@ import { Box } from '@chakra-ui/react';
...
@@ -2,7 +2,7 @@ import { Box } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
import
IndexingAlert
from
'
ui/home/IndexingAlert
'
;
import
IndexingAlert
Blocks
from
'
ui/home/IndexingAlertBlocks
'
;
interface
Props
{
interface
Props
{
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
...
@@ -18,7 +18,7 @@ const PageContent = ({ children, isHomePage }: Props) => {
...
@@ -18,7 +18,7 @@ const PageContent = ({ children, isHomePage }: Props) => {
paddingBottom=
{
10
}
paddingBottom=
{
10
}
paddingTop=
{
{
base
:
isHomePage
?
'
88px
'
:
'
138px
'
,
lg
:
0
}
}
paddingTop=
{
{
base
:
isHomePage
?
'
88px
'
:
'
138px
'
,
lg
:
0
}
}
>
>
{
!
appConfig
.
hideIndexingAlert
&&
<
IndexingAlert
display=
{
{
base
:
'
block
'
,
lg
:
'
none
'
}
}
/>
}
{
!
appConfig
.
hideIndexingAlert
&&
<
IndexingAlert
Blocks
display=
{
{
base
:
'
block
'
,
lg
:
'
none
'
}
}
/>
}
{
children
}
{
children
}
</
Box
>
</
Box
>
);
);
...
...
ui/snippets/footer/Footer.pw.tsx
View file @
b06bc511
...
@@ -96,4 +96,27 @@ base.describe('without custom links', () => {
...
@@ -96,4 +96,27 @@ base.describe('without custom links', () => {
await
expect
(
page
).
toHaveScreenshot
();
await
expect
(
page
).
toHaveScreenshot
();
});
});
base
(
'
with indexing alert +@dark-mode +@mobile
'
,
async
({
mount
,
page
})
=>
{
await
page
.
evaluate
(()
=>
{
window
.
ethereum
=
{
providers
:
[
{
isMetaMask
:
true
}
],
}
as
WindowProvider
;
});
const
API_URL
=
buildApiUrl
(
'
homepage_indexing_status
'
);
await
page
.
route
(
API_URL
,
(
route
)
=>
route
.
fulfill
({
status
:
200
,
body
:
JSON
.
stringify
({
finished_indexing
:
false
,
indexed_internal_transactions_ratio
:
0.1
}),
}));
const
component
=
await
mount
(
<
TestApp
>
<
Footer
/>
</
TestApp
>,
);
await
expect
(
component
).
toHaveScreenshot
();
});
});
});
ui/snippets/footer/Footer.tsx
View file @
b06bc511
...
@@ -14,6 +14,7 @@ import type { ResourceError } from 'lib/api/resources';
...
@@ -14,6 +14,7 @@ import type { ResourceError } from 'lib/api/resources';
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useIssueUrl
from
'
lib/hooks/useIssueUrl
'
;
import
useIssueUrl
from
'
lib/hooks/useIssueUrl
'
;
import
IndexingAlertIntTxs
from
'
ui/home/IndexingAlertIntTxs
'
;
import
NetworkAddToWallet
from
'
ui/shared/NetworkAddToWallet
'
;
import
NetworkAddToWallet
from
'
ui/shared/NetworkAddToWallet
'
;
import
ColorModeToggler
from
'
../header/ColorModeToggler
'
;
import
ColorModeToggler
from
'
../header/ColorModeToggler
'
;
...
@@ -81,6 +82,7 @@ const Footer = () => {
...
@@ -81,6 +82,7 @@ const Footer = () => {
<
Box
flexGrow=
"1"
mb=
{
{
base
:
8
,
lg
:
0
}
}
>
<
Box
flexGrow=
"1"
mb=
{
{
base
:
8
,
lg
:
0
}
}
>
<
Flex
>
<
Flex
>
<
ColorModeToggler
/>
<
ColorModeToggler
/>
{
!
appConfig
.
hideIndexingAlert
&&
<
IndexingAlertIntTxs
ml=
{
6
}
/>
}
<
NetworkAddToWallet
ml=
{
8
}
/>
<
NetworkAddToWallet
ml=
{
8
}
/>
</
Flex
>
</
Flex
>
<
Box
mt=
{
{
base
:
5
,
lg
:
'
44px
'
}
}
>
<
Box
mt=
{
{
base
:
5
,
lg
:
'
44px
'
}
}
>
...
...
ui/snippets/footer/__screenshots__/Footer.pw.tsx_dark-color-mode_without-custom-links-with-indexing-alert-dark-mode-mobile-1.png
0 → 100644
View file @
b06bc511
24.1 KB
ui/snippets/footer/__screenshots__/Footer.pw.tsx_default_without-custom-links-with-indexing-alert-dark-mode-mobile-1.png
0 → 100644
View file @
b06bc511
23.6 KB
ui/snippets/footer/__screenshots__/Footer.pw.tsx_mobile_without-custom-links-with-indexing-alert-dark-mode-mobile-1.png
0 → 100644
View file @
b06bc511
20.4 KB
ui/snippets/header/Header.tsx
View file @
b06bc511
...
@@ -3,7 +3,7 @@ import React from 'react';
...
@@ -3,7 +3,7 @@ import React from 'react';
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
import
{
useScrollDirection
}
from
'
lib/contexts/scrollDirection
'
;
import
{
useScrollDirection
}
from
'
lib/contexts/scrollDirection
'
;
import
IndexingAlert
from
'
ui/home/IndexingAlert
'
;
import
IndexingAlert
Blocks
from
'
ui/home/IndexingAlertBlocks
'
;
import
NetworkLogo
from
'
ui/snippets/networkMenu/NetworkLogo
'
;
import
NetworkLogo
from
'
ui/snippets/networkMenu/NetworkLogo
'
;
import
ProfileMenuDesktop
from
'
ui/snippets/profileMenu/ProfileMenuDesktop
'
;
import
ProfileMenuDesktop
from
'
ui/snippets/profileMenu/ProfileMenuDesktop
'
;
import
ProfileMenuMobile
from
'
ui/snippets/profileMenu/ProfileMenuMobile
'
;
import
ProfileMenuMobile
from
'
ui/snippets/profileMenu/ProfileMenuMobile
'
;
...
@@ -52,7 +52,7 @@ const Header = ({ isHomePage, renderSearchBar }: Props) => {
...
@@ -52,7 +52,7 @@ const Header = ({ isHomePage, renderSearchBar }: Props) => {
paddingTop=
{
9
}
paddingTop=
{
9
}
display=
{
{
base
:
'
none
'
,
lg
:
'
block
'
}
}
display=
{
{
base
:
'
none
'
,
lg
:
'
block
'
}
}
>
>
{
!
appConfig
.
hideIndexingAlert
&&
<
IndexingAlert
/>
}
{
!
appConfig
.
hideIndexingAlert
&&
<
IndexingAlert
Blocks
/>
}
{
!
isHomePage
&&
(
{
!
isHomePage
&&
(
<
HStack
<
HStack
as=
"header"
as=
"header"
...
...
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