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

[One Discover] Add summary column for logs contextual experience #192567

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
4e757a6
feat(discover): rename Document column to Summary
Sep 5, 2024
027cfdf
feat(discover): support discover services in profiles definition
Sep 6, 2024
21ca23e
refactor(discover): minor components adjustments
Sep 6, 2024
4358037
refactor(discover): resource column
Sep 6, 2024
9401f2a
feat(discover): responsive summary column
Sep 9, 2024
7c12e0b
feat(discover): custom popover
Sep 9, 2024
83c5b16
feat(discover): custom popover mvp
Sep 10, 2024
313fc72
refactor(discover): update summary conditions
Sep 11, 2024
bad95d1
refactor(discover): rename virtual column service
Sep 11, 2024
a8fb2d0
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 11, 2024
d1c1db5
Merge branch 'tonyghiani-feature/one-discover-summary-column-copy' in…
Sep 11, 2024
1acb0bc
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 11, 2024
0bbbcd8
refactor(discover): minor cleanups
Sep 11, 2024
c397fae
refactor(discover): update popover content
Sep 11, 2024
50e3000
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 12, 2024
bc6c06a
refactor(discover): apply lazy loading on summary column
Sep 12, 2024
63a5578
refactor(discover): remove cell popover
Sep 12, 2024
315a4db
refactor(discover): remove unused file
Sep 12, 2024
2c02f59
refactor(logs-explorer): switch to new summary column
Sep 12, 2024
307bbbc
refactor(logs-explorer): disable resource and content as default columns
Sep 12, 2024
5576690
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 13, 2024
b4f7759
Merge branch 'tonyghiani-feature/one-discover-summary-column' into fe…
Sep 13, 2024
bf1c501
refactor(discover): move summary column files
Sep 13, 2024
77671be
refactor(discover): align font size depending on grid params
Sep 13, 2024
63b468e
refactor(discover): fix broken tests
Sep 13, 2024
a055078
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 13, 2024
1b23a48
refactor(discover): fix i18n
Sep 13, 2024
afc9e47
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 16, 2024
6f45e83
test(discover): add basic testing for summary column
Sep 16, 2024
e479c2c
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 17, 2024
37b84af
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 17, 2024
403123a
refactor(discover): update getFieldValue and remove duplicate getFiel…
Sep 17, 2024
69c78bc
refactor(discover): minor code changes
Sep 17, 2024
3b459d6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 17, 2024
a0bf65b
refactor(discover): update checks
Sep 17, 2024
0e35022
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 17, 2024
bcf90dd
test(logs-explorer): skip tests for disabled features
Sep 17, 2024
7052b4e
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 17, 2024
4a1d21c
refactor(discover): fix conflict
Sep 17, 2024
ae6e75f
refactor(discover): skip tests for disabled features
Sep 17, 2024
d7c489b
refactor(discover): update test
Sep 17, 2024
a08552e
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 18, 2024
8bef034
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 18, 2024
97e90e5
Merge branch 'tonyghiani-feature/one-discover-summary-column' into fe…
Sep 18, 2024
ae8f145
refactor(discover): update test
Sep 18, 2024
93666a9
refactor(discover): use EuiCopy
Sep 20, 2024
b0fe55a
fix(discover): conditionally render resource block when missing for b…
Sep 20, 2024
e147b75
fix(discover): remove pre-optimization
Sep 20, 2024
e87d6a8
fix(discover): make popover wide for limited columns
Sep 20, 2024
4e0c3d4
fix(discover): pre-compute shouldShowFieldHandler once when creating …
Sep 20, 2024
7936e12
fix(discover): types and test
Sep 20, 2024
d5f2b91
fix(discover): remove profile manager singleton
Sep 20, 2024
aa06ab8
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 20, 2024
933b080
perf(discover): optimize document formatting to remove properties
Sep 20, 2024
b4f8a07
fix(discover): remove import
Sep 23, 2024
a0e5539
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 24, 2024
430cedc
refactor(discover): update styles
Sep 24, 2024
fff5e35
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 24, 2024
58ee8be
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 24, 2024
8938421
refactor(discover): update styles
Sep 24, 2024
69f3135
Merge branch 'feature/one-discover-summary-column' of github.com:tony…
Sep 24, 2024
42a4501
feat(discover): apply shared actions to summary column
Sep 24, 2024
1ba9d3a
refactor(discover): update test
Sep 24, 2024
ed9bc98
test(discover): add FT for summary column displaying
Sep 24, 2024
c01f2cc
test(discover): update FT test
Sep 24, 2024
ac22f2d
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 25, 2024
690ecfa
fix(discover): conflicts
Sep 25, 2024
a2cd794
refactor(discover): update styles and cleanup
Sep 25, 2024
a3ac8fe
refactor(discover): add popover close button
Sep 25, 2024
505dbc1
refactor(discover): remove unnecessary wrapper
Sep 25, 2024
9ff0c54
Fix default grid density and row height passed to getCellRenderers
davismcphee Sep 26, 2024
456d268
refactor(discover): change requests
Sep 26, 2024
4afb2a0
Merge pull request #2 from davismcphee/fix-default-density-and-row-he…
tonyghiani Sep 26, 2024
5bbe0a7
refactor(discover): fix imports
Sep 26, 2024
9199821
refactor(discover): remove unused property
Sep 26, 2024
1fe2ebf
refactor(discover): revert log level badge styles
Sep 27, 2024
cd0d7df
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 27, 2024
70d4bb6
Merge branch 'main' into feature/one-discover-summary-column
tonyghiani Sep 30, 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 @@ -32,19 +32,9 @@ export function getLogDocumentOverview(
const levelArray = doc.flattened[fieldConstants.LOG_LEVEL_FIELD];
const level =
Array.isArray(levelArray) && levelArray.length ? levelArray[0].toLowerCase() : levelArray;
const messageArray = doc.flattened[fieldConstants.MESSAGE_FIELD];
const message =
Array.isArray(messageArray) && messageArray.length ? messageArray[0] : messageArray;
const errorMessageArray = doc.flattened[fieldConstants.ERROR_MESSAGE_FIELD];
const errorMessage =
Array.isArray(errorMessageArray) && errorMessageArray.length
? errorMessageArray[0]
: errorMessageArray;
const eventOriginalArray = doc.flattened[fieldConstants.EVENT_ORIGINAL_FIELD];
const eventOriginal =
Array.isArray(eventOriginalArray) && eventOriginalArray.length
? eventOriginalArray[0]
: eventOriginalArray;
const message = formatField(fieldConstants.MESSAGE_FIELD);
const errorMessage = formatField(fieldConstants.ERROR_MESSAGE_FIELD);
const eventOriginal = formatField(fieldConstants.EVENT_ORIGINAL_FIELD);
const timestamp = formatField(fieldConstants.TIMESTAMP_FIELD);

// Service
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-unified-data-table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export { getTextBasedColumnsMeta } from './src/utils/get_columns_meta';
export { ROWS_HEIGHT_OPTIONS, DataGridDensity } from './src/constants';

export { JSONCodeEditorCommonMemoized } from './src/components/json_code_editor/json_code_editor_common';
export { SourceDocument } from './src/components/source_document';

export * from './src/types';
export * as columnActions from './src/components/actions/columns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const defaultProps: EuiDataGridCellPopoverElementProps = {
cellContentsElement: (<div>{'cellContentsElement'}</div>) as unknown as HTMLDivElement,
};

const renderTestComponent = () => {
const renderTestComponent = (overrideProps = {}) => {
const Renderer = getCustomCellPopoverRenderer();

render(<Renderer {...defaultProps} />);
render(<Renderer {...defaultProps} {...overrideProps} />);
};

describe('getCustomCellPopoverRenderer', () => {
Expand All @@ -41,6 +41,14 @@ describe('getCustomCellPopoverRenderer', () => {
it('should render DefaultCellPopover', () => {
renderTestComponent();

expect(setCellPopoverPropsMocks).toHaveBeenCalledWith({
panelClassName: 'unifiedDataTable__cellPopover',
});
});

it('should render a DefaultCellPopover with a wider panel for allowed columns', () => {
renderTestComponent({ columnId: '_source' });

expect(setCellPopoverPropsMocks).toHaveBeenCalledWith({
panelClassName: 'unifiedDataTable__cellPopover',
panelProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

import { EuiDataGridCellPopoverElementProps } from '@elastic/eui';
import React, { memo, useEffect } from 'react';
import { SOURCE_COLUMN } from './columns';

const FIELDS_WITH_WIDE_POPOVER = [SOURCE_COLUMN];

/*
*
Expand All @@ -23,14 +26,20 @@ export const getCustomCellPopoverRenderer = () => {
const RenderCustomCellPopoverMemoized = memo(function RenderCustomCellPopoverMemoized(
props: EuiDataGridCellPopoverElementProps
) {
const { setCellPopoverProps, DefaultCellPopover } = props;
const { columnId, setCellPopoverProps, DefaultCellPopover } = props;

useEffect(() => {
setCellPopoverProps({
const popoverProps: Parameters<typeof setCellPopoverProps>[0] = {
panelClassName: 'unifiedDataTable__cellPopover',
panelProps: { css: { maxInlineSize: 'min(75vw, 600px) !important' } },
});
}, [setCellPopoverProps]);
};

const shouldRenderWidePopover = FIELDS_WITH_WIDE_POPOVER.includes(columnId);
if (shouldRenderWidePopover) {
popoverProps.panelProps = { css: { maxInlineSize: 'min(75vw, 600px) !important' } };
}

setCellPopoverProps(popoverProps);
}, [columnId, setCellPopoverProps]);

return <DefaultCellPopover {...props} />;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ export function ContextAppContent({
const cellRenderers = useMemo(() => {
const getCellRenderers = getCellRenderersAccessor(() => ({}));
return getCellRenderers({
actions: { addFilter },
dataView,
density: DataGridDensity.COMPACT,
rowHeight: ROWS_HEIGHT_OPTIONS.single,
});
}, [getCellRenderersAccessor]);
}, [addFilter, dataView, getCellRenderersAccessor]);

const dataSource = useMemo(() => createDataSource({ dataView, query: undefined }), [dataView]);
const { filters } = useQuerySubscriber({ data: services.data });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { useContextualGridCustomisations } from '../../hooks/grid_customisations
import { useIsEsqlMode } from '../../hooks/use_is_esql_mode';
import { useAdditionalFieldGroups } from '../../hooks/sidebar/use_additional_field_groups';
import {
CellRenderersExtensionParams,
DISCOVER_CELL_ACTIONS_TRIGGER,
useAdditionalCellActions,
useProfileAccessor,
Expand Down Expand Up @@ -306,16 +307,26 @@ function DiscoverDocumentsComponent({
[dataView, onAddColumn, onAddFilter, onRemoveColumn, query, savedSearch.id, setExpandedDoc]
);

const cellRendererParams: CellRenderersExtensionParams = useMemo(
() => ({
actions: { addFilter: onAddFilter },
dataView,
density,
rowHeight,
}),
[onAddFilter, dataView, density, rowHeight]
);

const { rowAdditionalLeadingControls } = useDiscoverCustomization('data_table') || {};
const { customCellRenderer, customGridColumnsConfiguration } =
useContextualGridCustomisations({ density, rowHeight }) || {};
useContextualGridCustomisations(cellRendererParams) || {};
const additionalFieldGroups = useAdditionalFieldGroups();

const getCellRenderersAccessor = useProfileAccessor('getCellRenderers');
const cellRenderers = useMemo(() => {
const getCellRenderers = getCellRenderersAccessor(() => customCellRenderer ?? {});
return getCellRenderers({ density, rowHeight });
}, [customCellRenderer, getCellRenderersAccessor, density, rowHeight]);
return getCellRenderers(cellRendererParams);
}, [cellRendererParams, customCellRenderer, getCellRenderersAccessor]);

const documents = useObservable(stateContainer.dataState.data$.documents$);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@
*/

import { useMemo } from 'react';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { useDiscoverCustomization } from '../../../../customizations';
import { DataGridColumnsDeps, getDataGridColumnsConfiguration } from './logs';

export * from './logs';

type ContextualGridCustomizationParams = DataGridColumnsDeps['params'];
type ContextualGridCustomizationParams = DataGridColumnsDeps;

export const useContextualGridCustomisations = (params: ContextualGridCustomizationParams) => {
const { density, rowHeight } = params;
const { data } = useDiscoverServices();
// TODO / NOTE: This will eventually rely on Discover's context resolution to determine which fields
// are returned based on the data type.
const isLogsContext = useDiscoverCustomization('data_table')?.logsEnabled;

const virtualColumnsConfiguration = useMemo(() => {
if (!isLogsContext) return null;

return getDataGridColumnsConfiguration({ data, params: { density, rowHeight } });
}, [data, isLogsContext, density, rowHeight]);
return getDataGridColumnsConfiguration(params);
}, [isLogsContext, params]);

return virtualColumnsConfiguration;
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@
*/

import { SOURCE_COLUMN } from '@kbn/unified-data-table';
import { SummaryColumnFactoryDeps } from '../../../../components/data_types/logs/summary_column/summary_column';
import { getSummaryColumn } from '../../../../components/data_types/logs/summary_column';
import {
SummaryColumnGetterDeps,
getSummaryColumn,
} from '../../../../components/data_types/logs/summary_column';

export type DataGridColumnsDeps = CustomCellRendererDeps;

export const getDataGridColumnsConfiguration = ({ data, params }: DataGridColumnsDeps) => {
export const getDataGridColumnsConfiguration = (params: DataGridColumnsDeps) => {
return {
customCellRenderer: createCustomCellRenderer({ data, params }),
customCellRenderer: createCustomCellRenderer(params),
customGridColumnsConfiguration: createCustomGridColumnsConfiguration(),
};
};

type CustomCellRendererDeps = SummaryColumnFactoryDeps;
type CustomCellRendererDeps = SummaryColumnGetterDeps;

export const createCustomCellRenderer = (deps: CustomCellRendererDeps) => {
export const createCustomCellRenderer = (params: CustomCellRendererDeps) => {
return {
[SOURCE_COLUMN]: getSummaryColumn(deps),
[SOURCE_COLUMN]: getSummaryColumn(params),
};
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,30 @@ import {
EuiText,
EuiButtonIcon,
EuiTextTruncate,
EuiButtonEmpty,
EuiCopy,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { useBoolean } from '@kbn/react-hooks';
import { euiThemeVars } from '@kbn/ui-theme';
import { closeCellActionPopoverText, openCellActionPopoverAriaText } from './translations';
import { FilterInButton } from './filter_in_button';
import { FilterOutButton } from './filter_out_button';
import { CopyButton } from './copy_button';
import { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import {
actionFilterForText,
actionFilterOutText,
closeCellActionPopoverText,
copyValueAriaText,
copyValueText,
filterForText,
filterOutText,
openCellActionPopoverAriaText,
} from './translations';

const codeFontCSS = css`
font-family: ${euiThemeVars.euiCodeFontFamily};
`;

interface CellActionsPopoverProps {
onFilter?: DocViewFilterFn;
/* ECS mapping for the key */
property: string;
/* Value for the mapping, which will be displayed */
Expand All @@ -49,13 +59,20 @@ interface CellActionsPopoverProps {
}

export function CellActionsPopover({
tonyghiani marked this conversation as resolved.
Show resolved Hide resolved
onFilter,
property,
value,
renderValue,
renderPopoverTrigger,
}: CellActionsPopoverProps) {
const [isPopoverOpen, { toggle: togglePopover, off: closePopover }] = useBoolean(false);

const makeFilterHandlerByOperator = (operator: '+' | '-') => () => {
if (onFilter) {
onFilter(property, value, operator);
}
};

const popoverTriggerProps = {
onClick: togglePopover,
onClickAriaLabel: openCellActionPopoverAriaText,
Expand Down Expand Up @@ -94,30 +111,63 @@ export function CellActionsPopover({
</EuiFlexGroup>
<EuiPopoverFooter>
<EuiFlexGroup responsive={false} gutterSize="s" wrap={true}>
<FilterInButton value={value} property={property} />
<FilterOutButton value={value} property={property} />
<EuiButtonEmpty
key="addToFilterAction"
size="s"
iconType="plusInCircle"
aria-label={actionFilterForText(value)}
onClick={makeFilterHandlerByOperator('+')}
data-test-subj={`dataTableCellAction_addToFilterAction_${property}`}
>
{filterForText}
</EuiButtonEmpty>
<EuiButtonEmpty
key="removeFromFilterAction"
size="s"
iconType="minusInCircle"
aria-label={actionFilterOutText(value)}
onClick={makeFilterHandlerByOperator('-')}
data-test-subj={`dataTableCellAction_removeFromFilterAction_${property}`}
>
{filterOutText}
</EuiButtonEmpty>
</EuiFlexGroup>
</EuiPopoverFooter>
<EuiPopoverFooter>
<CopyButton value={value} property={property} />
<EuiCopy textToCopy={value}>
{(copy) => (
<EuiButtonEmpty
key="copyToClipboardAction"
size="s"
iconType="copyClipboard"
aria-label={copyValueAriaText(property)}
onClick={copy}
data-test-subj={`dataTableCellAction_copyToClipboardAction_${property}`}
>
{copyValueText}
</EuiButtonEmpty>
)}
</EuiCopy>
</EuiPopoverFooter>
</EuiPopover>
);
}

export interface FieldBadgeWithActionsProps
extends Pick<CellActionsPopoverProps, 'property' | 'value' | 'renderValue'> {
extends Pick<CellActionsPopoverProps, 'onFilter' | 'property' | 'value' | 'renderValue'> {
icon?: EuiBadgeProps['iconType'];
}

export function FieldBadgeWithActions({
icon,
onFilter,
property,
renderValue,
value,
}: FieldBadgeWithActionsProps) {
return (
<CellActionsPopover
onFilter={onFilter}
property={property}
value={value}
renderValue={renderValue}
Expand Down

This file was deleted.

Loading