src/platform/plugins/shared/unified_doc_viewer/README.md
This plugin contains services reliant on the plugin lifecycle for the unified doc viewer component (see @kbn/unified-doc-viewer).
Components in this package have Storybook stories to show examples.
Run yarn storybook unified_doc_viewer from the Kibana root to start the local Storybook development server.
Storybooks on main are published on build.
See the @kbn-storybook documentation for more information about Kibana integration with Storybook.
Doc viewer tabs can maintain state when users navigate between different tabs or switch between Discover tabs (as long as the flyout remains open and selected document remains the same).
Use restorable state when your custom doc viewer tab needs to:
import { createRestorableStateProvider } from '@kbn/restorable-state';
interface MyDocViewState {
expandedSections: string[];
selectedFilter: string | null;
}
const { withRestorableState, useRestorableState } = createRestorableStateProvider<MyDocViewState>();
withRestorableState and use useRestorableState for state management:export const MyDocView = withRestorableState((props) => {
const [expandedSections, setExpandedSections] = useRestorableState('expandedSections', []);
const [selectedFilter, setSelectedFilter] = useRestorableState('selectedFilter', null);
return <div></div>;
});
registry.add({
id: 'my_custom_doc_view',
title: 'My Custom View',
order: 10,
render: (props) => <MyDocView {...props} />,
});
See the example implementation in:
src/platform/plugins/shared/discover/public/context_awareness/profile_providers/example/example_data_source_profile/components/restorable_state_doc_view.tsxsrc/platform/plugins/shared/discover/public/context_awareness/profile_providers/example/example_data_source_profile/profile.tsx