[Discover] Split saved searches out of discover plugin (#138388)

This commit is contained in:
Joe Reuter 2022-08-12 11:19:40 +02:00 committed by GitHub
parent 945d456e71
commit fcf3b8bb21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 217 additions and 76 deletions

View file

@ -1341,7 +1341,7 @@ module.exports = {
* Discover overrides
*/
{
files: ['src/plugins/discover/**/*.{ts,tsx}'],
files: ['src/plugins/discover/**/*.{ts,tsx}', 'src/plugins/saved_search/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/ban-ts-comment': [

1
.github/CODEOWNERS vendored
View file

@ -10,6 +10,7 @@
# Data Discovery
/src/plugins/discover/ @elastic/kibana-data-discovery
/src/plugins/saved_search/ @elastic/kibana-data-discovery
/x-pack/plugins/discover_enhanced/ @elastic/kibana-data-discovery
/test/functional/apps/discover/ @elastic/kibana-data-discovery
/x-pack/plugins/graph/ @elastic/kibana-data-discovery

View file

@ -18,6 +18,7 @@
"dataViews": "src/plugins/data_views",
"devTools": "src/plugins/dev_tools",
"discover": "src/plugins/discover",
"savedSearch": "src/plugins/saved_search",
"embeddableApi": "src/plugins/embeddable",
"embeddableExamples": "examples/embeddable_examples",
"esQuery": "packages/kbn-es-query/src",

View file

@ -246,6 +246,10 @@ Content is fetched from the remote (https://feeds.elastic.co) once a day, with p
oss plugins.
|{kib-repo}blob/{branch}/src/plugins/saved_search/README.md[savedSearch]
|Contains the saved search saved object definition and helpers.
|{kib-repo}blob/{branch}/src/plugins/screenshot_mode/README.md[screenshotMode]
|The service exposed by this plugin informs consumers whether they should optimize for non-interactivity. In this way plugins can avoid loading unnecessary code, data or other services.

View file

@ -120,6 +120,7 @@ pageLoadAssetSize:
controls: 40000
expressionPartitionVis: 26338
sharedUX: 16225
savedSearch: 16225
ux: 20784
sessionView: 77750
cloudSecurityPosture: 19109

View file

@ -18,7 +18,7 @@
"expressions"
],
"optionalPlugins": ["home", "share", "usageCollection", "spaces", "triggersActionsUi"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "dataViews", "unifiedSearch"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "dataViews", "unifiedSearch", "savedSearch"],
"extraPublicDirs": ["common"],
"owner": {
"name": "Data Discovery",

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { SavedSearch } from '../services/saved_searches';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { createSearchSourceMock } from '@kbn/data-plugin/public/mocks';
import { dataViewMock } from './data_view';
import { dataViewWithTimefieldMock } from './data_view_with_timefield';

View file

@ -18,8 +18,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { HitsCounter } from '../hits_counter';
import { SavedSearch } from '../../../../services/saved_searches';
import { GetStateReturn } from '../../services/discover_state';
import { DiscoverHistogram } from './histogram';
import { DataCharts$, DataTotalHits$ } from '../../hooks/use_saved_search';

View file

@ -17,9 +17,9 @@ import {
IEmbeddable,
isErrorEmbeddable,
} from '@kbn/embeddable-plugin/public';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { FIELD_STATISTICS_LOADED } from './constants';
import type { SavedSearch } from '../../../../services/saved_searches';
import type { GetStateReturn } from '../../services/discover_state';
import { AvailableFields$, DataRefetch$ } from '../../hooks/use_saved_search';

View file

@ -15,6 +15,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types';
import { DiscoverGrid } from '../../../../components/discover_grid/discover_grid';
@ -27,7 +28,6 @@ import {
HIDE_ANNOUNCEMENTS,
} from '../../../../../common';
import { useColumns } from '../../../../hooks/use_data_grid_columns';
import { SavedSearch } from '../../../../services/saved_searches';
import { DataDocuments$, DataDocumentsMsg, RecordRawType } from '../../hooks/use_saved_search';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { useDataState } from '../../hooks/use_data_state';

View file

@ -42,12 +42,12 @@ import { useColumns } from '../../../../hooks/use_data_grid_columns';
import { DiscoverDocuments } from './discover_documents';
import { FetchStatus } from '../../../types';
import { useDataState } from '../../hooks/use_data_state';
import { SavedSearchURLConflictCallout } from '../../../../services/saved_searches';
import { FieldStatisticsTable } from '../field_stats_table';
import { VIEW_MODE } from '../../../../components/view_mode_toggle';
import { DOCUMENTS_VIEW_CLICK, FIELD_STATISTICS_VIEW_CLICK } from '../field_stats_table/constants';
import { hasActiveFilter } from './utils';
import { getRawRecordType } from '../../utils/get_raw_record_type';
import { SavedSearchURLConflictCallout } from '../../../../components/saved_search_url_conflict_callout/saved_search_url_conflict_callout';
/**
* Local storage key for sidebar persistence state

View file

@ -11,10 +11,10 @@ import type { SavedObject } from '@kbn/data-plugin/public';
import type { DataView, DataViewAttributes } from '@kbn/data-views-plugin/public';
import { ISearchSource } from '@kbn/data-plugin/public';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { DataTableRecord } from '../../../../types';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { DataRefetch$, SavedSearchData } from '../../hooks/use_saved_search';
import { SavedSearch } from '../../../../services/saved_searches';
export interface DiscoverLayoutProps {
dataView: DataView;

View file

@ -11,10 +11,10 @@ import type { ISearchSource } from '@kbn/data-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { unhashUrl } from '@kbn/kibana-utils-plugin/public';
import type { TopNavMenuData } from '@kbn/navigation-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { showOpenSearchPanel } from './show_open_search_panel';
import { getSharingData, showPublicUrlSwitch } from '../../../../utils/get_sharing_data';
import { DiscoverServices } from '../../../../build_services';
import { SavedSearch } from '../../../../services/saved_searches';
import { onSaveSearch } from './on_save_search';
import { GetStateReturn } from '../../services/discover_state';
import { openOptionsPopover } from './open_options_popover';

View file

@ -10,7 +10,7 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { SavedObjectSaveModal, showSaveModal, OnSaveProps } from '@kbn/saved-objects-plugin/public';
import { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearch, SaveSavedSearchOptions } from '../../../../services/saved_searches';
import { SavedSearch, SaveSavedSearchOptions } from '@kbn/saved-search-plugin/public';
import { DiscoverServices } from '../../../../build_services';
import { GetStateReturn } from '../../services/discover_state';
import { setBreadcrumbsTitle } from '../../../../utils/breadcrumbs';

View file

@ -9,14 +9,15 @@ import React, { useCallback, useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import type { DataViewAttributes } from '@kbn/data-views-plugin/public';
import type { SavedObject } from '@kbn/data-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { DiscoverLayout } from './components/layout';
import { setBreadcrumbsTitle } from '../../utils/breadcrumbs';
import { addHelpMenuToAppChrome } from '../../components/help_menu/help_menu_util';
import { useDiscoverState } from './hooks/use_discover_state';
import { useUrl } from './hooks/use_url';
import { SavedSearch, useSavedSearchAliasMatchRedirect } from '../../services/saved_searches';
import { useDiscoverServices } from '../../hooks/use_discover_services';
import { DataTableRecord } from '../../types';
import { useSavedSearchAliasMatchRedirect } from '../../hooks/saved_search_alias_match_redirect';
const DiscoverLayoutMemoized = React.memo(DiscoverLayout);

View file

@ -23,7 +23,7 @@ import {
SavedSearch,
getSavedSearch,
getSavedSearchFullPathUrl,
} from '../../services/saved_searches';
} from '@kbn/saved-search-plugin/public';
import { getState } from './services/discover_state';
import { loadDataView, resolveDataView } from './utils/resolve_data_view';
import { DiscoverMainApp } from './discover_main_app';

View file

@ -16,10 +16,10 @@ import {
AggregateQuery,
Query,
} from '@kbn/es-query';
import { SavedSearch, getSavedSearch } from '@kbn/saved-search-plugin/public';
import { getState } from '../services/discover_state';
import { getStateDefaults } from '../utils/get_state_defaults';
import { DiscoverServices } from '../../../build_services';
import { SavedSearch, getSavedSearch } from '../../../services/saved_searches';
import { loadDataView } from '../utils/resolve_data_view';
import { useSavedSearch as useSavedSearchData, DataDocumentsMsg } from './use_saved_search';
import {

View file

@ -10,6 +10,7 @@ import { BehaviorSubject, Subject } from 'rxjs';
import type { AutoRefreshDoneFn } from '@kbn/data-plugin/public';
import { ISearchSource } from '@kbn/data-plugin/public';
import { RequestAdapter } from '@kbn/inspector-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { getRawRecordType } from '../utils/get_raw_record_type';
import { DiscoverServices } from '../../../build_services';
import { DiscoverSearchSessionManager } from '../services/discover_search_session';
@ -22,7 +23,6 @@ import { fetchAll } from '../utils/fetch_all';
import { useBehaviorSubject } from './use_behavior_subject';
import { sendResetMsg } from './use_saved_search_messages';
import { getFetch$ } from '../utils/get_fetch_observable';
import { SavedSearch } from '../../../services/saved_searches';
import type { DataTableRecord } from '../../../types';
export interface SavedSearchData {

View file

@ -8,13 +8,13 @@
import { useMemo, useEffect } from 'react';
import { History } from 'history';
import { noSearchSessionStorageCapabilityMessage } from '@kbn/data-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { DiscoverSearchSessionManager } from '../services/discover_search_session';
import {
createSearchSessionRestorationDataProvider,
GetStateReturn,
} from '../services/discover_state';
import { DiscoverServices } from '../../../build_services';
import { SavedSearch } from '../../../services/saved_searches';
export function useSearchSession({
services,

View file

@ -14,7 +14,7 @@ import {
} from './discover_state';
import { createBrowserHistory, History } from 'history';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import type { SavedSearch } from '../../../services/saved_searches';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { SEARCH_FIELDS_FROM_SOURCE } from '../../../../common';
let history: History;

View file

@ -36,8 +36,8 @@ import {
syncQueryStateWithUrl,
} from '@kbn/data-plugin/public';
import { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { DiscoverGridSettings } from '../../../components/discover_grid/types';
import { SavedSearch } from '../../../services/saved_searches';
import { handleSourceColumnState } from '../../../utils/state_helpers';
import { DISCOVER_APP_LOCATOR, DiscoverAppLocatorParams } from '../../../locator';
import { VIEW_MODE } from '../../../components/view_mode_toggle';

View file

@ -9,6 +9,7 @@ import { DataPublicPluginStart, ISearchSource } from '@kbn/data-plugin/public';
import { Adapters } from '@kbn/inspector-plugin/common';
import { ReduxLikeStateContainer } from '@kbn/kibana-utils-plugin/common';
import { DataViewType } from '@kbn/data-views-plugin/public';
import type { SavedSearch, SortOrder } from '@kbn/saved-search-plugin/public';
import { getRawRecordType } from './get_raw_record_type';
import {
sendCompleteMsg,
@ -19,7 +20,6 @@ import {
sendResetMsg,
} from '../hooks/use_saved_search_messages';
import { updateSearchSource } from './update_search_source';
import type { SavedSearch, SortOrder } from '../../../services/saved_searches';
import { fetchDocuments } from './fetch_documents';
import { fetchTotalHits } from './fetch_total_hits';
import { fetchChart } from './fetch_chart';

View file

@ -10,13 +10,13 @@ import { cloneDeep, isEqual } from 'lodash';
import { IUiSettingsClient } from '@kbn/core/public';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import {
DEFAULT_COLUMNS_SETTING,
DOC_HIDE_TIME_COLUMN_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
} from '../../../../common';
import { SavedSearch } from '../../../services/saved_searches';
import { AppState } from '../services/discover_state';
import { getDefaultSort, getSortArray } from '../../../components/doc_table';

View file

@ -8,12 +8,12 @@
import { isOfAggregateQueryType } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/public';
import { SavedObjectSaveOpts } from '@kbn/saved-objects-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { saveSavedSearch } from '@kbn/saved-search-plugin/public';
import { updateSearchSource } from './update_search_source';
import { SavedSearch } from '../../../services/saved_searches';
import { AppState } from '../services/discover_state';
import type { SortOrder } from '../../../services/saved_searches';
import { DiscoverServices } from '../../../build_services';
import { saveSavedSearch } from '../../../services/saved_searches';
/**
* Helper function to update and persist the given savedSearch
*/

View file

@ -9,7 +9,7 @@
import { updateSearchSource } from './update_search_source';
import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import { dataViewMock } from '../../../__mocks__/data_view';
import type { SortOrder } from '../../../services/saved_searches';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { discoverServiceMock } from '../../../__mocks__/services';
describe('updateSearchSource', () => {

View file

@ -8,8 +8,8 @@
import { ISearchSource } from '@kbn/data-plugin/public';
import { DataViewType, DataView } from '@kbn/data-views-plugin/public';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
import { SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
import type { SortOrder } from '../../../services/saved_searches';
import { DiscoverServices } from '../../../build_services';
import { getSortForSearchSource } from '../../../components/doc_table';

View file

@ -11,9 +11,9 @@ import type { History } from 'history';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import { SavedSearchURLConflictCallout } from './saved_search_url_conflict_callout';
import type { SavedSearch } from './types';
import { spacesPluginMock } from '@kbn/spaces-plugin/public/mocks';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
describe('SavedSearchURLConflictCallout', () => {
let spaces: ReturnType<typeof spacesPluginMock.createStartContract>;

View file

@ -9,9 +9,7 @@
import { i18n } from '@kbn/i18n';
import type { History } from 'history';
import type { SpacesApi } from '@kbn/spaces-plugin/public';
import { getSavedSearchUrl } from './saved_searches_utils';
import type { SavedSearch } from './types';
import { getSavedSearchUrl, SavedSearch } from '@kbn/saved-search-plugin/public';
interface SavedSearchURLConflictCalloutProps {
savedSearch?: SavedSearch;

View file

@ -32,11 +32,11 @@ import { ISearchSource } from '@kbn/data-plugin/public';
import { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { RecordRawType } from '../application/main/hooks/use_saved_search';
import { buildDataTableRecord } from '../utils/build_data_record';
import { DataTableRecord, EsHitRecord } from '../types';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
import { SavedSearch } from '../services/saved_searches';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
import { DiscoverServices } from '../build_services';
import { SavedSearchEmbeddableComponent } from './saved_search_embeddable_component';

View file

@ -16,14 +16,14 @@ import {
import type { TimeRange } from '@kbn/es-query';
import { SearchInput, SearchOutput } from './types';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
import { SavedSearchEmbeddable } from './saved_search_embeddable';
import {
getSavedSearch,
getSavedSearchUrl,
throwErrorOnSavedSearchUrlConflict,
} from '../services/saved_searches';
} from '@kbn/saved-search-plugin/public';
import { SearchInput, SearchOutput } from './types';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
import { SavedSearchEmbeddable } from './saved_search_embeddable';
import { DiscoverServices } from '../build_services';
interface StartServices {

View file

@ -14,7 +14,7 @@ import {
} from '@kbn/embeddable-plugin/public';
import type { Filter, TimeRange, Query } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearch } from '../services/saved_searches';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { SortOrder } from '../components/doc_table/components/table_header/helpers';
export interface SearchInput extends EmbeddableInput {

View file

@ -8,7 +8,7 @@
import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import { updateSearchSource } from './update_search_source';
import { dataViewMock } from '../../__mocks__/data_view';
import type { SortOrder } from '../../services/saved_searches';
import type { SortOrder } from '@kbn/saved-search-plugin/public';
describe('updateSearchSource', () => {
const defaults = {

View file

@ -10,9 +10,9 @@ import { ApplicationStart } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { IEmbeddable, ViewMode } from '@kbn/embeddable-plugin/public';
import { Action } from '@kbn/ui-actions-plugin/public';
import { getSavedSearchUrl } from '@kbn/saved-search-plugin/public';
import { SavedSearchEmbeddable } from './saved_search_embeddable';
import { SEARCH_EMBEDDABLE_TYPE } from '../../common';
import { getSavedSearchUrl } from '../services/saved_searches';
export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH';

View file

@ -10,7 +10,7 @@ import { renderHook } from '@testing-library/react-hooks';
import type { History } from 'history';
import { useSavedSearchAliasMatchRedirect } from './saved_search_alias_match_redirect';
import type { SavedSearch } from './types';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { spacesPluginMock } from '@kbn/spaces-plugin/public/mocks';

View file

@ -10,9 +10,7 @@ import type { History } from 'history';
import { useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import type { SpacesApi } from '@kbn/spaces-plugin/public';
import { getSavedSearchUrl } from './saved_searches_utils';
import type { SavedSearch } from './types';
import { getSavedSearchUrl, SavedSearch } from '@kbn/saved-search-plugin/public';
interface SavedSearchAliasMatchRedirectProps {
savedSearch?: SavedSearch;

View file

@ -9,15 +9,6 @@
import { PluginInitializerContext } from '@kbn/core/public';
import { DiscoverPlugin } from './plugin';
export type { SavedSearch } from './services/saved_searches';
export {
getSavedSearch,
getSavedSearchFullPathUrl,
getSavedSearchUrl,
getSavedSearchUrlConflictMessage,
throwErrorOnSavedSearchUrlConflict,
} from './services/saved_searches';
export type { DiscoverSetup, DiscoverStart } from './plugin';
export function plugin(initializerContext: PluginInitializerContext) {
return new DiscoverPlugin(initializerContext);
@ -29,3 +20,16 @@ export { loadSharingDataHelpers } from './utils';
export { DISCOVER_APP_LOCATOR } from './locator';
export type { DiscoverAppLocator, DiscoverAppLocatorParams } from './locator';
// re-export types and static functions to give other plugins time to migrate away
export {
SavedSearch,
getSavedSearch,
getSavedSearchFullPathUrl,
getSavedSearchUrl,
getSavedSearchUrlConflictMessage,
throwErrorOnSavedSearchUrlConflict,
VIEW_MODE,
DiscoverGridSettings,
DiscoverGridSettingsColumn,
} from '@kbn/saved-search-plugin/public';

View file

@ -8,7 +8,7 @@
import { ChromeStart } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { SavedSearch } from '../services/saved_searches';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
export function getRootBreadcrumbs(breadcrumb?: string) {
return [

View file

@ -14,12 +14,12 @@ import type {
SerializedSearchSourceFields,
} from '@kbn/data-plugin/public';
import type { Filter } from '@kbn/es-query';
import type { SavedSearch, SortOrder } from '@kbn/saved-search-plugin/public';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
} from '../../common';
import type { SavedSearch, SortOrder } from '../services/saved_searches';
import { getSortForSearchSource } from '../components/doc_table';
import { AppState, isEqualFilters } from '../application/main/services/discover_state';

View file

@ -11,7 +11,6 @@ import type { PluginSetup as DataPluginSetup } from '@kbn/data-plugin/server';
import type { HomeServerPluginSetup } from '@kbn/home-plugin/server';
import { getUiSettings } from './ui_settings';
import { capabilitiesProvider } from './capabilities_provider';
import { getSavedSearchObjectType } from './saved_objects';
import { registerSampleData } from './sample_data';
export class DiscoverServerPlugin implements Plugin<object, object> {
@ -22,12 +21,8 @@ export class DiscoverServerPlugin implements Plugin<object, object> {
home?: HomeServerPluginSetup;
}
) {
const getSearchSourceMigrations = plugins.data.search.searchSource.getAllMigrations.bind(
plugins.data.search.searchSource
);
core.capabilities.registerProvider(capabilitiesProvider);
core.uiSettings.register(getUiSettings(core.docLinks));
core.savedObjects.registerType(getSavedSearchObjectType(getSearchSourceMigrations));
if (plugins.home) {
registerSampleData(plugins.home.sampleData);

View file

@ -8,8 +8,8 @@
import { i18n } from '@kbn/i18n';
import type { SampleDataRegistrySetup } from '@kbn/home-plugin/server';
import { getSavedSearchFullPathUrl } from '@kbn/saved-search-plugin/common';
import { APP_ICON } from '../../common';
import { getSavedSearchFullPathUrl } from '../../common/services/saved_searches';
function getDiscoverPathForSampleDataset(objId: string) {
// TODO: remove the time range from the URL query when saved search objects start supporting time range configuration

View file

@ -10,6 +10,7 @@
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../charts/tsconfig.json" },
{ "path": "../saved_search/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../expressions/tsconfig.json" },
{ "path": "../embeddable/tsconfig.json" },

View file

@ -0,0 +1,3 @@
# Saved search
Contains the saved search saved object definition and helpers.

View file

@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/src/plugins/saved_search'],
testRunner: 'jasmine2',
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/saved_search',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/src/plugins/saved_search/{common,public,server}/**/*.{js,ts,tsx}',
],
};

View file

@ -0,0 +1,16 @@
{
"id": "savedSearch",
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": [
"data"
],
"requiredBundles": ["kibanaUtils"],
"extraPublicDirs": ["common"],
"owner": {
"name": "Data Discovery",
"githubTeam": "kibana-data-discovery"
},
"description": "This plugin contains the definition and helper methods around saved searches, used by discover and visualizations."
}

View file

@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export type { SavedSearch, SaveSavedSearchOptions, SortOrder } from './services/saved_searches';
export {
getSavedSearch,
getSavedSearchFullPathUrl,
getSavedSearchUrl,
getSavedSearchUrlConflictMessage,
throwErrorOnSavedSearchUrlConflict,
saveSavedSearch,
} from './services/saved_searches';
export type {
DiscoverGridSettings,
DiscoverGridSettingsColumn,
} from './services/saved_searches/types';
export { VIEW_MODE } from './services/saved_searches/types';
export function plugin() {
return {
setup: () => {},
start: () => {},
};
}

View file

@ -13,8 +13,6 @@ export {
getSavedSearchUrlConflictMessage,
throwErrorOnSavedSearchUrlConflict,
} from './saved_searches_utils';
export { useSavedSearchAliasMatchRedirect } from './saved_search_alias_match_redirect';
export { SavedSearchURLConflictCallout } from './saved_search_url_conflict_callout';
export type { SaveSavedSearchOptions } from './save_saved_searches';
export { saveSavedSearch } from './save_saved_searches';
export { SAVED_SEARCH_TYPE } from './constants';

View file

@ -8,13 +8,10 @@
import { i18n } from '@kbn/i18n';
import type { SavedSearchAttributes, SavedSearch } from './types';
export {
getSavedSearchUrl,
getSavedSearchFullPathUrl,
} from '../../../common/services/saved_searches';
export { getSavedSearchUrl, getSavedSearchFullPathUrl } from '../../../common';
export const getSavedSearchUrlConflictMessage = async (savedSearch: SavedSearch) =>
i18n.translate('discover.savedSearchEmbeddable.legacyURLConflict.errorMessage', {
i18n.translate('savedSearch.legacyURLConflict.errorMessage', {
defaultMessage: `This search has the same URL as a legacy alias. Disable the alias to resolve this error : {json}`,
values: {
json: savedSearch.sharingSavedObjectProps?.errorJSON,

View file

@ -8,8 +8,19 @@
import type { ResolvedSimpleSavedObject } from '@kbn/core/public';
import type { ISearchSource } from '@kbn/data-plugin/public';
import { DiscoverGridSettingsColumn } from '../../components/discover_grid/types';
import { VIEW_MODE } from '../../components/view_mode_toggle';
export enum VIEW_MODE {
DOCUMENT_LEVEL = 'documents',
AGGREGATED_LEVEL = 'aggregated',
}
export interface DiscoverGridSettings {
columns?: Record<string, DiscoverGridSettingsColumn>;
}
export interface DiscoverGridSettingsColumn {
width?: number;
}
/** @internal **/
export interface SavedSearchAttributes {

View file

@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { SavedSearchServerPlugin } from './plugin';
export const plugin = () => new SavedSearchServerPlugin();

View file

@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { CoreSetup, CoreStart, Plugin } from '@kbn/core/server';
import type { PluginSetup as DataPluginSetup } from '@kbn/data-plugin/server';
import { getSavedSearchObjectType } from './saved_objects';
export class SavedSearchServerPlugin implements Plugin<object, object> {
public setup(
core: CoreSetup,
plugins: {
data: DataPluginSetup;
}
) {
const getSearchSourceMigrations = plugins.data.search.searchSource.getAllMigrations.bind(
plugins.data.search.searchSource
);
core.savedObjects.registerType(getSavedSearchObjectType(getSearchSourceMigrations));
return {};
}
public start(core: CoreStart) {
return {};
}
public stop() {}
}

View file

@ -0,0 +1,21 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
"../../../typings/**/*",
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../../../x-pack/plugins/spaces/tsconfig.json" }
]
}

View file

@ -19,7 +19,7 @@
"dataViewEditor"
],
"optionalPlugins": ["home", "share", "spaces", "savedObjectsTaggingOss"],
"requiredBundles": ["kibanaUtils", "discover", "kibanaReact"],
"requiredBundles": ["kibanaUtils", "savedSearch", "kibanaReact"],
"extraPublicDirs": ["common/constants", "common/utils", "common/expression_functions"],
"owner": {
"name": "Vis Editors",

View file

@ -26,7 +26,7 @@ import {
getSavedSearch,
SavedSearch,
throwErrorOnSavedSearchUrlConflict,
} from '@kbn/discover-plugin/public';
} from '@kbn/saved-search-plugin/public';
import { PersistedState } from './persisted_state';
import {
getTypes,

View file

@ -37,7 +37,7 @@ import type { UrlForwardingStart } from '@kbn/url-forwarding-plugin/public';
import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public';
import type { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import type { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plugin/public';
import type { SavedSearch } from '@kbn/discover-plugin/public';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import type {
Vis,
VisualizeEmbeddableContract,

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { getSavedSearch } from '@kbn/discover-plugin/public';
import { getSavedSearch } from '@kbn/saved-search-plugin/public';
import type { VisualizeInput, VisSavedObject, Vis, VisParams } from '../..';
import {
getVisualizationInstance,
@ -38,7 +38,7 @@ jest.mock('../../vis_async', () => ({
}));
const { createVisAsync } = jest.requireMock('../../vis_async');
jest.mock('@kbn/discover-plugin/public', () => ({
jest.mock('@kbn/saved-search-plugin/public', () => ({
getSavedSearch: jest.fn().mockResolvedValue({
id: 'savedSearch',
title: 'savedSearchTitle',

View file

@ -13,7 +13,7 @@ import {
getSavedSearch,
SavedSearch,
throwErrorOnSavedSearchUrlConflict,
} from '@kbn/discover-plugin/public';
} from '@kbn/saved-search-plugin/public';
import { createVisAsync } from '../../vis_async';
import { convertToSerializedVis, getSavedVisualization } from '../../utils/saved_visualize_utils';
import {

View file

@ -24,7 +24,7 @@
{ "path": "../saved_objects_tagging_oss/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
{ "path": "../discover/tsconfig.json" },
{ "path": "../saved_search/tsconfig.json" },
{ "path": "../url_forwarding/tsconfig.json" },
{ "path": "../navigation/tsconfig.json" },
{ "path": "../home/tsconfig.json" },

View file

@ -145,6 +145,8 @@
"@kbn/saved-objects-tagging-oss-plugin/*": ["src/plugins/saved_objects_tagging_oss/*"],
"@kbn/saved-objects-plugin": ["src/plugins/saved_objects"],
"@kbn/saved-objects-plugin/*": ["src/plugins/saved_objects/*"],
"@kbn/saved-search-plugin": ["src/plugins/saved_search"],
"@kbn/saved-search-plugin/*": ["src/plugins/saved_search/*"],
"@kbn/screenshot-mode-plugin": ["src/plugins/screenshot_mode"],
"@kbn/screenshot-mode-plugin/*": ["src/plugins/screenshot_mode/*"],
"@kbn/share-plugin": ["src/plugins/share"],

View file

@ -3189,7 +3189,6 @@
"discover.savedSearch.savedObjectName": "Recherche enregistrée",
"discover.savedSearchAliasMatchRedirect.objectNoun": "Recherche {savedSearch}",
"discover.savedSearchEmbeddable.action.viewSavedSearch.displayName": "Ouvrir dans Discover",
"discover.savedSearchEmbeddable.legacyURLConflict.errorMessage": "Cette recherche a la même URL qu'un alias hérité. Désactiver l'alias pour résoudre cette erreur : {json}",
"discover.savedSearchURLConflictCallout.objectNoun": "Recherche {savedSearch}",
"discover.searchGenerationWithDescription": "Tableau généré par la recherche {searchTitle}",
"discover.searchGenerationWithDescriptionGrid": "Tableau généré par la recherche {searchTitle} ({searchDescription})",

View file

@ -3187,7 +3187,6 @@
"discover.savedSearch.savedObjectName": "保存検索",
"discover.savedSearchAliasMatchRedirect.objectNoun": "{savedSearch}検索",
"discover.savedSearchEmbeddable.action.viewSavedSearch.displayName": "Discoverで開く",
"discover.savedSearchEmbeddable.legacyURLConflict.errorMessage": "この検索にはレガシーエイリアスと同じURLがあります。このエラーを解決するには、エイリアスを無効にしてください{json}",
"discover.savedSearchURLConflictCallout.objectNoun": "{savedSearch}検索",
"discover.searchGenerationWithDescription": "検索{searchTitle}で生成されたテーブル",
"discover.searchGenerationWithDescriptionGrid": "検索{searchTitle}で生成されたテーブル({searchDescription}",

View file

@ -3190,7 +3190,6 @@
"discover.savedSearch.savedObjectName": "已保存搜索",
"discover.savedSearchAliasMatchRedirect.objectNoun": "{savedSearch} 搜索",
"discover.savedSearchEmbeddable.action.viewSavedSearch.displayName": "在 Discover 中打开",
"discover.savedSearchEmbeddable.legacyURLConflict.errorMessage": "此搜索具有与旧版别名相同的 URL。请禁用别名以解决此错误{json}",
"discover.savedSearchURLConflictCallout.objectNoun": "{savedSearch} 搜索",
"discover.searchGenerationWithDescription": "搜索 {searchTitle} 生成的表",
"discover.searchGenerationWithDescriptionGrid": "搜索 {searchTitle} 生成的表({searchDescription}",