@@ -3,71 +3,82 @@ import React from 'react';
33import { AccessDenied } from '../../components/Errors/403' ;
44import { ResponseError } from '../../components/Errors/ResponseError' ;
55import { ResizeableDataTable } from '../../components/ResizeableDataTable/ResizeableDataTable' ;
6+ import { TableSkeleton } from '../../components/TableSkeleton/TableSkeleton' ;
67import { TableWithControlsLayout } from '../../components/TableWithControlsLayout/TableWithControlsLayout' ;
7- import { operationsApi } from '../../store/reducers/operations' ;
8- import { useAutoRefreshInterval } from '../../utils/hooks' ;
8+ import { DEFAULT_TABLE_SETTINGS } from '../../utils/constants' ;
99import { isAccessError } from '../../utils/response' ;
1010
1111import { OperationsControls } from './OperationsControls' ;
1212import { getColumns } from './columns' ;
1313import { OPERATIONS_SELECTED_COLUMNS_KEY } from './constants' ;
1414import i18n from './i18n' ;
1515import { b } from './shared' ;
16+ import { useOperationsInfiniteQuery } from './useOperationsInfiniteQuery' ;
1617import { useOperationsQueryParams } from './useOperationsQueryParams' ;
1718
1819interface OperationsProps {
1920 database : string ;
21+ scrollContainerRef ?: React . RefObject < HTMLElement > ;
2022}
2123
22- export function Operations ( { database} : OperationsProps ) {
23- const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
24-
25- const { kind, searchValue, pageSize, pageToken, handleKindChange, handleSearchChange} =
24+ export function Operations ( { database, scrollContainerRef} : OperationsProps ) {
25+ const { kind, searchValue, pageSize, handleKindChange, handleSearchChange} =
2626 useOperationsQueryParams ( ) ;
2727
28- const { data, isLoading, error, refetch} = operationsApi . useGetOperationListQuery (
29- { database, kind, page_size : pageSize , page_token : pageToken } ,
30- {
31- pollingInterval : autoRefreshInterval ,
32- } ,
33- ) ;
34-
35- const filteredOperations = React . useMemo ( ( ) => {
36- if ( ! data ?. operations ) {
37- return [ ] ;
38- }
39- return data . operations . filter ( ( op ) =>
40- op . id ?. toLowerCase ( ) . includes ( searchValue . toLowerCase ( ) ) ,
41- ) ;
42- } , [ data ?. operations , searchValue ] ) ;
28+ const { operations, isLoading, isLoadingMore, error, refreshTable, totalCount} =
29+ useOperationsInfiniteQuery ( {
30+ database,
31+ kind,
32+ pageSize,
33+ searchValue,
34+ scrollContainerRef,
35+ } ) ;
4336
4437 if ( isAccessError ( error ) ) {
4538 return < AccessDenied position = "left" /> ;
4639 }
4740
41+ const settings = React . useMemo ( ( ) => {
42+ return {
43+ ...DEFAULT_TABLE_SETTINGS ,
44+ sortable : false ,
45+ } ;
46+ } , [ ] ) ;
47+
4848 return (
4949 < TableWithControlsLayout >
5050 < TableWithControlsLayout . Controls >
5151 < OperationsControls
5252 kind = { kind }
5353 searchValue = { searchValue }
54- entitiesCountCurrent = { filteredOperations . length }
55- entitiesCountTotal = { data ?. operations ?. length }
54+ entitiesCountCurrent = { operations . length }
55+ entitiesCountTotal = { totalCount }
5656 entitiesLoading = { isLoading }
5757 handleKindChange = { handleKindChange }
5858 handleSearchChange = { handleSearchChange }
5959 />
6060 </ TableWithControlsLayout . Controls >
6161 { error ? < ResponseError error = { error } /> : null }
6262 < TableWithControlsLayout . Table loading = { isLoading } className = { b ( 'table' ) } >
63- { data ? (
63+ { operations . length > 0 || isLoading ? (
6464 < ResizeableDataTable
65- columns = { getColumns ( { database, refreshTable : refetch } ) }
65+ columns = { getColumns ( { database, refreshTable, kind } ) }
6666 columnsWidthLSKey = { OPERATIONS_SELECTED_COLUMNS_KEY }
67- data = { filteredOperations }
67+ data = { operations }
68+ settings = { settings }
6869 emptyDataMessage = { i18n ( 'title_empty' ) }
6970 />
70- ) : null }
71+ ) : (
72+ < div > { i18n ( 'title_empty' ) } </ div >
73+ ) }
74+ { isLoadingMore && (
75+ < TableSkeleton
76+ showHeader = { false }
77+ rows = { 3 }
78+ delay = { 0 }
79+ className = { b ( 'loading-more' ) }
80+ />
81+ ) }
7182 </ TableWithControlsLayout . Table >
7283 </ TableWithControlsLayout >
7384 ) ;
0 commit comments