Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Event Fields Browser performance #129861

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -279,6 +279,7 @@ export const EventFieldsBrowser = React.memo<Props>(
<StyledEuiInMemoryTable
className={EVENT_FIELDS_TABLE_CLASS_NAME}
items={items}
itemId={(item: TimelineEventsDetailsItem) => item.field}
columns={columns}
pagination={false}
rowProps={onSetRowProps}
Expand Down
14 changes: 12 additions & 2 deletions x-pack/plugins/timelines/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,27 @@ import type { TimelinesUIStart, TGridProps, TimelinesStartPlugins } from './type
import { tGridReducer } from './store/t_grid/reducer';
import { useDraggableKeyboardWrapper } from './components/drag_and_drop/draggable_keyboard_wrapper_hook';
import { useAddToTimeline, useAddToTimelineSensor } from './hooks/use_add_to_timeline';
import { getHoverActions } from './components/hover_actions';
import { getHoverActions, HoverActionsConfig } from './components/hover_actions';

export class TimelinesPlugin implements Plugin<void, TimelinesUIStart> {
private _store: Store | undefined;
private _storage = new Storage(localStorage);
private _storeUnsubscribe: Unsubscribe | undefined;

private _hoverActions: HoverActionsConfig | undefined;

public setup(core: CoreSetup) {}

public start(core: CoreStart, { data }: TimelinesStartPlugins): TimelinesUIStart {
return {
/** `getHoverActions` returns a new reference to `getAddToTimelineButton` each time it is called, but that value is used in dependency arrays and so it should be as stable as possible. Therefore we lazily store the reference to it. Note: this reference is deleted when the store is changed. */
getHoverActions: () => {
return getHoverActions(this._store);
if (this._hoverActions) {
return this._hoverActions;
} else {
this._hoverActions = getHoverActions(this._store);
return this._hoverActions;
}
},
getTGrid: (props: TGridProps) => {
if (props.type === 'standalone' && this._store) {
Expand Down Expand Up @@ -89,6 +97,8 @@ export class TimelinesPlugin implements Plugin<void, TimelinesUIStart> {

private setStore(store: Store) {
this._store = store;
// this is lazily calculated and that is dependent on the store
delete this._hoverActions;
}

public stop() {
Expand Down