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
1764f302
Commit
1764f302
authored
Jun 27, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log search on the search page
parent
a8fcd42f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
6 deletions
+40
-6
SearchResultListItem.tsx
ui/searchResults/SearchResultListItem.tsx
+18
-3
SearchResultTableItem.tsx
ui/searchResults/SearchResultTableItem.tsx
+20
-3
AddressLink.tsx
ui/shared/address/AddressLink.tsx
+2
-0
No files found.
ui/searchResults/SearchResultListItem.tsx
View file @
1764f302
...
@@ -8,6 +8,7 @@ import blockIcon from 'icons/block.svg';
...
@@ -8,6 +8,7 @@ import blockIcon from 'icons/block.svg';
import
labelIcon
from
'
icons/publictags.svg
'
;
import
labelIcon
from
'
icons/publictags.svg
'
;
import
txIcon
from
'
icons/transactions.svg
'
;
import
txIcon
from
'
icons/transactions.svg
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
trimTokenSymbol
from
'
lib/token/trimTokenSymbol
'
;
import
trimTokenSymbol
from
'
lib/token/trimTokenSymbol
'
;
import
Address
from
'
ui/shared/address/Address
'
;
import
Address
from
'
ui/shared/address/Address
'
;
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
...
@@ -25,6 +26,14 @@ interface Props {
...
@@ -25,6 +26,14 @@ interface Props {
const
SearchResultListItem
=
({
data
,
searchTerm
,
isLoading
}:
Props
)
=>
{
const
SearchResultListItem
=
({
data
,
searchTerm
,
isLoading
}:
Props
)
=>
{
const
handleLinkClick
=
React
.
useCallback
((
e
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
SEARCH_QUERY
,
{
'
Search query
'
:
searchTerm
,
'
Source page type
'
:
'
Search results
'
,
'
Result URL
'
:
e
.
currentTarget
.
href
,
});
},
[
searchTerm
]);
const
firstRow
=
(()
=>
{
const
firstRow
=
(()
=>
{
switch
(
data
.
type
)
{
switch
(
data
.
type
)
{
case
'
token
'
:
{
case
'
token
'
:
{
...
@@ -39,6 +48,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -39,6 +48,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
fontWeight=
{
700
}
fontWeight=
{
700
}
wordBreak=
"break-all"
wordBreak=
"break-all"
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
onClick=
{
handleLinkClick
}
>
>
<
Skeleton
isLoaded=
{
!
isLoading
}
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
name
,
searchTerm
)
}
}
/>
<
Skeleton
isLoaded=
{
!
isLoading
}
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
name
,
searchTerm
)
}
}
/>
</
LinkInternal
>
</
LinkInternal
>
...
@@ -53,7 +63,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -53,7 +63,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
<
Address
>
<
Address
>
<
AddressIcon
address=
{
{
hash
:
data
.
address
,
is_contract
:
data
.
type
===
'
contract
'
,
implementation_name
:
null
}
}
mr=
{
2
}
flexShrink=
{
0
}
/>
<
AddressIcon
address=
{
{
hash
:
data
.
address
,
is_contract
:
data
.
type
===
'
contract
'
,
implementation_name
:
null
}
}
mr=
{
2
}
flexShrink=
{
0
}
/>
<
Box
as=
{
shouldHighlightHash
?
'
mark
'
:
'
span
'
}
display=
"block"
whiteSpace=
"nowrap"
overflow=
"hidden"
>
<
Box
as=
{
shouldHighlightHash
?
'
mark
'
:
'
span
'
}
display=
"block"
whiteSpace=
"nowrap"
overflow=
"hidden"
>
<
AddressLink
type=
"address"
hash=
{
data
.
address
}
fontWeight=
{
700
}
display=
"block"
w=
"100%"
/>
<
AddressLink
type=
"address"
hash=
{
data
.
address
}
fontWeight=
{
700
}
display=
"block"
w=
"100%"
onClick=
{
handleLinkClick
}
/>
</
Box
>
</
Box
>
</
Address
>
</
Address
>
);
);
...
@@ -69,6 +79,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -69,6 +79,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
fontWeight=
{
700
}
fontWeight=
{
700
}
wordBreak=
"break-all"
wordBreak=
"break-all"
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
onClick=
{
handleLinkClick
}
>
>
<
span
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
data
.
name
,
searchTerm
)
}
}
/>
<
span
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
data
.
name
,
searchTerm
)
}
}
/>
</
LinkInternal
>
</
LinkInternal
>
...
@@ -81,7 +92,11 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -81,7 +92,11 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
return
(
return
(
<
Flex
alignItems=
"center"
>
<
Flex
alignItems=
"center"
>
<
Icon
as=
{
blockIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
Icon
as=
{
blockIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
LinkInternal
fontWeight=
{
700
}
href=
{
route
({
pathname
:
'
/block/[height_or_hash]
'
,
query
:
{
height_or_hash
:
String
(
data
.
block_hash
)
}
})
}
>
<
LinkInternal
fontWeight=
{
700
}
href=
{
route
({
pathname
:
'
/block/[height_or_hash]
'
,
query
:
{
height_or_hash
:
String
(
data
.
block_hash
)
}
})
}
onClick=
{
handleLinkClick
}
>
<
Box
as=
{
shouldHighlightHash
?
'
span
'
:
'
mark
'
}
>
{
data
.
block_number
}
</
Box
>
<
Box
as=
{
shouldHighlightHash
?
'
span
'
:
'
mark
'
}
>
{
data
.
block_number
}
</
Box
>
</
LinkInternal
>
</
LinkInternal
>
</
Flex
>
</
Flex
>
...
@@ -93,7 +108,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -93,7 +108,7 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
<
Flex
alignItems=
"center"
overflow=
"hidden"
>
<
Flex
alignItems=
"center"
overflow=
"hidden"
>
<
Icon
as=
{
txIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
Icon
as=
{
txIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
chakra
.
mark
display=
"block"
overflow=
"hidden"
>
<
chakra
.
mark
display=
"block"
overflow=
"hidden"
>
<
AddressLink
hash=
{
data
.
tx_hash
}
type=
"transaction"
fontWeight=
{
700
}
display=
"block"
/>
<
AddressLink
hash=
{
data
.
tx_hash
}
type=
"transaction"
fontWeight=
{
700
}
display=
"block"
onClick=
{
handleLinkClick
}
/>
</
chakra
.
mark
>
</
chakra
.
mark
>
</
Flex
>
</
Flex
>
);
);
...
...
ui/searchResults/SearchResultTableItem.tsx
View file @
1764f302
...
@@ -8,6 +8,7 @@ import blockIcon from 'icons/block.svg';
...
@@ -8,6 +8,7 @@ import blockIcon from 'icons/block.svg';
import
labelIcon
from
'
icons/publictags.svg
'
;
import
labelIcon
from
'
icons/publictags.svg
'
;
import
txIcon
from
'
icons/transactions.svg
'
;
import
txIcon
from
'
icons/transactions.svg
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
highlightText
from
'
lib/highlightText
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
trimTokenSymbol
from
'
lib/token/trimTokenSymbol
'
;
import
trimTokenSymbol
from
'
lib/token/trimTokenSymbol
'
;
import
Address
from
'
ui/shared/address/Address
'
;
import
Address
from
'
ui/shared/address/Address
'
;
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
...
@@ -24,6 +25,14 @@ interface Props {
...
@@ -24,6 +25,14 @@ interface Props {
const
SearchResultTableItem
=
({
data
,
searchTerm
,
isLoading
}:
Props
)
=>
{
const
SearchResultTableItem
=
({
data
,
searchTerm
,
isLoading
}:
Props
)
=>
{
const
handleLinkClick
=
React
.
useCallback
((
e
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
SEARCH_QUERY
,
{
'
Search query
'
:
searchTerm
,
'
Source page type
'
:
'
Search results
'
,
'
Result URL
'
:
e
.
currentTarget
.
href
,
});
},
[
searchTerm
]);
const
content
=
(()
=>
{
const
content
=
(()
=>
{
switch
(
data
.
type
)
{
switch
(
data
.
type
)
{
case
'
token
'
:
{
case
'
token
'
:
{
...
@@ -40,6 +49,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -40,6 +49,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
fontWeight=
{
700
}
fontWeight=
{
700
}
wordBreak=
"break-all"
wordBreak=
"break-all"
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
onClick=
{
handleLinkClick
}
>
>
<
Skeleton
isLoaded=
{
!
isLoading
}
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
name
,
searchTerm
)
}
}
/>
<
Skeleton
isLoaded=
{
!
isLoading
}
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
name
,
searchTerm
)
}
}
/>
</
LinkInternal
>
</
LinkInternal
>
...
@@ -58,6 +68,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -58,6 +68,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
case
'
address
'
:
{
case
'
address
'
:
{
if
(
data
.
name
)
{
if
(
data
.
name
)
{
const
shouldHighlightHash
=
data
.
address
.
toLowerCase
()
===
searchTerm
.
toLowerCase
();
const
shouldHighlightHash
=
data
.
address
.
toLowerCase
()
===
searchTerm
.
toLowerCase
();
return
(
return
(
<>
<>
<
Td
fontSize=
"sm"
>
<
Td
fontSize=
"sm"
>
...
@@ -68,6 +79,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -68,6 +79,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
fontWeight=
{
700
}
fontWeight=
{
700
}
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
onClick=
{
handleLinkClick
}
>
>
<
Box
as=
{
shouldHighlightHash
?
'
mark
'
:
'
span
'
}
display=
"block"
>
<
Box
as=
{
shouldHighlightHash
?
'
mark
'
:
'
span
'
}
display=
"block"
>
<
HashStringShortenDynamic
hash=
{
data
.
address
}
/>
<
HashStringShortenDynamic
hash=
{
data
.
address
}
/>
...
@@ -87,7 +99,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -87,7 +99,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<
Address
>
<
Address
>
<
AddressIcon
address=
{
{
hash
:
data
.
address
,
is_contract
:
data
.
type
===
'
contract
'
,
implementation_name
:
null
}
}
mr=
{
2
}
flexShrink=
{
0
}
/>
<
AddressIcon
address=
{
{
hash
:
data
.
address
,
is_contract
:
data
.
type
===
'
contract
'
,
implementation_name
:
null
}
}
mr=
{
2
}
flexShrink=
{
0
}
/>
<
mark
>
<
mark
>
<
AddressLink
hash=
{
data
.
address
}
type=
"address"
fontWeight=
{
700
}
/>
<
AddressLink
hash=
{
data
.
address
}
type=
"address"
fontWeight=
{
700
}
onClick=
{
handleLinkClick
}
/>
</
mark
>
</
mark
>
</
Address
>
</
Address
>
</
Td
>
</
Td
>
...
@@ -106,6 +118,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -106,6 +118,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
fontWeight=
{
700
}
fontWeight=
{
700
}
wordBreak=
"break-all"
wordBreak=
"break-all"
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
onClick=
{
handleLinkClick
}
>
>
<
span
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
data
.
name
,
searchTerm
)
}
}
/>
<
span
dangerouslySetInnerHTML=
{
{
__html
:
highlightText
(
data
.
name
,
searchTerm
)
}
}
/>
</
LinkInternal
>
</
LinkInternal
>
...
@@ -128,7 +141,11 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -128,7 +141,11 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<
Td
fontSize=
"sm"
>
<
Td
fontSize=
"sm"
>
<
Flex
alignItems=
"center"
>
<
Flex
alignItems=
"center"
>
<
Icon
as=
{
blockIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
Icon
as=
{
blockIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
LinkInternal
fontWeight=
{
700
}
href=
{
route
({
pathname
:
'
/block/[height_or_hash]
'
,
query
:
{
height_or_hash
:
String
(
data
.
block_hash
)
}
})
}
>
<
LinkInternal
fontWeight=
{
700
}
href=
{
route
({
pathname
:
'
/block/[height_or_hash]
'
,
query
:
{
height_or_hash
:
String
(
data
.
block_hash
)
}
})
}
onClick=
{
handleLinkClick
}
>
<
Box
as=
{
shouldHighlightHash
?
'
span
'
:
'
mark
'
}
>
{
data
.
block_number
}
</
Box
>
<
Box
as=
{
shouldHighlightHash
?
'
span
'
:
'
mark
'
}
>
{
data
.
block_number
}
</
Box
>
</
LinkInternal
>
</
LinkInternal
>
</
Flex
>
</
Flex
>
...
@@ -148,7 +165,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
...
@@ -148,7 +165,7 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<
Flex
alignItems=
"center"
>
<
Flex
alignItems=
"center"
>
<
Icon
as=
{
txIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
Icon
as=
{
txIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
"gray.500"
/>
<
mark
>
<
mark
>
<
AddressLink
hash=
{
data
.
tx_hash
}
type=
"transaction"
fontWeight=
{
700
}
/>
<
AddressLink
hash=
{
data
.
tx_hash
}
type=
"transaction"
fontWeight=
{
700
}
onClick=
{
handleLinkClick
}
/>
</
mark
>
</
mark
>
</
Flex
>
</
Flex
>
</
Td
>
</
Td
>
...
...
ui/shared/address/AddressLink.tsx
View file @
1764f302
...
@@ -18,6 +18,7 @@ type CommonProps = {
...
@@ -18,6 +18,7 @@ type CommonProps = {
fontWeight
?:
string
;
fontWeight
?:
string
;
alias
?:
string
|
null
;
alias
?:
string
|
null
;
isLoading
?:
boolean
;
isLoading
?:
boolean
;
onClick
?:
(
e
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
void
;
}
}
type
AddressTokenTxProps
=
{
type
AddressTokenTxProps
=
{
...
@@ -105,6 +106,7 @@ const AddressLink = (props: Props) => {
...
@@ -105,6 +106,7 @@ const AddressLink = (props: Props) => {
target=
{
target
}
target=
{
target
}
overflow=
"hidden"
overflow=
"hidden"
whiteSpace=
"nowrap"
whiteSpace=
"nowrap"
onClick=
{
props
.
onClick
}
>
>
{
content
}
{
content
}
</
LinkInternal
>
</
LinkInternal
>
...
...
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