Enhance Event Fields Browser performance (#129861)

* Enhance Event Fields Browser performance

* fixes checks

* Update x-pack/plugins/security_solution/public/common/components/event_details/event_fields_browser.tsx

Use idiomatic value for EUI's `itemId` field

Co-authored-by: Jan Monschke <janmonschke@fastmail.com>

Co-authored-by: Gloria Hornero <gloria.hornero@elastic.co>
Co-authored-by: Jan Monschke <janmonschke@fastmail.com>
This commit is contained in:
Robert Austin 2022-04-11 12:42:33 -04:00 committed by GitHub
parent dcbf9daa00
commit 47b62d83af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -279,6 +279,7 @@ export const EventFieldsBrowser = React.memo<Props>(
<StyledEuiInMemoryTable
className={EVENT_FIELDS_TABLE_CLASS_NAME}
items={items}
itemId="field"
columns={columns}
pagination={false}
rowProps={onSetRowProps}

View file

@ -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) {
@ -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() {