Skip to content

Commit

Permalink
[8.x] [Logs Overview] Add a flyout to show category document examples (
Browse files Browse the repository at this point in the history
…#194867) (#197966)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Logs Overview] Add a flyout to show category document examples
(#194867)](#194867)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kerry
Gallagher","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-24T14:49:27Z","message":"[Logs
Overview] Add a flyout to show category document examples
(#194867)\n\n## Summary\r\n\r\nImplements
https://github.com/elastic/kibana/issues/193450.\r\n\r\n## Discover
changes ⚠️ \r\n\r\nAs part of this we need to render a basic table with
the log level and\r\nsummary columns, which is technically context aware
but only in the\r\nsense we know we want it to be a logs context up
front.\r\n\r\nThe \"correct\" solution here (or at least from recent
conversations) is\r\nto use the saved search embeddable. There is
upcoming work planned to\r\nmove log stream component usages over to the
saved search embeddable.\r\nHowever, currently this isn't in a place to
just be dropped in without\r\nsome pretty extensive work. I didn't feel
comfortable doing a big push\r\non that work as a side effort to this
work, especially with a loose (if\r\npossible) 8.16 aim for
this.\r\n\r\nWhat I've done (and which isn't ideal I appreciate) is used
the start\r\ncontract of the Discover plugin to export the columns /
cells\r\npre-wrapped with the Discover services. It's not ideal in the
sense of\r\ndependencies, but technically Discover doesn't use logs
shared. I\r\nconsidered Discover shared but that's for registering
functionality for\r\nDiscover, rather than the other way
around.\r\n\r\nEventually we'll be able to remove this and convert over
to the new\r\nsolution. I'm all ears to a better solution, but there's a
big mismatch\r\nbetween the needs here and dropping in something that
exists currently.\r\nThankfully the changeset for Discover is small if
we're happy to keep\r\nthis temporarily.\r\n\r\nEdit: I've made some
notes
here:\r\nhttps://github.com/elastic/logs-dev/issues/111#issuecomment-2411096251\r\n\r\nEdit:
New package added
here:\r\nhttps://github.com/elastic/kibana/commit/c290819c1c1e1cb5a67d437cca7783c0e2302c8f\r\n\r\n##
Overview\r\n\r\nFrom a high level:\r\n\r\n- Adds a new state machine for
handling \"details\" to show in the flyout\r\n(document examples now,
plus details and a timeline later).\r\n\r\n- Hooks this up to a flyout
expanded from the categories table.\r\n\r\n- Provides linking to
Discover to view documents from the category in\r\nthe
flyout.\r\n\r\nI've also left some comments inline.\r\n\r\n## UI / UX
\r\n\r\n![Screenshot 2024-10-10 at 15
05\r\n21](https://github.com/user-attachments/assets/49b525b1-f730-4e90-9a84-05175edb8c40)\r\n\r\n\r\n![flyout_open](https://github.com/user-attachments/assets/0995b952-566b-4e09-80cf-20ad94343980)\r\n\r\n\r\n![discover_link](https://github.com/user-attachments/assets/249ef269-0105-48af-9c81-ebae1cfb1680)\r\n\r\n---------\r\n\r\nCo-authored-by:
Felix Stürmer <[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by: Felix
Stürmer <[email protected]>\r\nCo-authored-by: Julia
Rechkunova
<[email protected]>","sha":"6b63f7f6314e9c05525df32629be7ba769c6ab4c","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-logs","backport:version"],"title":"[Logs
Overview] Add a flyout to show category document examples
","number":194867,"url":"https://github.com/elastic/kibana/pull/194867","mergeCommit":{"message":"[Logs
Overview] Add a flyout to show category document examples
(#194867)\n\n## Summary\r\n\r\nImplements
https://github.com/elastic/kibana/issues/193450.\r\n\r\n## Discover
changes ⚠️ \r\n\r\nAs part of this we need to render a basic table with
the log level and\r\nsummary columns, which is technically context aware
but only in the\r\nsense we know we want it to be a logs context up
front.\r\n\r\nThe \"correct\" solution here (or at least from recent
conversations) is\r\nto use the saved search embeddable. There is
upcoming work planned to\r\nmove log stream component usages over to the
saved search embeddable.\r\nHowever, currently this isn't in a place to
just be dropped in without\r\nsome pretty extensive work. I didn't feel
comfortable doing a big push\r\non that work as a side effort to this
work, especially with a loose (if\r\npossible) 8.16 aim for
this.\r\n\r\nWhat I've done (and which isn't ideal I appreciate) is used
the start\r\ncontract of the Discover plugin to export the columns /
cells\r\npre-wrapped with the Discover services. It's not ideal in the
sense of\r\ndependencies, but technically Discover doesn't use logs
shared. I\r\nconsidered Discover shared but that's for registering
functionality for\r\nDiscover, rather than the other way
around.\r\n\r\nEventually we'll be able to remove this and convert over
to the new\r\nsolution. I'm all ears to a better solution, but there's a
big mismatch\r\nbetween the needs here and dropping in something that
exists currently.\r\nThankfully the changeset for Discover is small if
we're happy to keep\r\nthis temporarily.\r\n\r\nEdit: I've made some
notes
here:\r\nhttps://github.com/elastic/logs-dev/issues/111#issuecomment-2411096251\r\n\r\nEdit:
New package added
here:\r\nhttps://github.com/elastic/kibana/commit/c290819c1c1e1cb5a67d437cca7783c0e2302c8f\r\n\r\n##
Overview\r\n\r\nFrom a high level:\r\n\r\n- Adds a new state machine for
handling \"details\" to show in the flyout\r\n(document examples now,
plus details and a timeline later).\r\n\r\n- Hooks this up to a flyout
expanded from the categories table.\r\n\r\n- Provides linking to
Discover to view documents from the category in\r\nthe
flyout.\r\n\r\nI've also left some comments inline.\r\n\r\n## UI / UX
\r\n\r\n![Screenshot 2024-10-10 at 15
05\r\n21](https://github.com/user-attachments/assets/49b525b1-f730-4e90-9a84-05175edb8c40)\r\n\r\n\r\n![flyout_open](https://github.com/user-attachments/assets/0995b952-566b-4e09-80cf-20ad94343980)\r\n\r\n\r\n![discover_link](https://github.com/user-attachments/assets/249ef269-0105-48af-9c81-ebae1cfb1680)\r\n\r\n---------\r\n\r\nCo-authored-by:
Felix Stürmer <[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by: Felix
Stürmer <[email protected]>\r\nCo-authored-by: Julia
Rechkunova
<[email protected]>","sha":"6b63f7f6314e9c05525df32629be7ba769c6ab4c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194867","number":194867,"mergeCommit":{"message":"[Logs
Overview] Add a flyout to show category document examples
(#194867)\n\n## Summary\r\n\r\nImplements
https://github.com/elastic/kibana/issues/193450.\r\n\r\n## Discover
changes ⚠️ \r\n\r\nAs part of this we need to render a basic table with
the log level and\r\nsummary columns, which is technically context aware
but only in the\r\nsense we know we want it to be a logs context up
front.\r\n\r\nThe \"correct\" solution here (or at least from recent
conversations) is\r\nto use the saved search embeddable. There is
upcoming work planned to\r\nmove log stream component usages over to the
saved search embeddable.\r\nHowever, currently this isn't in a place to
just be dropped in without\r\nsome pretty extensive work. I didn't feel
comfortable doing a big push\r\non that work as a side effort to this
work, especially with a loose (if\r\npossible) 8.16 aim for
this.\r\n\r\nWhat I've done (and which isn't ideal I appreciate) is used
the start\r\ncontract of the Discover plugin to export the columns /
cells\r\npre-wrapped with the Discover services. It's not ideal in the
sense of\r\ndependencies, but technically Discover doesn't use logs
shared. I\r\nconsidered Discover shared but that's for registering
functionality for\r\nDiscover, rather than the other way
around.\r\n\r\nEventually we'll be able to remove this and convert over
to the new\r\nsolution. I'm all ears to a better solution, but there's a
big mismatch\r\nbetween the needs here and dropping in something that
exists currently.\r\nThankfully the changeset for Discover is small if
we're happy to keep\r\nthis temporarily.\r\n\r\nEdit: I've made some
notes
here:\r\nhttps://github.com/elastic/logs-dev/issues/111#issuecomment-2411096251\r\n\r\nEdit:
New package added
here:\r\nhttps://github.com/elastic/kibana/commit/c290819c1c1e1cb5a67d437cca7783c0e2302c8f\r\n\r\n##
Overview\r\n\r\nFrom a high level:\r\n\r\n- Adds a new state machine for
handling \"details\" to show in the flyout\r\n(document examples now,
plus details and a timeline later).\r\n\r\n- Hooks this up to a flyout
expanded from the categories table.\r\n\r\n- Provides linking to
Discover to view documents from the category in\r\nthe
flyout.\r\n\r\nI've also left some comments inline.\r\n\r\n## UI / UX
\r\n\r\n![Screenshot 2024-10-10 at 15
05\r\n21](https://github.com/user-attachments/assets/49b525b1-f730-4e90-9a84-05175edb8c40)\r\n\r\n\r\n![flyout_open](https://github.com/user-attachments/assets/0995b952-566b-4e09-80cf-20ad94343980)\r\n\r\n\r\n![discover_link](https://github.com/user-attachments/assets/249ef269-0105-48af-9c81-ebae1cfb1680)\r\n\r\n---------\r\n\r\nCo-authored-by:
Felix Stürmer <[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by: Felix
Stürmer <[email protected]>\r\nCo-authored-by: Julia
Rechkunova
<[email protected]>","sha":"6b63f7f6314e9c05525df32629be7ba769c6ab4c"}}]}]
BACKPORT-->

Co-authored-by: Kerry Gallagher <[email protected]>
  • Loading branch information
kibanamachine and Kerry350 authored Oct 28, 2024
1 parent fedd197 commit c4f03ae
Show file tree
Hide file tree
Showing 71 changed files with 1,766 additions and 904 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ packages/kbn-dev-proc-runner @elastic/kibana-operations
src/plugins/dev_tools @elastic/kibana-management
packages/kbn-dev-utils @elastic/kibana-operations
examples/developer_examples @elastic/appex-sharedux
packages/kbn-discover-contextual-components @elastic/obs-ux-logs-team @elastic/kibana-data-discovery
examples/discover_customization_examples @elastic/kibana-data-discovery
x-pack/plugins/discover_enhanced @elastic/kibana-data-discovery
src/plugins/discover @elastic/kibana-data-discovery
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dataViews": "src/plugins/data_views",
"defaultNavigation": "packages/default-nav",
"devTools": "src/plugins/dev_tools",
"discover": ["src/plugins/discover", "packages/kbn-discover-utils"],
"discover": ["src/plugins/discover", "packages/kbn-discover-utils", "packages/kbn-discover-contextual-components"],
"savedSearch": "src/plugins/saved_search",
"embeddableApi": "src/plugins/embeddable",
"presentationPanel": "src/plugins/presentation_panel",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@
"@kbn/default-nav-ml": "link:packages/default-nav/ml",
"@kbn/dev-tools-plugin": "link:src/plugins/dev_tools",
"@kbn/developer-examples-plugin": "link:examples/developer_examples",
"@kbn/discover-contextual-components": "link:packages/kbn-discover-contextual-components",
"@kbn/discover-customization-examples-plugin": "link:examples/discover_customization_examples",
"@kbn/discover-enhanced-plugin": "link:x-pack/plugins/discover_enhanced",
"@kbn/discover-plugin": "link:src/plugins/discover",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-discover-contextual-components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/discover-contextual-components

Houses contextual (e.g. logs) components that are used by Discover.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export interface SmartFieldGridColumnOptions {
type: 'smart-field';
smartField: 'content' | 'resource';
fallbackFields: string[];
width?: number;
}
export * from './src';
14 changes: 14 additions & 0 deletions packages/kbn-discover-contextual-components/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-discover-contextual-components'],
};
5 changes: 5 additions & 0 deletions packages/kbn-discover-contextual-components/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-browser",
"id": "@kbn/discover-contextual-components",
"owner": ["@elastic/obs-ux-logs-team", "@elastic/kibana-data-discovery"]
}
7 changes: 7 additions & 0 deletions packages/kbn-discover-contextual-components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/discover-contextual-components",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0",
"sideEffects": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {
import { css } from '@emotion/react';
import { useBoolean } from '@kbn/react-hooks';
import { euiThemeVars } from '@kbn/ui-theme';
import { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import type { SharePluginStart } from '@kbn/share-plugin/public';
import type { CoreStart } from '@kbn/core-lifecycle-browser';
import {
actionFilterForText,
actionFilterOutText,
Expand Down Expand Up @@ -109,30 +111,32 @@ export function CellActionsPopover({
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiPopoverFooter>
<EuiFlexGroup responsive={false} gutterSize="s" wrap={true}>
<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>
{onFilter ? (
<EuiPopoverFooter>
<EuiFlexGroup responsive={false} gutterSize="s" wrap={true}>
<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>
) : null}
<EuiPopoverFooter>
<EuiCopy textToCopy={value}>
{(copy) => (
Expand All @@ -158,13 +162,21 @@ export interface FieldBadgeWithActionsProps
icon?: EuiBadgeProps['iconType'];
}

interface FieldBadgeWithActionsDependencies {
core?: CoreStart;
share?: SharePluginStart;
}

export type FieldBadgeWithActionsPropsAndDependencies = FieldBadgeWithActionsProps &
FieldBadgeWithActionsDependencies;

export function FieldBadgeWithActions({
icon,
onFilter,
property,
renderValue,
value,
}: FieldBadgeWithActionsProps) {
}: FieldBadgeWithActionsPropsAndDependencies) {
return (
<CellActionsPopover
onFilter={onFilter}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export * from './summary_column';
export * from './log_level_badge_cell/log_level_badge_cell';
export * from './service_name_badge_with_actions';
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { buildDataTableRecord, DataTableRecord } from '@kbn/discover-utils';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { getLogLevelBadgeCell } from './log_level_badge_cell';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__/data_view';
import { DataTableRecord, buildDataTableRecord } from '@kbn/discover-utils';

const renderCell = (logLevelField: string, record: DataTableRecord) => {
const LogLevelBadgeCell = getLogLevelBadgeCell(logLevelField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import type { CSSObject } from '@emotion/react';
import React from 'react';
import type { DataGridCellValueElementProps } from '@kbn/unified-data-table/src/types';
import { LogLevelBadge } from '@kbn/discover-utils';
import type { DataGridCellValueElementProps } from '@kbn/unified-data-table';

const dataTestSubj = 'logLevelBadgeCell';
const badgeCss: CSSObject = { marginTop: '-4px' };
Expand All @@ -32,3 +32,5 @@ export const getLogLevelBadgeCell =
/>
);
};

export type LogLevelBadgeCell = ReturnType<typeof getLogLevelBadgeCell>;
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ import React from 'react';
import { getRouterLinkProps } from '@kbn/router-utils';
import { EuiLink } from '@elastic/eui';
import { OBSERVABILITY_ENTITY_CENTRIC_EXPERIENCE } from '@kbn/management-settings-ids';
import { SharePublicStart } from '@kbn/share-plugin/public/plugin';
import { useDiscoverServices } from '../../../hooks/use_discover_services';
import { FieldBadgeWithActions, FieldBadgeWithActionsProps } from './cell_actions_popover';
import type { SharePublicStart } from '@kbn/share-plugin/public/plugin';
import {
FieldBadgeWithActions,
FieldBadgeWithActionsProps,
FieldBadgeWithActionsPropsAndDependencies,
} from './cell_actions_popover';

const SERVICE_ENTITY_LOCATOR = 'SERVICE_ENTITY_LOCATOR';

export function ServiceNameBadgeWithActions(props: FieldBadgeWithActionsProps) {
const { share, core } = useDiscoverServices();
const canViewApm = core.application.capabilities.apm?.show || false;
export function ServiceNameBadgeWithActions(props: FieldBadgeWithActionsPropsAndDependencies) {
const { share, core } = props;
const canViewApm = core?.application.capabilities.apm?.show || false;
const isEntityCentricExperienceSettingEnabled = canViewApm
? core.uiSettings.get(OBSERVABILITY_ENTITY_CENTRIC_EXPERIENCE)
? core?.uiSettings.get(OBSERVABILITY_ENTITY_CENTRIC_EXPERIENCE)
: false;

const derivedPropsForEntityExperience = isEntityCentricExperienceSettingEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
getLogDocumentOverview,
getMessageFieldWithFallbacks,
} from '@kbn/discover-utils';
import * as constants from '../../../../../common/data_types/logs/constants';
import { MESSAGE_FIELD } from '@kbn/discover-utils';
import { formatJsonDocumentForContent } from './utils';

interface ContentProps extends DataGridCellValueElementProps {
Expand All @@ -32,7 +32,7 @@ const LogMessage = ({
value: string;
className: string;
}) => {
const shouldRenderFieldName = field !== constants.MESSAGE_FIELD;
const shouldRenderFieldName = field !== MESSAGE_FIELD;

if (shouldRenderFieldName) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export * from './content';
export * from './resource';
export * from './summary_column';
export * from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import React from 'react';
import { EuiBadge, EuiFlexGroup } from '@elastic/eui';
import { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import { CommonProps, EuiBadge, EuiFlexGroup } from '@elastic/eui';
import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import { ResourceFieldDescriptor } from './utils';

const MAX_LIMITED_FIELDS_VISIBLE = 3;
Expand All @@ -19,6 +19,7 @@ interface ResourceProps {
/* When true, the column will render a predefined number of resources and indicates with a badge how many more we have */
limited?: boolean;
onFilter?: DocViewFilterFn;
css?: CommonProps['css'];
}

export const Resource = ({ fields, limited = false, onFilter, ...props }: ResourceProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@
*/

import React from 'react';
import { buildDataTableRecord, DataTableRecord } from '@kbn/discover-utils';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { render, screen } from '@testing-library/react';
import SummaryColumn, { SummaryColumnFactoryDeps, SummaryColumnProps } from './summary_column';
import { DataGridDensity, ROWS_HEIGHT_OPTIONS } from '@kbn/unified-data-table';
import * as constants from '../../../../../common/data_types/logs/constants';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { discoverServiceMock } from '../../../../__mocks__/services';
import * as constants from '@kbn/discover-utils/src/data_types/logs/constants';
import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
import { coreMock as corePluginMock } from '@kbn/core/public/mocks';
import { DataTableRecord, buildDataTableRecord } from '@kbn/discover-utils';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__/data_view';

const renderSummary = (
record: DataTableRecord,
opts: Partial<SummaryColumnProps & SummaryColumnFactoryDeps> = {}
) => {
render(
<KibanaContextProvider services={discoverServiceMock}>
<SummaryColumn
rowIndex={0}
colIndex={0}
columnId="_source"
isExpandable={true}
isExpanded={false}
isDetails={false}
row={record}
dataView={dataViewMock}
fieldFormats={fieldFormatsMock}
setCellProps={() => {}}
closePopover={() => {}}
density={DataGridDensity.COMPACT}
rowHeight={ROWS_HEIGHT_OPTIONS.single}
onFilter={jest.fn()}
shouldShowFieldHandler={() => true}
{...opts}
/>
</KibanaContextProvider>
<SummaryColumn
rowIndex={0}
colIndex={0}
columnId="_source"
isExpandable={true}
isExpanded={false}
isDetails={false}
row={record}
dataView={dataViewMock}
fieldFormats={fieldFormatsMock}
setCellProps={() => {}}
closePopover={() => {}}
density={DataGridDensity.COMPACT}
rowHeight={ROWS_HEIGHT_OPTIONS.single}
onFilter={jest.fn()}
shouldShowFieldHandler={() => true}
core={corePluginMock.createStart()}
share={sharePluginMock.createStartContract()}
{...opts}
/>
);
};

Expand Down
Loading

0 comments on commit c4f03ae

Please sign in to comment.