Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export const getColumns = ({
</LocalizedDateTooltip>
);
},
sortable: true,
truncateText: true,
width: '20%',
},
Expand Down Expand Up @@ -180,7 +179,7 @@ export const getColumns = ({
},
{
align: 'center',
field: 'activate',
field: 'enabled',
name: i18n.COLUMN_ACTIVATE,
render: (value: Rule['enabled'], item: Rule) => (
<RuleSwitch
Expand Down Expand Up @@ -283,7 +282,6 @@ export const getMonitoringColumns = (): RulesStatusesColumns[] => {
</LocalizedDateTooltip>
);
},
sortable: true,
truncateText: true,
width: '20%',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down Expand Up @@ -127,9 +128,7 @@ export const AllRules = React.memo<AllRulesProps>(
});

const sorting = useMemo(
() => ({
sort: { field: 'enabled', direction: filterOptions.sortOrder },
}),
() => ({ sort: { field: 'enabled', direction: filterOptions.sortOrder } }),
[filterOptions.sortOrder]
);

Expand Down Expand Up @@ -171,7 +170,7 @@ export const AllRules = React.memo<AllRulesProps>(
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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +69 to +72
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for helping out our future selves! 😅

}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const AllRulesTablesComponent: React.FC<AllRulesTablesProps> = ({
onChange={tableOnChangeCallback}
pagination={paginationMemo}
ref={tableRef}
{...sorting}
sorting={sorting}
selection={hasNoPermissions ? undefined : euiBasicTableSelectionProps}
/>
)}
Expand All @@ -111,7 +111,7 @@ const AllRulesTablesComponent: React.FC<AllRulesTablesProps> = ({
noItemsMessage={emptyPrompt}
onChange={tableOnChangeCallback}
pagination={paginationMemo}
{...sorting}
sorting={sorting}
/>
)}
</>
Expand Down