Skip to content

Commit

Permalink
[8.x] [Discover] Support overriding `solutionNavId` used fo…
Browse files Browse the repository at this point in the history
…r root profile resolution in embeddable (#205986) (#206525)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Discover] Support overriding `solutionNavId` used for root
profile resolution in embeddable
(#205986)](#205986)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Davis
McPhee","email":"davis.mcphee@elastic.co"},"sourceCommit":{"committedDate":"2025-01-13T22:58:37Z","message":"[Discover]
Support overriding `solutionNavId` used for root profile resolution in
embeddable (#205986)\n\n## Summary\r\n\r\nThis PR adds support for
overriding the `solutionNavId` used for root\r\nprofile resolution
within the Discover embeddable, allowing consumers to\r\nforce specific
root profiles. Additionally the current usages
of\r\n`LazySavedSearchComponent` within Observability apps have been
updated\r\nto pass `solutionNavIdOverride: 'oblt'` to ensure their
embedded logs\r\ncomponents render in logs mode as
expected.\r\n\r\nResolves #203121.\r\n\r\n### Checklist\r\n\r\n- [ ] Any
text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"13d4813151ff0c7cb549cf0d22565a1f9d46fb68","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-minor","Team:obs-ux-logs","Team:obs-ux-infra_services","Project:OneDiscover"],"title":"[Discover]
Support overriding `solutionNavId` used for root profile resolution in
embeddable","number":205986,"url":"https://github.com/elastic/kibana/pull/205986","mergeCommit":{"message":"[Discover]
Support overriding `solutionNavId` used for root profile resolution in
embeddable (#205986)\n\n## Summary\r\n\r\nThis PR adds support for
overriding the `solutionNavId` used for root\r\nprofile resolution
within the Discover embeddable, allowing consumers to\r\nforce specific
root profiles. Additionally the current usages
of\r\n`LazySavedSearchComponent` within Observability apps have been
updated\r\nto pass `solutionNavIdOverride: 'oblt'` to ensure their
embedded logs\r\ncomponents render in logs mode as
expected.\r\n\r\nResolves #203121.\r\n\r\n### Checklist\r\n\r\n- [ ] Any
text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"13d4813151ff0c7cb549cf0d22565a1f9d46fb68"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205986","number":205986,"mergeCommit":{"message":"[Discover]
Support overriding `solutionNavId` used for root profile resolution in
embeddable (#205986)\n\n## Summary\r\n\r\nThis PR adds support for
overriding the `solutionNavId` used for root\r\nprofile resolution
within the Discover embeddable, allowing consumers to\r\nforce specific
root profiles. Additionally the current usages
of\r\n`LazySavedSearchComponent` within Observability apps have been
updated\r\nto pass `solutionNavIdOverride: 'oblt'` to ensure their
embedded logs\r\ncomponents render in logs mode as
expected.\r\n\r\nResolves #203121.\r\n\r\n### Checklist\r\n\r\n- [ ] Any
text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"13d4813151ff0c7cb549cf0d22565a1f9d46fb68"}}]}]
BACKPORT-->

Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
  • Loading branch information
kibanamachine and davismcphee authored Jan 14, 2025
1 parent 56fb054 commit c45c19f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -22,5 +22,10 @@ import { LazySavedSearchComponent } from '@kbn/saved-search-component';
filters={optionalFilters}
query={optionalQuery}
timestampField={optionalTimestampFieldString}
displayOptions={{
solutionNavIdOverride: 'oblt',
enableDocumentViewer: true,
enableFilters: false,
}}
/>
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const SavedSearchComponent: React.FC<SavedSearchComponentProps> = (props)
} = props;

const {
solutionNavIdOverride,
enableDocumentViewer: documentViewerEnabled = true,
enableFilters: filtersEnabled = true,
} = props.displayOptions ?? {};
Expand Down Expand Up @@ -75,6 +76,7 @@ export const SavedSearchComponent: React.FC<SavedSearchComponentProps> = (props)
attributes: { ...attributes, references },
timeRange,
nonPersistedDisplayOptions: {
solutionNavIdOverride,
enableDocumentViewer: documentViewerEnabled,
enableFilters: filtersEnabled,
},
Expand All @@ -100,6 +102,7 @@ export const SavedSearchComponent: React.FC<SavedSearchComponentProps> = (props)
index,
query,
searchSourceService,
solutionNavIdOverride,
timeRange,
timestampField,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const LogCategoryDocumentExamplesTable: React.FC<LogCategoryDocumentExamp
index={logsSource.indexName}
timestampField={logsSource.timestampField}
displayOptions={{
solutionNavIdOverride: 'oblt',
enableDocumentViewer: false,
enableFilters: false,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function ClassicServiceLogsStream() {
query={query}
height={'60vh'}
displayOptions={{
solutionNavIdOverride: 'oblt',
enableDocumentViewer: true,
enableFilters: false,
}}
Expand Down

0 comments on commit c45c19f

Please sign in to comment.