Skip to content

Commit c05e189

Browse files
authored
[8.19] [Data Discovery] Remove SO client usages (elastic#224495) (elastic#224978)
# Backport This will backport the following commits from `main` to `8.19`: - [[Data Discovery] Remove SO client usages (elastic#224495)](elastic#224495) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Davis McPhee","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-23T22:51:27Z","message":"[Data Discovery] Remove SO client usages (elastic#224495)\n\n## Summary\n\nWhile checking out our remaining browser SO client usages, I realized it\nwould be _really_ easy to get rid of them. This PR does that.\n\nResolves elastic#224357.\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"21a288a097ea0b5329ea6786295d49e5100bfa89","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:DataDiscovery","backport:version","v9.1.0","v8.19.0"],"title":"[Data Discovery] Remove SO client usages","number":224495,"url":"https://github.com/elastic/kibana/pull/224495","mergeCommit":{"message":"[Data Discovery] Remove SO client usages (elastic#224495)\n\n## Summary\n\nWhile checking out our remaining browser SO client usages, I realized it\nwould be _really_ easy to get rid of them. This PR does that.\n\nResolves elastic#224357.\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"21a288a097ea0b5329ea6786295d49e5100bfa89"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224495","number":224495,"mergeCommit":{"message":"[Data Discovery] Remove SO client usages (elastic#224495)\n\n## Summary\n\nWhile checking out our remaining browser SO client usages, I realized it\nwould be _really_ easy to get rid of them. This PR does that.\n\nResolves elastic#224357.\n\n### Checklist\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"21a288a097ea0b5329ea6786295d49e5100bfa89"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
1 parent 998ad61 commit c05e189

File tree

6 files changed

+18
-38
lines changed

6 files changed

+18
-38
lines changed

examples/discover_customization_examples/kibana.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"discover",
1313
"embeddable",
1414
"kibanaUtils",
15-
"data"
15+
"data",
16+
"savedSearch"
1617
]
1718
}
1819
}

examples/discover_customization_examples/public/plugin.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import { Route, Router, Routes } from '@kbn/shared-ux-router';
2525
import { I18nProvider } from '@kbn/i18n-react';
2626
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
2727
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
28+
import { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public';
29+
import type { SOWithMetadata } from '@kbn/content-management-utils';
30+
import type { SavedSearchAttributes } from '@kbn/saved-search-plugin/common';
2831
import image from './discover_customization_examples.png';
2932

3033
export interface DiscoverCustomizationExamplesSetupPlugins {
@@ -35,6 +38,7 @@ export interface DiscoverCustomizationExamplesSetupPlugins {
3538
export interface DiscoverCustomizationExamplesStartPlugins {
3639
discover: DiscoverStart;
3740
data: DataPublicPluginStart;
41+
savedSearch: SavedSearchPublicPluginStart;
3842
}
3943

4044
const PLUGIN_ID = 'discoverCustomizationExamples';
@@ -112,15 +116,13 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
112116
const togglePopover = () => setIsPopoverOpen((open) => !open);
113117
const closePopover = () => setIsPopoverOpen(false);
114118
const [savedSearches, setSavedSearches] = useState<
115-
Array<SimpleSavedObject<{ title: string }>>
119+
Array<SOWithMetadata<SavedSearchAttributes>>
116120
>([]);
117121

118122
useEffect(() => {
119-
core.savedObjects.client
120-
.find<{ title: string }>({ type: 'search' })
121-
.then((response) => {
122-
setSavedSearches(response.savedObjects);
123-
});
123+
plugins.savedSearch.getAll().then((response) => {
124+
setSavedSearches(response);
125+
});
124126
}, []);
125127

126128
const currentSavedSearch = useObservable(
@@ -154,7 +156,7 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
154156
id: 0,
155157
title: 'Saved logs views',
156158
items: savedSearches.map((savedSearch) => ({
157-
name: savedSearch.get('title'),
159+
name: savedSearch.attributes.title,
158160
onClick: () => stateContainer.actions.onOpenSavedSearch(savedSearch.id),
159161
icon: savedSearch.id === currentSavedSearch.id ? 'check' : 'empty',
160162
'data-test-subj': `logsViewSelectorOption-${savedSearch.attributes.title.replace(

examples/discover_customization_examples/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"@kbn/i18n-react",
1414
"@kbn/react-kibana-context-theme",
1515
"@kbn/data-plugin",
16+
"@kbn/saved-search-plugin",
17+
"@kbn/content-management-utils",
1618
],
1719
"exclude": ["target/**/*"]
1820
}

src/platform/plugins/shared/discover/public/application/main/state_management/discover_state.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -398,32 +398,6 @@ describe('Test discover state actions', () => {
398398
discoverServiceMock.data.search.searchSource.create = jest
399399
.fn()
400400
.mockReturnValue(savedSearchMock.searchSource);
401-
discoverServiceMock.core.savedObjects.client.resolve = jest.fn().mockReturnValue({
402-
saved_object: {
403-
attributes: {
404-
kibanaSavedObjectMeta: {
405-
searchSourceJSON:
406-
'{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}',
407-
},
408-
title: 'The saved search that will save the world',
409-
sort: [],
410-
columns: ['test123'],
411-
description: 'description',
412-
hideChart: false,
413-
},
414-
id: 'the-saved-search-id',
415-
type: 'search',
416-
references: [
417-
{
418-
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
419-
id: 'the-data-view-id',
420-
type: 'index-pattern',
421-
},
422-
],
423-
namespaces: ['default'],
424-
},
425-
outcome: 'exactMatch',
426-
});
427401
});
428402

429403
afterEach(() => {

src/platform/plugins/shared/saved_search/public/services/saved_searches/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
*/
99

1010
import type { Reference } from '@kbn/content-management-utils';
11-
import type { ResolvedSimpleSavedObject } from '@kbn/core/public';
11+
import type { SavedObjectsResolveResponse } from '@kbn/core-saved-objects-api-server';
1212
import type { SavedSearch as SavedSearchCommon, SavedSearchAttributes } from '../../../common';
1313

1414
/** @public **/
1515
export interface SavedSearch extends SavedSearchCommon {
1616
sharingSavedObjectProps?: {
17-
outcome?: ResolvedSimpleSavedObject['outcome'];
18-
aliasTargetId?: ResolvedSimpleSavedObject['alias_target_id'];
19-
aliasPurpose?: ResolvedSimpleSavedObject['alias_purpose'];
17+
outcome?: SavedObjectsResolveResponse['outcome'];
18+
aliasTargetId?: SavedObjectsResolveResponse['alias_target_id'];
19+
aliasPurpose?: SavedObjectsResolveResponse['alias_purpose'];
2020
errorJSON?: string;
2121
};
2222
}

src/platform/plugins/shared/saved_search/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@kbn/utility-types",
2929
"@kbn/search-types",
3030
"@kbn/unified-data-table",
31+
"@kbn/core-saved-objects-api-server",
3132
],
3233
"exclude": ["target/**/*"]
3334
}

0 commit comments

Comments
 (0)