Skip to content

Commit

Permalink
[Security/Timelines] Remove deprecated closePopover call
Browse files Browse the repository at this point in the history
- for closeCellPopover ref API
  • Loading branch information
cee-chen committed Apr 7, 2022
1 parent 4984200 commit 86b4a0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,20 @@ export const cellActions: TGridCellAction[] = [
header,
timelineId,
pageSize,
closeCellPopover,
}: {
data: TimelineNonEcsData[][];
ecsData: Ecs[];
header?: ColumnHeaderOptions;
timelineId: string;
pageSize: number;
closeCellPopover?: () => void;
}) => {
if (header !== undefined) {
return function FieldValue({
rowIndex,
columnId,
Component,
closePopover,
}: EuiDataGridColumnCellActionProps) {
const {
pageRowIndex,
Expand Down Expand Up @@ -331,7 +332,7 @@ export const cellActions: TGridCellAction[] = [
truncate={false}
title={title}
linkValue={linkValue}
onClick={closePopover}
onClick={closeCellPopover}
/>
) : (
// data grid expects each cell action always return an element, it crashes if returns null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type TGridCellAction = ({
header,
pageSize,
timelineId,
closeCellPopover,
}: {
browserFields: BrowserFields;
/** each row of data is represented as one TimelineNonEcsData[] */
Expand All @@ -58,6 +59,7 @@ export type TGridCellAction = ({
header?: ColumnHeaderOptions;
pageSize: number;
timelineId: string;
closeCellPopover?: () => void;
}) => (props: EuiDataGridColumnCellActionProps) => ReactNode;

/** The specification of a column header */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import {
EuiDataGrid,
EuiDataGridRefProps,
EuiDataGridColumn,
EuiDataGridCellValueElementProps,
EuiDataGridControlColumn,
Expand All @@ -28,6 +29,7 @@ import React, {
useMemo,
useState,
useContext,
useRef,
} from 'react';
import { connect, ConnectedProps, useDispatch } from 'react-redux';

Expand Down Expand Up @@ -337,6 +339,8 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
trailingControlColumns = EMPTY_CONTROL_COLUMNS,
unit = defaultUnit,
}) => {
const dataGridRef = useRef<EuiDataGridRefProps>(null);

const dispatch = useDispatch();
const getManageTimeline = useMemo(() => tGridSelectors.getManageTimelineById(), []);
const { queryFields, selectAll } = useDeepEqualSelector((state) =>
Expand Down Expand Up @@ -687,6 +691,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
header: columnHeaders.find((h) => h.id === header.id),
pageSize,
timelineId: id,
closeCellPopover: dataGridRef.current?.closeCellPopover,
});
return {
...header,
Expand Down Expand Up @@ -837,6 +842,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
onChangeItemsPerPage,
onChangePage,
}}
ref={dataGridRef}
/>
</EuiDataGridContainer>
)}
Expand Down

0 comments on commit 86b4a0f

Please sign in to comment.