Skip to content

Commit

Permalink
Add sample doc viewer flyout implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
davismcphee committed Sep 13, 2024
1 parent 02896c5 commit 836fdab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <GridFlyout {...props} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -46,3 +47,12 @@ export const getRenderAppWrapper: DataSourceProfileProvider['profile']['getRende
</testContext.Provider>
);
};

export const getRenderDocViewerFlyout: DataSourceProfileProvider['profile']['getRenderDocViewerFlyout'] =
() => (props) => {
return (
<EuiFlyout onClose={props.onClose}>
<pre>{JSON.stringify(props.hit, null, 2)}</pre>
</EuiFlyout>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ 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
): DataSourceProfileProvider => ({
profileId: 'logs-data-source-profile',
profile: {
getRenderAppWrapper,
getRenderDocViewerFlyout,
getRowIndicatorProvider,
getCellRenderers,
getRowAdditionalLeadingControls,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/public/context_awareness/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 836fdab

Please sign in to comment.