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] Integrate Vanilla Unified Data Table in Timeline #176064

Merged
merged 76 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
78cfc74
wip udt
michaelolo24 Jan 16, 2024
7eb5b4d
use control columns completed
michaelolo24 Jan 22, 2024
5dff62f
wip column
michaelolo24 Jan 24, 2024
72cfff5
got table visible
michaelolo24 Jan 26, 2024
258ed5d
move query tab to new file
michaelolo24 Feb 1, 2024
20921de
Continued refactor of table code
michaelolo24 Feb 1, 2024
dfde043
fix: add appropriate actions and unified table changes
logeekal Feb 9, 2024
b1556c7
fix: column auto adjust width
logeekal Feb 13, 2024
769d5ce
fix: Field Formatting
logeekal Feb 13, 2024
1a4b9a4
fix: flyout issues + rename var
logeekal Feb 15, 2024
e87c5a9
switch off feature flag by default
logeekal Feb 15, 2024
aed026b
fix: housekeeping
logeekal Feb 15, 2024
a5c7a81
fix: cypress + unit tests
logeekal Feb 20, 2024
c2e3719
Merged main -> current branch
logeekal Feb 20, 2024
6fb3bef
fix: types
logeekal Feb 20, 2024
9595983
fix: alert acount
logeekal Feb 21, 2024
d42cb2e
fix: some tests + remove unnecessary changes
logeekal Feb 21, 2024
f3faa32
Merge branch 'main' into integrate-unified-data-table-1
logeekal Feb 21, 2024
aa41a23
fix: translations
logeekal Feb 22, 2024
aaf4ba4
fix: more translations
logeekal Feb 22, 2024
c994a04
fix: add query tab unit tests
logeekal Feb 23, 2024
2d6e0b8
fix: tests
logeekal Feb 26, 2024
5a03ece
fix: more tests
logeekal Mar 2, 2024
963363f
Merged main -> current branch
logeekal Mar 2, 2024
05bd286
fix: types + tests
logeekal Mar 4, 2024
332bfc2
fix: more types + better mock
logeekal Mar 4, 2024
d67ac0f
complete query tab unified tests
logeekal Mar 6, 2024
a8401a4
Merge main --> current branch
logeekal Mar 6, 2024
92cc95e
fix: test + cell action metadata
logeekal Mar 6, 2024
288195c
fix: tests
logeekal Mar 6, 2024
ff4feea
fix: test instability
logeekal Mar 7, 2024
a22d803
test: unified list test
logeekal Mar 7, 2024
c0fbb5f
test: adding drag capability incremental save
logeekal Mar 7, 2024
1dfe8f4
refactor: delete unnecessary files + code
logeekal Mar 8, 2024
1fe3ea6
fix: add useGetScopedSourcererDataViewTests
logeekal Mar 11, 2024
4c8fe91
fix: deduped last updated date component
logeekal Mar 11, 2024
4a61483
refactor: better class names
logeekal Mar 11, 2024
fa5d8e0
fix: data grid highlight class
logeekal Mar 11, 2024
b2d9ea5
fix: unecessary change revert
logeekal Mar 11, 2024
6b81b0b
Deduped getColumnHeader for unified header columns
logeekal Mar 11, 2024
ab22474
test: updateTimelineColumnWidth
logeekal Mar 11, 2024
2863544
remove unncessary change
logeekal Mar 11, 2024
20edaae
fix: row height table
logeekal Mar 11, 2024
81ab130
Merge branch 'main' into integrate-unified-data-table-1
logeekal Mar 11, 2024
df53346
Merge branch 'main' into integrate-unified-data-table-1
logeekal Mar 12, 2024
a141c2b
fix: deduped field formatters
logeekal Mar 12, 2024
2837017
fix: tests
logeekal Mar 13, 2024
9074af3
tests: unified_component unit tests
logeekal Mar 14, 2024
97425cd
fix: types
logeekal Mar 14, 2024
6551476
Merge branch 'main' into integrate-unified-data-table-1
kibanamachine Mar 14, 2024
374c0c7
test: unified data table
logeekal Mar 22, 2024
1d05271
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Mar 22, 2024
87655c5
test: more of them 🧪
logeekal Mar 25, 2024
642109f
fix: add with data view HOC
logeekal Mar 25, 2024
077c0c1
tests: open_timeline
logeekal Mar 26, 2024
c0934bd
fix: revert duplicate timeline change
logeekal Mar 26, 2024
557344d
test: cypress
logeekal Mar 26, 2024
d7af041
fix: more tests + cypress
logeekal Mar 26, 2024
248226f
Merge branch 'main' into integrate-unified-data-table-1
logeekal Mar 26, 2024
c421fa3
fix: Issue with merge -> main
logeekal Mar 26, 2024
cf159a7
review feedback
logeekal Mar 27, 2024
8694f9e
fix: try increasing test timeout
logeekal Mar 27, 2024
56c1ae6
update test snapshot
logeekal Mar 27, 2024
0bfc88b
fix: add timeouts to test
logeekal Mar 27, 2024
770f1f8
test: add timeout
logeekal Mar 27, 2024
d01ba94
fix: add z-index to old flyout
logeekal Mar 27, 2024
a4b1e9c
tests: update cypress + jest test timeout
logeekal Mar 27, 2024
472c173
update timeout time
michaelolo24 Mar 27, 2024
112a343
Merge branch 'main' into integrate-unified-data-table-1
logeekal Mar 28, 2024
7360c8c
fix: merge issues
logeekal Mar 28, 2024
84fe0fb
fix: review feedback cypress
logeekal Mar 28, 2024
c312a7b
fix: add brokenInServerlessQA tag
logeekal Mar 28, 2024
8e840b2
Merge remote-tracking branch 'upstream/main' into integrate-unified-d…
michaelolo24 Mar 29, 2024
2df4376
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Mar 29, 2024
4aa05e9
update timeline helpers tests
michaelolo24 Apr 1, 2024
2467a37
Merge remote-tracking branch 'upstream/main' into integrate-unified-d…
michaelolo24 Apr 1, 2024
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 @@ -161,45 +161,49 @@ describe('useDataGridColumnsCellActions', () => {
cellAction1.getByTestId(`dataGridColumnCellAction-${action1.id}`).click();

await waitFor(() => {
expect(action1.execute).toHaveBeenCalledWith(
expect.objectContaining({
data: [
{
value: fieldValues[field1.name][1],
field: {
name: field1.name,
type: field1.type,
aggregatable: true,
searchable: true,
},
expect(action1.execute).toHaveBeenCalledWith({
data: [
{
value: fieldValues[field1.name][1],
field: {
name: field1.name,
type: field1.type,
aggregatable: true,
searchable: true,
},
],
trigger: { id: useDataGridColumnsCellActionsProps.triggerId },
})
);
},
],
metadata: {
some: 'value',
},
nodeRef: expect.any(Object),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the element ref?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelolo24 , Yes it is provided to call closeCellActionPopover but this is not added in this PR. I just made the assertion to be more exact as it was needed here.

trigger: { id: useDataGridColumnsCellActionsProps.triggerId },
});
});

const cellAction2 = renderCellAction(result.current[1][1], { rowIndex: 2 });

cellAction2.getByTestId(`dataGridColumnCellAction-${action2.id}`).click();

await waitFor(() => {
expect(action2.execute).toHaveBeenCalledWith(
expect.objectContaining({
data: [
{
value: fieldValues[field2.name][2],
field: {
name: field2.name,
type: field2.type,
aggregatable: true,
searchable: true,
},
expect(action2.execute).toHaveBeenCalledWith({
data: [
{
value: fieldValues[field2.name][2],
field: {
name: field2.name,
type: field2.type,
aggregatable: true,
searchable: true,
},
],
trigger: { id: useDataGridColumnsCellActionsProps.triggerId },
})
);
},
],
metadata: {
some: 'value',
},
nodeRef: expect.any(Object),
trigger: { id: useDataGridColumnsCellActionsProps.triggerId },
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
font-family: $euiCodeFontFamily;
}

.dscDocsGrid__cell--expanded {
background-color: $euiColorHighlight;
}

.dscDocsGrid__cell--selected {
background-color: $euiColorHighlight;
}

.unifiedDataTable__cellPopover {
// Fixes https://github.com/elastic/kibana/issues/145216 in Chrome
.lines-content.monaco-editor-background {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function getProps(): UnifiedDataTableProps {
data: services.data,
theme: services.theme,
},
cellActionsMetadata: {
someKey: 'someValue',
},
};
}

Expand Down Expand Up @@ -253,13 +256,15 @@ describe('UnifiedDataTable', () => {
columns: ['message'],
onFieldEdited: jest.fn(),
});
expect(mockUseDataGridColumnsCellActions).toHaveBeenCalledWith(
expect.objectContaining({
triggerId: undefined,
getCellValue: expect.any(Function),
fields: undefined,
})
);
expect(mockUseDataGridColumnsCellActions).toHaveBeenCalledWith({
triggerId: undefined,
getCellValue: expect.any(Function),
fields: undefined,
dataGridRef: expect.any(Object),
metadata: {
someKey: 'someValue',
},
});
});

it('should call useDataGridColumnsCellActions properly when cellActionsTriggerId defined', async () => {
Expand All @@ -269,16 +274,18 @@ describe('UnifiedDataTable', () => {
onFieldEdited: jest.fn(),
cellActionsTriggerId: 'test',
});
expect(mockUseDataGridColumnsCellActions).toHaveBeenCalledWith(
expect.objectContaining({
triggerId: 'test',
getCellValue: expect.any(Function),
fields: [
dataViewMock.getFieldByName('@timestamp')?.toSpec(),
dataViewMock.getFieldByName('message')?.toSpec(),
],
})
);
expect(mockUseDataGridColumnsCellActions).toHaveBeenCalledWith({
triggerId: 'test',
getCellValue: expect.any(Function),
fields: [
dataViewMock.getFieldByName('@timestamp')?.toSpec(),
dataViewMock.getFieldByName('message')?.toSpec(),
],
dataGridRef: expect.any(Object),
metadata: {
someKey: 'someValue',
},
});
});
});

Expand Down
13 changes: 12 additions & 1 deletion packages/kbn-unified-data-table/src/components/data_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ export interface UnifiedDataTableProps {
* Optional row line height override. Default is 1.6em.
*/
rowLineHeightOverride?: string;
/**
* Custom set of properties used by some actions.
* An action might require a specific set of metadata properties to render.
* This data is sent directly to actions.
*/
cellActionsMetadata?: Record<string, unknown>;
}

export const EuiDataGridMemoized = React.memo(EuiDataGrid);
Expand Down Expand Up @@ -429,11 +435,13 @@ export const UnifiedDataTable = ({
componentsTourSteps,
gridStyleOverride,
rowLineHeightOverride,
cellActionsMetadata,
customGridColumnsConfiguration,
customControlColumnsConfiguration,
}: UnifiedDataTableProps) => {
const { fieldFormats, toastNotifications, dataViewFieldEditor, uiSettings, storage, data } =
services;

const { darkMode } = useObservable(services.theme?.theme$ ?? of(themeDefault), themeDefault);
const dataGridRef = useRef<EuiDataGridRefProps>(null);
const [selectedDocs, setSelectedDocs] = useState<string[]>([]);
Expand Down Expand Up @@ -668,6 +676,7 @@ export const UnifiedDataTable = ({
getCellValue,
triggerId: cellActionsTriggerId,
dataGridRef,
metadata: cellActionsMetadata,
});

const {
Expand Down Expand Up @@ -715,11 +724,14 @@ export const UnifiedDataTable = ({
visibleCellActions,
columnTypes,
showColumnTokens,
headerRowHeight,
headerRowHeightLines,
customGridColumnsConfiguration,
}),
[
columnTypes,
showColumnTokens,
headerRowHeight,
columnsCellActions,
customGridColumnsConfiguration,
dataView,
Expand All @@ -732,7 +744,6 @@ export const UnifiedDataTable = ({
isSortEnabled,
onFilter,
settings,
showColumnTokens,
toastNotifications,
uiSettings,
valueToStringConverter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
useEuiTheme,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { euiDarkVars as themeDark, euiLightVars as themeLight } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import { css } from '@emotion/react';
import type { DataTableRecord } from '@kbn/discover-utils/types';
Expand All @@ -40,9 +39,7 @@ export const SelectButton = ({ rowIndex, setCellProps }: EuiDataGridCellValueEle
useEffect(() => {
if (expanded && doc && expanded.id === doc.id) {
setCellProps({
style: {
backgroundColor: isDarkMode ? themeDark.euiColorHighlight : themeLight.euiColorHighlight,
},
className: 'dscDocsGrid__cell--selected',
logeekal marked this conversation as resolved.
Show resolved Hide resolved
});
} else {
setCellProps({ style: undefined });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import React, { useContext, useEffect, useRef, useState } from 'react';
import { EuiButtonIcon, EuiDataGridCellValueElementProps, EuiToolTip } from '@elastic/eui';
import { euiLightVars as themeLight, euiDarkVars as themeDark } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import { UnifiedDataTableContext } from '../table_context';
import { DataTableRowControl } from './data_table_row_control';
Expand All @@ -31,9 +30,7 @@ export const ExpandButton = ({ rowIndex, setCellProps }: EuiDataGridCellValueEle
});
} else if (expanded && current && expanded.id === current.id) {
setCellProps({
style: {
backgroundColor: isDarkMode ? themeDark.euiColorHighlight : themeLight.euiColorHighlight,
},
className: 'dscDocsGrid__cell--expanded',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
className: 'dscDocsGrid__cell--expanded',
className: 'unifiedDataTable__cell--expanded',

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done: 4a61483

});
} else {
setCellProps({ style: undefined });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import React, { useContext, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { euiLightVars as themeLight, euiDarkVars as themeDark } from '@kbn/ui-theme';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import {
EuiDataGridCellValueElementProps,
Expand Down Expand Up @@ -62,32 +61,22 @@ export const getRenderCellValueFn = ({
const ctx = useContext(UnifiedDataTableContext);

useEffect(() => {
if (!externalCustomRenderers) {
if (row?.isAnchor) {
setCellProps({
className: 'dscDocsGrid__cell--highlight',
});
} else if (ctx.expanded && row && ctx.expanded.id === row.id) {
setCellProps({
style: {
backgroundColor: ctx.isDarkMode
? themeDark.euiColorHighlight
: themeLight.euiColorHighlight,
},
});
} else {
setCellProps({ style: undefined });
}
if (row?.isAnchor) {
setCellProps({
className: 'dscDocsGrid__cell--highlight',
});
} else if (ctx.expanded && row && ctx.expanded.id === row.id) {
setCellProps({
className: 'dscDocsGrid__cell--expanded',
logeekal marked this conversation as resolved.
Show resolved Hide resolved
});
} else {
setCellProps({ style: undefined });
}
}, [ctx, row, setCellProps]);

if (typeof row === 'undefined') {
return <span className={CELL_CLASS}>-</span>;
}

if (!!externalCustomRenderers && !!externalCustomRenderers[columnId]) {
return (
<>
<span className={CELL_CLASS}>
{externalCustomRenderers[columnId]({
rowIndex,
columnId,
Expand All @@ -101,10 +90,14 @@ export const getRenderCellValueFn = ({
fieldFormats,
closePopover,
})}
</>
</span>
);
}

if (typeof row === 'undefined') {
return <span className={CELL_CLASS}>-</span>;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why these lines were moved below since it seems like it works the same as before with the additional && row check above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. It is a strange change and I am not sure why this was done. I have reverted it and you can check it here


/**
* when using the fields api this code is used to show top level objects
* this is used for legacy stuff like displaying products of our ecommerce dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export const UnifiedFieldListSidebarComponent: React.FC<UnifiedFieldListSidebarP
'data-test-subj':
stateService.creationOptions.dataTestSubj?.fieldListAddFieldButtonTestSubj ??
'unifiedFieldListAddField',
className: 'unifiedFieldListSidebar__addBtn',
};
const buttonAddFieldLabel = i18n.translate(
'unifiedFieldList.fieldListSidebar.addFieldButtonLabel',
Expand Down
Loading