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
e74cce21
Commit
e74cce21
authored
Dec 01, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pagination for block txs
parent
421cb9c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
40 deletions
+54
-40
block.ts
types/api/block.ts
+1
-0
pagination.ts
types/api/pagination.ts
+1
-1
BlockTxs.tsx
ui/block/BlockTxs.tsx
+0
-24
Block.tsx
ui/pages/Block.tsx
+30
-6
TxsContent.tsx
ui/txs/TxsContent.tsx
+15
-5
TxsTable.tsx
ui/txs/TxsTable.tsx
+7
-4
No files found.
types/api/block.ts
View file @
e74cce21
...
...
@@ -44,6 +44,7 @@ export interface BlockTransactionsResponse {
next_page_params
:
{
block_number
:
number
;
items_count
:
number
;
index
:
number
;
}
|
null
;
}
...
...
types/api/pagination.ts
View file @
e74cce21
...
...
@@ -41,7 +41,7 @@ type PaginationFields = {
export
const
PAGINATION_FIELDS
:
PaginationFields
=
{
[
QueryKeys
.
blocks
]:
[
'
block_number
'
,
'
items_count
'
],
[
QueryKeys
.
blockTxs
]:
[
'
block_number
'
,
'
items_count
'
],
[
QueryKeys
.
blockTxs
]:
[
'
block_number
'
,
'
items_count
'
,
'
index
'
],
[
QueryKeys
.
txsValidate
]:
[
'
block_number
'
,
'
items_count
'
,
'
filter
'
,
'
index
'
],
[
QueryKeys
.
txsPending
]:
[
'
filter
'
,
'
hash
'
,
'
inserted_at
'
],
[
QueryKeys
.
txInternals
]:
[
'
block_number
'
,
'
items_count
'
,
'
transaction_hash
'
,
'
index
'
,
'
transaction_index
'
],
...
...
ui/block/BlockTxs.tsx
deleted
100644 → 0
View file @
421cb9c0
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
useQueryWithPages
from
'
lib/hooks/useQueryWithPages
'
;
import
TxsContent
from
'
ui/txs/TxsContent
'
;
const
BlockTxs
=
()
=>
{
const
router
=
useRouter
();
const
txsQuery
=
useQueryWithPages
({
apiPath
:
`/node-api/blocks/
${
router
.
query
.
id
}
/transactions`
,
queryName
:
QueryKeys
.
blockTxs
,
});
return
(
<
TxsContent
query=
{
txsQuery
}
showBlockInfo=
{
false
}
/>
);
};
export
default
BlockTxs
;
ui/pages/Block.tsx
View file @
e74cce21
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
type
{
RoutedTab
}
from
'
ui/shared/RoutedTabs/types
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useQueryWithPages
from
'
lib/hooks/useQueryWithPages
'
;
import
BlockDetails
from
'
ui/block/BlockDetails
'
;
import
BlockTxs
from
'
ui/block/BlockTxs
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
Pagination
from
'
ui/shared/Pagination
'
;
import
RoutedTabs
from
'
ui/shared/RoutedTabs/RoutedTabs
'
;
import
TxsContent
from
'
ui/txs/TxsContent
'
;
const
TABS
:
Array
<
RoutedTab
>
=
[
{
id
:
'
index
'
,
title
:
'
Details
'
,
component
:
<
BlockDetails
/>
},
{
id
:
'
txs
'
,
title
:
'
Transactions
'
,
component
:
<
BlockTxs
/>
},
];
const
TAB_LIST_PROPS
=
{
marginBottom
:
0
,
py
:
5
,
marginTop
:
-
5
,
};
const
BlockPageContent
=
()
=>
{
const
router
=
useRouter
();
const
isMobile
=
useIsMobile
();
const
blockTxsQuery
=
useQueryWithPages
({
apiPath
:
`/node-api/blocks/
${
router
.
query
.
id
}
/transactions`
,
queryName
:
QueryKeys
.
blockTxs
,
options
:
{
enabled
:
Boolean
(
router
.
query
.
id
&&
router
.
query
.
tab
===
'
txs
'
),
},
});
if
(
!
router
.
query
.
id
)
{
return
null
;
}
const
tabs
:
Array
<
RoutedTab
>
=
[
{
id
:
'
index
'
,
title
:
'
Details
'
,
component
:
<
BlockDetails
/>
},
{
id
:
'
txs
'
,
title
:
'
Transactions
'
,
component
:
<
TxsContent
query=
{
blockTxsQuery
}
showBlockInfo=
{
false
}
showSocketInfo=
{
false
}
/>
},
];
return
(
<
Page
>
<
PageTitle
text=
{
`Block #${ router.query.id }`
}
/>
<
RoutedTabs
tabs=
{
TABS
}
/>
<
RoutedTabs
tabs=
{
tabs
}
tabListProps=
{
isMobile
?
undefined
:
TAB_LIST_PROPS
}
rightSlot=
{
isMobile
?
null
:
<
Pagination
{
...
blockTxsQuery
.
pagination
}
/>
}
stickyEnabled=
{
!
isMobile
}
/>
</
Page
>
);
};
...
...
ui/txs/TxsContent.tsx
View file @
e74cce21
...
...
@@ -23,9 +23,10 @@ type QueryResult = UseQueryResult<TxsResponse> & {
type
Props
=
{
query
:
QueryResult
;
showBlockInfo
?:
boolean
;
showSocketInfo
?:
boolean
;
}
const
TxsContent
=
({
query
,
showBlockInfo
=
true
}:
Props
)
=>
{
const
TxsContent
=
({
query
,
showBlockInfo
=
true
,
showSocketInfo
=
true
}:
Props
)
=>
{
const
{
data
,
isLoading
,
isError
,
setSortByField
,
setSortByValue
,
sorting
}
=
useTxsSort
(
query
);
const
isPaginatorHidden
=
!
isLoading
&&
!
isError
&&
query
.
pagination
.
page
===
1
&&
!
query
.
pagination
.
hasNextPage
;
const
isMobile
=
useIsMobile
();
...
...
@@ -54,14 +55,23 @@ const TxsContent = ({ query, showBlockInfo = true }: Props) => {
<>
<
Show
below=
"lg"
ssr=
{
false
}
>
<
Box
>
<
TxsNewItemNotice
>
{
({
content
})
=>
<
Box
>
{
content
}
</
Box
>
}
</
TxsNewItemNotice
>
{
showSocketInfo
&&
(
<
TxsNewItemNotice
>
{
({
content
})
=>
<
Box
>
{
content
}
</
Box
>
}
</
TxsNewItemNotice
>
)
}
{
txs
.
map
(
tx
=>
<
TxsListItem
tx=
{
tx
}
key=
{
tx
.
hash
}
showBlockInfo=
{
showBlockInfo
}
/>)
}
</
Box
>
</
Show
>
<
Hide
below=
"lg"
ssr=
{
false
}
>
<
TxsTable
txs=
{
txs
}
sort=
{
setSortByField
}
sorting=
{
sorting
}
showBlockInfo=
{
showBlockInfo
}
top=
{
isPaginatorHidden
?
0
:
80
}
/>
<
TxsTable
txs=
{
txs
}
sort=
{
setSortByField
}
sorting=
{
sorting
}
showBlockInfo=
{
showBlockInfo
}
showSocketInfo=
{
showSocketInfo
}
top=
{
isPaginatorHidden
?
0
:
80
}
/>
</
Hide
>
</>
);
...
...
ui/txs/TxsTable.tsx
View file @
e74cce21
...
...
@@ -17,9 +17,10 @@ type Props = {
sorting
?:
Sort
;
top
:
number
;
showBlockInfo
:
boolean
;
showSocketInfo
:
boolean
;
}
const
TxsTable
=
({
txs
,
sort
,
sorting
,
top
,
showBlockInfo
}:
Props
)
=>
{
const
TxsTable
=
({
txs
,
sort
,
sorting
,
top
,
showBlockInfo
,
showSocketInfo
}:
Props
)
=>
{
return
(
<
Table
variant=
"simple"
minWidth=
"950px"
size=
"xs"
>
<
TheadSticky
top=
{
top
}
>
...
...
@@ -49,9 +50,11 @@ const TxsTable = ({ txs, sort, sorting, top, showBlockInfo }: Props) => {
</
Tr
>
</
TheadSticky
>
<
Tbody
>
<
TxsNewItemNotice
borderRadius=
{
0
}
>
{
({
content
})
=>
<
Tr
><
Td
colSpan=
{
10
}
p=
{
0
}
>
{
content
}
</
Td
></
Tr
>
}
</
TxsNewItemNotice
>
{
showSocketInfo
&&
(
<
TxsNewItemNotice
borderRadius=
{
0
}
>
{
({
content
})
=>
<
Tr
><
Td
colSpan=
{
10
}
p=
{
0
}
>
{
content
}
</
Td
></
Tr
>
}
</
TxsNewItemNotice
>
)
}
{
txs
.
map
((
item
)
=>
(
<
TxsTableItem
key=
{
item
.
hash
}
...
...
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