mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Discover] Support overriding solutionNavId
used for root profile resolution in embeddable (#205986)
## Summary This PR adds support for overriding the `solutionNavId` used for root profile resolution within the Discover embeddable, allowing consumers to force specific root profiles. Additionally the current usages of `LazySavedSearchComponent` within Observability apps have been updated to pass `solutionNavIdOverride: 'oblt'` to ensure their embedded logs components render in logs mode as expected. Resolves #203121. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
parent
1d90b394ca
commit
13d4813151
7 changed files with 41 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
A component wrapper around Discover session embeddable. This can be used in solutions without being within a Dasboard context.
|
||||
|
||||
This can be used to render a context-aware (logs etc) "document table".
|
||||
This can be used to render a context-aware (logs etc) "document table".
|
||||
|
||||
In the past you may have used the Log Stream Component to achieve this, this component supersedes that.
|
||||
|
||||
|
@ -22,5 +22,10 @@ import { LazySavedSearchComponent } from '@kbn/saved-search-component';
|
|||
filters={optionalFilters}
|
||||
query={optionalQuery}
|
||||
timestampField={optionalTimestampFieldString}
|
||||
displayOptions={{
|
||||
solutionNavIdOverride: 'oblt',
|
||||
enableDocumentViewer: true,
|
||||
enableFilters: false,
|
||||
}}
|
||||
/>
|
||||
```
|
||||
```
|
||||
|
|
|
@ -41,6 +41,7 @@ export const SavedSearchComponent: React.FC<SavedSearchComponentProps> = (props)
|
|||
} = props;
|
||||
|
||||
const {
|
||||
solutionNavIdOverride,
|
||||
enableDocumentViewer: documentViewerEnabled = true,
|
||||
enableFilters: filtersEnabled = true,
|
||||
} = props.displayOptions ?? {};
|
||||
|
@ -75,6 +76,7 @@ export const SavedSearchComponent: React.FC<SavedSearchComponentProps> = (props)
|
|||
attributes: { ...attributes, references },
|
||||
timeRange,
|
||||
nonPersistedDisplayOptions: {
|
||||
solutionNavIdOverride,
|
||||
enableDocumentViewer: documentViewerEnabled,
|
||||
enableFilters: filtersEnabled,
|
||||
},
|
||||
|
@ -100,6 +102,7 @@ export const SavedSearchComponent: React.FC<SavedSearchComponentProps> = (props)
|
|||
index,
|
||||
query,
|
||||
searchSourceService,
|
||||
solutionNavIdOverride,
|
||||
timeRange,
|
||||
timestampField,
|
||||
]);
|
||||
|
|
|
@ -244,6 +244,31 @@ describe('saved search embeddable', () => {
|
|||
expect(resolveRootProfileSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should allow overriding the solutionNavId used to resolve the root profile', async () => {
|
||||
const resolveRootProfileSpy = jest.spyOn(
|
||||
discoverServiceMock.profilesManager,
|
||||
'resolveRootProfile'
|
||||
);
|
||||
const initialRuntimeState = {
|
||||
...getInitialRuntimeState(),
|
||||
nonPersistedDisplayOptions: {
|
||||
solutionNavIdOverride: 'search' as const,
|
||||
},
|
||||
};
|
||||
await factory.buildEmbeddable(
|
||||
initialRuntimeState,
|
||||
buildApiMock,
|
||||
uuid,
|
||||
mockedDashboardApi,
|
||||
jest.fn().mockImplementation((newApi) => newApi),
|
||||
initialRuntimeState // initialRuntimeState only contains lastSavedRuntimeState
|
||||
);
|
||||
await waitOneTick(); // wait for build to complete
|
||||
expect(resolveRootProfileSpy).toHaveBeenCalledWith({
|
||||
solutionNavId: 'search',
|
||||
});
|
||||
});
|
||||
|
||||
it('should resolve data source profile when fetching', async () => {
|
||||
const resolveDataSourceProfileSpy = jest.spyOn(
|
||||
discoverServiceMock.profilesManager,
|
||||
|
|
|
@ -69,9 +69,9 @@ export const getSearchEmbeddableFactory = ({
|
|||
},
|
||||
buildEmbeddable: async (initialState, buildApi, uuid, parentApi) => {
|
||||
/** One Discover context awareness */
|
||||
const solutionNavId = await firstValueFrom(
|
||||
discoverServices.core.chrome.getActiveSolutionNavId$()
|
||||
);
|
||||
const solutionNavId =
|
||||
initialState.nonPersistedDisplayOptions?.solutionNavIdOverride ??
|
||||
(await firstValueFrom(discoverServices.core.chrome.getActiveSolutionNavId$()));
|
||||
const { getRenderAppWrapper } = await discoverServices.profilesManager.resolveRootProfile({
|
||||
solutionNavId,
|
||||
});
|
||||
|
|
|
@ -64,6 +64,7 @@ export type SearchEmbeddableSerializedAttributes = Omit<
|
|||
// These are options that are not persisted in the saved object, but can be used by solutions
|
||||
// when utilising the SavedSearchComponent package outside of dashboard contexts.
|
||||
export interface NonPersistedDisplayOptions {
|
||||
solutionNavIdOverride?: 'oblt' | 'security' | 'search';
|
||||
enableDocumentViewer?: boolean;
|
||||
enableFilters?: boolean;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ export const LogCategoryDocumentExamplesTable: React.FC<LogCategoryDocumentExamp
|
|||
index={logsSource.indexName}
|
||||
timestampField={logsSource.timestampField}
|
||||
displayOptions={{
|
||||
solutionNavIdOverride: 'oblt',
|
||||
enableDocumentViewer: false,
|
||||
enableFilters: false,
|
||||
}}
|
||||
|
|
|
@ -95,6 +95,7 @@ export function ClassicServiceLogsStream() {
|
|||
query={query}
|
||||
height={'60vh'}
|
||||
displayOptions={{
|
||||
solutionNavIdOverride: 'oblt',
|
||||
enableDocumentViewer: true,
|
||||
enableFilters: false,
|
||||
}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue