mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[Data Discovery] Remove SO client usages (#224495)
## Summary While checking out our remaining browser SO client usages, I realized it would be _really_ easy to get rid of them. This PR does that. Resolves #224357. ### 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) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b929ec2efc
commit
21a288a097
6 changed files with 18 additions and 38 deletions
|
@ -12,7 +12,8 @@
|
||||||
"discover",
|
"discover",
|
||||||
"embeddable",
|
"embeddable",
|
||||||
"kibanaUtils",
|
"kibanaUtils",
|
||||||
"data"
|
"data",
|
||||||
|
"savedSearch"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ import { Route, Router, Routes } from '@kbn/shared-ux-router';
|
||||||
import { I18nProvider } from '@kbn/i18n-react';
|
import { I18nProvider } from '@kbn/i18n-react';
|
||||||
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
|
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
|
||||||
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||||
|
import { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public';
|
||||||
|
import type { SOWithMetadata } from '@kbn/content-management-utils';
|
||||||
|
import type { SavedSearchAttributes } from '@kbn/saved-search-plugin/common';
|
||||||
import image from './discover_customization_examples.png';
|
import image from './discover_customization_examples.png';
|
||||||
|
|
||||||
export interface DiscoverCustomizationExamplesSetupPlugins {
|
export interface DiscoverCustomizationExamplesSetupPlugins {
|
||||||
|
@ -35,6 +38,7 @@ export interface DiscoverCustomizationExamplesSetupPlugins {
|
||||||
export interface DiscoverCustomizationExamplesStartPlugins {
|
export interface DiscoverCustomizationExamplesStartPlugins {
|
||||||
discover: DiscoverStart;
|
discover: DiscoverStart;
|
||||||
data: DataPublicPluginStart;
|
data: DataPublicPluginStart;
|
||||||
|
savedSearch: SavedSearchPublicPluginStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PLUGIN_ID = 'discoverCustomizationExamples';
|
const PLUGIN_ID = 'discoverCustomizationExamples';
|
||||||
|
@ -112,14 +116,12 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
|
||||||
const togglePopover = () => setIsPopoverOpen((open) => !open);
|
const togglePopover = () => setIsPopoverOpen((open) => !open);
|
||||||
const closePopover = () => setIsPopoverOpen(false);
|
const closePopover = () => setIsPopoverOpen(false);
|
||||||
const [savedSearches, setSavedSearches] = useState<
|
const [savedSearches, setSavedSearches] = useState<
|
||||||
Array<SimpleSavedObject<{ title: string }>>
|
Array<SOWithMetadata<SavedSearchAttributes>>
|
||||||
>([]);
|
>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
core.savedObjects.client
|
plugins.savedSearch.getAll().then((response) => {
|
||||||
.find<{ title: string }>({ type: 'search' })
|
setSavedSearches(response);
|
||||||
.then((response) => {
|
|
||||||
setSavedSearches(response.savedObjects);
|
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -154,7 +156,7 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
|
||||||
id: 0,
|
id: 0,
|
||||||
title: 'Saved logs views',
|
title: 'Saved logs views',
|
||||||
items: savedSearches.map((savedSearch) => ({
|
items: savedSearches.map((savedSearch) => ({
|
||||||
name: savedSearch.get('title'),
|
name: savedSearch.attributes.title,
|
||||||
onClick: () => stateContainer.actions.onOpenSavedSearch(savedSearch.id),
|
onClick: () => stateContainer.actions.onOpenSavedSearch(savedSearch.id),
|
||||||
icon: savedSearch.id === currentSavedSearch.id ? 'check' : 'empty',
|
icon: savedSearch.id === currentSavedSearch.id ? 'check' : 'empty',
|
||||||
'data-test-subj': `logsViewSelectorOption-${savedSearch.attributes.title.replace(
|
'data-test-subj': `logsViewSelectorOption-${savedSearch.attributes.title.replace(
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
"@kbn/i18n-react",
|
"@kbn/i18n-react",
|
||||||
"@kbn/react-kibana-context-theme",
|
"@kbn/react-kibana-context-theme",
|
||||||
"@kbn/data-plugin",
|
"@kbn/data-plugin",
|
||||||
|
"@kbn/saved-search-plugin",
|
||||||
|
"@kbn/content-management-utils",
|
||||||
],
|
],
|
||||||
"exclude": ["target/**/*"]
|
"exclude": ["target/**/*"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,32 +409,6 @@ describe('Discover state', () => {
|
||||||
mockServices.data.search.searchSource.create = jest
|
mockServices.data.search.searchSource.create = jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockReturnValue(savedSearchMock.searchSource);
|
.mockReturnValue(savedSearchMock.searchSource);
|
||||||
mockServices.core.savedObjects.client.resolve = jest.fn().mockReturnValue({
|
|
||||||
saved_object: {
|
|
||||||
attributes: {
|
|
||||||
kibanaSavedObjectMeta: {
|
|
||||||
searchSourceJSON:
|
|
||||||
'{"query":{"query":"","language":"kuery"},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}',
|
|
||||||
},
|
|
||||||
title: 'The saved search that will save the world',
|
|
||||||
sort: [],
|
|
||||||
columns: ['test123'],
|
|
||||||
description: 'description',
|
|
||||||
hideChart: false,
|
|
||||||
},
|
|
||||||
id: 'the-saved-search-id',
|
|
||||||
type: 'search',
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
id: 'the-data-view-id',
|
|
||||||
type: 'index-pattern',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
namespaces: ['default'],
|
|
||||||
},
|
|
||||||
outcome: 'exactMatch',
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -8,15 +8,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Reference } from '@kbn/content-management-utils';
|
import type { Reference } from '@kbn/content-management-utils';
|
||||||
import type { ResolvedSimpleSavedObject } from '@kbn/core/public';
|
import type { SavedObjectsResolveResponse } from '@kbn/core-saved-objects-api-server';
|
||||||
import type { SavedSearch as SavedSearchCommon, SavedSearchAttributes } from '../../../common';
|
import type { SavedSearch as SavedSearchCommon, SavedSearchAttributes } from '../../../common';
|
||||||
|
|
||||||
/** @public **/
|
/** @public **/
|
||||||
export interface SavedSearch extends SavedSearchCommon {
|
export interface SavedSearch extends SavedSearchCommon {
|
||||||
sharingSavedObjectProps?: {
|
sharingSavedObjectProps?: {
|
||||||
outcome?: ResolvedSimpleSavedObject['outcome'];
|
outcome?: SavedObjectsResolveResponse['outcome'];
|
||||||
aliasTargetId?: ResolvedSimpleSavedObject['alias_target_id'];
|
aliasTargetId?: SavedObjectsResolveResponse['alias_target_id'];
|
||||||
aliasPurpose?: ResolvedSimpleSavedObject['alias_purpose'];
|
aliasPurpose?: SavedObjectsResolveResponse['alias_purpose'];
|
||||||
errorJSON?: string;
|
errorJSON?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
"@kbn/utility-types",
|
"@kbn/utility-types",
|
||||||
"@kbn/search-types",
|
"@kbn/search-types",
|
||||||
"@kbn/unified-data-table",
|
"@kbn/unified-data-table",
|
||||||
|
"@kbn/core-saved-objects-api-server",
|
||||||
],
|
],
|
||||||
"exclude": ["target/**/*"]
|
"exclude": ["target/**/*"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue