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

[Security Solution][Bug] fix popover in t-grid #145025

Merged
merged 14 commits into from
Nov 16, 2022
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 @@ -25,9 +25,11 @@ import { addProvider } from '../../../timelines/store/timeline/actions';
export const getAddToTimelineCellAction = ({
data,
pageSize,
closeCellPopover,
}: {
data?: TimelineNonEcsData[][];
pageSize: number;
closeCellPopover?: () => void;
}) =>
data && data.length > 0
? function AddToTimeline({ rowIndex, columnId, Component }: EuiDataGridColumnCellActionProps) {
Expand Down Expand Up @@ -97,6 +99,9 @@ export const getAddToTimelineCellAction = ({
providers: dataProvider,
})
);
if (closeCellPopover) {
closeCellPopover();
}
}, [dataProvider, dispatch]);

const addToTimelineProps = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import { EmptyComponent, useKibanaServices } from './helpers';
export const getCopyCellAction = ({
data,
pageSize,
closeCellPopover,
}: {
data?: TimelineNonEcsData[][];
pageSize: number;
closeCellPopover?: () => void;
}) =>
data && data.length > 0
? function CopyButton({ rowIndex, columnId, Component }: EuiDataGridColumnCellActionProps) {
Expand All @@ -45,6 +47,7 @@ export const getCopyCellAction = ({
ownFocus: false,
showTooltip: false,
value,
onClick: closeCellPopover,
};
}, [Component, columnId, value]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Props {
scopeId: string;
value: string[] | undefined;
onFilterAdded?: () => void;
closeCellPopover?: () => void;
}

const StyledFlexGroup = styled(EuiFlexGroup)`
Expand All @@ -40,6 +41,7 @@ const ExpandedCellValueActionsComponent: React.FC<Props> = ({
onFilterAdded,
scopeId,
value,
closeCellPopover,
}) => {
const {
timelines,
Expand Down Expand Up @@ -99,6 +101,7 @@ const ExpandedCellValueActionsComponent: React.FC<Props> = ({
size: 's',
showTooltip: false,
value,
onClick: closeCellPopover,
})}
</EuiFlexItem>
<EuiFlexItem>
Expand All @@ -111,6 +114,7 @@ const ExpandedCellValueActionsComponent: React.FC<Props> = ({
size: 's',
showTooltip: false,
value,
onClick: closeCellPopover,
})}
</EuiFlexItem>
</StyledFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import { EmptyComponent, onFilterAdded, useKibanaServices } from './helpers';
export const getFilterForCellAction = ({
data,
pageSize,
closeCellPopover,
}: {
data?: TimelineNonEcsData[][];
pageSize: number;
closeCellPopover?: () => void;
}) =>
data && data.length > 0
? function FilterFor({ rowIndex, columnId, Component }: EuiDataGridColumnCellActionProps) {
Expand Down Expand Up @@ -47,6 +49,7 @@ export const getFilterForCellAction = ({
ownFocus: false,
showTooltip: false,
value,
onClick: closeCellPopover,
};
}, [Component, columnId, filterManager, value]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import { EmptyComponent, onFilterAdded, useKibanaServices } from './helpers';
export const getFilterOutCellAction = ({
data,
pageSize,
closeCellPopover,
}: {
data?: TimelineNonEcsData[][];
pageSize: number;
closeCellPopover?: () => void;
}) =>
data && data.length > 0
? function FilterOut({ rowIndex, columnId, Component }: EuiDataGridColumnCellActionProps) {
Expand Down Expand Up @@ -47,6 +49,7 @@ export const getFilterOutCellAction = ({
ownFocus: false,
showTooltip: false,
value,
onClick: closeCellPopover,
};
}, [Component, columnId, filterManager, value]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const DefaultCellRenderer: React.FC<CellValueElementProps> = ({
setCellProps,
scopeId,
truncate,
closeCellPopover,
}) => {
const asPlainText = useMemo(() => {
return getLinkColumnDefinition(header.id, header.type, undefined) !== undefined && !isTimeline;
Expand Down Expand Up @@ -72,6 +73,7 @@ export const DefaultCellRenderer: React.FC<CellValueElementProps> = ({
globalFilters={globalFilters}
scopeId={scopeId}
value={values}
closeCellPopover={closeCellPopover}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export type CellValueElementProps = EuiDataGridCellValueElementProps & {
scopeId: string;
truncate?: boolean;
key?: string;
closeCellPopover?: () => void;
};
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
setEventsDeleted,
hasAlertsCrudPermissions,
]);
const closeCellPopoverAction = dataGridRef.current?.closeCellPopover;
const columnsWithCellActions: EuiDataGridColumn[] = useMemo(
() =>
columnHeaders.map((header) => {
Expand All @@ -743,7 +744,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
header: columnHeaders.find((h) => h.id === header.id),
pageSize,
scopeId: id,
closeCellPopover: dataGridRef.current?.closeCellPopover,
closeCellPopover: closeCellPopoverAction,
});
return {
...header,
Expand Down Expand Up @@ -782,6 +783,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
dispatch,
id,
pageSize,
closeCellPopoverAction,
]
);

Expand Down Expand Up @@ -833,6 +835,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
setCellProps,
scopeId: id,
truncate: isDetails ? false : true,
closeCellPopover: closeCellPopoverAction,
}) as React.ReactElement;
};
return Cell;
Expand All @@ -846,6 +849,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
renderCellValue,
rowRenderers,
theme,
closeCellPopoverAction,
]);

const onChangeItemsPerPage = useCallback(
Expand Down