mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Make dashboard listing initial render faster (#206618)
## Summary Follow up to https://github.com/elastic/kibana/pull/201401 I opened perf profiler in overview cluster (1000 dashboards) and noticed a very slow function. The slowness was likely caused by two spread operators on each iteration, but there was likely something more to it from the engine perspective because it was very-very slow. Before (318 ms, ~1000 dashboard)  After (<1ms, same data) 
This commit is contained in:
parent
f4651a82cd
commit
d51e35e8ff
1 changed files with 14 additions and 14 deletions
|
@ -64,6 +64,13 @@ import type { RowActions, SearchQueryError, TableItemsRowActions } from './types
|
|||
import { sortByRecentlyAccessed } from './components/table_sort_select';
|
||||
import { ContentEditorActivityRow } from './components/content_editor_activity_row';
|
||||
|
||||
const disabledEditAction = {
|
||||
enabled: false,
|
||||
reason: i18n.translate('contentManagement.tableList.managedItemNoEdit', {
|
||||
defaultMessage: 'Elastic manages this item. Clone it to make changes.',
|
||||
}),
|
||||
};
|
||||
|
||||
interface ContentEditorConfig
|
||||
extends Pick<OpenContentEditorParams, 'isReadonly' | 'onSave' | 'customValidators'> {
|
||||
enabled?: boolean;
|
||||
|
@ -527,24 +534,17 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
|
|||
|
||||
const tableItemsRowActions = useMemo(() => {
|
||||
return items.reduce<TableItemsRowActions>((acc, item) => {
|
||||
const ret = {
|
||||
...acc,
|
||||
[item.id]: rowItemActions ? rowItemActions(item) : undefined,
|
||||
};
|
||||
acc[item.id] = rowItemActions ? rowItemActions(item) : undefined;
|
||||
|
||||
if (item.managed) {
|
||||
ret[item.id] = {
|
||||
edit: {
|
||||
enabled: false,
|
||||
reason: i18n.translate('contentManagement.tableList.managedItemNoEdit', {
|
||||
defaultMessage: 'Elastic manages this item. Clone it to make changes.',
|
||||
}),
|
||||
},
|
||||
...ret[item.id],
|
||||
};
|
||||
if (acc[item.id]) {
|
||||
acc[item.id]!.edit = disabledEditAction;
|
||||
} else {
|
||||
acc[item.id] = { edit: disabledEditAction };
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return acc;
|
||||
}, {});
|
||||
}, [items, rowItemActions]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue