diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx index a155f3eb2803c..5157bd81403e2 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx @@ -144,7 +144,6 @@ export const getColumns = ({ ); }, - sortable: true, truncateText: true, width: '20%', }, @@ -180,7 +179,7 @@ export const getColumns = ({ }, { align: 'center', - field: 'activate', + field: 'enabled', name: i18n.COLUMN_ACTIVATE, render: (value: Rule['enabled'], item: Rule) => ( { ); }, - sortable: true, truncateText: true, width: '20%', }, diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx index 4003b71b95d77..1a98272546440 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx @@ -41,11 +41,12 @@ import { showRulesTable } from './helpers'; import { allRulesReducer, State } from './reducer'; import { RulesTableFilters } from './rules_table_filters/rules_table_filters'; +const SORT_FIELD = 'enabled'; const initialState: State = { exportRuleIds: [], filterOptions: { filter: '', - sortField: 'enabled', + sortField: SORT_FIELD, sortOrder: 'desc', }, loadingRuleIds: [], @@ -127,9 +128,7 @@ export const AllRules = React.memo( }); const sorting = useMemo( - () => ({ - sort: { field: 'enabled', direction: filterOptions.sortOrder }, - }), + () => ({ sort: { field: 'enabled', direction: filterOptions.sortOrder } }), [filterOptions.sortOrder] ); @@ -171,7 +170,7 @@ export const AllRules = React.memo( dispatch({ type: 'updateFilterOptions', filterOptions: { - sortField: 'enabled', // Only enabled is supported for sorting currently + sortField: SORT_FIELD, // Only enabled is supported for sorting currently sortOrder: sort?.direction ?? 'desc', }, pagination: { page: page.index + 1, perPage: page.size }, diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/reducer.ts b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/reducer.ts index 0a4d169d13154..bc5297e7628b7 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/reducer.ts +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/reducer.ts @@ -66,7 +66,10 @@ export const allRulesReducer = ( tableRef.current != null && tableRef.current.changeSelection != null ) { - tableRef.current.changeSelection([]); + // for future devs: eui basic table is not giving us a prop to set the value, so + // we are using the ref in setTimeout to reset on the next loop so that we + // do not get a warning telling us we are trying to update during a render + window.setTimeout(() => tableRef?.current?.changeSelection([]), 0); } return { diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx index 92ccbc864ab5a..0fd07f30a00b6 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx @@ -97,7 +97,7 @@ const AllRulesTablesComponent: React.FC = ({ onChange={tableOnChangeCallback} pagination={paginationMemo} ref={tableRef} - {...sorting} + sorting={sorting} selection={hasNoPermissions ? undefined : euiBasicTableSelectionProps} /> )} @@ -111,7 +111,7 @@ const AllRulesTablesComponent: React.FC = ({ noItemsMessage={emptyPrompt} onChange={tableOnChangeCallback} pagination={paginationMemo} - {...sorting} + sorting={sorting} /> )}