Skip to content

Commit d43b8dc

Browse files
committed
removes sortable=true from non-sortable columns, fixes naming of sortable column field from activate to enabled to match the field eui expects to sort on, fixes react render warning due to resetting tableRef's current field during a render
1 parent e1d8d51 commit d43b8dc

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export const getColumns = ({
144144
</LocalizedDateTooltip>
145145
);
146146
},
147-
sortable: true,
148147
truncateText: true,
149148
width: '20%',
150149
},
@@ -180,7 +179,7 @@ export const getColumns = ({
180179
},
181180
{
182181
align: 'center',
183-
field: 'activate',
182+
field: 'enabled',
184183
name: i18n.COLUMN_ACTIVATE,
185184
render: (value: Rule['enabled'], item: Rule) => (
186185
<RuleSwitch
@@ -283,7 +282,6 @@ export const getMonitoringColumns = (): RulesStatusesColumns[] => {
283282
</LocalizedDateTooltip>
284283
);
285284
},
286-
sortable: true,
287285
truncateText: true,
288286
width: '20%',
289287
},

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ import { showRulesTable } from './helpers';
4141
import { allRulesReducer, State } from './reducer';
4242
import { RulesTableFilters } from './rules_table_filters/rules_table_filters';
4343

44+
const SORT_FIELD = 'enabled';
4445
const initialState: State = {
4546
exportRuleIds: [],
4647
filterOptions: {
4748
filter: '',
48-
sortField: 'enabled',
49+
sortField: SORT_FIELD,
4950
sortOrder: 'desc',
5051
},
5152
loadingRuleIds: [],
@@ -127,9 +128,7 @@ export const AllRules = React.memo<AllRulesProps>(
127128
});
128129

129130
const sorting = useMemo(
130-
() => ({
131-
sort: { field: 'enabled', direction: filterOptions.sortOrder },
132-
}),
131+
() => ({ sort: { field: 'enabled', direction: filterOptions.sortOrder } }),
133132
[filterOptions.sortOrder]
134133
);
135134

@@ -171,7 +170,7 @@ export const AllRules = React.memo<AllRulesProps>(
171170
dispatch({
172171
type: 'updateFilterOptions',
173172
filterOptions: {
174-
sortField: 'enabled', // Only enabled is supported for sorting currently
173+
sortField: SORT_FIELD, // Only enabled is supported for sorting currently
175174
sortOrder: sort?.direction ?? 'desc',
176175
},
177176
pagination: { page: page.index + 1, perPage: page.size },

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/reducer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ export const allRulesReducer = (
6666
tableRef.current != null &&
6767
tableRef.current.changeSelection != null
6868
) {
69-
tableRef.current.changeSelection([]);
69+
// for future devs: eui basic table is not giving us a prop to set the value, so
70+
// we are using the ref in setTimeout to reset on the next loop so that we
71+
// do not get a warning telling us we are trying to update during a render
72+
window.setTimeout(() => tableRef?.current?.changeSelection([]), 0);
7073
}
7174

7275
return {

0 commit comments

Comments
 (0)