From 836fdab64987d919efcee930e15ed2d9c3544c77 Mon Sep 17 00:00:00 2001 From: Davis McPhee Date: Fri, 13 Sep 2024 18:59:31 -0300 Subject: [PATCH] Add sample doc viewer flyout implementation --- .../discover_grid_flyout/discover_grid_flyout.tsx | 6 +++--- .../accessors/get_cell_renderers.tsx | 10 ++++++++++ .../common/logs_data_source_profile/profile.ts | 3 ++- src/plugins/discover/public/context_awareness/types.ts | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/components/discover_grid_flyout/discover_grid_flyout.tsx b/src/plugins/discover/public/components/discover_grid_flyout/discover_grid_flyout.tsx index b1590d5e0d172..7121831358e82 100644 --- a/src/plugins/discover/public/components/discover_grid_flyout/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/components/discover_grid_flyout/discover_grid_flyout.tsx @@ -43,12 +43,12 @@ export interface DiscoverGridFlyoutProps { * Flyout displaying an expanded Elasticsearch document */ export function DiscoverGridFlyout(props: DiscoverGridFlyoutProps) { - const getRenderDocViewerOverride = useProfileAccessor('getRenderDocViewerOverride', { + const getRenderDocViewerFlyout = useProfileAccessor('getRenderDocViewerFlyout', { record: props.hit, }); const GridFlyout = useMemo( - () => getRenderDocViewerOverride(DefaultDiscoverGridFlyout), - [getRenderDocViewerOverride] + () => getRenderDocViewerFlyout(DefaultDiscoverGridFlyout), + [getRenderDocViewerFlyout] ); return ; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_cell_renderers.tsx b/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_cell_renderers.tsx index c310743d249de..738a3cc5e7b18 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_cell_renderers.tsx +++ b/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_cell_renderers.tsx @@ -9,6 +9,7 @@ import React, { createContext, useContext } from 'react'; import { getFieldValue } from '@kbn/discover-utils'; +import { EuiFlyout } from '@elastic/eui'; import { LOG_LEVEL_FIELDS } from '../../../../../../common/data_types/logs/constants'; import { getLogLevelBadgeCell } from '../../../../../components/data_types/logs/log_level_badge_cell'; import type { DataSourceProfileProvider } from '../../../../profiles'; @@ -46,3 +47,12 @@ export const getRenderAppWrapper: DataSourceProfileProvider['profile']['getRende ); }; + +export const getRenderDocViewerFlyout: DataSourceProfileProvider['profile']['getRenderDocViewerFlyout'] = + () => (props) => { + return ( + +
{JSON.stringify(props.hit, null, 2)}
+
+ ); + }; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts b/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts index eb7f08b1d44a6..c3a679411789f 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts @@ -15,7 +15,7 @@ import { getRowAdditionalLeadingControls, } from './accessors'; import { extractIndexPatternFrom } from '../../extract_index_pattern_from'; -import { getRenderAppWrapper } from './accessors/get_cell_renderers'; +import { getRenderAppWrapper, getRenderDocViewerFlyout } from './accessors/get_cell_renderers'; export const createLogsDataSourceProfileProvider = ( services: ProfileProviderServices @@ -23,6 +23,7 @@ export const createLogsDataSourceProfileProvider = ( profileId: 'logs-data-source-profile', profile: { getRenderAppWrapper, + getRenderDocViewerFlyout, getRowIndicatorProvider, getCellRenderers, getRowAdditionalLeadingControls, diff --git a/src/plugins/discover/public/context_awareness/types.ts b/src/plugins/discover/public/context_awareness/types.ts index 7fe8e468b0df7..634fc26932370 100644 --- a/src/plugins/discover/public/context_awareness/types.ts +++ b/src/plugins/discover/public/context_awareness/types.ts @@ -272,5 +272,5 @@ export interface Profile { * @param props The doc viewer override props * @returns The custom doc viewer component */ - getRenderDocViewerOverride: (props: DiscoverGridFlyoutProps) => ReactElement; + getRenderDocViewerFlyout: (props: DiscoverGridFlyoutProps) => ReactElement; }