4
4
*/
5
5
6
6
import { CriteriaWithPagination , EuiInMemoryTable } from '@elastic/eui' ;
7
- import React from 'react' ;
7
+ import React , { useState } from 'react' ;
8
8
import { RuleItem } from './types/interfaces' ;
9
9
import { getRulesColumns } from './utils/constants' ;
10
10
import { Search } from '@opensearch-project/oui/src/eui_components/basic_table' ;
@@ -70,12 +70,17 @@ export const DetectionRulesTable: React.FC<DetectionRulesTableProps> = ({
70
70
} ,
71
71
] ,
72
72
} ;
73
-
73
+ const [ pagination , setPagination ] = useState ( { pageIndex : pageIndex || 0 } ) ;
74
74
const allRulesEnabled = ruleItems . every ( ( item ) => item . active ) ;
75
75
ruleItems . sort ( ( a , b ) => {
76
76
return ( rulePriorityBySeverity [ a . severity ] || 6 ) - ( rulePriorityBySeverity [ b . severity ] || 6 ) ;
77
77
} ) ;
78
78
79
+ const onTableChangeHandler = ( pagination : CriteriaWithPagination < T > ) => {
80
+ setPagination ( { pageIndex : pagination . page . index } ) ;
81
+ onTableChange && onTableChange ( pagination ) ;
82
+ } ;
83
+
79
84
return (
80
85
< div style = { { padding : 10 } } >
81
86
< EuiInMemoryTable
@@ -88,14 +93,8 @@ export const DetectionRulesTable: React.FC<DetectionRulesTableProps> = ({
88
93
items = { ruleItems }
89
94
itemId = { ( item : RuleItem ) => `${ item . name } ` }
90
95
search = { search }
91
- pagination = {
92
- pageIndex !== undefined
93
- ? {
94
- pageIndex,
95
- }
96
- : true
97
- }
98
- onTableChange = { onTableChange }
96
+ pagination = { pagination }
97
+ onTableChange = { onTableChangeHandler }
99
98
loading = { loading }
100
99
data-test-subj = { 'edit-detector-rules-table' }
101
100
/>
0 commit comments