diff --git a/public/pages/CreateDetector/components/DefineDetector/components/DetectionRules/DetectionRulesTable.tsx b/public/pages/CreateDetector/components/DefineDetector/components/DetectionRules/DetectionRulesTable.tsx index c80126b18..c6be37e46 100644 --- a/public/pages/CreateDetector/components/DefineDetector/components/DetectionRules/DetectionRulesTable.tsx +++ b/public/pages/CreateDetector/components/DefineDetector/components/DetectionRules/DetectionRulesTable.tsx @@ -4,7 +4,7 @@ */ import { CriteriaWithPagination, EuiInMemoryTable } from '@elastic/eui'; -import React from 'react'; +import React, { useState } from 'react'; import { RuleItem } from './types/interfaces'; import { getRulesColumns } from './utils/constants'; import { Search } from '@opensearch-project/oui/src/eui_components/basic_table'; @@ -70,12 +70,17 @@ export const DetectionRulesTable: React.FC = ({ }, ], }; - + const [pagination, setPagination] = useState({ pageIndex: pageIndex || 0 }); const allRulesEnabled = ruleItems.every((item) => item.active); ruleItems.sort((a, b) => { return (rulePriorityBySeverity[a.severity] || 6) - (rulePriorityBySeverity[b.severity] || 6); }); + const onTableChangeHandler = (pagination: CriteriaWithPagination) => { + setPagination({ pageIndex: pagination.page.index }); + onTableChange && onTableChange(pagination); + }; + return (
= ({ items={ruleItems} itemId={(item: RuleItem) => `${item.name}`} search={search} - pagination={ - pageIndex !== undefined - ? { - pageIndex, - } - : true - } - onTableChange={onTableChange} + pagination={pagination} + onTableChange={onTableChangeHandler} loading={loading} data-test-subj={'edit-detector-rules-table'} />