import './doc_viewer.scss' ; import React from 'react' ; import { EuiTabbedContent } from '@elastic/eui' ; import { getDocViewsRegistry } from '../../../opensearch_dashboards_services' ; import { DocViewerTab } from './doc_viewer_tab' ; import { DocView , DocViewRenderProps } from '../../doc_views/doc_views_types' ; /**
 * Rendering tabs with different views of 1 OpenSearch hit in Discover.
 * The tabs are provided by the `docs_views` registry.
 * A view can contain a React `component`, or any JS framework by using
 * a `render` function.
 */ export function DocViewer ( renderProps ) { const docViewsRegistry = getDocViewsRegistry ( ) ; const tabs = docViewsRegistry . getDocViewsSorted ( renderProps . hit ) . map ( ( { title , render , component } , idx ) => { return { id : `osd_doc_viewer_tab_${ idx }` , name : title , content : ( < DocViewerTab id = { idx } title = { title } component = { component } renderProps = { renderProps } render = { render } / > ) , } ; } ) ; if ( ! tabs . length ) { return null ; } return ( < div className = "osdDocViewer" > < EuiTabbedContent tabs = { tabs } /> < /div>); }