| LegacyRequest, requestSpecificBasePath: string) => void;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.irouter.handlelegacyerrors.md b/docs/development/core/server/kibana-plugin-server.irouter.handlelegacyerrors.md
index ff71f13466cf88..238424b1df1d52 100644
--- a/docs/development/core/server/kibana-plugin-server.irouter.handlelegacyerrors.md
+++ b/docs/development/core/server/kibana-plugin-server.irouter.handlelegacyerrors.md
@@ -1,13 +1,13 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IRouter](./kibana-plugin-server.irouter.md) > [handleLegacyErrors](./kibana-plugin-server.irouter.handlelegacyerrors.md)
-
-## IRouter.handleLegacyErrors property
-
-Wrap a router handler to catch and converts legacy boom errors to proper custom errors.
-
-Signature:
-
-```typescript
-handleLegacyErrors: (handler: RequestHandler
) => RequestHandler
;
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IRouter](./kibana-plugin-server.irouter.md) > [handleLegacyErrors](./kibana-plugin-server.irouter.handlelegacyerrors.md)
+
+## IRouter.handleLegacyErrors property
+
+Wrap a router handler to catch and converts legacy boom errors to proper custom errors.
+
+Signature:
+
+```typescript
+
(handler: RequestHandler
) => RequestHandler
;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md b/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md
index 23a72fc3c68b3a..4fbcf0981f1140 100644
--- a/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md
+++ b/docs/development/core/server/kibana-plugin-server.routeconfig.validate.md
@@ -1,62 +1,62 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteConfig](./kibana-plugin-server.routeconfig.md) > [validate](./kibana-plugin-server.routeconfig.validate.md)
-
-## RouteConfig.validate property
-
-A schema created with `@kbn/config-schema` that every request will be validated against.
-
-Signature:
-
-```typescript
-validate: RouteValidatorFullConfig
| false;
-```
-
-## Remarks
-
-You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`;
-
-## Example
-
-
-```ts
- import { schema } from '@kbn/config-schema';
- router.get({
- path: 'path/{id}',
- validate: {
- params: schema.object({
- id: schema.string(),
- }),
- query: schema.object({...}),
- body: schema.object({...}),
- },
-},
-(context, req, res,) {
- req.params; // type Readonly<{id: string}>
- console.log(req.params.id); // value
-});
-
-router.get({
- path: 'path/{id}',
- validate: false, // handler has no access to params, query, body values.
-},
-(context, req, res,) {
- req.params; // type Readonly<{}>;
- console.log(req.params.id); // undefined
-});
-
-router.get({
- path: 'path/{id}',
- validate: {
- // handler has access to raw non-validated params in runtime
- params: schema.object({}, { allowUnknowns: true })
- },
-},
-(context, req, res,) {
- req.params; // type Readonly<{}>;
- console.log(req.params.id); // value
- myValidationLibrary.validate({ params: req.params });
-});
-
-```
-
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteConfig](./kibana-plugin-server.routeconfig.md) > [validate](./kibana-plugin-server.routeconfig.validate.md)
+
+## RouteConfig.validate property
+
+A schema created with `@kbn/config-schema` that every request will be validated against.
+
+Signature:
+
+```typescript
+RouteValidatorFullConfig
| false;
+```
+
+## Remarks
+
+You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`;
+
+## Example
+
+
+```ts
+ import { schema } from '@kbn/config-schema';
+ router.get({
+ path: 'path/{id}',
+ validate: {
+ params: schema.object({
+ id: schema.string(),
+ }),
+ query: schema.object({...}),
+ body: schema.object({...}),
+ },
+},
+(context, req, res,) {
+ req.params; // type Readonly<{id: string}>
+ console.log(req.params.id); // value
+});
+
+router.get({
+ path: 'path/{id}',
+ validate: false, // handler has no access to params, query, body values.
+},
+(context, req, res,) {
+ req.params; // type Readonly<{}>;
+ console.log(req.params.id); // undefined
+});
+
+router.get({
+ path: 'path/{id}',
+ validate: {
+ // handler has access to raw non-validated params in runtime
+ params: schema.object({}, { allowUnknowns: true })
+ },
+},
+(context, req, res,) {
+ req.params; // type Readonly<{}>;
+ console.log(req.params.id); // value
+ myValidationLibrary.validate({ params: req.params });
+});
+
+```
+
diff --git a/docs/development/core/server/kibana-plugin-server.routevalidationerror._constructor_.md b/docs/development/core/server/kibana-plugin-server.routevalidationerror._constructor_.md
index 551e13faaf1542..31dc6ceb919952 100644
--- a/docs/development/core/server/kibana-plugin-server.routevalidationerror._constructor_.md
+++ b/docs/development/core/server/kibana-plugin-server.routevalidationerror._constructor_.md
@@ -1,21 +1,21 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) > [(constructor)](./kibana-plugin-server.routevalidationerror._constructor_.md)
-
-## RouteValidationError.(constructor)
-
-Constructs a new instance of the `RouteValidationError` class
-
-Signature:
-
-```typescript
-constructor(error: Error | string, path?: string[]);
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| error | Error | string
| |
-| path | string[]
| |
-
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) > [(constructor)](./kibana-plugin-server.routevalidationerror._constructor_.md)
+
+## RouteValidationError.(constructor)
+
+Constructs a new instance of the `RouteValidationError` class
+
+Signature:
+
+```typescript
+constructor(error;: Error | string, path?: string[];)
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| error | Error | string
| |
+| path | string[]
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.badrequest.md b/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.badrequest.md
index 36ea6103fb352d..2462ae17943bee 100644
--- a/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.badrequest.md
+++ b/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.badrequest.md
@@ -1,13 +1,13 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) > [badRequest](./kibana-plugin-server.routevalidationresultfactory.badrequest.md)
-
-## RouteValidationResultFactory.badRequest property
-
-Signature:
-
-```typescript
-badRequest: (error: Error | string, path?: string[]) => {
- error: RouteValidationError;
- };
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) > [badRequest](./kibana-plugin-server.routevalidationresultfactory.badrequest.md)
+
+## RouteValidationResultFactory.badRequest property
+
+Signature:
+
+```typescript
+(error: Error | string, path?: string[]) => {
+ RouteValidationError;
+ };
+```
diff --git a/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.ok.md b/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.ok.md
index eca6a31bd547f5..c86ef616de1030 100644
--- a/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.ok.md
+++ b/docs/development/core/server/kibana-plugin-server.routevalidationresultfactory.ok.md
@@ -1,13 +1,13 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) > [ok](./kibana-plugin-server.routevalidationresultfactory.ok.md)
-
-## RouteValidationResultFactory.ok property
-
-Signature:
-
-```typescript
-ok: (value: T) => {
- value: T;
- };
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) > [ok](./kibana-plugin-server.routevalidationresultfactory.ok.md)
+
+## RouteValidationResultFactory.ok property
+
+Signature:
+
+```typescript
+(value: T) => {
+ T;
+ };
+```
diff --git a/docs/development/core/server/kibana-plugin-server.routevalidatoroptions.unsafe.md b/docs/development/core/server/kibana-plugin-server.routevalidatoroptions.unsafe.md
index 0406a372c4e9d7..b1c75e6dbdf67c 100644
--- a/docs/development/core/server/kibana-plugin-server.routevalidatoroptions.unsafe.md
+++ b/docs/development/core/server/kibana-plugin-server.routevalidatoroptions.unsafe.md
@@ -1,17 +1,18 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) > [unsafe](./kibana-plugin-server.routevalidatoroptions.unsafe.md)
-
-## RouteValidatorOptions.unsafe property
-
-Set the `unsafe` config to avoid running some additional internal \*safe\* validations on top of your custom validation
-
-Signature:
-
-```typescript
-unsafe?: {
- params?: boolean;
- query?: boolean;
- body?: boolean;
- };
-```
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) > [unsafe](./kibana-plugin-server.routevalidatoroptions.unsafe.md)
+
+## RouteValidatorOptions.unsafe property
+
+Set the `unsafe` config to avoid running some additional internal \*safe\* validations on top of your custom validation
+
+Signature:
+
+```typescript
+unsafe?: {
+ params?: boolean;
+ query?: boolean;
+ body?: boolean;
+ }
+
+```
diff --git a/src/legacy/core_plugins/data/public/index.ts b/src/legacy/core_plugins/data/public/index.ts
index c9ce825f3596e6..09881c00c63b6e 100644
--- a/src/legacy/core_plugins/data/public/index.ts
+++ b/src/legacy/core_plugins/data/public/index.ts
@@ -30,9 +30,16 @@ export function plugin() {
export { DataStart };
export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns';
-export { SavedQuery, SavedQueryTimeFilter } from '../../../../plugins/data/public';
+export { EsQuerySortValue, FetchOptions, ISearchSource, SortDirection } from './search/types';
+export { SearchSourceFields } from './search/types';
+export {
+ SavedQueryAttributes,
+ SavedQuery,
+ SavedQueryTimeFilter,
+} from '../../../../plugins/data/public';
/** @public static code */
export * from '../common';
export { FilterStateManager } from './filter/filter_manager';
export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns';
+export { getRequestInspectorStats, getResponseInspectorStats } from './search';
diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts
index 676904faf6f2ff..893e477b38583d 100644
--- a/src/legacy/core_plugins/data/public/plugin.ts
+++ b/src/legacy/core_plugins/data/public/plugin.ts
@@ -18,10 +18,16 @@
*/
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
+import { SearchService, SearchStart } from './search';
import { DataPublicPluginStart } from '../../../../plugins/data/public';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { setFieldFormats } from '../../../../plugins/data/public/services';
+import {
+ setFieldFormats,
+ setNotifications,
+ setIndexPatterns,
+ setQueryService,
+ // eslint-disable-next-line @kbn/eslint/no-restricted-paths
+} from '../../../../plugins/data/public/services';
export interface DataPluginStartDependencies {
data: DataPublicPluginStart;
@@ -32,8 +38,9 @@ export interface DataPluginStartDependencies {
*
* @public
*/
-// eslint-disable-next-line @typescript-eslint/no-empty-interface
-export interface DataStart {}
+export interface DataStart {
+ search: SearchStart;
+}
/**
* Data Plugin - public
@@ -48,13 +55,24 @@ export interface DataStart {}
*/
export class DataPlugin implements Plugin {
+ private readonly search = new SearchService();
+
public setup(core: CoreSetup) {}
public start(core: CoreStart, { data }: DataPluginStartDependencies): DataStart {
// This is required for when Angular code uses Field and FieldList.
setFieldFormats(data.fieldFormats);
- return {};
+ setQueryService(data.query);
+ setIndexPatterns(data.indexPatterns);
+ setFieldFormats(data.fieldFormats);
+ setNotifications(core.notifications);
+
+ return {
+ search: this.search.start(core),
+ };
}
- public stop() {}
+ public stop() {
+ this.search.stop();
+ }
}
diff --git a/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts b/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts
index c94d35d1f7f2a5..4ec4dbd7f88d69 100644
--- a/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts
+++ b/src/legacy/core_plugins/data/public/search/expressions/esaggs.ts
@@ -21,43 +21,43 @@ import { get, has } from 'lodash';
import { i18n } from '@kbn/i18n';
import { AggConfigs } from 'ui/agg_types/agg_configs';
import { createFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';
-import chrome from 'ui/chrome';
-import { Query, TimeRange, esFilters } from 'src/plugins/data/public';
import {
KibanaContext,
KibanaDatatable,
ExpressionFunction,
KibanaDatatableColumn,
} from 'src/plugins/expressions/public';
-import { npStart } from 'ui/new_platform';
+import {
+ Query,
+ TimeRange,
+ esFilters,
+ getTime,
+ FilterManager,
+} from '../../../../../../plugins/data/public';
import {
SearchSource,
- SearchSourceContract,
+ ISearchSource,
getRequestInspectorStats,
getResponseInspectorStats,
} from '../../../../../ui/public/courier';
-// @ts-ignore
-import {
- FilterBarQueryFilterProvider,
- QueryFilter,
-} from '../../../../../ui/public/filter_manager/query_filter';
import { buildTabularInspectorData } from '../../../../../ui/public/inspector/build_tabular_inspector_data';
import { calculateObjectHash } from '../../../../visualizations/public';
-import { getTime } from '../../../../../ui/public/timefilter';
// @ts-ignore
import { tabifyAggResponse } from '../../../../../ui/public/agg_response/tabify/tabify';
import { PersistedState } from '../../../../../ui/public/persisted_state';
import { Adapters } from '../../../../../../plugins/inspector/public';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { getQueryService, getIndexPatterns } from '../../../../../../plugins/data/public/services';
export interface RequestHandlerParams {
- searchSource: SearchSourceContract;
+ searchSource: ISearchSource;
aggs: AggConfigs;
timeRange?: TimeRange;
query?: Query;
filters?: esFilters.Filter[];
forceFetch: boolean;
- queryFilter: QueryFilter;
+ filterManager: FilterManager;
uiState?: PersistedState;
partialRows?: boolean;
inspectorAdapters: Adapters;
@@ -90,7 +90,7 @@ const handleCourierRequest = async ({
partialRows,
metricsAtAllLevels,
inspectorAdapters,
- queryFilter,
+ filterManager,
abortSignal,
}: RequestHandlerParams) => {
// Create a new search source that inherits the original search source
@@ -216,7 +216,7 @@ const handleCourierRequest = async ({
}
inspectorAdapters.data.setTabularLoader(
- () => buildTabularInspectorData((searchSource as any).tabifiedResponse, queryFilter),
+ () => buildTabularInspectorData((searchSource as any).tabifiedResponse, filterManager),
{ returnsFormattedValues: true }
);
@@ -259,10 +259,8 @@ export const esaggs = (): ExpressionFunction
diff --git a/src/legacy/ui/public/courier/fetch/components/__snapshots__/shard_failure_table.test.tsx.snap b/src/legacy/core_plugins/data/public/search/fetch/components/__snapshots__/shard_failure_table.test.tsx.snap
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/__snapshots__/shard_failure_table.test.tsx.snap
rename to src/legacy/core_plugins/data/public/search/fetch/components/__snapshots__/shard_failure_table.test.tsx.snap
diff --git a/src/legacy/ui/public/courier/fetch/components/_shard_failure_modal.scss b/src/legacy/core_plugins/data/public/search/fetch/components/_shard_failure_modal.scss
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/_shard_failure_modal.scss
rename to src/legacy/core_plugins/data/public/search/fetch/components/_shard_failure_modal.scss
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_description.test.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description.test.tsx
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_description.test.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description.test.tsx
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_description.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description.tsx
similarity index 96%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_description.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description.tsx
index 6028a50cf9c3e4..60e0e35a0f1520 100644
--- a/src/legacy/ui/public/courier/fetch/components/shard_failure_description.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description.tsx
@@ -19,7 +19,7 @@
import React from 'react';
import { EuiCodeBlock, EuiDescriptionList, EuiSpacer } from '@elastic/eui';
import { ShardFailure } from './shard_failure_types';
-import { getFlattenedObject } from '../../../../../../legacy/utils/get_flattened_object';
+import { getFlattenedObject } from '../../../../../../../legacy/utils/get_flattened_object';
import { ShardFailureDescriptionHeader } from './shard_failure_description_header';
/**
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_description_header.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description_header.tsx
similarity index 96%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_description_header.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description_header.tsx
index ea4f33f9e914ef..947f33efa242c0 100644
--- a/src/legacy/ui/public/courier/fetch/components/shard_failure_description_header.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_description_header.tsx
@@ -35,7 +35,7 @@ export function getFailureSummaryText(failure: ShardFailure, failureDetails?: st
const displayDetails =
typeof failureDetails === 'string' ? failureDetails : getFailureSummaryDetailsText(failure);
- return i18n.translate('common.ui.courier.fetch.shardsFailedModal.failureHeader', {
+ return i18n.translate('data.search.searchSource.fetch.shardsFailedModal.failureHeader', {
defaultMessage: '{failureName} at {failureDetails}',
values: { failureName, failureDetails: displayDetails },
description: 'Summary of shard failures, e.g. "IllegalArgumentException at shard 0 node xyz"',
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_modal.test.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_modal.test.tsx
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_modal.test.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_modal.test.tsx
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_modal.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_modal.tsx
similarity index 85%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_modal.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_modal.tsx
index d028a831a6e398..65cb49c6115756 100644
--- a/src/legacy/ui/public/courier/fetch/components/shard_failure_modal.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_modal.tsx
@@ -59,15 +59,18 @@ export function ShardFailureModal({ request, response, title, onClose }: Props)
const tabs = [
{
id: 'table',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tabHeaderShardFailures', {
- defaultMessage: 'Shard failures',
- description: 'Name of the tab displaying shard failures',
- }),
+ name: i18n.translate(
+ 'data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures',
+ {
+ defaultMessage: 'Shard failures',
+ description: 'Name of the tab displaying shard failures',
+ }
+ ),
content: ,
},
{
id: 'json-request',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tabHeaderRequest', {
+ name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tabHeaderRequest', {
defaultMessage: 'Request',
description: 'Name of the tab displaying the JSON request',
}),
@@ -79,7 +82,7 @@ export function ShardFailureModal({ request, response, title, onClose }: Props)
},
{
id: 'json-response',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tabHeaderResponse', {
+ name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse', {
defaultMessage: 'Response',
description: 'Name of the tab displaying the JSON response',
}),
@@ -104,7 +107,7 @@ export function ShardFailureModal({ request, response, title, onClose }: Props)
{copy => (
@@ -112,7 +115,7 @@ export function ShardFailureModal({ request, response, title, onClose }: Props)
onClose()} fill data-test-sub="closeShardFailureModal">
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.test.mocks.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.test.mocks.tsx
similarity index 77%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.test.mocks.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.test.mocks.tsx
index b09270881cc05c..4dd4d5943fadcc 100644
--- a/src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.test.mocks.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.test.mocks.tsx
@@ -16,16 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
+
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { setOverlays } from '../../../../../../../plugins/data/public/services';
+import { OverlayStart } from 'kibana/public';
+
export const openModal = jest.fn();
-jest.doMock('ui/new_platform', () => {
- return {
- npStart: {
- core: {
- overlays: {
- openModal,
- },
- },
- },
- };
-});
+setOverlays(({
+ openModal,
+} as unknown) as OverlayStart);
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.test.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.test.tsx
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.test.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.test.tsx
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.tsx
similarity index 84%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.tsx
index b02344ce6dd728..c3ff042083473c 100644
--- a/src/legacy/ui/public/courier/fetch/components/shard_failure_open_modal_button.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_open_modal_button.tsx
@@ -17,12 +17,12 @@
* under the License.
*/
import React from 'react';
-// @ts-ignore
-import { npStart } from 'ui/new_platform';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiButton, EuiTextAlign } from '@elastic/eui';
-import { toMountPoint } from '../../../../../../plugins/kibana_react/public';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { getOverlays } from '../../../../../../../plugins/data/public/services';
+import { toMountPoint } from '../../../../../../../plugins/kibana_react/public';
import { ShardFailureModal } from './shard_failure_modal';
import { ResponseWithShardFailure, Request } from './shard_failure_types';
@@ -34,7 +34,7 @@ interface Props {
export function ShardFailureOpenModalButton({ request, response, title }: Props) {
function onClick() {
- const modal = npStart.core.overlays.openModal(
+ const modal = getOverlays().openModal(
toMountPoint(
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_table.test.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_table.test.tsx
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_table.test.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_table.test.tsx
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_table.tsx b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_table.tsx
similarity index 87%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_table.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_table.tsx
index 54de64e52f745e..5d5047631231ab 100644
--- a/src/legacy/ui/public/courier/fetch/components/shard_failure_table.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_table.tsx
@@ -44,7 +44,7 @@ export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) {
render: (item: ListItem) => {
const failureSummeryText = getFailureSummaryText(item);
const collapseLabel = i18n.translate(
- 'common.ui.courier.fetch.shardsFailedModal.tableRowCollapse',
+ 'data.search.searchSource.fetch.shardsFailedModal.tableRowCollapse',
{
defaultMessage: 'Collapse {rowDescription}',
description: 'Collapse a row of a table with failures',
@@ -53,7 +53,7 @@ export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) {
);
const expandLabel = i18n.translate(
- 'common.ui.courier.fetch.shardsFailedModal.tableRowExpand',
+ 'data.search.searchSource.fetch.shardsFailedModal.tableRowExpand',
{
defaultMessage: 'Expand {rowDescription}',
description: 'Expand a row of a table with failures',
@@ -81,7 +81,7 @@ export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) {
},
{
field: 'shard',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tableColShard', {
+ name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tableColShard', {
defaultMessage: 'Shard',
}),
sortable: true,
@@ -90,7 +90,7 @@ export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) {
},
{
field: 'index',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tableColIndex', {
+ name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tableColIndex', {
defaultMessage: 'Index',
}),
sortable: true,
@@ -98,7 +98,7 @@ export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) {
},
{
field: 'node',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tableColNode', {
+ name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tableColNode', {
defaultMessage: 'Node',
}),
sortable: true,
@@ -106,7 +106,7 @@ export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) {
},
{
field: 'reason.type',
- name: i18n.translate('common.ui.courier.fetch.shardsFailedModal.tableColReason', {
+ name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tableColReason', {
defaultMessage: 'Reason',
}),
truncateText: true,
diff --git a/src/legacy/ui/public/courier/fetch/components/shard_failure_types.ts b/src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_types.ts
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/components/shard_failure_types.ts
rename to src/legacy/core_plugins/data/public/search/fetch/components/shard_failure_types.ts
diff --git a/src/legacy/ui/public/courier/fetch/errors.ts b/src/legacy/core_plugins/data/public/search/fetch/errors.ts
similarity index 91%
rename from src/legacy/ui/public/courier/fetch/errors.ts
rename to src/legacy/core_plugins/data/public/search/fetch/errors.ts
index a2ac013915b4bb..5f5dc0452df513 100644
--- a/src/legacy/ui/public/courier/fetch/errors.ts
+++ b/src/legacy/core_plugins/data/public/search/fetch/errors.ts
@@ -17,9 +17,10 @@
* under the License.
*/
-import { SearchError } from '../../courier';
-import { KbnError } from '../../../../../plugins/kibana_utils/public';
+import { SearchError } from '../search_strategy';
+import { KbnError } from '../../../../../../plugins/kibana_utils/public';
import { SearchResponse } from '../types';
+
/**
* Request Failure - When an entire multi request fails
* @param {Error} err - the Error that came back
diff --git a/src/legacy/ui/public/courier/fetch/fetch_soon.test.ts b/src/legacy/core_plugins/data/public/search/fetch/fetch_soon.test.ts
similarity index 98%
rename from src/legacy/ui/public/courier/fetch/fetch_soon.test.ts
rename to src/legacy/core_plugins/data/public/search/fetch/fetch_soon.test.ts
index d96fb536985da0..69a343c78b1e12 100644
--- a/src/legacy/ui/public/courier/fetch/fetch_soon.test.ts
+++ b/src/legacy/core_plugins/data/public/search/fetch/fetch_soon.test.ts
@@ -19,7 +19,7 @@
import { fetchSoon } from './fetch_soon';
import { callClient } from './call_client';
-import { IUiSettingsClient } from '../../../../../core/public';
+import { IUiSettingsClient } from '../../../../../../core/public';
import { FetchHandlers, FetchOptions } from './types';
import { SearchRequest, SearchResponse } from '../types';
diff --git a/src/legacy/ui/public/courier/fetch/fetch_soon.ts b/src/legacy/core_plugins/data/public/search/fetch/fetch_soon.ts
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/fetch_soon.ts
rename to src/legacy/core_plugins/data/public/search/fetch/fetch_soon.ts
diff --git a/src/legacy/ui/public/courier/fetch/get_search_params.test.ts b/src/legacy/core_plugins/data/public/search/fetch/get_search_params.test.ts
similarity index 98%
rename from src/legacy/ui/public/courier/fetch/get_search_params.test.ts
rename to src/legacy/core_plugins/data/public/search/fetch/get_search_params.test.ts
index 76f3105d7f942e..f856aa77bf1f8e 100644
--- a/src/legacy/ui/public/courier/fetch/get_search_params.test.ts
+++ b/src/legacy/core_plugins/data/public/search/fetch/get_search_params.test.ts
@@ -18,7 +18,7 @@
*/
import { getMSearchParams, getSearchParams } from './get_search_params';
-import { IUiSettingsClient } from '../../../../../core/public';
+import { IUiSettingsClient } from '../../../../../../core/public';
function getConfigStub(config: any = {}) {
return {
diff --git a/src/legacy/ui/public/courier/fetch/get_search_params.ts b/src/legacy/core_plugins/data/public/search/fetch/get_search_params.ts
similarity index 97%
rename from src/legacy/ui/public/courier/fetch/get_search_params.ts
rename to src/legacy/core_plugins/data/public/search/fetch/get_search_params.ts
index 9fb8f2c728c6f0..de9ec4cb920e8e 100644
--- a/src/legacy/ui/public/courier/fetch/get_search_params.ts
+++ b/src/legacy/core_plugins/data/public/search/fetch/get_search_params.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IUiSettingsClient } from '../../../../../core/public';
+import { IUiSettingsClient } from '../../../../../../core/public';
const sessionId = Date.now();
diff --git a/src/legacy/ui/public/courier/fetch/handle_response.test.ts b/src/legacy/core_plugins/data/public/search/fetch/handle_response.test.ts
similarity index 67%
rename from src/legacy/ui/public/courier/fetch/handle_response.test.ts
rename to src/legacy/core_plugins/data/public/search/fetch/handle_response.test.ts
index 0163aca7771610..231ebf56993b6e 100644
--- a/src/legacy/ui/public/courier/fetch/handle_response.test.ts
+++ b/src/legacy/core_plugins/data/public/search/fetch/handle_response.test.ts
@@ -18,15 +18,12 @@
*/
import { handleResponse } from './handle_response';
-import { toastNotifications } from '../../notify/toasts';
-jest.mock('../../notify/toasts', () => {
- return {
- toastNotifications: {
- addWarning: jest.fn(),
- },
- };
-});
+// Temporary disable eslint, will be removed after moving to new platform folder
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { notificationServiceMock } from '../../../../../../core/public/notifications/notifications_service.mock';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { setNotifications } from '../../../../../../plugins/data/public/services';
jest.mock('@kbn/i18n', () => {
return {
@@ -37,8 +34,11 @@ jest.mock('@kbn/i18n', () => {
});
describe('handleResponse', () => {
+ const notifications = notificationServiceMock.createStartContract();
+
beforeEach(() => {
- (toastNotifications.addWarning as jest.Mock).mockReset();
+ setNotifications(notifications);
+ (notifications.toasts.addWarning as jest.Mock).mockReset();
});
test('should notify if timed out', () => {
@@ -48,8 +48,8 @@ describe('handleResponse', () => {
};
const result = handleResponse(request, response);
expect(result).toBe(response);
- expect(toastNotifications.addWarning).toBeCalled();
- expect((toastNotifications.addWarning as jest.Mock).mock.calls[0][0].title).toMatch(
+ expect(notifications.toasts.addWarning).toBeCalled();
+ expect((notifications.toasts.addWarning as jest.Mock).mock.calls[0][0].title).toMatch(
'request timed out'
);
});
@@ -63,8 +63,8 @@ describe('handleResponse', () => {
};
const result = handleResponse(request, response);
expect(result).toBe(response);
- expect(toastNotifications.addWarning).toBeCalled();
- expect((toastNotifications.addWarning as jest.Mock).mock.calls[0][0].title).toMatch(
+ expect(notifications.toasts.addWarning).toBeCalled();
+ expect((notifications.toasts.addWarning as jest.Mock).mock.calls[0][0].title).toMatch(
'shards failed'
);
});
diff --git a/src/legacy/ui/public/courier/fetch/handle_response.tsx b/src/legacy/core_plugins/data/public/search/fetch/handle_response.tsx
similarity index 77%
rename from src/legacy/ui/public/courier/fetch/handle_response.tsx
rename to src/legacy/core_plugins/data/public/search/fetch/handle_response.tsx
index d7f2263268f8c4..a08b7d14fd1c37 100644
--- a/src/legacy/ui/public/courier/fetch/handle_response.tsx
+++ b/src/legacy/core_plugins/data/public/search/fetch/handle_response.tsx
@@ -20,23 +20,24 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSpacer } from '@elastic/eui';
-import { toastNotifications } from '../../notify/toasts';
import { ShardFailureOpenModalButton } from './components/shard_failure_open_modal_button';
import { Request, ResponseWithShardFailure } from './components/shard_failure_types';
import { SearchRequest, SearchResponse } from '../types';
-import { toMountPoint } from '../../../../../plugins/kibana_react/public';
+import { toMountPoint } from '../../../../../../plugins/kibana_react/public';
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { getNotifications } from '../../../../../../plugins/data/public/services';
export function handleResponse(request: SearchRequest, response: SearchResponse) {
if (response.timed_out) {
- toastNotifications.addWarning({
- title: i18n.translate('common.ui.courier.fetch.requestTimedOutNotificationMessage', {
+ getNotifications().toasts.addWarning({
+ title: i18n.translate('data.search.searchSource.fetch.requestTimedOutNotificationMessage', {
defaultMessage: 'Data might be incomplete because your request timed out',
}),
});
}
if (response._shards && response._shards.failed) {
- const title = i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
+ const title = i18n.translate('data.search.searchSource.fetch.shardsFailedNotificationMessage', {
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
values: {
shardsFailed: response._shards.failed,
@@ -44,7 +45,7 @@ export function handleResponse(request: SearchRequest, response: SearchResponse)
},
});
const description = i18n.translate(
- 'common.ui.courier.fetch.shardsFailedNotificationDescription',
+ 'data.search.searchSource.fetch.shardsFailedNotificationDescription',
{
defaultMessage: 'The data you are seeing might be incomplete or wrong.',
}
@@ -62,7 +63,7 @@ export function handleResponse(request: SearchRequest, response: SearchResponse)
>
);
- toastNotifications.addWarning({ title, text });
+ getNotifications().toasts.addWarning({ title, text });
}
return response;
diff --git a/src/legacy/ui/public/courier/fetch/index.ts b/src/legacy/core_plugins/data/public/search/fetch/index.ts
similarity index 100%
rename from src/legacy/ui/public/courier/fetch/index.ts
rename to src/legacy/core_plugins/data/public/search/fetch/index.ts
diff --git a/src/legacy/ui/public/courier/fetch/types.ts b/src/legacy/core_plugins/data/public/search/fetch/types.ts
similarity index 95%
rename from src/legacy/ui/public/courier/fetch/types.ts
rename to src/legacy/core_plugins/data/public/search/fetch/types.ts
index 03bf51ae15d453..0887a1f84c7c8c 100644
--- a/src/legacy/ui/public/courier/fetch/types.ts
+++ b/src/legacy/core_plugins/data/public/search/fetch/types.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IUiSettingsClient } from '../../../../../core/public';
+import { IUiSettingsClient } from '../../../../../../core/public';
import { SearchRequest, SearchResponse } from '../types';
export interface ApiCaller {
diff --git a/src/legacy/core_plugins/data/public/search/index.ts b/src/legacy/core_plugins/data/public/search/index.ts
index 9880b336e76e5c..d930a472195147 100644
--- a/src/legacy/core_plugins/data/public/search/index.ts
+++ b/src/legacy/core_plugins/data/public/search/index.ts
@@ -16,3 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
+export { SearchService, SearchSetup, SearchStart } from './search_service';
+
+export { getRequestInspectorStats, getResponseInspectorStats } from './utils';
diff --git a/src/legacy/core_plugins/data/public/search/search_service.ts b/src/legacy/core_plugins/data/public/search/search_service.ts
new file mode 100644
index 00000000000000..85701187fb31d8
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/search_service.ts
@@ -0,0 +1,51 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Plugin, CoreSetup, CoreStart } from '../../../../../core/public';
+import { SearchSource } from './search_source';
+import { defaultSearchStrategy } from './search_strategy';
+import { SearchStrategyProvider } from './search_strategy/types';
+
+export interface SearchSetup {} // eslint-disable-line @typescript-eslint/no-empty-interface
+
+export interface SearchStart {
+ defaultSearchStrategy: SearchStrategyProvider;
+ SearchSource: typeof SearchSource;
+}
+
+/**
+ * The contract provided here is a new platform shim for ui/courier.
+ *
+ * Once it has been refactored to work with new platform services,
+ * it will move into the existing search service in src/plugins/data/public/search
+ */
+export class SearchService implements Plugin {
+ public setup(core: CoreSetup): SearchSetup {
+ return {};
+ }
+
+ public start(core: CoreStart): SearchStart {
+ return {
+ defaultSearchStrategy,
+ SearchSource,
+ };
+ }
+
+ public stop() {}
+}
diff --git a/src/legacy/ui/public/courier/search_source/filter_docvalue_fields.test.ts b/src/legacy/core_plugins/data/public/search/search_source/filter_docvalue_fields.test.ts
similarity index 100%
rename from src/legacy/ui/public/courier/search_source/filter_docvalue_fields.test.ts
rename to src/legacy/core_plugins/data/public/search/search_source/filter_docvalue_fields.test.ts
diff --git a/src/legacy/ui/public/courier/search_source/filter_docvalue_fields.ts b/src/legacy/core_plugins/data/public/search/search_source/filter_docvalue_fields.ts
similarity index 100%
rename from src/legacy/ui/public/courier/search_source/filter_docvalue_fields.ts
rename to src/legacy/core_plugins/data/public/search/search_source/filter_docvalue_fields.ts
diff --git a/src/legacy/ui/public/saved_objects/saved_object_registry.ts b/src/legacy/core_plugins/data/public/search/search_source/index.ts
similarity index 79%
rename from src/legacy/ui/public/saved_objects/saved_object_registry.ts
rename to src/legacy/core_plugins/data/public/search/search_source/index.ts
index 34b91267bfb322..72170adc2b1296 100644
--- a/src/legacy/ui/public/saved_objects/saved_object_registry.ts
+++ b/src/legacy/core_plugins/data/public/search/search_source/index.ts
@@ -17,10 +17,4 @@
* under the License.
*/
-import { uiRegistry } from '../registry/_registry';
-
-export const SavedObjectRegistryProvider = uiRegistry({
- name: 'savedObjects',
- index: ['loaderProperties.name'],
- order: ['loaderProperties.name'],
-});
+export * from './search_source';
diff --git a/src/legacy/core_plugins/data/public/search/search_source/mocks.ts b/src/legacy/core_plugins/data/public/search/search_source/mocks.ts
new file mode 100644
index 00000000000000..fd72158012de6f
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/search_source/mocks.ts
@@ -0,0 +1,59 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"), you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ISearchSource } from './search_source';
+
+export const searchSourceMock: MockedKeys = {
+ setPreferredSearchStrategyId: jest.fn(),
+ setFields: jest.fn().mockReturnThis(),
+ setField: jest.fn().mockReturnThis(),
+ getId: jest.fn(),
+ getFields: jest.fn(),
+ getField: jest.fn(),
+ getOwnField: jest.fn(),
+ create: jest.fn().mockReturnThis(),
+ createCopy: jest.fn().mockReturnThis(),
+ createChild: jest.fn().mockReturnThis(),
+ setParent: jest.fn(),
+ getParent: jest.fn().mockReturnThis(),
+ fetch: jest.fn().mockResolvedValue({}),
+ onRequestStart: jest.fn(),
+ getSearchRequestBody: jest.fn(),
+ destroy: jest.fn(),
+ history: [],
+};
diff --git a/src/legacy/ui/public/courier/search_source/normalize_sort_request.test.ts b/src/legacy/core_plugins/data/public/search/search_source/normalize_sort_request.test.ts
similarity index 97%
rename from src/legacy/ui/public/courier/search_source/normalize_sort_request.test.ts
rename to src/legacy/core_plugins/data/public/search/search_source/normalize_sort_request.test.ts
index d27b01eb5cf7cf..22d1d931a9d096 100644
--- a/src/legacy/ui/public/courier/search_source/normalize_sort_request.test.ts
+++ b/src/legacy/core_plugins/data/public/search/search_source/normalize_sort_request.test.ts
@@ -19,7 +19,7 @@
import { normalizeSortRequest } from './normalize_sort_request';
import { SortDirection } from './types';
-import { IndexPattern } from '../../../../core_plugins/data/public/index_patterns';
+import { IIndexPattern } from '../../../../../../plugins/data/public';
jest.mock('ui/new_platform');
@@ -40,7 +40,7 @@ describe('SearchSource#normalizeSortRequest', function() {
};
const indexPattern = {
fields: [scriptedField, murmurScriptedField],
- } as IndexPattern;
+ } as IIndexPattern;
it('should return an array', function() {
const sortable = { someField: SortDirection.desc };
diff --git a/src/legacy/ui/public/courier/search_source/normalize_sort_request.ts b/src/legacy/core_plugins/data/public/search/search_source/normalize_sort_request.ts
similarity index 93%
rename from src/legacy/ui/public/courier/search_source/normalize_sort_request.ts
rename to src/legacy/core_plugins/data/public/search/search_source/normalize_sort_request.ts
index 0f8fc8076caa08..93834c95514dc2 100644
--- a/src/legacy/ui/public/courier/search_source/normalize_sort_request.ts
+++ b/src/legacy/core_plugins/data/public/search/search_source/normalize_sort_request.ts
@@ -17,12 +17,12 @@
* under the License.
*/
-import { IndexPattern } from '../../../../core_plugins/data/public';
+import { IIndexPattern } from '../../../../../../plugins/data/public';
import { EsQuerySortValue, SortOptions } from './types';
export function normalizeSortRequest(
sortObject: EsQuerySortValue | EsQuerySortValue[],
- indexPattern: IndexPattern | string | undefined,
+ indexPattern: IIndexPattern | string | undefined,
defaultSortOptions: SortOptions = {}
) {
const sortArray: EsQuerySortValue[] = Array.isArray(sortObject) ? sortObject : [sortObject];
@@ -38,7 +38,7 @@ export function normalizeSortRequest(
*/
function normalize(
sortable: EsQuerySortValue,
- indexPattern: IndexPattern | string | undefined,
+ indexPattern: IIndexPattern | string | undefined,
defaultSortOptions: any
) {
const [[sortField, sortOrder]] = Object.entries(sortable);
diff --git a/src/legacy/ui/public/courier/search_source/search_source.test.ts b/src/legacy/core_plugins/data/public/search/search_source/search_source.test.ts
similarity index 98%
rename from src/legacy/ui/public/courier/search_source/search_source.test.ts
rename to src/legacy/core_plugins/data/public/search/search_source/search_source.test.ts
index ddd3717f55e297..28f8dba9a75de3 100644
--- a/src/legacy/ui/public/courier/search_source/search_source.test.ts
+++ b/src/legacy/core_plugins/data/public/search/search_source/search_source.test.ts
@@ -18,7 +18,7 @@
*/
import { SearchSource } from '../search_source';
-import { IndexPattern } from '../../../../core_plugins/data/public';
+import { IndexPattern } from '../../../../../../plugins/data/public';
jest.mock('ui/new_platform');
@@ -26,7 +26,7 @@ jest.mock('../fetch', () => ({
fetchSoon: jest.fn().mockResolvedValue({}),
}));
-jest.mock('../../chrome', () => ({
+jest.mock('ui/chrome', () => ({
dangerouslyGetActiveInjector: () => ({
get: jest.fn(),
}),
diff --git a/src/legacy/core_plugins/data/public/search/search_source/search_source.ts b/src/legacy/core_plugins/data/public/search/search_source/search_source.ts
new file mode 100644
index 00000000000000..6efcae4d4b88dc
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/search_source/search_source.ts
@@ -0,0 +1,410 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @name SearchSource
+ *
+ * @description A promise-based stream of search results that can inherit from other search sources.
+ *
+ * Because filters/queries in Kibana have different levels of persistence and come from different
+ * places, it is important to keep track of where filters come from for when they are saved back to
+ * the savedObject store in the Kibana index. To do this, we create trees of searchSource objects
+ * that can have associated query parameters (index, query, filter, etc) which can also inherit from
+ * other searchSource objects.
+ *
+ * At query time, all of the searchSource objects that have subscribers are "flattened", at which
+ * point the query params from the searchSource are collected while traversing up the inheritance
+ * chain. At each link in the chain a decision about how to merge the query params is made until a
+ * single set of query parameters is created for each active searchSource (a searchSource with
+ * subscribers).
+ *
+ * That set of query parameters is then sent to elasticsearch. This is how the filter hierarchy
+ * works in Kibana.
+ *
+ * Visualize, starting from a new search:
+ *
+ * - the `savedVis.searchSource` is set as the `appSearchSource`.
+ * - The `savedVis.searchSource` would normally inherit from the `appSearchSource`, but now it is
+ * upgraded to inherit from the `rootSearchSource`.
+ * - Any interaction with the visualization will still apply filters to the `appSearchSource`, so
+ * they will be stored directly on the `savedVis.searchSource`.
+ * - Any interaction with the time filter will be written to the `rootSearchSource`, so those
+ * filters will not be saved by the `savedVis`.
+ * - When the `savedVis` is saved to elasticsearch, it takes with it all the filters that are
+ * defined on it directly, but none of the ones that it inherits from other places.
+ *
+ * Visualize, starting from an existing search:
+ *
+ * - The `savedVis` loads the `savedSearch` on which it is built.
+ * - The `savedVis.searchSource` is set to inherit from the `saveSearch.searchSource` and set as
+ * the `appSearchSource`.
+ * - The `savedSearch.searchSource`, is set to inherit from the `rootSearchSource`.
+ * - Then the `savedVis` is written to elasticsearch it will be flattened and only include the
+ * filters created in the visualize application and will reconnect the filters from the
+ * `savedSearch` at runtime to prevent losing the relationship
+ *
+ * Dashboard search sources:
+ *
+ * - Each panel in a dashboard has a search source.
+ * - The `savedDashboard` also has a searchsource, and it is set as the `appSearchSource`.
+ * - Each panel's search source inherits from the `appSearchSource`, meaning that they inherit from
+ * the dashboard search source.
+ * - When a filter is added to the search box, or via a visualization, it is written to the
+ * `appSearchSource`.
+ */
+
+import _ from 'lodash';
+import { npSetup } from 'ui/new_platform';
+import chrome from 'ui/chrome';
+import { normalizeSortRequest } from './normalize_sort_request';
+import { fetchSoon } from '../fetch';
+import { fieldWildcardFilter } from '../../../../../../plugins/kibana_utils/public';
+import { getHighlightRequest, esFilters, esQuery } from '../../../../../../plugins/data/public';
+import { RequestFailure } from '../fetch/errors';
+import { filterDocvalueFields } from './filter_docvalue_fields';
+import { SearchSourceOptions, SearchSourceFields, SearchRequest } from './types';
+import { FetchOptions, ApiCaller } from '../fetch/types';
+
+const esShardTimeout = npSetup.core.injectedMetadata.getInjectedVar('esShardTimeout') as number;
+const config = npSetup.core.uiSettings;
+
+export type ISearchSource = Pick;
+
+export class SearchSource {
+ private id: string = _.uniqueId('data_source');
+ private searchStrategyId?: string;
+ private parent?: SearchSource;
+ private requestStartHandlers: Array<
+ (searchSource: ISearchSource, options?: FetchOptions) => Promise
+ > = [];
+ private inheritOptions: SearchSourceOptions = {};
+ public history: SearchRequest[] = [];
+
+ constructor(private fields: SearchSourceFields = {}) {}
+
+ /** ***
+ * PUBLIC API
+ *****/
+
+ setPreferredSearchStrategyId(searchStrategyId: string) {
+ this.searchStrategyId = searchStrategyId;
+ }
+
+ setFields(newFields: SearchSourceFields) {
+ this.fields = newFields;
+ return this;
+ }
+
+ setField(field: K, value: SearchSourceFields[K]) {
+ if (value == null) {
+ delete this.fields[field];
+ } else {
+ this.fields[field] = value;
+ }
+ return this;
+ }
+
+ getId() {
+ return this.id;
+ }
+
+ getFields() {
+ return { ...this.fields };
+ }
+
+ /**
+ * Get fields from the fields
+ */
+ getField(field: K, recurse = true): SearchSourceFields[K] {
+ if (!recurse || this.fields[field] !== void 0) {
+ return this.fields[field];
+ }
+ const parent = this.getParent();
+ return parent && parent.getField(field);
+ }
+
+ /**
+ * Get the field from our own fields, don't traverse up the chain
+ */
+ getOwnField(field: K): SearchSourceFields[K] {
+ return this.getField(field, false);
+ }
+
+ create() {
+ return new SearchSource();
+ }
+
+ createCopy() {
+ const newSearchSource = new SearchSource();
+ newSearchSource.setFields({ ...this.fields });
+ // when serializing the internal fields we lose the internal classes used in the index
+ // pattern, so we have to set it again to workaround this behavior
+ newSearchSource.setField('index', this.getField('index'));
+ newSearchSource.setParent(this.getParent());
+ return newSearchSource;
+ }
+
+ createChild(options = {}) {
+ const childSearchSource = new SearchSource();
+ childSearchSource.setParent(this, options);
+ return childSearchSource;
+ }
+
+ /**
+ * Set a searchSource that this source should inherit from
+ * @param {SearchSource} parent - the parent searchSource
+ * @param {SearchSourceOptions} options - the inherit options
+ * @return {this} - chainable
+ */
+ setParent(parent?: ISearchSource, options: SearchSourceOptions = {}) {
+ this.parent = parent as SearchSource;
+ this.inheritOptions = options;
+ return this;
+ }
+
+ /**
+ * Get the parent of this SearchSource
+ * @return {undefined|searchSource}
+ */
+ getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Fetch this source and reject the returned Promise on error
+ *
+ * @async
+ */
+ async fetch(options: FetchOptions = {}) {
+ const $injector = await chrome.dangerouslyGetActiveInjector();
+ const es = $injector.get('es') as ApiCaller;
+
+ await this.requestIsStarting(options);
+
+ const searchRequest = await this.flatten();
+ this.history = [searchRequest];
+
+ const response = await fetchSoon(
+ searchRequest,
+ {
+ ...(this.searchStrategyId && { searchStrategyId: this.searchStrategyId }),
+ ...options,
+ },
+ { es, config, esShardTimeout }
+ );
+
+ if (response.error) {
+ throw new RequestFailure(null, response);
+ }
+
+ return response;
+ }
+
+ /**
+ * Add a handler that will be notified whenever requests start
+ * @param {Function} handler
+ * @return {undefined}
+ */
+ onRequestStart(
+ handler: (searchSource: ISearchSource, options?: FetchOptions) => Promise
+ ) {
+ this.requestStartHandlers.push(handler);
+ }
+
+ async getSearchRequestBody() {
+ const searchRequest = await this.flatten();
+ return searchRequest.body;
+ }
+
+ /**
+ * Completely destroy the SearchSource.
+ * @return {undefined}
+ */
+ destroy() {
+ this.requestStartHandlers.length = 0;
+ }
+
+ /** ****
+ * PRIVATE APIS
+ ******/
+
+ /**
+ * Called by requests of this search source when they are started
+ * @param {Courier.Request} request
+ * @param options
+ * @return {Promise}
+ */
+ private requestIsStarting(options: FetchOptions = {}) {
+ const handlers = [...this.requestStartHandlers];
+ // If callParentStartHandlers has been set to true, we also call all
+ // handlers of parent search sources.
+ if (this.inheritOptions.callParentStartHandlers) {
+ let searchSource = this.getParent();
+ while (searchSource) {
+ handlers.push(...searchSource.requestStartHandlers);
+ searchSource = searchSource.getParent();
+ }
+ }
+
+ return Promise.all(handlers.map(fn => fn(this, options)));
+ }
+
+ /**
+ * Used to merge properties into the data within ._flatten().
+ * The data is passed in and modified by the function
+ *
+ * @param {object} data - the current merged data
+ * @param {*} val - the value at `key`
+ * @param {*} key - The key of `val`
+ * @return {undefined}
+ */
+ private mergeProp(
+ data: SearchRequest,
+ val: SearchSourceFields[K],
+ key: K
+ ) {
+ val = typeof val === 'function' ? val(this) : val;
+ if (val == null || !key) return;
+
+ const addToRoot = (rootKey: string, value: any) => {
+ data[rootKey] = value;
+ };
+
+ /**
+ * Add the key and val to the body of the request
+ */
+ const addToBody = (bodyKey: string, value: any) => {
+ // ignore if we already have a value
+ if (data.body[bodyKey] == null) {
+ data.body[bodyKey] = value;
+ }
+ };
+
+ switch (key) {
+ case 'filter':
+ return addToRoot('filters', (data.filters || []).concat(val));
+ case 'query':
+ return addToRoot(key, (data[key] || []).concat(val));
+ case 'fields':
+ const fields = _.uniq((data[key] || []).concat(val));
+ return addToRoot(key, fields);
+ case 'index':
+ case 'type':
+ case 'highlightAll':
+ return key && data[key] == null && addToRoot(key, val);
+ case 'searchAfter':
+ return addToBody('search_after', val);
+ case 'source':
+ return addToBody('_source', val);
+ case 'sort':
+ const sort = normalizeSortRequest(val, this.getField('index'), config.get('sort:options'));
+ return addToBody(key, sort);
+ default:
+ return addToBody(key, val);
+ }
+ }
+
+ /**
+ * Walk the inheritance chain of a source and return its
+ * flat representation (taking into account merging rules)
+ * @returns {Promise}
+ * @resolved {Object|null} - the flat data of the SearchSource
+ */
+ private mergeProps(root = this, searchRequest: SearchRequest = { body: {} }) {
+ Object.entries(this.fields).forEach(([key, value]) => {
+ this.mergeProp(searchRequest, value, key as keyof SearchSourceFields);
+ });
+ if (this.parent) {
+ this.parent.mergeProps(root, searchRequest);
+ }
+ return searchRequest;
+ }
+
+ private flatten() {
+ const searchRequest = this.mergeProps();
+
+ searchRequest.body = searchRequest.body || {};
+ const { body, index, fields, query, filters, highlightAll } = searchRequest;
+
+ const computedFields = index ? index.getComputedFields() : {};
+
+ body.stored_fields = computedFields.storedFields;
+ body.script_fields = body.script_fields || {};
+ _.extend(body.script_fields, computedFields.scriptFields);
+
+ const defaultDocValueFields = computedFields.docvalueFields
+ ? computedFields.docvalueFields
+ : [];
+ body.docvalue_fields = body.docvalue_fields || defaultDocValueFields;
+
+ if (!body.hasOwnProperty('_source') && index) {
+ body._source = index.getSourceFiltering();
+ }
+
+ if (body._source) {
+ // exclude source fields for this index pattern specified by the user
+ const filter = fieldWildcardFilter(body._source.excludes, config.get('metaFields'));
+ body.docvalue_fields = body.docvalue_fields.filter((docvalueField: any) =>
+ filter(docvalueField.field)
+ );
+ }
+
+ // if we only want to search for certain fields
+ if (fields) {
+ // filter out the docvalue_fields, and script_fields to only include those that we are concerned with
+ body.docvalue_fields = filterDocvalueFields(body.docvalue_fields, fields);
+ body.script_fields = _.pick(body.script_fields, fields);
+
+ // request the remaining fields from both stored_fields and _source
+ const remainingFields = _.difference(fields, _.keys(body.script_fields));
+ body.stored_fields = remainingFields;
+ _.set(body, '_source.includes', remainingFields);
+ }
+
+ const esQueryConfigs = esQuery.getEsQueryConfig(config);
+ body.query = esQuery.buildEsQuery(index, query, filters, esQueryConfigs);
+
+ if (highlightAll && body.query) {
+ body.highlight = getHighlightRequest(body.query, config.get('doc_table:highlight'));
+ delete searchRequest.highlightAll;
+ }
+
+ const translateToQuery = (filter: esFilters.Filter) => filter && (filter.query || filter);
+
+ // re-write filters within filter aggregations
+ (function recurse(aggBranch) {
+ if (!aggBranch) return;
+ Object.keys(aggBranch).forEach(function(id) {
+ const agg = aggBranch[id];
+
+ if (agg.filters) {
+ // translate filters aggregations
+ const { filters: aggFilters } = agg.filters;
+ Object.keys(aggFilters).forEach(filterId => {
+ aggFilters[filterId] = translateToQuery(aggFilters[filterId]);
+ });
+ }
+
+ recurse(agg.aggs || agg.aggregations);
+ });
+ })(body.aggs || body.aggregations);
+
+ return searchRequest;
+ }
+}
diff --git a/src/legacy/ui/public/courier/search_source/types.ts b/src/legacy/core_plugins/data/public/search/search_source/types.ts
similarity index 94%
rename from src/legacy/ui/public/courier/search_source/types.ts
rename to src/legacy/core_plugins/data/public/search/search_source/types.ts
index 8fd6d8cfa5fa09..9c5b57519d75f9 100644
--- a/src/legacy/ui/public/courier/search_source/types.ts
+++ b/src/legacy/core_plugins/data/public/search/search_source/types.ts
@@ -17,7 +17,7 @@
* under the License.
*/
import { NameList } from 'elasticsearch';
-import { esFilters, Query, IndexPattern } from '../../../../../plugins/data/public';
+import { esFilters, IndexPattern, Query } from '../../../../../../plugins/data/public';
export type EsQuerySearchAfter = [string | number, string | number];
@@ -54,7 +54,7 @@ export interface SearchSourceOptions {
callParentStartHandlers?: boolean;
}
-export { SearchSourceContract } from './search_source';
+export { ISearchSource } from './search_source';
export interface SortOptions {
mode?: 'min' | 'max' | 'sum' | 'avg' | 'median';
diff --git a/src/legacy/ui/public/courier/search_strategy/default_search_strategy.test.ts b/src/legacy/core_plugins/data/public/search/search_strategy/default_search_strategy.test.ts
similarity index 98%
rename from src/legacy/ui/public/courier/search_strategy/default_search_strategy.test.ts
rename to src/legacy/core_plugins/data/public/search/search_strategy/default_search_strategy.test.ts
index 53a857a72c1a3a..0ec6a6c2e143e7 100644
--- a/src/legacy/ui/public/courier/search_strategy/default_search_strategy.test.ts
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/default_search_strategy.test.ts
@@ -18,7 +18,7 @@
*/
import { defaultSearchStrategy } from './default_search_strategy';
-import { IUiSettingsClient } from '../../../../../core/public';
+import { IUiSettingsClient } from '../../../../../../core/public';
import { SearchStrategySearchParams } from './types';
const { search } = defaultSearchStrategy;
diff --git a/src/legacy/core_plugins/data/public/search/search_strategy/default_search_strategy.ts b/src/legacy/core_plugins/data/public/search/search_strategy/default_search_strategy.ts
new file mode 100644
index 00000000000000..9bfa1df71aa81a
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/default_search_strategy.ts
@@ -0,0 +1,78 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { SearchStrategyProvider, SearchStrategySearchParams } from './types';
+import { isDefaultTypeIndexPattern } from './is_default_type_index_pattern';
+import {
+ getSearchParams,
+ getMSearchParams,
+ getPreference,
+ getTimeout,
+} from '../fetch/get_search_params';
+
+export const defaultSearchStrategy: SearchStrategyProvider = {
+ id: 'default',
+
+ search: params => {
+ return params.config.get('courier:batchSearches') ? msearch(params) : search(params);
+ },
+
+ isViable: indexPattern => {
+ return indexPattern && isDefaultTypeIndexPattern(indexPattern);
+ },
+};
+
+function msearch({ searchRequests, es, config, esShardTimeout }: SearchStrategySearchParams) {
+ const inlineRequests = searchRequests.map(({ index, body, search_type: searchType }) => {
+ const inlineHeader = {
+ index: index.title || index,
+ search_type: searchType,
+ ignore_unavailable: true,
+ preference: getPreference(config),
+ };
+ const inlineBody = {
+ ...body,
+ timeout: getTimeout(esShardTimeout),
+ };
+ return `${JSON.stringify(inlineHeader)}\n${JSON.stringify(inlineBody)}`;
+ });
+
+ const searching = es.msearch({
+ ...getMSearchParams(config),
+ body: `${inlineRequests.join('\n')}\n`,
+ });
+ return {
+ searching: searching.then(({ responses }) => responses),
+ abort: searching.abort,
+ };
+}
+
+function search({ searchRequests, es, config, esShardTimeout }: SearchStrategySearchParams) {
+ const abortController = new AbortController();
+ const searchParams = getSearchParams(config, esShardTimeout);
+ const promises = searchRequests.map(({ index, body }) => {
+ const searching = es.search({ index: index.title || index, body, ...searchParams });
+ abortController.signal.addEventListener('abort', searching.abort);
+ return searching.catch(({ response }) => JSON.parse(response));
+ });
+ return {
+ searching: Promise.all(promises),
+ abort: () => abortController.abort(),
+ };
+}
diff --git a/src/legacy/core_plugins/data/public/search/search_strategy/index.ts b/src/legacy/core_plugins/data/public/search/search_strategy/index.ts
new file mode 100644
index 00000000000000..1584baa4faade4
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/index.ts
@@ -0,0 +1,31 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export {
+ addSearchStrategy,
+ hasSearchStategyForIndexPattern,
+ getSearchStrategyById,
+ getSearchStrategyForSearchRequest,
+} from './search_strategy_registry';
+
+export { defaultSearchStrategy } from './default_search_strategy';
+
+export { isDefaultTypeIndexPattern } from './is_default_type_index_pattern';
+
+export { SearchError, getSearchErrorType } from './search_error';
diff --git a/src/legacy/ui/public/courier/search_strategy/is_default_type_index_pattern.ts b/src/legacy/core_plugins/data/public/search/search_strategy/is_default_type_index_pattern.ts
similarity index 93%
rename from src/legacy/ui/public/courier/search_strategy/is_default_type_index_pattern.ts
rename to src/legacy/core_plugins/data/public/search/search_strategy/is_default_type_index_pattern.ts
index 3785ce63410787..7d03b1dc9e0b1a 100644
--- a/src/legacy/ui/public/courier/search_strategy/is_default_type_index_pattern.ts
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/is_default_type_index_pattern.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IndexPattern } from '../../../../core_plugins/data/public';
+import { IndexPattern } from '../../../../../../plugins/data/public';
export const isDefaultTypeIndexPattern = (indexPattern: IndexPattern) => {
// Default index patterns don't have `type` defined.
diff --git a/src/legacy/ui/public/courier/search_strategy/no_op_search_strategy.ts b/src/legacy/core_plugins/data/public/search/search_strategy/no_op_search_strategy.ts
similarity index 83%
rename from src/legacy/ui/public/courier/search_strategy/no_op_search_strategy.ts
rename to src/legacy/core_plugins/data/public/search/search_strategy/no_op_search_strategy.ts
index 24c3876cfcc051..dc7331e614a0e4 100644
--- a/src/legacy/ui/public/courier/search_strategy/no_op_search_strategy.ts
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/no_op_search_strategy.ts
@@ -27,11 +27,14 @@ export const noOpSearchStrategy: SearchStrategyProvider = {
search: () => {
const searchError = new SearchError({
status: '418', // "I'm a teapot" error
- title: i18n.translate('common.ui.courier.noSearchStrategyRegisteredErrorMessageTitle', {
- defaultMessage: 'No search strategy registered',
- }),
+ title: i18n.translate(
+ 'data.search.searchSource.noSearchStrategyRegisteredErrorMessageTitle',
+ {
+ defaultMessage: 'No search strategy registered',
+ }
+ ),
message: i18n.translate(
- 'common.ui.courier.noSearchStrategyRegisteredErrorMessageDescription',
+ 'data.search.searchSource.noSearchStrategyRegisteredErrorMessageDescription',
{
defaultMessage: `Couldn't find a search strategy for the search request`,
}
diff --git a/src/legacy/core_plugins/data/public/search/search_strategy/search_error.ts b/src/legacy/core_plugins/data/public/search/search_strategy/search_error.ts
new file mode 100644
index 00000000000000..d4042fb17499cb
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/search_error.ts
@@ -0,0 +1,62 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+interface SearchErrorOptions {
+ status: string;
+ title: string;
+ message: string;
+ path: string;
+ type: string;
+}
+
+export class SearchError extends Error {
+ public name: string;
+ public status: string;
+ public title: string;
+ public message: string;
+ public path: string;
+ public type: string;
+
+ constructor({ status, title, message, path, type }: SearchErrorOptions) {
+ super(message);
+ this.name = 'SearchError';
+ this.status = status;
+ this.title = title;
+ this.message = message;
+ this.path = path;
+ this.type = type;
+
+ // captureStackTrace is only available in the V8 engine, so any browser using
+ // a different JS engine won't have access to this method.
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, SearchError);
+ }
+
+ // Babel doesn't support traditional `extends` syntax for built-in classes.
+ // https://babeljs.io/docs/en/caveats/#classes
+ Object.setPrototypeOf(this, SearchError.prototype);
+ }
+}
+
+export function getSearchErrorType({ message }: Pick) {
+ const msg = message.toLowerCase();
+ if (msg.indexOf('unsupported query') > -1) {
+ return 'UNSUPPORTED_QUERY';
+ }
+}
diff --git a/src/legacy/ui/public/courier/search_strategy/search_strategy_registry.test.ts b/src/legacy/core_plugins/data/public/search/search_strategy/search_strategy_registry.test.ts
similarity index 98%
rename from src/legacy/ui/public/courier/search_strategy/search_strategy_registry.test.ts
rename to src/legacy/core_plugins/data/public/search/search_strategy/search_strategy_registry.test.ts
index ae2ed6128c8ea8..73b011896a97dc 100644
--- a/src/legacy/ui/public/courier/search_strategy/search_strategy_registry.test.ts
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/search_strategy_registry.test.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IndexPattern } from '../../../../core_plugins/data/public';
+import { IndexPattern } from '../../../../../../plugins/data/public';
import { noOpSearchStrategy } from './no_op_search_strategy';
import {
searchStrategies,
diff --git a/src/legacy/ui/public/courier/search_strategy/search_strategy_registry.ts b/src/legacy/core_plugins/data/public/search/search_strategy/search_strategy_registry.ts
similarity index 97%
rename from src/legacy/ui/public/courier/search_strategy/search_strategy_registry.ts
rename to src/legacy/core_plugins/data/public/search/search_strategy/search_strategy_registry.ts
index 9ef007f97531ea..d814a04737f753 100644
--- a/src/legacy/ui/public/courier/search_strategy/search_strategy_registry.ts
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/search_strategy_registry.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IndexPattern } from '../../../../core_plugins/data/public';
+import { IndexPattern } from '../../../../../../plugins/data/public';
import { SearchStrategyProvider } from './types';
import { noOpSearchStrategy } from './no_op_search_strategy';
import { SearchResponse } from '../types';
diff --git a/src/legacy/ui/public/courier/search_strategy/types.ts b/src/legacy/core_plugins/data/public/search/search_strategy/types.ts
similarity index 94%
rename from src/legacy/ui/public/courier/search_strategy/types.ts
rename to src/legacy/core_plugins/data/public/search/search_strategy/types.ts
index 1542f9824a5b1b..ad8576589e4e38 100644
--- a/src/legacy/ui/public/courier/search_strategy/types.ts
+++ b/src/legacy/core_plugins/data/public/search/search_strategy/types.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { IndexPattern } from '../../../../core_plugins/data/public';
+import { IndexPattern } from '../../../../../../plugins/data/public';
import { FetchHandlers } from '../fetch/types';
import { SearchRequest, SearchResponse } from '../types';
diff --git a/src/legacy/core_plugins/data/public/search/types.ts b/src/legacy/core_plugins/data/public/search/types.ts
new file mode 100644
index 00000000000000..23d74ce6a57da8
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/types.ts
@@ -0,0 +1,23 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from './fetch/types';
+export * from './search_source/types';
+export * from './search_strategy/types';
+export * from './utils/types';
diff --git a/src/legacy/ui/public/courier/utils/courier_inspector_utils.ts b/src/legacy/core_plugins/data/public/search/utils/courier_inspector_utils.ts
similarity index 72%
rename from src/legacy/ui/public/courier/utils/courier_inspector_utils.ts
rename to src/legacy/core_plugins/data/public/search/utils/courier_inspector_utils.ts
index b4d5d5537333e3..7f7d216d8f0f3f 100644
--- a/src/legacy/ui/public/courier/utils/courier_inspector_utils.ts
+++ b/src/legacy/core_plugins/data/public/search/utils/courier_inspector_utils.ts
@@ -26,28 +26,28 @@
import { i18n } from '@kbn/i18n';
import { SearchResponse } from 'elasticsearch';
-import { SearchSourceContract, RequestInspectorStats } from '../types';
+import { ISearchSource, RequestInspectorStats } from '../types';
-export function getRequestInspectorStats(searchSource: SearchSourceContract) {
+export function getRequestInspectorStats(searchSource: ISearchSource) {
const stats: RequestInspectorStats = {};
const index = searchSource.getField('index');
if (index) {
stats.indexPattern = {
- label: i18n.translate('common.ui.courier.indexPatternLabel', {
+ label: i18n.translate('data.search.searchSource.indexPatternLabel', {
defaultMessage: 'Index pattern',
}),
value: index.title,
- description: i18n.translate('common.ui.courier.indexPatternDescription', {
+ description: i18n.translate('data.search.searchSource.indexPatternDescription', {
defaultMessage: 'The index pattern that connected to the Elasticsearch indices.',
}),
};
stats.indexPatternId = {
- label: i18n.translate('common.ui.courier.indexPatternIdLabel', {
+ label: i18n.translate('data.search.searchSource.indexPatternIdLabel', {
defaultMessage: 'Index pattern ID',
}),
value: index.id!,
- description: i18n.translate('common.ui.courier.indexPatternIdDescription', {
+ description: i18n.translate('data.search.searchSource.indexPatternIdDescription', {
defaultMessage: 'The ID in the {kibanaIndexPattern} index.',
values: { kibanaIndexPattern: '.kibana' },
}),
@@ -58,7 +58,7 @@ export function getRequestInspectorStats(searchSource: SearchSourceContract) {
}
export function getResponseInspectorStats(
- searchSource: SearchSourceContract,
+ searchSource: ISearchSource,
resp: SearchResponse
) {
const lastRequest = searchSource.history && searchSource.history[searchSource.history.length - 1];
@@ -66,14 +66,14 @@ export function getResponseInspectorStats(
if (resp && resp.took) {
stats.queryTime = {
- label: i18n.translate('common.ui.courier.queryTimeLabel', {
+ label: i18n.translate('data.search.searchSource.queryTimeLabel', {
defaultMessage: 'Query time',
}),
- value: i18n.translate('common.ui.courier.queryTimeValue', {
+ value: i18n.translate('data.search.searchSource.queryTimeValue', {
defaultMessage: '{queryTime}ms',
values: { queryTime: resp.took },
}),
- description: i18n.translate('common.ui.courier.queryTimeDescription', {
+ description: i18n.translate('data.search.searchSource.queryTimeDescription', {
defaultMessage:
'The time it took to process the query. ' +
'Does not include the time to send the request or parse it in the browser.',
@@ -83,21 +83,21 @@ export function getResponseInspectorStats(
if (resp && resp.hits) {
stats.hitsTotal = {
- label: i18n.translate('common.ui.courier.hitsTotalLabel', {
+ label: i18n.translate('data.search.searchSource.hitsTotalLabel', {
defaultMessage: 'Hits (total)',
}),
value: `${resp.hits.total}`,
- description: i18n.translate('common.ui.courier.hitsTotalDescription', {
+ description: i18n.translate('data.search.searchSource.hitsTotalDescription', {
defaultMessage: 'The number of documents that match the query.',
}),
};
stats.hits = {
- label: i18n.translate('common.ui.courier.hitsLabel', {
+ label: i18n.translate('data.search.searchSource.hitsLabel', {
defaultMessage: 'Hits',
}),
value: `${resp.hits.hits.length}`,
- description: i18n.translate('common.ui.courier.hitsDescription', {
+ description: i18n.translate('data.search.searchSource.hitsDescription', {
defaultMessage: 'The number of documents returned by the query.',
}),
};
@@ -105,14 +105,14 @@ export function getResponseInspectorStats(
if (lastRequest && (lastRequest.ms === 0 || lastRequest.ms)) {
stats.requestTime = {
- label: i18n.translate('common.ui.courier.requestTimeLabel', {
+ label: i18n.translate('data.search.searchSource.requestTimeLabel', {
defaultMessage: 'Request time',
}),
- value: i18n.translate('common.ui.courier.requestTimeValue', {
+ value: i18n.translate('data.search.searchSource.requestTimeValue', {
defaultMessage: '{requestTime}ms',
values: { requestTime: lastRequest.ms },
}),
- description: i18n.translate('common.ui.courier.requestTimeDescription', {
+ description: i18n.translate('data.search.searchSource.requestTimeDescription', {
defaultMessage:
'The time of the request from the browser to Elasticsearch and back. ' +
'Does not include the time the requested waited in the queue.',
diff --git a/src/legacy/core_plugins/data/public/search/utils/index.ts b/src/legacy/core_plugins/data/public/search/utils/index.ts
new file mode 100644
index 00000000000000..021ece8701e981
--- /dev/null
+++ b/src/legacy/core_plugins/data/public/search/utils/index.ts
@@ -0,0 +1,20 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from './courier_inspector_utils';
diff --git a/src/legacy/ui/public/courier/utils/types.ts b/src/legacy/core_plugins/data/public/search/utils/types.ts
similarity index 100%
rename from src/legacy/ui/public/courier/utils/types.ts
rename to src/legacy/core_plugins/data/public/search/utils/types.ts
diff --git a/src/legacy/core_plugins/input_control_vis/public/legacy_imports.ts b/src/legacy/core_plugins/input_control_vis/public/legacy_imports.ts
index 864ce3b146689f..176fe68fe4788a 100644
--- a/src/legacy/core_plugins/input_control_vis/public/legacy_imports.ts
+++ b/src/legacy/core_plugins/input_control_vis/public/legacy_imports.ts
@@ -17,13 +17,13 @@
* under the License.
*/
-import { SearchSource as SearchSourceClass } from 'ui/courier';
+import { SearchSource as SearchSourceClass, ISearchSource } from 'ui/courier';
import { Class } from '@kbn/utility-types';
export { Vis, VisParams } from 'ui/vis';
export { VisOptionsProps } from 'ui/vis/editors/default';
export { ValidatedDualRange } from 'ui/validated_range';
-export { SearchSourceFields } from 'ui/courier/types';
+export { SearchSourceFields } from '../../data/public';
-export type SearchSource = Class;
+export type SearchSource = Class;
export const SearchSource = SearchSourceClass;
diff --git a/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx b/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx
index bad006aa8c7d5a..24efbc2d41f4fd 100644
--- a/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx
+++ b/src/legacy/core_plugins/kbn_doc_views/public/views/table/table.test.tsx
@@ -24,6 +24,8 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { flattenHitWrapper } from '../../../../data/public/';
import { DocViewTable } from './table';
+jest.mock('ui/new_platform');
+
// @ts-ignore
const indexPattern = {
fields: {
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/index.ts b/src/legacy/core_plugins/kibana/public/dashboard/index.ts
index 76d9933a3d5670..fd39f28a7673a1 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/index.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/index.ts
@@ -17,17 +17,11 @@
* under the License.
*/
-import {
- npSetup,
- npStart,
- SavedObjectRegistryProvider,
- legacyChrome,
- IPrivate,
-} from './legacy_imports';
+import { npSetup, npStart, legacyChrome } from './legacy_imports';
import { DashboardPlugin, LegacyAngularInjectedDependencies } from './plugin';
import { start as data } from '../../../data/public/legacy';
import { start as embeddables } from '../../../embeddable_api/public/np_ready/public/legacy';
-import './saved_dashboard/saved_dashboards';
+import './saved_dashboard/saved_dashboard_register';
import './dashboard_config';
export * from './np_ready/dashboard_constants';
@@ -39,14 +33,8 @@ export * from './np_ready/dashboard_constants';
async function getAngularDependencies(): Promise {
const injector = await legacyChrome.dangerouslyGetActiveInjector();
- const Private = injector.get('Private');
-
- const savedObjectRegistry = Private(SavedObjectRegistryProvider);
-
return {
dashboardConfig: injector.get('dashboardConfig'),
- savedObjectRegistry,
- savedDashboards: injector.get('savedDashboards'),
};
}
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts
index d3c17d1176c104..ec0913e5fb3e77 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts
@@ -32,7 +32,6 @@ export { AppState } from 'ui/state_management/app_state';
export { AppStateClass } from 'ui/state_management/app_state';
export { SavedObjectSaveOpts } from 'ui/saved_objects/types';
export { npSetup, npStart } from 'ui/new_platform';
-export { SavedObjectRegistryProvider } from 'ui/saved_objects';
export { IPrivate } from 'ui/private';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
@@ -65,5 +64,6 @@ export { stateMonitorFactory, StateMonitor } from 'ui/state_management/state_mon
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';
export { IInjector } from 'ui/chrome';
+export { SavedObjectLoader } from 'ui/saved_objects';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../visualize_embeddable';
export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts
index 298dcee12dc35b..2a5dedab981510 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/application.ts
@@ -42,6 +42,7 @@ import {
RedirectWhenMissingProvider,
confirmModalFactory,
configureAppAngularModule,
+ SavedObjectLoader,
IPrivate,
} from '../legacy_imports';
@@ -57,9 +58,8 @@ export interface RenderDeps {
npDataStart: NpDataStart;
navigation: NavigationStart;
savedObjectsClient: SavedObjectsClientContract;
- savedObjectRegistry: any;
+ savedDashboards: SavedObjectLoader;
dashboardConfig: any;
- savedDashboards: any;
dashboardCapabilities: any;
uiSettings: IUiSettingsClient;
chrome: ChromeStart;
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js
index a4fda5eda8a321..540bfcf5aa6847 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js
+++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/legacy_app.js
@@ -98,7 +98,8 @@ export function initDashboardApp(app, deps) {
...defaults,
template: dashboardListingTemplate,
controller($injector, $location, $scope) {
- const services = deps.savedObjectRegistry.byLoaderPropertiesName;
+ const service = deps.savedDashboards;
+
const kbnUrl = $injector.get('kbnUrl');
const dashboardConfig = deps.dashboardConfig;
@@ -107,7 +108,7 @@ export function initDashboardApp(app, deps) {
kbnUrl.redirect(DashboardConstants.CREATE_NEW_DASHBOARD_URL);
};
$scope.find = search => {
- return services.dashboards.find(search, $scope.listingLimit);
+ return service.find(search, $scope.listingLimit);
};
$scope.editItem = ({ id }) => {
kbnUrl.redirect(`${createDashboardEditUrl(id)}?_a=(viewMode:edit)`);
@@ -116,7 +117,7 @@ export function initDashboardApp(app, deps) {
return deps.addBasePath(`#${createDashboardEditUrl(id)}`);
};
$scope.delete = dashboards => {
- return services.dashboards.delete(dashboards.map(d => d.id));
+ return service.delete(dashboards.map(d => d.id));
};
$scope.hideWriteControls = dashboardConfig.getHideWriteControls();
$scope.initialFilter = $location.search().filter || EMPTY_FILTER;
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts b/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts
index 76deff201e5ee7..ca4b18a37504c6 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/plugin.ts
@@ -39,11 +39,10 @@ import {
} from '../../../../../plugins/home/public';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';
+import { createSavedDashboardLoader } from './saved_dashboard/saved_dashboards';
export interface LegacyAngularInjectedDependencies {
dashboardConfig: any;
- savedObjectRegistry: any;
- savedDashboards: any;
}
export interface DashboardPluginStartDependencies {
@@ -90,6 +89,13 @@ export class DashboardPlugin implements Plugin {
npDataStart,
} = this.startDependencies;
const angularDependencies = await getAngularDependencies();
+ const savedDashboards = createSavedDashboardLoader({
+ savedObjectsClient,
+ indexPatterns: npDataStart.indexPatterns,
+ chrome: contextCore.chrome,
+ overlays: contextCore.overlays,
+ });
+
const deps: RenderDeps = {
core: contextCore as LegacyCoreStart,
...angularDependencies,
@@ -97,6 +103,7 @@ export class DashboardPlugin implements Plugin {
share,
npDataStart,
savedObjectsClient,
+ savedDashboards,
chrome: contextCore.chrome,
addBasePath: contextCore.http.basePath.prepend,
uiSettings: contextCore.uiSettings,
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.ts b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.ts
index 7f4d7402fcffce..18e15b215523e4 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.ts
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { SearchSourceContract } from 'ui/courier';
+import { ISearchSource } from 'ui/courier';
import { SavedObject, SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedObjectClass } from 'ui/saved_objects/saved_object';
import { extractReferences, injectReferences } from './saved_dashboard_references';
@@ -36,7 +36,7 @@ export interface SavedObjectDashboard extends SavedObject {
uiStateJSON?: string;
lastSavedTitle: string;
refreshInterval?: RefreshInterval;
- searchSource: SearchSourceContract;
+ searchSource: ISearchSource;
getQuery(): Query;
getFilters(): esFilters.Filter[];
}
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.ts b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.ts
index 31ee7299e1ff16..b9ea49ca4fd441 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.ts
@@ -16,10 +16,31 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { i18n } from '@kbn/i18n';
+import { npStart } from 'ui/new_platform';
+// @ts-ignore
+import { uiModules } from 'ui/modules';
+// @ts-ignore
+import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
+import { createSavedDashboardLoader } from './saved_dashboards';
-import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
-import './saved_dashboards';
+const module = uiModules.get('app/dashboard');
-SavedObjectRegistryProvider.register((savedDashboards: any) => {
- return savedDashboards;
+// Register this service with the saved object registry so it can be
+// edited by the object editor.
+savedObjectManagementRegistry.register({
+ service: 'savedDashboards',
+ title: i18n.translate('kbn.dashboard.savedDashboardsTitle', {
+ defaultMessage: 'dashboards',
+ }),
});
+
+// this is no longer used in the conroller, but just here for savedObjectManagementRegistry
+module.service('savedDashboards', () =>
+ createSavedDashboardLoader({
+ savedObjectsClient: npStart.core.savedObjects.client,
+ indexPatterns: npStart.plugins.data.indexPatterns,
+ chrome: npStart.core.chrome,
+ overlays: npStart.core.overlays,
+ })
+);
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.ts b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.ts
index 768dc6650595f7..4ece5d46358ba5 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboards.ts
@@ -17,36 +17,11 @@
* under the License.
*/
-import { i18n } from '@kbn/i18n';
-import { npStart } from 'ui/new_platform';
-// @ts-ignore
-import { uiModules } from 'ui/modules';
import { SavedObjectLoader } from 'ui/saved_objects';
-// @ts-ignore
-import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
+import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedDashboardClass } from './saved_dashboard';
-const module = uiModules.get('app/dashboard');
-
-// Register this service with the saved object registry so it can be
-// edited by the object editor.
-savedObjectManagementRegistry.register({
- service: 'savedDashboards',
- title: i18n.translate('kbn.dashboard.savedDashboardsTitle', {
- defaultMessage: 'dashboards',
- }),
-});
-
-// This is the only thing that gets injected into controllers
-module.service('savedDashboards', function() {
- const savedObjectsClient = npStart.core.savedObjects.client;
- const services = {
- savedObjectsClient,
- indexPatterns: npStart.plugins.data.indexPatterns,
- chrome: npStart.core.chrome,
- overlays: npStart.core.overlays,
- };
-
+export function createSavedDashboardLoader(services: SavedObjectKibanaServices) {
const SavedDashboard = createSavedDashboardClass(services);
- return new SavedObjectLoader(SavedDashboard, savedObjectsClient, npStart.core.chrome);
-});
+ return new SavedObjectLoader(SavedDashboard, services.savedObjectsClient, services.chrome);
+}
diff --git a/src/legacy/core_plugins/kibana/public/discover/index.ts b/src/legacy/core_plugins/kibana/public/discover/index.ts
index e85408dc9bf6b9..347f545dea4c95 100644
--- a/src/legacy/core_plugins/kibana/public/discover/index.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/index.ts
@@ -18,7 +18,6 @@
*/
import { PluginInitializer, PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';
-import { SavedObjectRegistryProvider } from 'ui/saved_objects';
import { DiscoverPlugin, DiscoverSetup, DiscoverStart } from './plugin';
// Core will be looking for this when loading our plugin in the new platform
@@ -33,8 +32,4 @@ export const pluginInstance = plugin({} as PluginInitializerContext);
pluginInstance.start(npStart.core, npStart.plugins);
})();
-SavedObjectRegistryProvider.register((savedSearches: any) => {
- return savedSearches;
-});
-
export { createSavedSearchesService } from './saved_searches/saved_searches';
diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts
index ae388a243dd2bf..ca169e5f803ab6 100644
--- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts
@@ -65,8 +65,8 @@ export {
SearchSource,
EsQuerySortValue,
SortDirection,
- SearchSourceContract,
-} from '../../../../ui/public/courier';
+ ISearchSource,
+} from 'ui/courier';
// @ts-ignore
export { intervalOptions } from 'ui/agg_types/buckets/_interval_options';
// @ts-ignore
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context/api/utils/fetch_hits_in_interval.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context/api/utils/fetch_hits_in_interval.ts
index 1351421e1af04f..e7df44e6fe61c7 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context/api/utils/fetch_hits_in_interval.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context/api/utils/fetch_hits_in_interval.ts
@@ -16,11 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import {
- EsQuerySortValue,
- SortDirection,
- SearchSourceContract,
-} from '../../../../../kibana_services';
+import { EsQuerySortValue, SortDirection, ISearchSource } from '../../../../../kibana_services';
import { convertTimeValueToIso } from './date_conversion';
import { EsHitRecordList } from '../context';
import { IntervalValue } from './generate_intervals';
@@ -40,7 +36,7 @@ interface RangeQuery {
* and filters set.
*/
export async function fetchHitsInInterval(
- searchSource: SearchSourceContract,
+ searchSource: ISearchSource,
timeField: string,
sort: [EsQuerySortValue, EsQuerySortValue],
sortDir: SortDirection,
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts
index 14f70570452516..3aa8dea816694f 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts
@@ -50,7 +50,7 @@ import {
getServices,
IndexPattern,
RequestAdapter,
- SearchSourceContract,
+ ISearchSource,
} from '../../kibana_services';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
@@ -89,7 +89,7 @@ export class SearchEmbeddable extends Embeddable
private inspectorAdaptors: Adapters;
private searchScope?: SearchScope;
private panelTitle: string = '';
- private filtersSearchSource?: SearchSourceContract;
+ private filtersSearchSource?: ISearchSource;
private searchInstance?: JQLite;
private autoRefreshFetchSubscription?: Subscription;
private subscription?: Subscription;
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts
index c8920e351fccad..d36a6b02e1f7a4 100644
--- a/src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts
@@ -17,14 +17,13 @@
* under the License.
*/
-import { SearchSourceContract } from '../kibana_services';
+import { ISearchSource } from '../kibana_services';
import { SortOrder } from './angular/doc_table/components/table_header/helpers';
-export { SortOrder } from './angular/doc_table/components/table_header/helpers';
export interface SavedSearch {
readonly id: string;
title: string;
- searchSource: SearchSourceContract;
+ searchSource: ISearchSource;
description?: string;
columns: string[];
sort: SortOrder[];
diff --git a/src/legacy/core_plugins/kibana/public/discover/saved_searches/saved_searches_register.ts b/src/legacy/core_plugins/kibana/public/discover/saved_searches/saved_searches_register.ts
index bdb1495a33925f..ab7894fd5e730b 100644
--- a/src/legacy/core_plugins/kibana/public/discover/saved_searches/saved_searches_register.ts
+++ b/src/legacy/core_plugins/kibana/public/discover/saved_searches/saved_searches_register.ts
@@ -31,13 +31,13 @@ savedObjectManagementRegistry.register({
service: 'savedSearches',
title: 'searches',
});
+const services = {
+ savedObjectsClient: npStart.core.savedObjects.client,
+ indexPatterns: npStart.plugins.data.indexPatterns,
+ chrome: npStart.core.chrome,
+ overlays: npStart.core.overlays,
+};
+const savedSearches = createSavedSearchesService(services);
+
const module = uiModules.get('discover/saved_searches');
-module.service('savedSearches', () => {
- const services = {
- savedObjectsClient: npStart.core.savedObjects.client,
- indexPatterns: npStart.plugins.data.indexPatterns,
- chrome: npStart.core.chrome,
- overlays: npStart.core.overlays,
- };
- return createSavedSearchesService(services);
-});
+module.service('savedSearches', () => savedSearches);
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js
index 9d84c033837434..ffc9aed9a27a3b 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js
+++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js
@@ -27,7 +27,7 @@ import { fatalError, toastNotifications } from 'ui/notify';
import uiRoutes from 'ui/routes';
import { uiModules } from 'ui/modules';
import template from './edit_index_pattern.html';
-import { fieldWildcardMatcher } from 'ui/field_wildcard';
+import { fieldWildcardMatcher } from '../../../../../../../../plugins/kibana_utils/public';
import { setup as managementSetup } from '../../../../../../management/public/legacy';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/index.ts b/src/legacy/core_plugins/kibana/public/visualize/index.ts
index bd605c5393d218..a389a44197baf4 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/index.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/index.ts
@@ -25,7 +25,6 @@ import {
legacyChrome,
npSetup,
npStart,
- SavedObjectRegistryProvider,
VisEditorTypesRegistryProvider,
} from './legacy_imports';
import { VisualizePlugin, LegacyAngularInjectedDependencies } from './plugin';
@@ -45,13 +44,10 @@ async function getAngularDependencies(): Promise('Private');
const editorTypes = Private(VisEditorTypesRegistryProvider);
- const savedObjectRegistry = Private(SavedObjectRegistryProvider);
return {
legacyChrome,
editorTypes,
- savedObjectRegistry,
- savedVisualizations: injector.get('savedVisualizations'),
};
}
@@ -69,3 +65,5 @@ async function getAngularDependencies(): Promise {
const isLabsEnabled = uiSettings.get('visualize:enableLabs');
- return visualizationService
+ return savedVisualizations
.findListItems(filter, uiSettings.get('savedObjects:listingLimit'))
.then(result => {
this.totalItems = result.total;
diff --git a/src/legacy/core_plugins/kibana/public/visualize/plugin.ts b/src/legacy/core_plugins/kibana/public/visualize/plugin.ts
index d1afa2d0651946..9ea26f129895ce 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/plugin.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/plugin.ts
@@ -46,14 +46,12 @@ import {
VisualizeEmbeddableFactory,
VISUALIZE_EMBEDDABLE_TYPE,
} from './legacy_imports';
-import { SavedVisualizations } from './np_ready/types';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
+import { createSavedVisLoader } from './saved_visualizations/saved_visualizations';
export interface LegacyAngularInjectedDependencies {
legacyChrome: any;
editorTypes: any;
- savedObjectRegistry: any;
- savedVisualizations: SavedVisualizations;
}
export interface VisualizePluginStartDependencies {
@@ -110,6 +108,12 @@ export class VisualizePlugin implements Plugin {
} = this.startDependencies;
const angularDependencies = await getAngularDependencies();
+ const savedVisualizations = createSavedVisLoader({
+ savedObjectsClient,
+ indexPatterns: data.indexPatterns,
+ chrome: contextCore.chrome,
+ overlays: contextCore.overlays,
+ });
const deps: VisualizeKibanaServices = {
...angularDependencies,
addBasePath: contextCore.http.basePath.prepend,
@@ -122,6 +126,7 @@ export class VisualizePlugin implements Plugin {
localStorage: new Storage(localStorage),
navigation,
savedObjectsClient,
+ savedVisualizations,
savedQueryService: data.query.savedQueries,
share,
toastNotifications: contextCore.notifications.toasts,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.ts b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.ts
index 803474b1f7b3f1..cbf72339804ce9 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.ts
@@ -16,15 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
+import { npStart } from 'ui/new_platform';
+// @ts-ignore
+import { uiModules } from 'ui/modules';
// @ts-ignore
import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
import './saved_visualizations';
+import { createSavedVisLoader } from './saved_visualizations';
-SavedObjectRegistryProvider.register((savedVisualizations: any) => {
- return savedVisualizations;
-});
+const services = {
+ savedObjectsClient: npStart.core.savedObjects.client,
+ indexPatterns: npStart.plugins.data.indexPatterns,
+ chrome: npStart.core.chrome,
+ overlays: npStart.core.overlays,
+};
+
+const savedObjectLoaderVisualize = createSavedVisLoader(services);
// Register this service with the saved object registry so it can be
// edited by the object editor.
@@ -32,3 +39,5 @@ savedObjectManagementRegistry.register({
service: 'savedVisualizations',
title: 'visualizations',
});
+
+uiModules.get('app/visualize').service('savedVisualizations', () => savedObjectLoaderVisualize);
diff --git a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.ts b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.ts
index aa8d20fed48289..c19c7818c1fbda 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualizations.ts
@@ -16,26 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { npStart } from 'ui/new_platform';
-// @ts-ignore
-import { uiModules } from 'ui/modules';
import { SavedObjectLoader } from 'ui/saved_objects';
+import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
// @ts-ignore
import { findListItems } from './find_list_items';
import { createSavedVisClass } from './_saved_vis';
import { createVisualizeEditUrl } from '..';
-const app = uiModules.get('app/visualize');
-app.service('savedVisualizations', function() {
- const savedObjectsClient = npStart.core.savedObjects.client;
- const services = {
- savedObjectsClient,
- indexPatterns: npStart.plugins.data.indexPatterns,
- chrome: npStart.core.chrome,
- overlays: npStart.core.overlays,
- };
+export function createSavedVisLoader(services: SavedObjectKibanaServices) {
+ const { savedObjectsClient } = services;
+
class SavedObjectLoaderVisualize extends SavedObjectLoader {
mapHitSource = (source: Record, id: string) => {
const visTypes = visualizations.types;
@@ -81,6 +73,5 @@ app.service('savedVisualizations', function() {
}
}
const SavedVis = createSavedVisClass(services);
-
- return new SavedObjectLoaderVisualize(SavedVis, savedObjectsClient, npStart.core.chrome);
-});
+ return new SavedObjectLoaderVisualize(SavedVis, savedObjectsClient, services.chrome);
+}
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts
index 6aade246d5f653..fc91742c53cca5 100644
--- a/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts
@@ -29,7 +29,7 @@ import { getTableAggs } from 'ui/visualize/loader/pipeline_helpers/utilities';
import { AppState } from 'ui/state_management/app_state';
import { npStart } from 'ui/new_platform';
import { IExpressionLoaderParams } from 'src/plugins/expressions/public';
-import { SearchSourceContract } from 'ui/courier';
+import { ISearchSource } from 'ui/courier';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
IIndexPattern,
@@ -54,7 +54,7 @@ const getKeys = (o: T): Array => Object.keys(o) as Array<
export interface VisSavedObject extends SavedObject {
vis: Vis;
description?: string;
- searchSource: SearchSourceContract;
+ searchSource: ISearchSource;
title: string;
uiStateJSON?: string;
destroy: () => void;
@@ -277,7 +277,13 @@ export class VisualizeEmbeddable extends Embeddable {
- const visTypesWithoutInspector = ['markdown', 'input_control_vis', 'metrics', 'vega'];
+ const visTypesWithoutInspector = [
+ 'markdown',
+ 'input_control_vis',
+ 'metrics',
+ 'vega',
+ 'timelion',
+ ];
if (visTypesWithoutInspector.includes(this.vis.type.name)) {
return false;
}
diff --git a/src/legacy/core_plugins/timelion/public/app.js b/src/legacy/core_plugins/timelion/public/app.js
index 365e74e93c4ada..7ef722ee3a277c 100644
--- a/src/legacy/core_plugins/timelion/public/app.js
+++ b/src/legacy/core_plugins/timelion/public/app.js
@@ -23,7 +23,6 @@ import { i18n } from '@kbn/i18n';
import { capabilities } from 'ui/capabilities';
import { docTitle } from 'ui/doc_title';
-import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { fatalError, toastNotifications } from 'ui/notify';
import { timezoneProvider } from 'ui/vis/lib/timezone';
import { timefilter } from 'ui/timefilter';
@@ -36,16 +35,15 @@ require('ui/autoload/all');
// TODO: remove ui imports completely (move to plugins)
import 'ui/directives/input_focus';
-import 'ui/directives/saved_object_finder';
+import './directives/saved_object_finder';
import 'ui/directives/listen';
import 'ui/kbn_top_nav';
import 'ui/saved_objects/ui/saved_object_save_as_checkbox';
import '../../data/public/legacy';
-import './services/saved_sheets';
-import './services/_saved_sheet';
import './services/saved_sheet_register';
import rootTemplate from 'plugins/timelion/index.html';
+import { createSavedVisLoader } from '../../kibana/public/visualize';
require('plugins/timelion/directives/cells/cells');
require('plugins/timelion/directives/fixed_element');
@@ -130,8 +128,12 @@ app.controller('timelion', function(
timefilter.enableAutoRefreshSelector();
timefilter.enableTimeRangeSelector();
- const savedVisualizations = Private(SavedObjectRegistryProvider).byLoaderPropertiesName
- .visualizations;
+ const savedVisualizations = createSavedVisLoader({
+ savedObjectsClient: npStart.core.savedObjects.client,
+ indexPatterns: npStart.plugins.data.indexPatterns,
+ chrome: npStart.core.chrome,
+ overlays: npStart.core.overlays,
+ });
const timezone = Private(timezoneProvider)();
const defaultExpression = '.es(*)';
diff --git a/src/legacy/ui/public/directives/partials/saved_object_finder.html b/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.html
similarity index 86%
rename from src/legacy/ui/public/directives/partials/saved_object_finder.html
rename to src/legacy/core_plugins/timelion/public/directives/saved_object_finder.html
index adf7f5dacae9a6..ad148801c03a4a 100644
--- a/src/legacy/ui/public/directives/partials/saved_object_finder.html
+++ b/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.html
@@ -23,7 +23,7 @@
@@ -33,7 +33,7 @@
ng-if="onAddNew"
ng-click="onAddNew()"
data-test-subj="addNewSavedObjectLink"
- i18n-id="common.ui.savedObjectFinder.addNewItemButtonLabel"
+ i18n-id="timelion.savedObjectFinder.addNewItemButtonLabel"
i18n-default-message="Add new {item}"
i18n-values="{item: finder.properties.noun}"
i18n-description="{item} can be a type of object in Kibana, like 'visualization', 'dashboard', etc"
@@ -43,7 +43,7 @@
class="kuiButton kuiButton--secondary"
ng-if="!useLocalManagement"
ng-click="finder.manageObjects(finder.properties.name)"
- i18n-id="common.ui.savedObjectFinder.manageItemsButtonLabel"
+ i18n-id="timelion.savedObjectFinder.manageItemsButtonLabel"
i18n-default-message="Manage {items}"
i18n-values="{items: finder.properties.nouns}"
i18n-description="{items} can be a type of object in Kibana, like 'visualizations', 'dashboards', etc"
@@ -64,11 +64,11 @@
aria-live="assertive"
>
@@ -108,7 +108,7 @@
class="list-group-item list-group-no-results"
ng-if="finder.hits.length === 0"
>
-
{
- return savedSheets;
-});
diff --git a/src/legacy/core_plugins/timelion/public/services/saved_sheets.ts b/src/legacy/core_plugins/timelion/public/services/saved_sheets.ts
index d851b5a8636581..df3898e3410ddd 100644
--- a/src/legacy/core_plugins/timelion/public/services/saved_sheets.ts
+++ b/src/legacy/core_plugins/timelion/public/services/saved_sheets.ts
@@ -33,29 +33,28 @@ savedObjectManagementRegistry.register({
title: 'sheets',
});
-// This is the only thing that gets injected into controllers
-module.service('savedSheets', function() {
- const savedObjectsClient = npStart.core.savedObjects.client;
- const services = {
- savedObjectsClient,
- indexPatterns: npStart.plugins.data.indexPatterns,
- chrome: npStart.core.chrome,
- overlays: npStart.core.overlays,
- };
+const savedObjectsClient = npStart.core.savedObjects.client;
+const services = {
+ savedObjectsClient,
+ indexPatterns: npStart.plugins.data.indexPatterns,
+ chrome: npStart.core.chrome,
+ overlays: npStart.core.overlays,
+};
- const SavedSheet = createSavedSheetClass(services, npStart.core.uiSettings);
+const SavedSheet = createSavedSheetClass(services, npStart.core.uiSettings);
- const savedSheetLoader = new SavedObjectLoader(
- SavedSheet,
- savedObjectsClient,
- npStart.core.chrome
- );
- savedSheetLoader.urlFor = id => `#/${encodeURIComponent(id)}`;
- // Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
- savedSheetLoader.loaderProperties = {
- name: 'timelion-sheet',
- noun: 'Saved Sheets',
- nouns: 'saved sheets',
- };
- return savedSheetLoader;
-});
+export const savedSheetLoader = new SavedObjectLoader(
+ SavedSheet,
+ savedObjectsClient,
+ npStart.core.chrome
+);
+savedSheetLoader.urlFor = id => `#/${encodeURIComponent(id)}`;
+// Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
+savedSheetLoader.loaderProperties = {
+ name: 'timelion-sheet',
+ noun: 'Saved Sheets',
+ nouns: 'saved sheets',
+};
+
+// This is the only thing that gets injected into controllers
+module.service('savedSheets', () => savedSheetLoader);
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts
index 0f9e9c11a9dbc2..59c6bddb64521d 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts
@@ -28,7 +28,7 @@ import {
createFormat,
} from '../../../legacy_imports';
// eslint-disable-next-line
-import { SearchSourceContract } from '../../../../../../ui/public/courier/search_source/search_source';
+import { ISearchSource } from '../../../../../../ui/public/courier/search_source/search_source';
import { Vis, VisParams, VisState } from '..';
interface SchemaConfigParams {
@@ -466,7 +466,7 @@ export const buildVislibDimensions = async (
// take a Vis object and decorate it with the necessary params (dimensions, bucket, metric, etc)
export const getVisParams = async (
vis: Vis,
- params: { searchSource: SearchSourceContract; timeRange?: any; abortSignal?: AbortSignal }
+ params: { searchSource: ISearchSource; timeRange?: any; abortSignal?: AbortSignal }
) => {
const schemas = getSchemas(vis, params.timeRange);
let visConfig = cloneDeep(vis.params);
@@ -484,7 +484,7 @@ export const getVisParams = async (
export const buildPipeline = async (
vis: Vis,
params: {
- searchSource: SearchSourceContract;
+ searchSource: ISearchSource;
timeRange?: any;
}
) => {
diff --git a/src/legacy/ui/public/agg_types/agg_config.ts b/src/legacy/ui/public/agg_types/agg_config.ts
index 9306ffcaff9fd9..07e0d46e4eb70c 100644
--- a/src/legacy/ui/public/agg_types/agg_config.ts
+++ b/src/legacy/ui/public/agg_types/agg_config.ts
@@ -27,7 +27,7 @@
import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
-import { SearchSourceContract, FetchOptions } from '../courier/types';
+import { ISearchSource, FetchOptions } from '../courier/types';
import { AggType } from './agg_type';
import { AggGroupNames } from '../vis/editors/default/agg_groups';
import { writeParams } from './agg_params';
@@ -236,7 +236,7 @@ export class AggConfig {
* @param {Courier.FetchOptions} options
* @return {Promise}
*/
- onSearchRequestStart(searchSource: SearchSourceContract, options?: FetchOptions) {
+ onSearchRequestStart(searchSource: ISearchSource, options?: FetchOptions) {
if (!this.type) {
return Promise.resolve();
}
diff --git a/src/legacy/ui/public/agg_types/agg_configs.ts b/src/legacy/ui/public/agg_types/agg_configs.ts
index b5a7474c99b0e7..ece9c90d09b689 100644
--- a/src/legacy/ui/public/agg_types/agg_configs.ts
+++ b/src/legacy/ui/public/agg_types/agg_configs.ts
@@ -32,7 +32,7 @@ import { Schema } from '../vis/editors/default/schemas';
import { AggConfig, AggConfigOptions } from './agg_config';
import { AggGroupNames } from '../vis/editors/default/agg_groups';
import { IndexPattern } from '../../../core_plugins/data/public';
-import { SearchSourceContract, FetchOptions } from '../courier/types';
+import { ISearchSource, FetchOptions } from '../courier/types';
type Schemas = Record;
@@ -306,7 +306,7 @@ export class AggConfigs {
return _.find(reqAgg.getResponseAggs(), { id });
}
- onSearchRequestStart(searchSource: SearchSourceContract, options?: FetchOptions) {
+ onSearchRequestStart(searchSource: ISearchSource, options?: FetchOptions) {
return Promise.all(
// @ts-ignore
this.getRequestAggs().map((agg: AggConfig) => agg.onSearchRequestStart(searchSource, options))
diff --git a/src/legacy/ui/public/agg_types/agg_type.ts b/src/legacy/ui/public/agg_types/agg_type.ts
index ff4c6875ec6c06..39be1983223bc2 100644
--- a/src/legacy/ui/public/agg_types/agg_type.ts
+++ b/src/legacy/ui/public/agg_types/agg_type.ts
@@ -24,7 +24,7 @@ import { initParams } from './agg_params';
import { AggConfig } from '../vis';
import { AggConfigs } from './agg_configs';
-import { SearchSource } from '../courier';
+import { ISearchSource } from '../courier';
import { Adapters } from '../inspector';
import { BaseParamType } from './param_types/base';
import { AggParamType } from '../agg_types/param_types/agg';
@@ -51,7 +51,7 @@ export interface AggTypeConfig<
resp: any,
aggConfigs: AggConfigs,
aggConfig: TAggConfig,
- searchSource: SearchSource,
+ searchSource: ISearchSource,
inspectorAdapters: Adapters,
abortSignal?: AbortSignal
) => Promise;
@@ -180,7 +180,7 @@ export class AggType<
resp: any,
aggConfigs: AggConfigs,
aggConfig: TAggConfig,
- searchSource: SearchSource,
+ searchSource: ISearchSource,
inspectorAdapters: Adapters,
abortSignal?: AbortSignal
) => Promise;
diff --git a/src/legacy/ui/public/agg_types/buckets/terms.ts b/src/legacy/ui/public/agg_types/buckets/terms.ts
index ef9ceb96b005de..c805e53eb2b913 100644
--- a/src/legacy/ui/public/agg_types/buckets/terms.ts
+++ b/src/legacy/ui/public/agg_types/buckets/terms.ts
@@ -19,7 +19,7 @@
import { noop } from 'lodash';
import { i18n } from '@kbn/i18n';
-import { SearchSource, getRequestInspectorStats, getResponseInspectorStats } from '../../courier';
+import { ISearchSource, getRequestInspectorStats, getResponseInspectorStats } from '../../courier';
import { BucketAggType } from './_bucket_agg_type';
import { BUCKET_TYPES } from './bucket_agg_types';
import { IBucketAggConfig } from './_bucket_agg_type';
@@ -90,7 +90,7 @@ export const termsBucketAgg = new BucketAggType({
resp: any,
aggConfigs: AggConfigs,
aggConfig: IBucketAggConfig,
- searchSource: SearchSource,
+ searchSource: ISearchSource,
inspectorAdapters: Adapters,
abortSignal?: AbortSignal
) => {
diff --git a/src/legacy/ui/public/agg_types/param_types/base.ts b/src/legacy/ui/public/agg_types/param_types/base.ts
index bc8fd30e6324e3..f466a9512edf90 100644
--- a/src/legacy/ui/public/agg_types/param_types/base.ts
+++ b/src/legacy/ui/public/agg_types/param_types/base.ts
@@ -19,7 +19,7 @@
import { AggConfigs } from '../agg_configs';
import { AggConfig } from '../../vis';
-import { SearchSourceContract, FetchOptions } from '../../courier/types';
+import { ISearchSource, FetchOptions } from '../../courier/types';
export class BaseParamType {
name: string;
@@ -54,7 +54,7 @@ export class BaseParamType {
*/
modifyAggConfigOnSearchRequestStart: (
aggConfig: TAggConfig,
- searchSource?: SearchSourceContract,
+ searchSource?: ISearchSource,
options?: FetchOptions
) => void;
diff --git a/src/legacy/ui/public/courier/_index.scss b/src/legacy/ui/public/courier/_index.scss
index a5b3911b1d53c8..17382cfa30ce53 100644
--- a/src/legacy/ui/public/courier/_index.scss
+++ b/src/legacy/ui/public/courier/_index.scss
@@ -1 +1 @@
-@import './fetch/components/shard_failure_modal';
\ No newline at end of file
+@import '../../../core_plugins/data/public/search/fetch/components/shard_failure_modal';
\ No newline at end of file
diff --git a/src/legacy/ui/public/courier/index.ts b/src/legacy/ui/public/courier/index.ts
index c8a06ec2a5518d..709ff1c11e9013 100644
--- a/src/legacy/ui/public/courier/index.ts
+++ b/src/legacy/ui/public/courier/index.ts
@@ -17,31 +17,46 @@
* under the License.
*/
-export { SearchSource } from './search_source';
+/**
+ * Nothing to see here!
+ *
+ * Courier / SearchSource has moved to the data plugin, and is being
+ * re-exported from ui/courier for backwards compatibility.
+ */
+
+import { start as dataStart } from '../../../core_plugins/data/public/legacy';
+
+// runtime contracts
+export const { defaultSearchStrategy, SearchSource } = dataStart.search;
+
+// types
+export {
+ ISearchSource,
+ EsQuerySortValue, // used externally by Discover
+ FetchOptions, // used externally by AggTypes
+ SortDirection, // used externally by Discover
+} from '../../../core_plugins/data/public';
+
+// static code
+export {
+ getRequestInspectorStats,
+ getResponseInspectorStats,
+} from '../../../core_plugins/data/public';
// TODO: Exporting this mock outside of jest tests causes errors because
// jest is undefined. Need to refactor the mock to be consistent with
// other NP-style mocks.
// export { searchSourceMock } from './search_source/mocks';
+// Most these can probably be made internal to the search
+// service, so we are temporarily deeply importing them
+// until we relocate them to a longer-term home.
+/* eslint-disable @kbn/eslint/no-restricted-paths */
export {
addSearchStrategy, // used externally by Rollups
getSearchErrorType, // used externally by Rollups
hasSearchStategyForIndexPattern, // used externally by Discover
isDefaultTypeIndexPattern, // used externally by Discover
SearchError, // used externally by Visualizations & Rollups
-} from './search_strategy';
-
-export {
- getRequestInspectorStats,
- getResponseInspectorStats,
-} from './utils/courier_inspector_utils';
-
-// types
-export { SearchSourceContract } from './search_source';
-
-export {
- EsQuerySortValue, // used externally by Discover
- FetchOptions, // used externally by AggTypes
- SortDirection, // used externally by Discover
-} from './types';
+} from '../../../core_plugins/data/public/search/search_strategy';
+/* eslint-enable @kbn/eslint/no-restricted-paths */
diff --git a/src/legacy/ui/public/courier/search_source/index.ts b/src/legacy/ui/public/courier/search_source/index.ts
index 72170adc2b1296..e7ca48a894b3dc 100644
--- a/src/legacy/ui/public/courier/search_source/index.ts
+++ b/src/legacy/ui/public/courier/search_source/index.ts
@@ -17,4 +17,4 @@
* under the License.
*/
-export * from './search_source';
+export { SearchSource, ISearchSource } from '../index';
diff --git a/src/legacy/ui/public/courier/search_source/mocks.ts b/src/legacy/ui/public/courier/search_source/mocks.ts
index 2b83f379b4f090..7b7843d22f5198 100644
--- a/src/legacy/ui/public/courier/search_source/mocks.ts
+++ b/src/legacy/ui/public/courier/search_source/mocks.ts
@@ -36,9 +36,11 @@
* under the License.
*/
-import { SearchSourceContract } from './search_source';
+// This mock is here for BWC, but will be left behind and replaced by
+// the data service mock in the new platform.
+import { ISearchSource } from '../index';
-export const searchSourceMock: MockedKeys = {
+export const searchSourceMock: MockedKeys = {
setPreferredSearchStrategyId: jest.fn(),
setFields: jest.fn().mockReturnThis(),
setField: jest.fn().mockReturnThis(),
diff --git a/src/legacy/ui/public/courier/search_source/search_source.ts b/src/legacy/ui/public/courier/search_source/search_source.ts
index e862bb1118a74b..e7ca48a894b3dc 100644
--- a/src/legacy/ui/public/courier/search_source/search_source.ts
+++ b/src/legacy/ui/public/courier/search_source/search_source.ts
@@ -17,394 +17,4 @@
* under the License.
*/
-/**
- * @name SearchSource
- *
- * @description A promise-based stream of search results that can inherit from other search sources.
- *
- * Because filters/queries in Kibana have different levels of persistence and come from different
- * places, it is important to keep track of where filters come from for when they are saved back to
- * the savedObject store in the Kibana index. To do this, we create trees of searchSource objects
- * that can have associated query parameters (index, query, filter, etc) which can also inherit from
- * other searchSource objects.
- *
- * At query time, all of the searchSource objects that have subscribers are "flattened", at which
- * point the query params from the searchSource are collected while traversing up the inheritance
- * chain. At each link in the chain a decision about how to merge the query params is made until a
- * single set of query parameters is created for each active searchSource (a searchSource with
- * subscribers).
- *
- * That set of query parameters is then sent to elasticsearch. This is how the filter hierarchy
- * works in Kibana.
- *
- * Visualize, starting from a new search:
- *
- * - the `savedVis.searchSource` is set as the `appSearchSource`.
- * - The `savedVis.searchSource` would normally inherit from the `appSearchSource`, but now it is
- * upgraded to inherit from the `rootSearchSource`.
- * - Any interaction with the visualization will still apply filters to the `appSearchSource`, so
- * they will be stored directly on the `savedVis.searchSource`.
- * - Any interaction with the time filter will be written to the `rootSearchSource`, so those
- * filters will not be saved by the `savedVis`.
- * - When the `savedVis` is saved to elasticsearch, it takes with it all the filters that are
- * defined on it directly, but none of the ones that it inherits from other places.
- *
- * Visualize, starting from an existing search:
- *
- * - The `savedVis` loads the `savedSearch` on which it is built.
- * - The `savedVis.searchSource` is set to inherit from the `saveSearch.searchSource` and set as
- * the `appSearchSource`.
- * - The `savedSearch.searchSource`, is set to inherit from the `rootSearchSource`.
- * - Then the `savedVis` is written to elasticsearch it will be flattened and only include the
- * filters created in the visualize application and will reconnect the filters from the
- * `savedSearch` at runtime to prevent losing the relationship
- *
- * Dashboard search sources:
- *
- * - Each panel in a dashboard has a search source.
- * - The `savedDashboard` also has a searchsource, and it is set as the `appSearchSource`.
- * - Each panel's search source inherits from the `appSearchSource`, meaning that they inherit from
- * the dashboard search source.
- * - When a filter is added to the search box, or via a visualization, it is written to the
- * `appSearchSource`.
- */
-
-import _ from 'lodash';
-import { npSetup } from 'ui/new_platform';
-import { normalizeSortRequest } from './normalize_sort_request';
-import { fetchSoon } from '../fetch';
-import { fieldWildcardFilter } from '../../field_wildcard';
-import { getHighlightRequest, esFilters, esQuery } from '../../../../../plugins/data/public';
-import chrome from '../../chrome';
-import { RequestFailure } from '../fetch/errors';
-import { filterDocvalueFields } from './filter_docvalue_fields';
-import { SearchSourceOptions, SearchSourceFields, SearchRequest } from './types';
-import { FetchOptions, ApiCaller } from '../fetch/types';
-
-const esShardTimeout = npSetup.core.injectedMetadata.getInjectedVar('esShardTimeout') as number;
-const config = npSetup.core.uiSettings;
-
-export type SearchSourceContract = Pick;
-
-export class SearchSource {
- private id: string = _.uniqueId('data_source');
- private searchStrategyId?: string;
- private parent?: SearchSource;
- private requestStartHandlers: Array<
- (searchSource: SearchSourceContract, options?: FetchOptions) => Promise
- > = [];
- private inheritOptions: SearchSourceOptions = {};
- public history: SearchRequest[] = [];
-
- constructor(private fields: SearchSourceFields = {}) {}
-
- /** ***
- * PUBLIC API
- *****/
-
- setPreferredSearchStrategyId(searchStrategyId: string) {
- this.searchStrategyId = searchStrategyId;
- }
-
- setFields(newFields: SearchSourceFields) {
- this.fields = newFields;
- return this;
- }
-
- setField(field: K, value: SearchSourceFields[K]) {
- if (value == null) {
- delete this.fields[field];
- } else {
- this.fields[field] = value;
- }
- return this;
- }
-
- getId() {
- return this.id;
- }
-
- getFields() {
- return { ...this.fields };
- }
-
- /**
- * Get fields from the fields
- */
- getField(field: K, recurse = true): SearchSourceFields[K] {
- if (!recurse || this.fields[field] !== void 0) {
- return this.fields[field];
- }
- const parent = this.getParent();
- return parent && parent.getField(field);
- }
-
- /**
- * Get the field from our own fields, don't traverse up the chain
- */
- getOwnField(field: K): SearchSourceFields[K] {
- return this.getField(field, false);
- }
-
- create() {
- return new SearchSource();
- }
-
- createCopy() {
- const newSearchSource = new SearchSource();
- newSearchSource.setFields({ ...this.fields });
- // when serializing the internal fields we lose the internal classes used in the index
- // pattern, so we have to set it again to workaround this behavior
- newSearchSource.setField('index', this.getField('index'));
- newSearchSource.setParent(this.getParent());
- return newSearchSource;
- }
-
- createChild(options = {}) {
- const childSearchSource = new SearchSource();
- childSearchSource.setParent(this, options);
- return childSearchSource;
- }
-
- /**
- * Set a searchSource that this source should inherit from
- * @param {SearchSource} parent - the parent searchSource
- * @param {SearchSourceOptions} options - the inherit options
- * @return {this} - chainable
- */
- setParent(parent?: SearchSourceContract, options: SearchSourceOptions = {}) {
- this.parent = parent as SearchSource;
- this.inheritOptions = options;
- return this;
- }
-
- /**
- * Get the parent of this SearchSource
- * @return {undefined|searchSource}
- */
- getParent() {
- return this.parent;
- }
-
- /**
- * Fetch this source and reject the returned Promise on error
- *
- * @async
- */
- async fetch(options: FetchOptions = {}) {
- const $injector = await chrome.dangerouslyGetActiveInjector();
- const es = $injector.get('es') as ApiCaller;
-
- await this.requestIsStarting(options);
-
- const searchRequest = await this.flatten();
- this.history = [searchRequest];
-
- const response = await fetchSoon(
- searchRequest,
- {
- ...(this.searchStrategyId && { searchStrategyId: this.searchStrategyId }),
- ...options,
- },
- { es, config, esShardTimeout }
- );
-
- if (response.error) {
- throw new RequestFailure(null, response);
- }
-
- return response;
- }
-
- /**
- * Add a handler that will be notified whenever requests start
- * @param {Function} handler
- * @return {undefined}
- */
- onRequestStart(
- handler: (searchSource: SearchSourceContract, options?: FetchOptions) => Promise
- ) {
- this.requestStartHandlers.push(handler);
- }
-
- async getSearchRequestBody() {
- const searchRequest = await this.flatten();
- return searchRequest.body;
- }
-
- /**
- * Completely destroy the SearchSource.
- * @return {undefined}
- */
- destroy() {
- this.requestStartHandlers.length = 0;
- }
-
- /** ****
- * PRIVATE APIS
- ******/
-
- /**
- * Called by requests of this search source when they are started
- * @param {Courier.Request} request
- * @param options
- * @return {Promise}
- */
- private requestIsStarting(options: FetchOptions = {}) {
- const handlers = [...this.requestStartHandlers];
- // If callParentStartHandlers has been set to true, we also call all
- // handlers of parent search sources.
- if (this.inheritOptions.callParentStartHandlers) {
- let searchSource = this.getParent();
- while (searchSource) {
- handlers.push(...searchSource.requestStartHandlers);
- searchSource = searchSource.getParent();
- }
- }
-
- return Promise.all(handlers.map(fn => fn(this, options)));
- }
-
- /**
- * Used to merge properties into the data within ._flatten().
- * The data is passed in and modified by the function
- *
- * @param {object} data - the current merged data
- * @param {*} val - the value at `key`
- * @param {*} key - The key of `val`
- * @return {undefined}
- */
- private mergeProp(
- data: SearchRequest,
- val: SearchSourceFields[K],
- key: K
- ) {
- val = typeof val === 'function' ? val(this) : val;
- if (val == null || !key) return;
-
- const addToRoot = (rootKey: string, value: any) => {
- data[rootKey] = value;
- };
-
- /**
- * Add the key and val to the body of the request
- */
- const addToBody = (bodyKey: string, value: any) => {
- // ignore if we already have a value
- if (data.body[bodyKey] == null) {
- data.body[bodyKey] = value;
- }
- };
-
- switch (key) {
- case 'filter':
- return addToRoot('filters', (data.filters || []).concat(val));
- case 'query':
- return addToRoot(key, (data[key] || []).concat(val));
- case 'fields':
- const fields = _.uniq((data[key] || []).concat(val));
- return addToRoot(key, fields);
- case 'index':
- case 'type':
- case 'highlightAll':
- return key && data[key] == null && addToRoot(key, val);
- case 'searchAfter':
- return addToBody('search_after', val);
- case 'source':
- return addToBody('_source', val);
- case 'sort':
- const sort = normalizeSortRequest(val, this.getField('index'), config.get('sort:options'));
- return addToBody(key, sort);
- default:
- return addToBody(key, val);
- }
- }
-
- /**
- * Walk the inheritance chain of a source and return its
- * flat representation (taking into account merging rules)
- * @returns {Promise}
- * @resolved {Object|null} - the flat data of the SearchSource
- */
- private mergeProps(root = this, searchRequest: SearchRequest = { body: {} }) {
- Object.entries(this.fields).forEach(([key, value]) => {
- this.mergeProp(searchRequest, value, key as keyof SearchSourceFields);
- });
- if (this.parent) {
- this.parent.mergeProps(root, searchRequest);
- }
- return searchRequest;
- }
-
- private flatten() {
- const searchRequest = this.mergeProps();
-
- searchRequest.body = searchRequest.body || {};
- const { body, index, fields, query, filters, highlightAll } = searchRequest;
-
- const computedFields = index ? index.getComputedFields() : {};
-
- body.stored_fields = computedFields.storedFields;
- body.script_fields = body.script_fields || {};
- _.extend(body.script_fields, computedFields.scriptFields);
-
- const defaultDocValueFields = computedFields.docvalueFields
- ? computedFields.docvalueFields
- : [];
- body.docvalue_fields = body.docvalue_fields || defaultDocValueFields;
-
- if (!body.hasOwnProperty('_source') && index) {
- body._source = index.getSourceFiltering();
- }
-
- if (body._source) {
- // exclude source fields for this index pattern specified by the user
- const filter = fieldWildcardFilter(body._source.excludes, config.get('metaFields'));
- body.docvalue_fields = body.docvalue_fields.filter((docvalueField: any) =>
- filter(docvalueField.field)
- );
- }
-
- // if we only want to search for certain fields
- if (fields) {
- // filter out the docvalue_fields, and script_fields to only include those that we are concerned with
- body.docvalue_fields = filterDocvalueFields(body.docvalue_fields, fields);
- body.script_fields = _.pick(body.script_fields, fields);
-
- // request the remaining fields from both stored_fields and _source
- const remainingFields = _.difference(fields, _.keys(body.script_fields));
- body.stored_fields = remainingFields;
- _.set(body, '_source.includes', remainingFields);
- }
-
- const esQueryConfigs = esQuery.getEsQueryConfig(config);
- body.query = esQuery.buildEsQuery(index, query, filters, esQueryConfigs);
-
- if (highlightAll && body.query) {
- body.highlight = getHighlightRequest(body.query, config.get('doc_table:highlight'));
- delete searchRequest.highlightAll;
- }
-
- const translateToQuery = (filter: esFilters.Filter) => filter && (filter.query || filter);
-
- // re-write filters within filter aggregations
- (function recurse(aggBranch) {
- if (!aggBranch) return;
- Object.keys(aggBranch).forEach(function(id) {
- const agg = aggBranch[id];
-
- if (agg.filters) {
- // translate filters aggregations
- const { filters: aggFilters } = agg.filters;
- Object.keys(aggFilters).forEach(filterId => {
- aggFilters[filterId] = translateToQuery(aggFilters[filterId]);
- });
- }
-
- recurse(agg.aggs || agg.aggregations);
- });
- })(body.aggs || body.aggregations);
-
- return searchRequest;
- }
-}
+export { SearchSource, ISearchSource } from '../index';
diff --git a/src/legacy/ui/public/courier/search_strategy/default_search_strategy.ts b/src/legacy/ui/public/courier/search_strategy/default_search_strategy.ts
index 5be4fef0766555..55dee19cae32a8 100644
--- a/src/legacy/ui/public/courier/search_strategy/default_search_strategy.ts
+++ b/src/legacy/ui/public/courier/search_strategy/default_search_strategy.ts
@@ -17,65 +17,8 @@
* under the License.
*/
-import { SearchStrategyProvider, SearchStrategySearchParams } from './types';
-import { addSearchStrategy } from './search_strategy_registry';
-import { isDefaultTypeIndexPattern } from './is_default_type_index_pattern';
-import {
- getSearchParams,
- getMSearchParams,
- getPreference,
- getTimeout,
-} from '../fetch/get_search_params';
-
-export const defaultSearchStrategy: SearchStrategyProvider = {
- id: 'default',
-
- search: params => {
- return params.config.get('courier:batchSearches') ? msearch(params) : search(params);
- },
-
- isViable: indexPattern => {
- return indexPattern && isDefaultTypeIndexPattern(indexPattern);
- },
-};
-
-function msearch({ searchRequests, es, config, esShardTimeout }: SearchStrategySearchParams) {
- const inlineRequests = searchRequests.map(({ index, body, search_type: searchType }) => {
- const inlineHeader = {
- index: index.title || index,
- search_type: searchType,
- ignore_unavailable: true,
- preference: getPreference(config),
- };
- const inlineBody = {
- ...body,
- timeout: getTimeout(esShardTimeout),
- };
- return `${JSON.stringify(inlineHeader)}\n${JSON.stringify(inlineBody)}`;
- });
-
- const searching = es.msearch({
- ...getMSearchParams(config),
- body: `${inlineRequests.join('\n')}\n`,
- });
- return {
- searching: searching.then(({ responses }) => responses),
- abort: searching.abort,
- };
-}
-
-function search({ searchRequests, es, config, esShardTimeout }: SearchStrategySearchParams) {
- const abortController = new AbortController();
- const searchParams = getSearchParams(config, esShardTimeout);
- const promises = searchRequests.map(({ index, body }) => {
- const searching = es.search({ index: index.title || index, body, ...searchParams });
- abortController.signal.addEventListener('abort', searching.abort);
- return searching.catch(({ response }) => JSON.parse(response));
- });
- return {
- searching: Promise.all(promises),
- abort: () => abortController.abort(),
- };
-}
+import { addSearchStrategy, defaultSearchStrategy } from '../index';
addSearchStrategy(defaultSearchStrategy);
+
+export { defaultSearchStrategy };
diff --git a/src/legacy/ui/public/courier/search_strategy/index.ts b/src/legacy/ui/public/courier/search_strategy/index.ts
index 229d0cbb1da5da..1dce0316596d07 100644
--- a/src/legacy/ui/public/courier/search_strategy/index.ts
+++ b/src/legacy/ui/public/courier/search_strategy/index.ts
@@ -20,10 +20,6 @@
export {
addSearchStrategy,
hasSearchStategyForIndexPattern,
- getSearchStrategyById,
- getSearchStrategyForSearchRequest,
-} from './search_strategy_registry';
-
-export { isDefaultTypeIndexPattern } from './is_default_type_index_pattern';
-
-export { SearchError, getSearchErrorType } from './search_error';
+ isDefaultTypeIndexPattern,
+ SearchError,
+} from '../index';
diff --git a/src/legacy/ui/public/courier/search_strategy/search_error.ts b/src/legacy/ui/public/courier/search_strategy/search_error.ts
index d4042fb17499cb..a815ac4ff008f4 100644
--- a/src/legacy/ui/public/courier/search_strategy/search_error.ts
+++ b/src/legacy/ui/public/courier/search_strategy/search_error.ts
@@ -17,46 +17,4 @@
* under the License.
*/
-interface SearchErrorOptions {
- status: string;
- title: string;
- message: string;
- path: string;
- type: string;
-}
-
-export class SearchError extends Error {
- public name: string;
- public status: string;
- public title: string;
- public message: string;
- public path: string;
- public type: string;
-
- constructor({ status, title, message, path, type }: SearchErrorOptions) {
- super(message);
- this.name = 'SearchError';
- this.status = status;
- this.title = title;
- this.message = message;
- this.path = path;
- this.type = type;
-
- // captureStackTrace is only available in the V8 engine, so any browser using
- // a different JS engine won't have access to this method.
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, SearchError);
- }
-
- // Babel doesn't support traditional `extends` syntax for built-in classes.
- // https://babeljs.io/docs/en/caveats/#classes
- Object.setPrototypeOf(this, SearchError.prototype);
- }
-}
-
-export function getSearchErrorType({ message }: Pick) {
- const msg = message.toLowerCase();
- if (msg.indexOf('unsupported query') > -1) {
- return 'UNSUPPORTED_QUERY';
- }
-}
+export { SearchError } from '../index';
diff --git a/src/legacy/ui/public/courier/types.ts b/src/legacy/ui/public/courier/types.ts
index 23d74ce6a57da8..75035ceef321fa 100644
--- a/src/legacy/ui/public/courier/types.ts
+++ b/src/legacy/ui/public/courier/types.ts
@@ -17,7 +17,9 @@
* under the License.
*/
-export * from './fetch/types';
-export * from './search_source/types';
-export * from './search_strategy/types';
-export * from './utils/types';
+export {
+ ISearchSource,
+ EsQuerySortValue, // used externally by Discover
+ FetchOptions, // used externally by AggTypes
+ SortDirection, // used externally by Discover
+} from './index';
diff --git a/src/legacy/ui/public/saved_objects/index.ts b/src/legacy/ui/public/saved_objects/index.ts
index 3c77a02c608c65..129938ebe05090 100644
--- a/src/legacy/ui/public/saved_objects/index.ts
+++ b/src/legacy/ui/public/saved_objects/index.ts
@@ -17,7 +17,6 @@
* under the License.
*/
-export { SavedObjectRegistryProvider } from './saved_object_registry';
export { SavedObjectsClientProvider } from './saved_objects_client_provider';
export { SavedObjectLoader } from './saved_object_loader';
export { findObjectByTitle } from './helpers/find_object_by_title';
diff --git a/src/legacy/ui/public/saved_objects/types.ts b/src/legacy/ui/public/saved_objects/types.ts
index c4e6438424046f..2578c2015e819f 100644
--- a/src/legacy/ui/public/saved_objects/types.ts
+++ b/src/legacy/ui/public/saved_objects/types.ts
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
import {
ChromeStart,
OverlayStart,
@@ -23,7 +24,7 @@ import {
SavedObjectAttributes,
SavedObjectReference,
} from 'kibana/public';
-import { SearchSource, SearchSourceContract } from 'ui/courier';
+import { ISearchSource } from 'ui/courier';
import { IIndexPattern, IndexPatternsContract } from '../../../../plugins/data/public';
export interface SavedObject {
@@ -46,7 +47,7 @@ export interface SavedObject {
lastSavedTitle: string;
migrationVersion?: Record;
save: (saveOptions: SavedObjectSaveOpts) => Promise;
- searchSource?: SearchSourceContract;
+ searchSource?: ISearchSource;
showInRecentlyAccessed: boolean;
title: string;
}
@@ -88,7 +89,7 @@ export interface SavedObjectConfig {
mapping?: any;
migrationVersion?: Record;
path?: string;
- searchSource?: SearchSource | boolean;
+ searchSource?: ISearchSource | boolean;
type?: string;
}
diff --git a/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts b/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts
index a9203415321faa..5054c34118f786 100644
--- a/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts
+++ b/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts
@@ -24,13 +24,13 @@ import { toastNotifications } from 'ui/notify';
import { AggConfig } from 'ui/vis';
import { timefilter } from 'ui/timefilter';
import { Vis } from '../../../vis';
-import { SearchSource, SearchSourceContract } from '../../../courier';
+import { SearchSource, ISearchSource } from '../../../courier';
import { esFilters, Query } from '../../../../../../plugins/data/public';
interface QueryGeohashBoundsParams {
filters?: esFilters.Filter[];
query?: Query;
- searchSource?: SearchSourceContract;
+ searchSource?: ISearchSource;
}
/**
diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/_dashboard_grid.scss b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/_dashboard_grid.scss
index 9efd36b05095e1..a205e611531b69 100644
--- a/src/plugins/dashboard_embeddable_container/public/embeddable/grid/_dashboard_grid.scss
+++ b/src/plugins/dashboard_embeddable_container/public/embeddable/grid/_dashboard_grid.scss
@@ -74,7 +74,7 @@
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' viewBox='0 0 6 6'%3E%3Cpolygon fill='#{hexToRGB($euiColorDarkShade)}' points='6 6 0 6 0 4.2 4 4.2 4.2 4.2 4.2 0 6 0' /%3E%3C/svg%3E%0A");
&::after {
- border: none;
+ border: none !important; /** overrides library default visual indicator **/
}
&:hover,
diff --git a/src/plugins/data/public/services.ts b/src/plugins/data/public/services.ts
index 4a832105b69918..76b3283220f673 100644
--- a/src/plugins/data/public/services.ts
+++ b/src/plugins/data/public/services.ts
@@ -22,6 +22,7 @@ import { CoreStart } from 'kibana/public';
import { FieldFormatsStart } from '.';
import { createGetterSetter } from '../../kibana_utils/public';
import { IndexPatternsContract } from './index_patterns';
+import { DataPublicPluginStart } from './types';
export const [getNotifications, setNotifications] = createGetterSetter(
'Notifications'
@@ -36,3 +37,7 @@ export const [getOverlays, setOverlays] = createGetterSetter(
'IndexPatterns'
);
+
+export const [getQueryService, setQueryService] = createGetterSetter<
+ DataPublicPluginStart['query']
+>('Query');
diff --git a/src/legacy/ui/public/field_wildcard/field_wildcard.test.ts b/src/plugins/kibana_utils/public/field_wildcard/field_wildcard.test.ts
similarity index 100%
rename from src/legacy/ui/public/field_wildcard/field_wildcard.test.ts
rename to src/plugins/kibana_utils/public/field_wildcard/field_wildcard.test.ts
diff --git a/src/legacy/ui/public/field_wildcard/field_wildcard.ts b/src/plugins/kibana_utils/public/field_wildcard/field_wildcard.ts
similarity index 100%
rename from src/legacy/ui/public/field_wildcard/field_wildcard.ts
rename to src/plugins/kibana_utils/public/field_wildcard/field_wildcard.ts
diff --git a/src/legacy/ui/public/field_wildcard/index.ts b/src/plugins/kibana_utils/public/field_wildcard/index.ts
similarity index 100%
rename from src/legacy/ui/public/field_wildcard/index.ts
rename to src/plugins/kibana_utils/public/field_wildcard/index.ts
diff --git a/src/plugins/kibana_utils/public/index.ts b/src/plugins/kibana_utils/public/index.ts
index 6e6b5c582b0eb9..af2fc9e31b21bb 100644
--- a/src/plugins/kibana_utils/public/index.ts
+++ b/src/plugins/kibana_utils/public/index.ts
@@ -21,6 +21,7 @@ export { defer } from '../common';
export * from './core';
export * from './errors';
export * from './field_mapping';
+export * from './field_wildcard';
export * from './parse';
export * from './render_complete';
export * from './resize_checker';
diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/merge_tables.test.ts b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/merge_tables.test.ts
index 8f124c25542c75..ffb8be1deaa9ef 100644
--- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/merge_tables.test.ts
+++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/merge_tables.test.ts
@@ -8,6 +8,8 @@ import moment from 'moment';
import { mergeTables } from './merge_tables';
import { KibanaDatatable } from 'src/plugins/expressions/public';
+jest.mock('ui/new_platform');
+
describe('lens_merge_tables', () => {
it('should produce a row with the nested table as defined', () => {
const sampleTable1: KibanaDatatable = {
diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx
index ea9fa516d4d916..2bd6c7106a952a 100644
--- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx
+++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx
@@ -14,19 +14,35 @@ import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { createMockedIndexPattern } from '../../mocks';
import { IndexPatternPrivateState } from '../../types';
-jest.mock('ui/new_platform', () => ({
- npStart: {
- core: {
- uiSettings: {
- get: (path: string) => {
- if (path === 'histogram:maxBars') {
- return 10;
- }
+jest.mock('ui/new_platform', () => {
+ // Due to the way we are handling shims in the NP migration, we need
+ // to mock core here so that upstream services don't cause these
+ // tests to fail. Ordinarly `jest.mock('ui/new_platform')` would be
+ // sufficient, however we need to mock one of the `uiSettings` return
+ // values for this suite, so we must manually assemble the mock.
+ // Because babel hoists `jest` we must use an inline `require`
+ // to ensure the core mocks are available (`jest.doMock` doesn't
+ // work in this case). This mock should be able to be replaced
+ // altogether once Lens has migrated to the new platform.
+ const { coreMock } = require('src/core/public/mocks'); // eslint-disable-line @typescript-eslint/no-var-requires
+ return {
+ npSetup: {
+ core: coreMock.createSetup(),
+ },
+ npStart: {
+ core: {
+ ...coreMock.createStart(),
+ uiSettings: {
+ get: (path: string) => {
+ if (path === 'histogram:maxBars') {
+ return 10;
+ }
+ },
},
},
},
- },
-}));
+ };
+});
const defaultOptions = {
storage: {} as IStorageWrapper,
diff --git a/x-pack/legacy/plugins/siem/public/apps/index.ts b/x-pack/legacy/plugins/siem/public/apps/index.ts
index 73f9b65ba35460..0cc5c5584e1b76 100644
--- a/x-pack/legacy/plugins/siem/public/apps/index.ts
+++ b/x-pack/legacy/plugins/siem/public/apps/index.ts
@@ -8,8 +8,11 @@ import chrome from 'ui/chrome';
import { npStart } from 'ui/new_platform';
import { Plugin } from './plugin';
+const { data, embeddable, inspector, uiActions } = npStart.plugins;
+const startPlugins = { data, embeddable, inspector, uiActions };
+
new Plugin(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
{ opaqueId: Symbol('siem'), env: {} as any, config: { get: () => ({} as any) } },
chrome
-).start(npStart.core, npStart.plugins);
+).start(npStart.core, startPlugins);
diff --git a/x-pack/legacy/plugins/siem/public/apps/plugin.tsx b/x-pack/legacy/plugins/siem/public/apps/plugin.tsx
index 1f19841788ddb6..aa42504e07635f 100644
--- a/x-pack/legacy/plugins/siem/public/apps/plugin.tsx
+++ b/x-pack/legacy/plugins/siem/public/apps/plugin.tsx
@@ -10,11 +10,18 @@ import { LegacyCoreStart, PluginInitializerContext } from 'src/core/public';
import { PluginsStart } from 'ui/new_platform/new_platform';
import { Chrome } from 'ui/chrome';
+import { DEFAULT_KBN_VERSION, DEFAULT_TIMEZONE_BROWSER } from '../../common/constants';
import { SiemApp } from './start_app';
import template from './template.html';
export const ROOT_ELEMENT_ID = 'react-siem-root';
+export type StartCore = LegacyCoreStart;
+export type StartPlugins = Required<
+ Pick
+>;
+export type StartServices = StartCore & StartPlugins;
+
export class Plugin {
constructor(
// @ts-ignore this is added to satisfy the New Platform typing constraint,
@@ -25,7 +32,11 @@ export class Plugin {
this.chrome = chrome;
}
- public start(core: LegacyCoreStart, plugins: PluginsStart) {
+ public start(core: StartCore, plugins: StartPlugins) {
+ // TODO(rylnd): These are unknown by uiSettings by default
+ core.uiSettings.set(DEFAULT_KBN_VERSION, '8.0.0');
+ core.uiSettings.set(DEFAULT_TIMEZONE_BROWSER, 'UTC');
+
// @ts-ignore improper type description
this.chrome.setRootTemplate(template);
const checkForRoot = () => {
diff --git a/x-pack/legacy/plugins/siem/public/apps/start_app.tsx b/x-pack/legacy/plugins/siem/public/apps/start_app.tsx
index 4549db946b815d..54180b51fe0398 100644
--- a/x-pack/legacy/plugins/siem/public/apps/start_app.tsx
+++ b/x-pack/legacy/plugins/siem/public/apps/start_app.tsx
@@ -9,8 +9,6 @@ import React, { memo, FC } from 'react';
import { ApolloProvider } from 'react-apollo';
import { Provider as ReduxStoreProvider } from 'react-redux';
import { ThemeProvider } from 'styled-components';
-import { LegacyCoreStart } from 'kibana/public';
-import { PluginsStart } from 'ui/new_platform/new_platform';
import { EuiErrorBoundary } from '@elastic/eui';
import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json';
@@ -19,16 +17,14 @@ import { BehaviorSubject } from 'rxjs';
import { pluck } from 'rxjs/operators';
import { I18nContext } from 'ui/i18n';
-import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
+import { KibanaContextProvider, useUiSetting$ } from '../lib/kibana';
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
import { DEFAULT_DARK_MODE } from '../../common/constants';
import { ErrorToastDispatcher } from '../components/error_toast_dispatcher';
import { compose } from '../lib/compose/kibana_compose';
import { AppFrontendLibs } from '../lib/lib';
-import { KibanaCoreContextProvider } from '../lib/compose/kibana_core';
-import { KibanaPluginsContextProvider } from '../lib/compose/kibana_plugins';
-import { useKibanaUiSetting } from '../lib/settings/use_kibana_ui_setting';
+import { StartCore, StartPlugins } from './plugin';
import { PageRouter } from '../routes';
import { createStore } from '../store';
import { GlobalToaster, ManageGlobalToaster } from '../components/toasters';
@@ -44,7 +40,7 @@ const StartApp: FC = memo(libs => {
const store = createStore(undefined, libs$.pipe(pluck('apolloClient')));
const AppPluginRoot = memo(() => {
- const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
+ const [darkMode] = useUiSetting$(DEFAULT_DARK_MODE);
return (
@@ -77,21 +73,15 @@ const StartApp: FC = memo(libs => {
export const ROOT_ELEMENT_ID = 'react-siem-root';
-export const SiemApp = memo<{ core: LegacyCoreStart; plugins: PluginsStart }>(
- ({ core, plugins }) => (
-
-
-
-
-
-
-
- )
-);
+export const SiemApp = memo<{ core: StartCore; plugins: StartPlugins }>(({ core, plugins }) => (
+
+
+
+));
diff --git a/x-pack/legacy/plugins/siem/public/components/bytes/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/bytes/index.test.tsx
index 2321b06c07cc0a..6816bff24f1cd2 100644
--- a/x-pack/legacy/plugins/siem/public/components/bytes/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/bytes/index.test.tsx
@@ -12,8 +12,6 @@ import { useMountAppended } from '../../utils/use_mount_appended';
import { Bytes } from '.';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('Bytes', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/charts/areachart.test.tsx b/x-pack/legacy/plugins/siem/public/components/charts/areachart.test.tsx
index 25bd2a9d560593..2b99efc05fd8cb 100644
--- a/x-pack/legacy/plugins/siem/public/components/charts/areachart.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/charts/areachart.test.tsx
@@ -11,6 +11,8 @@ import { AreaChartBaseComponent, AreaChartComponent } from './areachart';
import { ChartSeriesData } from './common';
import { ScaleType, AreaSeries, Axis } from '@elastic/charts';
+jest.mock('../../lib/kibana');
+
const customHeight = '100px';
const customWidth = '120px';
const chartDataSets = [
diff --git a/x-pack/legacy/plugins/siem/public/components/charts/areachart.tsx b/x-pack/legacy/plugins/siem/public/components/charts/areachart.tsx
index c644d148cc1c3d..297563c8e31cfe 100644
--- a/x-pack/legacy/plugins/siem/public/components/charts/areachart.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/charts/areachart.tsx
@@ -21,7 +21,6 @@ import { getOr, get, isNull, isNumber } from 'lodash/fp';
import { AutoSizer } from '../auto_sizer';
import { ChartPlaceHolder } from './chart_place_holder';
import {
- browserTimezone,
chartDefaultSettings,
ChartSeriesConfigs,
ChartSeriesData,
@@ -29,6 +28,8 @@ import {
getChartWidth,
getSeriesStyle,
WrappedByAutoSizer,
+ useTheme,
+ useBrowserTimeZone,
} from './common';
// custom series styles: https://ela.st/areachart-styling
@@ -72,12 +73,15 @@ export const AreaChartBaseComponent = ({
height: string | null | undefined;
configs?: ChartSeriesConfigs | undefined;
}) => {
+ const theme = useTheme();
+ const timeZone = useBrowserTimeZone();
const xTickFormatter = get('configs.axis.xTickFormatter', chartConfigs);
const yTickFormatter = get('configs.axis.yTickFormatter', chartConfigs);
const xAxisId = getAxisId(`group-${data[0].key}-x`);
const yAxisId = getAxisId(`group-${data[0].key}-y`);
const settings = {
...chartDefaultSettings,
+ theme,
...get('configs.settings', chartConfigs),
};
return chartConfigs.width && chartConfigs.height ? (
@@ -95,7 +99,7 @@ export const AreaChartBaseComponent = ({
data={series.value || undefined}
xScaleType={getOr(ScaleType.Linear, 'configs.series.xScaleType', chartConfigs)}
yScaleType={getOr(ScaleType.Linear, 'configs.series.yScaleType', chartConfigs)}
- timeZone={browserTimezone}
+ timeZone={timeZone}
xAccessor="x"
yAccessors={['y']}
areaSeriesStyle={getSeriesLineStyle()}
diff --git a/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx b/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx
index e28d330d31ba90..506b1ceb5ed830 100644
--- a/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx
@@ -11,6 +11,8 @@ import { BarChartBaseComponent, BarChartComponent } from './barchart';
import { ChartSeriesData } from './common';
import { BarSeries, ScaleType, Axis } from '@elastic/charts';
+jest.mock('../../lib/kibana');
+
const customHeight = '100px';
const customWidth = '120px';
const chartDataSets = [
diff --git a/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx b/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx
index 99ad995e48852d..ee8b4eaf6b08ca 100644
--- a/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx
@@ -19,16 +19,17 @@ import { getOr, get, isNumber } from 'lodash/fp';
import { AutoSizer } from '../auto_sizer';
import { ChartPlaceHolder } from './chart_place_holder';
import {
- browserTimezone,
chartDefaultSettings,
ChartSeriesConfigs,
ChartSeriesData,
checkIfAllValuesAreZero,
- getSeriesStyle,
getChartHeight,
getChartWidth,
+ getSeriesStyle,
SeriesType,
WrappedByAutoSizer,
+ useBrowserTimeZone,
+ useTheme,
} from './common';
const checkIfAllTheDataInTheSeriesAreValid = (series: ChartSeriesData): series is ChartSeriesData =>
@@ -53,6 +54,8 @@ export const BarChartBaseComponent = ({
height: string | null | undefined;
configs?: ChartSeriesConfigs | undefined;
}) => {
+ const theme = useTheme();
+ const timeZone = useBrowserTimeZone();
const xTickFormatter = get('configs.axis.xTickFormatter', chartConfigs);
const yTickFormatter = get('configs.axis.yTickFormatter', chartConfigs);
const tickSize = getOr(0, 'configs.axis.tickSize', chartConfigs);
@@ -60,6 +63,7 @@ export const BarChartBaseComponent = ({
const yAxisId = getAxisId(`stat-items-barchart-${data[0].key}-y`);
const settings = {
...chartDefaultSettings,
+ theme,
...get('configs.settings', chartConfigs),
};
@@ -79,7 +83,7 @@ export const BarChartBaseComponent = ({
yScaleType={getOr(ScaleType.Linear, 'configs.series.yScaleType', chartConfigs)}
xAccessor="x"
yAccessors={['y']}
- timeZone={browserTimezone}
+ timeZone={timeZone}
splitSeriesAccessors={['g']}
data={series.value!}
stackAccessors={get('configs.series.stackAccessors', chartConfigs)}
diff --git a/x-pack/legacy/plugins/siem/public/components/charts/common.test.tsx b/x-pack/legacy/plugins/siem/public/components/charts/common.test.tsx
index 0bb4da69a978a3..e9df0d3885a18e 100644
--- a/x-pack/legacy/plugins/siem/public/components/charts/common.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/charts/common.test.tsx
@@ -5,23 +5,27 @@
*/
import { shallow } from 'enzyme';
import React from 'react';
+import { renderHook } from '@testing-library/react-hooks';
+
+import { useUiSetting } from '../../lib/kibana';
import {
checkIfAllValuesAreZero,
defaultChartHeight,
getChartHeight,
getChartWidth,
getSeriesStyle,
- getTheme,
SeriesType,
WrappedByAutoSizer,
ChartSeriesData,
+ useTheme,
} from './common';
-import { mergeWithDefaultTheme, LIGHT_THEME } from '@elastic/charts';
+
+jest.mock('../../lib/kibana');
jest.mock('@elastic/charts', () => {
return {
+ ...jest.requireActual('@elastic/charts'),
getSpecId: jest.fn(() => {}),
- mergeWithDefaultTheme: jest.fn(),
};
});
@@ -57,21 +61,6 @@ describe('getSeriesStyle', () => {
});
});
-describe('getTheme', () => {
- it('should merge custom theme with default theme', () => {
- const defaultTheme = {
- chartMargins: { bottom: 0, left: 0, right: 0, top: 4 },
- chartPaddings: { bottom: 0, left: 0, right: 0, top: 0 },
- scales: {
- barsPadding: 0.05,
- },
- };
- getTheme();
- expect((mergeWithDefaultTheme as jest.Mock).mock.calls[0][0]).toMatchObject(defaultTheme);
- expect((mergeWithDefaultTheme as jest.Mock).mock.calls[0][1]).toEqual(LIGHT_THEME);
- });
-});
-
describe('getChartHeight', () => {
it('should render customHeight', () => {
const height = getChartHeight(10, 100);
@@ -197,4 +186,23 @@ describe('checkIfAllValuesAreZero', () => {
expect(result).toBeTruthy();
});
});
+
+ describe('useTheme', () => {
+ it('merges our spacing with the default theme', () => {
+ const { result } = renderHook(() => useTheme());
+
+ expect(result.current).toEqual(
+ expect.objectContaining({ chartMargins: expect.objectContaining({ top: 4, bottom: 0 }) })
+ );
+ });
+
+ it('returns a different theme depending on user settings', () => {
+ const { result: defaultResult } = renderHook(() => useTheme());
+ (useUiSetting as jest.Mock).mockImplementation(() => true);
+
+ const { result: darkResult } = renderHook(() => useTheme());
+
+ expect(defaultResult.current).not.toMatchObject(darkResult.current);
+ });
+ });
});
diff --git a/x-pack/legacy/plugins/siem/public/components/charts/common.tsx b/x-pack/legacy/plugins/siem/public/components/charts/common.tsx
index 7ac91437920e5e..dfb201fc3d9274 100644
--- a/x-pack/legacy/plugins/siem/public/components/charts/common.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/charts/common.tsx
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import chrome from 'ui/chrome';
import {
CustomSeriesColorsMap,
DARK_THEME,
@@ -21,6 +20,7 @@ import {
} from '@elastic/charts';
import moment from 'moment-timezone';
import styled from 'styled-components';
+import { useUiSetting } from '../../lib/kibana';
import { DEFAULT_DATE_FORMAT_TZ, DEFAULT_DARK_MODE } from '../../../common/constants';
export const defaultChartHeight = '100%';
@@ -95,27 +95,28 @@ export const getSeriesStyle = (
};
// Apply margins and paddings: https://ela.st/charts-spacing
-export const getTheme = () => {
- const theme: PartialTheme = {
- chartMargins: {
- left: 0,
- right: 0,
- // Apply some paddings to the top to avoid chopping the y tick https://ela.st/chopping-edge
- top: 4,
- bottom: 0,
- },
- chartPaddings: {
- left: 0,
- right: 0,
- top: 0,
- bottom: 0,
- },
- scales: {
- barsPadding: 0.05,
- },
- };
- const isDarkMode: boolean = chrome.getUiSettingsClient().get(DEFAULT_DARK_MODE);
+const theme: PartialTheme = {
+ chartMargins: {
+ left: 0,
+ right: 0,
+ // Apply some paddings to the top to avoid chopping the y tick https://ela.st/chopping-edge
+ top: 4,
+ bottom: 0,
+ },
+ chartPaddings: {
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ },
+ scales: {
+ barsPadding: 0.05,
+ },
+};
+export const useTheme = () => {
+ const isDarkMode = useUiSetting(DEFAULT_DARK_MODE);
const defaultTheme = isDarkMode ? DARK_THEME : LIGHT_THEME;
+
return mergeWithDefaultTheme(theme, defaultTheme);
};
@@ -126,11 +127,12 @@ export const chartDefaultSettings = {
showLegend: false,
showLegendDisplayValue: false,
debug: false,
- theme: getTheme(),
};
-const kibanaTimezone: string = chrome.getUiSettingsClient().get(DEFAULT_DATE_FORMAT_TZ);
-export const browserTimezone = kibanaTimezone === 'Browser' ? moment.tz.guess() : kibanaTimezone;
+export const useBrowserTimeZone = () => {
+ const kibanaTimezone = useUiSetting(DEFAULT_DATE_FORMAT_TZ);
+ return kibanaTimezone === 'Browser' ? moment.tz.guess() : kibanaTimezone;
+};
export const getChartHeight = (customHeight?: number, autoSizerHeight?: number): string => {
const height = customHeight || autoSizerHeight;
diff --git a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar.test.tsx b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar.test.tsx
index 68522377bd8477..a5eac381f92150 100644
--- a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar.test.tsx
@@ -9,7 +9,6 @@ import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../../mock/ui_settings';
import { TestProviders } from '../../../mock';
import {
UtilityBar,
@@ -19,8 +18,6 @@ import {
UtilityBarText,
} from './index';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('UtilityBar', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_action.test.tsx b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_action.test.tsx
index 7921c1ef42200d..2610fb44532f59 100644
--- a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_action.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_action.test.tsx
@@ -8,12 +8,9 @@ import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../../mock/ui_settings';
import { TestProviders } from '../../../mock';
import { UtilityBarAction } from './index';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('UtilityBarAction', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_group.test.tsx b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_group.test.tsx
index 294d27fa95b3d9..59ef7021d40493 100644
--- a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_group.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_group.test.tsx
@@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../../mock/ui_settings';
import { TestProviders } from '../../../mock';
import { UtilityBarGroup, UtilityBarText } from './index';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('UtilityBarGroup', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_section.test.tsx b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_section.test.tsx
index e0e0acc3a71c91..baa4331ced8f88 100644
--- a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_section.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_section.test.tsx
@@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../../mock/ui_settings';
import { TestProviders } from '../../../mock';
import { UtilityBarGroup, UtilityBarSection, UtilityBarText } from './index';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('UtilityBarSection', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_text.test.tsx b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_text.test.tsx
index 29e1844bb2d4fe..794f207fd88e36 100644
--- a/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_text.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/detection_engine/utility_bar/utility_bar_text.test.tsx
@@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../../mock/ui_settings';
import { TestProviders } from '../../../mock';
import { UtilityBarText } from './index';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('UtilityBarText', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/embedded_map.test.tsx.snap b/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/embedded_map.test.tsx.snap
index 2444fd0bc2b7d4..d5de7ab508a73d 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/embedded_map.test.tsx.snap
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/embedded_map.test.tsx.snap
@@ -9,7 +9,7 @@ exports[`EmbeddedMapComponent renders correctly against snapshot 1`] = `
size="xs"
>
Map configuration help
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/index_patterns_missing_prompt.test.tsx.snap b/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/index_patterns_missing_prompt.test.tsx.snap
index 6794aab2057036..2eefdf767dce16 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/index_patterns_missing_prompt.test.tsx.snap
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/__snapshots__/index_patterns_missing_prompt.test.tsx.snap
@@ -21,7 +21,7 @@ exports[`IndexPatternsMissingPrompt renders correctly against snapshot 1`] = `
values={
Object {
"beats":
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable.test.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable.test.tsx
index c0d70754e78bd4..884d5bc348d6f3 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable.test.tsx
@@ -8,11 +8,8 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../mock/ui_settings';
import { Embeddable } from './embeddable';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('Embeddable', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable_header.test.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable_header.test.tsx
index 6387de30aa265a..aa247b69eb4eb2 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable_header.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embeddable_header.test.tsx
@@ -8,12 +8,9 @@ import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../mock/ui_settings';
import { TestProviders } from '../../mock';
import { EmbeddableHeader } from './embeddable_header';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('EmbeddableHeader', () => {
test('it renders', () => {
const wrapper = shallow();
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.test.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.test.tsx
index 1ed1075542f71f..007916595fd6ad 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.test.tsx
@@ -7,10 +7,10 @@
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as React from 'react';
+
+import { useIndexPatterns } from '../../hooks/use_index_patterns';
import { EmbeddedMapComponent } from './embedded_map';
import { SetQuery } from './types';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
-import { useIndexPatterns } from '../../hooks/use_index_patterns';
jest.mock('../search_bar', () => ({
siemFilterManager: {
@@ -22,22 +22,7 @@ const mockUseIndexPatterns = useIndexPatterns as jest.Mock;
jest.mock('../../hooks/use_index_patterns');
mockUseIndexPatterns.mockImplementation(() => [true, []]);
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: {
- get$: () => 'world',
- },
- injectedMetadata: {
- getKibanaVersion: () => '8.0.0',
- },
-}));
-
-jest.mock('../../lib/compose/kibana_plugins');
-
-jest.mock('ui/vis/lib/timezone', () => ({
- timezoneProvider: () => () => 'America/New_York',
-}));
+jest.mock('../../lib/kibana');
describe('EmbeddedMapComponent', () => {
let setQuery: SetQuery;
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx
index e33539af0bfe86..b39d43cc01b425 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx
@@ -8,16 +8,12 @@ import { EuiLink, EuiText } from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { createPortalNode, InPortal } from 'react-reverse-portal';
import styled, { css } from 'styled-components';
-import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
import { EmbeddablePanel } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { getIndexPatternTitleIdMapping } from '../../hooks/api/helpers';
import { useIndexPatterns } from '../../hooks/use_index_patterns';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
-import { useKibanaPlugins } from '../../lib/compose/kibana_plugins';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
import { Loader } from '../loader';
import { useStateToaster } from '../toasters';
import { Embeddable } from './embeddable';
@@ -28,6 +24,7 @@ import { MapToolTip } from './map_tool_tip/map_tool_tip';
import * as i18n from './translations';
import { MapEmbeddable, SetQuery } from './types';
import { Query, esFilters } from '../../../../../../../src/plugins/data/public';
+import { useKibana, useUiSetting$ } from '../../lib/kibana';
import {
SavedObjectFinderProps,
SavedObjectFinderUi,
@@ -96,7 +93,7 @@ export const EmbeddedMapComponent = ({
const [, dispatchToaster] = useStateToaster();
const [loadingKibanaIndexPatterns, kibanaIndexPatterns] = useIndexPatterns();
- const [siemDefaultIndices] = useKibanaUiSetting(DEFAULT_INDEX_KEY);
+ const [siemDefaultIndices] = useUiSetting$(DEFAULT_INDEX_KEY);
// This portalNode provided by react-reverse-portal allows us re-parent the MapToolTip within our
// own component tree instead of the embeddables (default). This is necessary to have access to
@@ -104,8 +101,7 @@ export const EmbeddedMapComponent = ({
// Search InPortal/OutPortal for implementation touch points
const portalNode = React.useMemo(() => createPortalNode(), []);
- const plugins = useKibanaPlugins();
- const core = useKibanaCore();
+ const { services } = useKibana();
// Initial Load useEffect
useEffect(() => {
@@ -131,7 +127,7 @@ export const EmbeddedMapComponent = ({
endDate,
setQuery,
portalNode,
- plugins.embeddable
+ services.embeddable
);
if (isSubscribed) {
setEmbeddable(embeddableObject);
@@ -180,7 +176,11 @@ export const EmbeddedMapComponent = ({
}, [startDate, endDate]);
const SavedObjectFinder = (props: SavedObjectFinderProps) => (
-
+
);
return isError ? null : (
@@ -188,7 +188,7 @@ export const EmbeddedMapComponent = ({
{i18n.EMBEDDABLE_HEADER_HELP}
@@ -205,12 +205,12 @@ export const EmbeddedMapComponent = ({
) : !isLoading && isIndexError ? (
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map_helpers.test.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map_helpers.test.tsx
index b4b2b98ddb8d6b..4e5fcee4398279 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map_helpers.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map_helpers.test.tsx
@@ -9,7 +9,6 @@ import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
import { createPortalNode } from 'react-reverse-portal';
jest.mock('ui/new_platform');
-jest.mock('../../lib/settings/use_kibana_ui_setting');
jest.mock('uuid', () => {
return {
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.test.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.test.tsx
index d32b62900431c2..d04329edff4756 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.test.tsx
@@ -7,12 +7,10 @@
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as React from 'react';
+
import { IndexPatternsMissingPromptComponent } from './index_patterns_missing_prompt';
-jest.mock('ui/documentation_links', () => ({
- ELASTIC_WEBSITE_URL: 'https://www.elastic.co',
- DOC_LINK_VERSION: 'current',
-}));
+jest.mock('../../lib/kibana');
describe('IndexPatternsMissingPrompt', () => {
test('renders correctly against snapshot', () => {
diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.tsx
index 6533be49c3430f..798e3d2c10f97f 100644
--- a/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/embeddables/index_patterns_missing_prompt.tsx
@@ -8,66 +8,70 @@ import { EuiButton, EuiCode, EuiEmptyPrompt } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import * as React from 'react';
import chrome from 'ui/chrome';
-import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
+import { useKibana } from '../../lib/kibana';
import * as i18n from './translations';
-export const IndexPatternsMissingPromptComponent = () => (
- {i18n.ERROR_TITLE}}
- titleSize="xs"
- body={
- <>
-
-
- {'siem:defaultIndex'}
-
- ),
- beats: (
-
- {'beats'}
-
- ),
- setup: {'setup'},
- example: {'./packetbeat setup'},
- }}
- />
-
+export const IndexPatternsMissingPromptComponent = () => {
+ const docLinks = useKibana().services.docLinks;
-
-
-
- >
- }
- actions={
-
- {i18n.ERROR_BUTTON}
-
- }
- />
-);
+ return (
+
{i18n.ERROR_TITLE}}
+ titleSize="xs"
+ body={
+ <>
+
+
+ {'siem:defaultIndex'}
+
+ ),
+ beats: (
+
+ {'beats'}
+
+ ),
+ setup: {'setup'},
+ example: {'./packetbeat setup'},
+ }}
+ />
+
+
+
+
+
+ >
+ }
+ actions={
+
+ {i18n.ERROR_BUTTON}
+
+ }
+ />
+ );
+};
IndexPatternsMissingPromptComponent.displayName = 'IndexPatternsMissingPromptComponent';
diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/event_details.test.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/event_details.test.tsx
index f1e96392d6afcb..d97da7797bb451 100644
--- a/x-pack/legacy/plugins/siem/public/components/event_details/event_details.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/event_details/event_details.test.tsx
@@ -16,8 +16,6 @@ import { mockBrowserFields } from '../../containers/source/mock';
import { defaultHeaders } from '../../mock/header';
import { useMountAppended } from '../../utils/use_mount_appended';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('EventDetails', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.test.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.test.tsx
index 2c28ab8696f0ef..25f95bfa1d383f 100644
--- a/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.test.tsx
@@ -14,7 +14,7 @@ import { mockBrowserFields } from '../../containers/source/mock';
import { defaultHeaders } from '../../mock/header';
import { useMountAppended } from '../../utils/use_mount_appended';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../lib/kibana');
describe('EventFieldsBrowser', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.test.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.test.tsx
index 5ddf17bd77d74f..b44d83c27a60d3 100644
--- a/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.test.tsx
@@ -8,25 +8,17 @@ import React from 'react';
import { MockedProvider } from 'react-apollo/test-utils';
import { mockIndexPattern, TestProviders } from '../../mock';
-import { mockUiSettings } from '../../mock/ui_settings';
import { wait } from '../../lib/helpers';
import { mockEventViewerResponse } from './mock';
import { StatefulEventsViewer } from '.';
import { defaultHeaders } from './default_headers';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
import { useFetchIndexPatterns } from '../../containers/detection_engine/rules/fetch_index_patterns';
import { mockBrowserFields } from '../../containers/source/mock';
import { eventsDefaultModel } from './default_model';
import { useMountAppended } from '../../utils/use_mount_appended';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
+jest.mock('../../lib/kibana');
const mockUseFetchIndexPatterns: jest.Mock = useFetchIndexPatterns as jest.Mock;
jest.mock('../../containers/detection_engine/rules/fetch_index_patterns');
diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx
index 7c4369e952d6f7..aaf88e68684ca0 100644
--- a/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx
@@ -12,7 +12,7 @@ import styled from 'styled-components';
import { BrowserFields } from '../../containers/source';
import { TimelineQuery } from '../../containers/timeline';
import { Direction } from '../../graphql/types';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
+import { useKibana } from '../../lib/kibana';
import { KqlMode } from '../../store/timeline/model';
import { AutoSizer } from '../auto_sizer';
import { HeaderSection } from '../header_section';
@@ -93,9 +93,9 @@ export const EventsViewer = React.memo(
utilityBar,
}) => {
const columnsHeader = isEmpty(columns) ? defaultHeaders : columns;
- const core = useKibanaCore();
+ const kibana = useKibana();
const combinedQueries = combineQueries({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
dataProviders,
indexPattern,
browserFields,
diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/index.test.tsx
index e46153c18c2b5e..27c3abf7f6824c 100644
--- a/x-pack/legacy/plugins/siem/public/components/events_viewer/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/index.test.tsx
@@ -7,10 +7,8 @@
import React from 'react';
import { MockedProvider } from 'react-apollo/test-utils';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
import { wait } from '../../lib/helpers';
import { mockIndexPattern, TestProviders } from '../../mock';
-import { mockUiSettings } from '../../mock/ui_settings';
import { useMountAppended } from '../../utils/use_mount_appended';
import { mockEventViewerResponse } from './mock';
@@ -19,13 +17,7 @@ import { useFetchIndexPatterns } from '../../containers/detection_engine/rules/f
import { mockBrowserFields } from '../../containers/source/mock';
import { eventsDefaultModel } from './default_model';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
+jest.mock('../../lib/kibana');
const mockUseFetchIndexPatterns: jest.Mock = useFetchIndexPatterns as jest.Mock;
jest.mock('../../containers/detection_engine/rules/fetch_index_patterns');
diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/index.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/index.tsx
index 385352a62d5b31..9b8ec243d5f387 100644
--- a/x-pack/legacy/plugins/siem/public/components/events_viewer/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/index.tsx
@@ -8,7 +8,6 @@ import { isEqual } from 'lodash/fp';
import React, { useCallback, useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { ActionCreator } from 'typescript-fsa';
-import chrome from 'ui/chrome';
import { inputsModel, inputsSelectors, State, timelineSelectors } from '../../store';
import { inputsActions, timelineActions } from '../../store/actions';
import { KqlMode, SubsetTimelineModel, TimelineModel } from '../../store/timeline/model';
@@ -18,6 +17,7 @@ import { Sort } from '../timeline/body/sort';
import { OnChangeItemsPerPage } from '../timeline/events';
import { esFilters, Query } from '../../../../../../../src/plugins/data/public';
+import { useUiSetting } from '../../lib/kibana';
import { EventsViewer } from './events_viewer';
import { InputsModelId } from '../../store/inputs/constants';
import { useFetchIndexPatterns } from '../../containers/detection_engine/rules/fetch_index_patterns';
@@ -116,7 +116,7 @@ const StatefulEventsViewerComponent = React.memo(
}) => {
const [showInspect, setShowInspect] = useState(false);
const [{ browserFields, indexPatterns }] = useFetchIndexPatterns(
- defaultIndices ?? chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY)
+ defaultIndices ?? useUiSetting(DEFAULT_INDEX_KEY)
);
useEffect(() => {
diff --git a/x-pack/legacy/plugins/siem/public/components/flyout/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/flyout/index.test.tsx
index 86a8952a10efa6..be7e8fac70bf53 100644
--- a/x-pack/legacy/plugins/siem/public/components/flyout/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/flyout/index.test.tsx
@@ -20,8 +20,6 @@ import { FlyoutButton } from './button';
const testFlyoutHeight = 980;
const usersViewing = ['elastic'];
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('Flyout', () => {
const state: State = mockGlobalState;
diff --git a/x-pack/legacy/plugins/siem/public/components/flyout/pane/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/flyout/pane/index.test.tsx
index 66e9bc700b3a16..246261035508bd 100644
--- a/x-pack/legacy/plugins/siem/public/components/flyout/pane/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/flyout/pane/index.test.tsx
@@ -8,26 +8,15 @@ import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as React from 'react';
-import { flyoutHeaderHeight } from '../';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
import { TestProviders } from '../../../mock';
-import { mockUiSettings } from '../../../mock/ui_settings';
+import { flyoutHeaderHeight } from '..';
import { Pane } from '.';
const testFlyoutHeight = 980;
const testWidth = 640;
const usersViewing = ['elastic'];
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('ui/new_platform');
-jest.mock('../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
-
-jest.mock('ui/vis/lib/timezone', () => ({
- timezoneProvider: () => () => 'America/New_York',
-}));
+jest.mock('../../../lib/kibana');
describe('Pane', () => {
test('renders correctly against snapshot', () => {
diff --git a/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.test.tsx
index a517820361f9fe..8c27a55d3a6b0e 100644
--- a/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.test.tsx
@@ -8,27 +8,25 @@ import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as React from 'react';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
import { mockFrameworks, getMockKibanaUiSetting } from '../../mock';
+import { useUiSetting$ } from '../../lib/kibana';
import { PreferenceFormattedBytesComponent } from '.';
-const mockUseKibanaUiSetting: jest.Mock = useKibanaUiSetting as jest.Mock;
-jest.mock('../../lib/settings/use_kibana_ui_setting', () => ({
- useKibanaUiSetting: jest.fn(),
-}));
+jest.mock('../../lib/kibana');
+const mockUseUiSetting$ = useUiSetting$ as jest.Mock;
describe('formatted_bytes', () => {
describe('PreferenceFormattedBytes', () => {
describe('rendering', () => {
beforeEach(() => {
- mockUseKibanaUiSetting.mockClear();
+ mockUseUiSetting$.mockClear();
});
const bytes = '2806422';
test('renders correctly against snapshot', () => {
- mockUseKibanaUiSetting.mockImplementation(
+ mockUseUiSetting$.mockImplementation(
getMockKibanaUiSetting(mockFrameworks.default_browser)
);
const wrapper = shallow();
@@ -36,13 +34,13 @@ describe('formatted_bytes', () => {
});
test('it renders bytes to hardcoded format when no configuration exists', () => {
- mockUseKibanaUiSetting.mockImplementation(() => [null]);
+ mockUseUiSetting$.mockImplementation(() => [null]);
const wrapper = mount();
expect(wrapper.text()).toEqual('2.7MB');
});
test('it renders bytes according to the default format', () => {
- mockUseKibanaUiSetting.mockImplementation(
+ mockUseUiSetting$.mockImplementation(
getMockKibanaUiSetting(mockFrameworks.default_browser)
);
const wrapper = mount();
@@ -50,7 +48,7 @@ describe('formatted_bytes', () => {
});
test('it renders bytes supplied as a number according to the default format', () => {
- mockUseKibanaUiSetting.mockImplementation(
+ mockUseUiSetting$.mockImplementation(
getMockKibanaUiSetting(mockFrameworks.default_browser)
);
const wrapper = mount();
@@ -58,9 +56,7 @@ describe('formatted_bytes', () => {
});
test('it renders bytes according to new format', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.bytes_short)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.bytes_short));
const wrapper = mount();
expect(wrapper.text()).toEqual('3MB');
});
diff --git a/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx b/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx
index 408e8d7ad4d802..003ce0879b7b51 100644
--- a/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx
@@ -8,10 +8,10 @@ import * as React from 'react';
import numeral from '@elastic/numeral';
import { DEFAULT_BYTES_FORMAT } from '../../../common/constants';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../lib/kibana';
export const PreferenceFormattedBytesComponent = ({ value }: { value: string | number }) => {
- const [bytesFormat] = useKibanaUiSetting(DEFAULT_BYTES_FORMAT);
+ const [bytesFormat] = useUiSetting$(DEFAULT_BYTES_FORMAT);
return (
<>{bytesFormat ? numeral(value).format(bytesFormat) : numeral(value).format('0,0.[0]b')}>
);
diff --git a/x-pack/legacy/plugins/siem/public/components/formatted_date/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/formatted_date/index.test.tsx
index df361a06d3805f..dad1d5feb5c6e8 100644
--- a/x-pack/legacy/plugins/siem/public/components/formatted_date/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/formatted_date/index.test.tsx
@@ -9,24 +9,18 @@ import toJson from 'enzyme-to-json';
import moment from 'moment-timezone';
import * as React from 'react';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../lib/kibana';
import { mockFrameworks, TestProviders, MockFrameworks, getMockKibanaUiSetting } from '../../mock';
-
-import { PreferenceFormattedDate, FormattedDate, FormattedRelativePreferenceDate } from '.';
import { getEmptyString, getEmptyValue } from '../empty_value';
+import { PreferenceFormattedDate, FormattedDate, FormattedRelativePreferenceDate } from '.';
-const mockUseKibanaUiSetting: jest.Mock = useKibanaUiSetting as jest.Mock;
-jest.mock('../../lib/settings/use_kibana_ui_setting', () => ({
- useKibanaUiSetting: jest.fn(),
-}));
+jest.mock('../../lib/kibana');
+const mockUseUiSetting$ = useUiSetting$ as jest.Mock;
describe('formatted_date', () => {
describe('PreferenceFormattedDate', () => {
describe('rendering', () => {
- beforeEach(() => {
- mockUseKibanaUiSetting.mockClear();
- });
const isoDateString = '2019-02-25T22:27:05.000Z';
const isoDate = new Date(isoDateString);
const configFormattedDateString = (dateString: string, config: MockFrameworks): string =>
@@ -38,21 +32,19 @@ describe('formatted_date', () => {
.format(config.dateFormat);
test('renders correctly against snapshot', () => {
- mockUseKibanaUiSetting.mockImplementation(() => [null]);
+ mockUseUiSetting$.mockImplementation(() => [null]);
const wrapper = mount();
expect(toJson(wrapper)).toMatchSnapshot();
});
test('it renders the UTC ISO8601 date string supplied when no configuration exists', () => {
- mockUseKibanaUiSetting.mockImplementation(() => [null]);
+ mockUseUiSetting$.mockImplementation(() => [null]);
const wrapper = mount();
expect(wrapper.text()).toEqual(isoDateString);
});
test('it renders the UTC ISO8601 date supplied when the default configuration exists', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount();
expect(wrapper.text()).toEqual(
@@ -61,7 +53,7 @@ describe('formatted_date', () => {
});
test('it renders the correct tz when the default browser configuration exists', () => {
- mockUseKibanaUiSetting.mockImplementation(
+ mockUseUiSetting$.mockImplementation(
getMockKibanaUiSetting(mockFrameworks.default_browser)
);
const wrapper = mount();
@@ -71,9 +63,7 @@ describe('formatted_date', () => {
});
test('it renders the correct tz when a non-UTC configuration exists', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_MT)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_MT));
const wrapper = mount();
expect(wrapper.text()).toEqual(
configFormattedDateString(isoDateString, mockFrameworks.default_MT)
@@ -84,30 +74,20 @@ describe('formatted_date', () => {
describe('FormattedDate', () => {
describe('rendering', () => {
- beforeEach(() => {
- mockUseKibanaUiSetting.mockClear();
- });
-
test('it renders against a numeric epoch', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount();
expect(wrapper.text()).toEqual('May 28, 2019 @ 21:35:39.000');
});
test('it renders against a string epoch', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount();
expect(wrapper.text()).toEqual('May 28, 2019 @ 21:35:39.000');
});
test('it renders against a ISO string', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount(
);
@@ -115,9 +95,7 @@ describe('formatted_date', () => {
});
test('it renders against an empty string as an empty string placeholder', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount(
@@ -127,9 +105,7 @@ describe('formatted_date', () => {
});
test('it renders against an null as a EMPTY_VALUE', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount(
@@ -139,9 +115,7 @@ describe('formatted_date', () => {
});
test('it renders against an undefined as a EMPTY_VALUE', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount(
@@ -151,9 +125,7 @@ describe('formatted_date', () => {
});
test('it renders against an invalid date time as just the string its self', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting(mockFrameworks.default_UTC)
- );
+ mockUseUiSetting$.mockImplementation(getMockKibanaUiSetting(mockFrameworks.default_UTC));
const wrapper = mount(
diff --git a/x-pack/legacy/plugins/siem/public/components/formatted_date/index.tsx b/x-pack/legacy/plugins/siem/public/components/formatted_date/index.tsx
index 37bf3653f3b629..19e8ec3f95d269 100644
--- a/x-pack/legacy/plugins/siem/public/components/formatted_date/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/formatted_date/index.tsx
@@ -8,20 +8,21 @@ import moment from 'moment-timezone';
import * as React from 'react';
import { FormattedRelative } from '@kbn/i18n/react';
+import { useUiSetting$ } from '../../lib/kibana';
+
import {
DEFAULT_DATE_FORMAT,
DEFAULT_DATE_FORMAT_TZ,
DEFAULT_TIMEZONE_BROWSER,
} from '../../../common/constants';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
import { getOrEmptyTagFromValue } from '../empty_value';
import { LocalizedDateTooltip } from '../localized_date_tooltip';
import { getMaybeDate } from './maybe_date';
export const PreferenceFormattedDate = React.memo<{ value: Date }>(({ value }) => {
- const [dateFormat] = useKibanaUiSetting(DEFAULT_DATE_FORMAT);
- const [dateFormatTz] = useKibanaUiSetting(DEFAULT_DATE_FORMAT_TZ);
- const [timezone] = useKibanaUiSetting(DEFAULT_TIMEZONE_BROWSER);
+ const [dateFormat] = useUiSetting$(DEFAULT_DATE_FORMAT);
+ const [dateFormatTz] = useUiSetting$(DEFAULT_DATE_FORMAT_TZ);
+ const [timezone] = useUiSetting$(DEFAULT_TIMEZONE_BROWSER);
return (
<>
diff --git a/x-pack/legacy/plugins/siem/public/components/header_global/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/header_global/index.test.tsx
index b3eb599af94077..a45bed87829bfb 100644
--- a/x-pack/legacy/plugins/siem/public/components/header_global/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/header_global/index.test.tsx
@@ -9,10 +9,9 @@ import toJson from 'enzyme-to-json';
import React from 'react';
import '../../mock/match_media';
-import '../../mock/ui_settings';
import { HeaderGlobal } from './index';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
+jest.mock('ui/new_platform');
// Test will fail because we will to need to mock some core services to make the test work
// For now let's forget about SiemSearchBar
diff --git a/x-pack/legacy/plugins/siem/public/components/header_page/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/header_page/index.test.tsx
index 5644a344f91d6d..633ff90524de67 100644
--- a/x-pack/legacy/plugins/siem/public/components/header_page/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/header_page/index.test.tsx
@@ -10,12 +10,9 @@ import toJson from 'enzyme-to-json';
import React from 'react';
import { TestProviders } from '../../mock';
-import '../../mock/ui_settings';
import { HeaderPage } from './index';
import { useMountAppended } from '../../utils/use_mount_appended';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('HeaderPage', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx
index 8606758c68d2cc..fbd8642c01facd 100644
--- a/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx
@@ -10,11 +10,8 @@ import toJson from 'enzyme-to-json';
import React from 'react';
import { TestProviders } from '../../mock';
-import '../../mock/ui_settings';
import { HeaderSection } from './index';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('HeaderSection', () => {
test('it renders', () => {
const wrapper = shallow();
diff --git a/x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
index e2ada4682fdec5..dcecc636d9f0fd 100644
--- a/x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
@@ -13,7 +13,6 @@ import { mockLastEventTimeQuery } from '../../containers/events/last_event_time/
import { useMountAppended } from '../../utils/use_mount_appended';
import { useLastEventTimeQuery } from '../../containers/events/last_event_time';
import { TestProviders } from '../../mock';
-import '../../mock/ui_settings';
import { LastEventTime } from '.';
diff --git a/x-pack/legacy/plugins/siem/public/components/link_icon/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/link_icon/index.test.tsx
index 7f9133a0de7c07..87761a51a431f4 100644
--- a/x-pack/legacy/plugins/siem/public/components/link_icon/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/link_icon/index.test.tsx
@@ -9,11 +9,8 @@ import toJson from 'enzyme-to-json';
import React from 'react';
import { TestProviders } from '../../mock';
-import '../../mock/ui_settings';
import { LinkIcon } from './index';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('LinkIcon', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx
index bdd8a0c544ed86..87d4e072e42990 100644
--- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx
@@ -9,12 +9,7 @@ import * as React from 'react';
import { MatrixHistogram } from '.';
-jest.mock('@elastic/eui', () => {
- return {
- EuiPanel: (children: JSX.Element) => <>{children}>,
- EuiLoadingContent: () => ,
- };
-});
+jest.mock('../../lib/kibana');
jest.mock('../loader', () => {
return {
@@ -22,10 +17,6 @@ jest.mock('../loader', () => {
};
});
-jest.mock('../../lib/settings/use_kibana_ui_setting', () => {
- return { useKibanaUiSetting: () => [false] };
-});
-
jest.mock('../header_section', () => {
return {
HeaderSection: () => ,
diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx
index e1ccfd79a89a0b..c29b5282e13af2 100644
--- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx
@@ -14,7 +14,7 @@ import { BarChart } from '../charts/barchart';
import { HeaderSection } from '../header_section';
import { ChartSeriesData } from '../charts/common';
import { DEFAULT_DARK_MODE } from '../../../common/constants';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../lib/kibana';
import { Loader } from '../loader';
import { Panel } from '../panel';
import { getBarchartConfigs, getCustomChartData } from './utils';
@@ -45,7 +45,7 @@ export const MatrixHistogram = ({
showLegend,
});
const [showInspect, setShowInspect] = useState(false);
- const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
+ const [darkMode] = useUiSetting$(DEFAULT_DARK_MODE);
const [loadingInitial, setLoadingInitial] = useState(false);
const barChartData: ChartSeriesData[] = getCustomChartData(data, mapping);
diff --git a/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts b/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts
index 130c326339b1b2..bce99c943c7a5d 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts
+++ b/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts
@@ -14,7 +14,7 @@ import { useStateToaster } from '../../toasters';
import { errorToToaster } from '../api/error_to_toaster';
import * as i18n from './translations';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import {
DEFAULT_ANOMALY_SCORE,
DEFAULT_TIMEZONE_BROWSER,
@@ -67,9 +67,9 @@ export const useAnomaliesTableData = ({
const capabilities = useContext(MlCapabilitiesContext);
const userPermissions = hasMlUserPermissions(capabilities);
const [, dispatchToaster] = useStateToaster();
- const [timezone] = useKibanaUiSetting(DEFAULT_TIMEZONE_BROWSER);
- const [anomalyScore] = useKibanaUiSetting(DEFAULT_ANOMALY_SCORE);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [timezone] = useUiSetting$(DEFAULT_TIMEZONE_BROWSER);
+ const [anomalyScore] = useUiSetting$(DEFAULT_ANOMALY_SCORE);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const siemJobIds = siemJobs.filter(job => job.isInstalled).map(job => job.id);
diff --git a/x-pack/legacy/plugins/siem/public/components/ml/permissions/ml_capabilities_provider.tsx b/x-pack/legacy/plugins/siem/public/components/ml/permissions/ml_capabilities_provider.tsx
index 352f39a75ded16..b8d6908df464e7 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml/permissions/ml_capabilities_provider.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml/permissions/ml_capabilities_provider.tsx
@@ -11,7 +11,7 @@ import { getMlCapabilities } from '../api/get_ml_capabilities';
import { emptyMlCapabilities } from '../empty_ml_capabilities';
import { errorToToaster } from '../api/error_to_toaster';
import { useStateToaster } from '../../toasters';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import * as i18n from './translations';
@@ -36,7 +36,7 @@ export const MlCapabilitiesProvider = React.memo<{ children: JSX.Element }>(({ c
emptyMlCapabilitiesProvider
);
const [, dispatchToaster] = useStateToaster();
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
useEffect(() => {
let isSubscribed = true;
diff --git a/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_score.test.tsx b/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_score.test.tsx
index f7d9052b19a2f2..cf24d6c02a1381 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_score.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_score.test.tsx
@@ -17,8 +17,6 @@ import { Anomalies } from '../types';
const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
const narrowDateRange = jest.fn();
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('anomaly_scores', () => {
let anomalies: Anomalies = cloneDeep(mockAnomalies);
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_scores.test.tsx b/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_scores.test.tsx
index f01df381384569..759e84e36f4acc 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_scores.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml/score/anomaly_scores.test.tsx
@@ -18,8 +18,6 @@ import { useMountAppended } from '../../../utils/use_mount_appended';
const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
const narrowDateRange = jest.fn();
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('anomaly_scores', () => {
let anomalies: Anomalies = cloneDeep(mockAnomalies);
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/ml/score/create_descriptions_list.test.tsx b/x-pack/legacy/plugins/siem/public/components/ml/score/create_descriptions_list.test.tsx
index d55c6972d5cacb..f00fb62d74ac3e 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml/score/create_descriptions_list.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml/score/create_descriptions_list.test.tsx
@@ -12,7 +12,7 @@ import { createDescriptionList } from './create_description_list';
import { EuiDescriptionList } from '@elastic/eui';
import { Anomaly } from '../types';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
diff --git a/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx b/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx
index 0bef34a7edc44e..f9d110d711d075 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx
@@ -12,7 +12,7 @@ import { hasMlUserPermissions } from '../../ml/permissions/has_ml_user_permissio
import { MlCapabilitiesContext } from '../../ml/permissions/ml_capabilities_provider';
import { useStateToaster } from '../../toasters';
import { errorToToaster } from '../../ml/api/error_to_toaster';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_INDEX_KEY, DEFAULT_KBN_VERSION } from '../../../../common/constants';
import * as i18n from './translations';
@@ -33,8 +33,8 @@ export const useSiemJobs = (refetchData: boolean): Return => {
const [loading, setLoading] = useState(true);
const capabilities = useContext(MlCapabilitiesContext);
const userPermissions = hasMlUserPermissions(capabilities);
- const [siemDefaultIndex] = useKibanaUiSetting(DEFAULT_INDEX_KEY);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [siemDefaultIndex] = useUiSetting$(DEFAULT_INDEX_KEY);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
useEffect(() => {
diff --git a/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.test.tsx b/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.test.tsx
index 1a8360fe82c584..987c63be3f7be1 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.test.tsx
@@ -9,7 +9,8 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { MlPopover } from './ml_popover';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
+jest.mock('ui/new_platform');
+jest.mock('../../lib/kibana');
jest.mock('../ml/permissions/has_ml_admin_permissions', () => ({
hasMlAdminPermissions: () => true,
diff --git a/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.tsx b/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.tsx
index 0b33ab83d2a476..c34ed51d229942 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/ml_popover/ml_popover.tsx
@@ -9,10 +9,9 @@ import { FormattedMessage } from '@kbn/i18n/react';
import moment from 'moment';
import React, { useContext, useReducer, useState } from 'react';
import styled from 'styled-components';
-import { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } from 'ui/documentation_links';
import { DEFAULT_KBN_VERSION } from '../../../common/constants';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
+import { useKibana, useUiSetting$ } from '../../lib/kibana';
import { METRIC_TYPE, TELEMETRY_EVENT, trackUiAction as track } from '../../lib/track_usage';
import { errorToToaster } from '../ml/api/error_to_toaster';
import { hasMlAdminPermissions } from '../ml/permissions/has_ml_admin_permissions';
@@ -98,10 +97,11 @@ export const MlPopover = React.memo(() => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [filterProperties, setFilterProperties] = useState(defaultFilterProps);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [isLoadingSiemJobs, siemJobs] = useSiemJobs(refreshToggle);
const [, dispatchToaster] = useStateToaster();
const capabilities = useContext(MlCapabilitiesContext);
+ const docLinks = useKibana().services.docLinks;
// Enable/Disable Job & Datafeed -- passed to JobsTable for use as callback on JobSwitch
const enableDatafeed = async (job: SiemJob, latestTimestampMs: number, enable: boolean) => {
@@ -226,7 +226,7 @@ export const MlPopover = React.memo(() => {
values={{
mlDocs: (
diff --git a/x-pack/legacy/plugins/siem/public/components/ml_popover/types.ts b/x-pack/legacy/plugins/siem/public/components/ml_popover/types.ts
index 88481e140cb03e..f8794c19639618 100644
--- a/x-pack/legacy/plugins/siem/public/components/ml_popover/types.ts
+++ b/x-pack/legacy/plugins/siem/public/components/ml_popover/types.ts
@@ -13,7 +13,7 @@ export interface Group {
}
export interface CheckRecognizerProps {
- indexPatternName: string;
+ indexPatternName: string[];
kbnVersion: string;
signal: AbortSignal;
}
diff --git a/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx
index 2d8c201e41462f..22531983b23992 100644
--- a/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/netflow/index.test.tsx
@@ -57,8 +57,6 @@ import {
} from '../source_destination/field_names';
import { useMountAppended } from '../../utils/use_mount_appended';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
const getNetflowInstance = () => (
{
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline.test.tsx
index 690e8877b50197..dbc7199aac7253 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline.test.tsx
@@ -17,7 +17,7 @@ import { mockTimelineResults } from '../../mock/timeline_results';
import { OpenTimeline } from './open_timeline';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from './constants';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../lib/kibana');
describe('OpenTimeline', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/index.test.tsx
index 03383a6cb66126..e3dc6d974b5e04 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/index.test.tsx
@@ -16,7 +16,7 @@ import { mockOpenTimelineQueryResults } from '../../../mock/timeline_results';
import { OpenTimelineModal } from '.';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
jest.mock('../../../utils/apollo_context', () => ({
useApolloClient: () => ({}),
}));
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx
index 4237caf8f3c513..a5abb42c2e3b66 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx
@@ -17,7 +17,7 @@ import { mockTimelineResults } from '../../../mock/timeline_results';
import { OpenTimelineModalBody } from './open_timeline_modal_body';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
describe('OpenTimelineModal', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_button.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_button.test.tsx
index a5e436c73f93bc..9a70fd476e89e9 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_button.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/open_timeline_modal/open_timeline_modal_button.test.tsx
@@ -17,8 +17,6 @@ import * as i18n from '../translations';
import { OpenTimelineModalButton } from './open_timeline_modal_button';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
describe('OpenTimelineModalButton', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/actions_columns.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/actions_columns.test.tsx
index 30a02a974ba92b..749ba8672abead 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/actions_columns.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/actions_columns.test.tsx
@@ -17,7 +17,7 @@ import { OpenTimelineResult } from '../types';
import { TimelinesTable } from '.';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
describe('#getActionsColumns', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/common_columns.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/common_columns.test.tsx
index ae68019c2fe698..fa08df1df4785b 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/common_columns.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/common_columns.test.tsx
@@ -21,7 +21,7 @@ import { TimelinesTable } from '.';
import * as i18n from '../translations';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
describe('#getCommonColumns', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/extended_columns.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/extended_columns.test.tsx
index bf5adc8aca5332..13362e0f43a28c 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/extended_columns.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/extended_columns.test.tsx
@@ -20,7 +20,7 @@ import { TimelinesTable } from '.';
import * as i18n from '../translations';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
describe('#getExtendedColumns', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/icon_header_columns.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/icon_header_columns.test.tsx
index e5047662eef678..b6048b85eea753 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/icon_header_columns.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/icon_header_columns.test.tsx
@@ -16,7 +16,7 @@ import { TimelinesTable } from '.';
import { OpenTimelineResult } from '../types';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
describe('#getActionsColumns', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/index.test.tsx
index 6cf56ad6a770fe..d75863d1ccb8bd 100644
--- a/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/timelines_table/index.test.tsx
@@ -18,7 +18,7 @@ import { TimelinesTable, TimelinesTableProps } from '.';
import * as i18n from '../translations';
import { DEFAULT_SORT_DIRECTION, DEFAULT_SORT_FIELD } from '../constants';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../lib/kibana');
describe('TimelinesTable', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/page/detection_engine/histogram_signals/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/detection_engine/histogram_signals/index.test.tsx
index c0d0feca5d53c7..ad1d80a7618543 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/detection_engine/histogram_signals/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/detection_engine/histogram_signals/index.test.tsx
@@ -8,12 +8,9 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../../../mock/ui_settings';
import { TestProviders } from '../../../../mock';
import { HistogramSignals } from './index';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
describe('HistogramSignals', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
index 6c3ab048492366..35c1eded18f15d 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
@@ -12,26 +12,25 @@ import { render, act } from '@testing-library/react';
import { mockFirstLastSeenHostQuery } from '../../../../containers/hosts/first_last_seen/mock';
import { wait } from '../../../../lib/helpers';
import { TestProviders } from '../../../../mock';
-import '../../../../mock/ui_settings';
import { FirstLastSeenHost, FirstLastSeenHostType } from '.';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
-// Suppress warnings about "react-apollo" until we migrate to apollo@3
-/* eslint-disable no-console */
-const originalError = console.error;
-beforeAll(() => {
- console.error = jest.fn();
-});
-afterAll(() => {
- console.error = originalError;
-});
+jest.mock('../../../../lib/kibana');
describe('FirstLastSeen Component', () => {
const firstSeen = 'Apr 8, 2019 @ 16:09:40.692';
const lastSeen = 'Apr 8, 2019 @ 18:35:45.064';
+ // Suppress warnings about "react-apollo" until we migrate to apollo@3
+ /* eslint-disable no-console */
+ const originalError = console.error;
+ beforeAll(() => {
+ console.error = jest.fn();
+ });
+ afterAll(() => {
+ console.error = originalError;
+ });
+
test('Loading', async () => {
const { container } = render(
diff --git a/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx
index 437d14edeb5c8d..9e3f8f91d5cf78 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx
@@ -12,7 +12,7 @@ import React, { useContext, useState, useCallback } from 'react';
import { DEFAULT_DARK_MODE } from '../../../../../common/constants';
import { DescriptionList } from '../../../../../common/utility_types';
-import { useKibanaUiSetting } from '../../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../../lib/kibana';
import { getEmptyTagValue } from '../../../empty_value';
import { DefaultFieldRenderer, hostIdRenderer } from '../../../field_renderers/field_renderers';
import { InspectButton } from '../../../inspect';
@@ -59,7 +59,7 @@ export const HostOverview = React.memo(
const [showInspect, setShowInspect] = useState(false);
const capabilities = useContext(MlCapabilitiesContext);
const userPermissions = hasMlUserPermissions(capabilities);
- const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
+ const [darkMode] = useUiSetting$(DEFAULT_DARK_MODE);
const getDefaultRenderer = (fieldName: string, fieldData: HostItem) => (
({
- uiSettings: mockUiSettings,
-}));
-
// Test will fail because we will to need to mock some core services to make the test work
// For now let's forget about SiemSearchBar and QueryBar
jest.mock('../../../search_bar', () => ({
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx
index 8cb55f0d0fb589..0c4e5943995176 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx
@@ -11,7 +11,7 @@ import React, { useContext, useState, useCallback } from 'react';
import { DEFAULT_DARK_MODE } from '../../../../../common/constants';
import { DescriptionList } from '../../../../../common/utility_types';
-import { useKibanaUiSetting } from '../../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../../lib/kibana';
import { FlowTarget, IpOverviewData, Overview } from '../../../../graphql/types';
import { networkModel } from '../../../../store';
import { getEmptyTagValue } from '../../../empty_value';
@@ -74,7 +74,7 @@ export const IpOverview = React.memo(
const [showInspect, setShowInspect] = useState(false);
const capabilities = useContext(MlCapabilitiesContext);
const userPermissions = hasMlUserPermissions(capabilities);
- const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
+ const [darkMode] = useUiSetting$(DEFAULT_DARK_MODE);
const typeData: Overview = data[flowTarget]!;
const column: DescriptionList[] = [
{
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx
index 0537b95ca6cf75..b88653bcadde8a 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx
@@ -18,8 +18,6 @@ import { useMountAppended } from '../../../../utils/use_mount_appended';
import { NetworkDnsTable } from '.';
import { mockData } from './mock';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
describe('NetworkTopNFlow Table Component', () => {
const loadPage = jest.fn();
const state: State = mockGlobalState;
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/network_http_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/network_http_table/index.test.tsx
index 50d64817f81f8f..81e0c7fad7b391 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/network_http_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/network_http_table/index.test.tsx
@@ -18,8 +18,6 @@ import { createStore, networkModel, State } from '../../../../store';
import { NetworkHttpTable } from '.';
import { mockData } from './mock';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
describe('NetworkHttp Table Component', () => {
const loadPage = jest.fn();
const state: State = mockGlobalState;
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/network_top_countries_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/network_top_countries_table/index.test.tsx
index eb4179a0404314..8fd245b0772431 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/network_top_countries_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/network_top_countries_table/index.test.tsx
@@ -24,7 +24,6 @@ import { createStore, networkModel, State } from '../../../../store';
import { NetworkTopCountriesTable } from '.';
import { mockData } from './mock';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
describe('NetworkTopCountries Table Component', () => {
const loadPage = jest.fn();
const state: State = mockGlobalState;
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx
index 3157847b323768..5c4aa862283f20 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx
@@ -24,8 +24,6 @@ import { createStore, networkModel, State } from '../../../../store';
import { NetworkTopNFlowTable } from '.';
import { mockData } from './mock';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
describe('NetworkTopNFlow Table Component', () => {
const loadPage = jest.fn();
const state: State = mockGlobalState;
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/tls_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/tls_table/index.test.tsx
index 4313c455a0df1a..920d1cd8210e5a 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/tls_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/tls_table/index.test.tsx
@@ -18,8 +18,6 @@ import { createStore, networkModel, State } from '../../../../store';
import { TlsTable } from '.';
import { mockTlsData } from './mock';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
describe('Tls Table Component', () => {
const loadPage = jest.fn();
const state: State = mockGlobalState;
diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/users_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/users_table/index.test.tsx
index d6b9ec24de0aa0..d01923f01543f4 100644
--- a/x-pack/legacy/plugins/siem/public/components/page/network/users_table/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/page/network/users_table/index.test.tsx
@@ -19,8 +19,6 @@ import { createStore, networkModel, State } from '../../../../store';
import { UsersTable } from '.';
import { mockUsersData } from './mock';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
-
jest.mock('../../../search_bar', () => ({
siemFilterManager: {
addFilters: jest.fn(),
diff --git a/x-pack/legacy/plugins/siem/public/components/progress_inline/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/progress_inline/index.test.tsx
index d99a4201c4c728..8ecc50402cef10 100644
--- a/x-pack/legacy/plugins/siem/public/components/progress_inline/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/progress_inline/index.test.tsx
@@ -8,11 +8,8 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../mock/ui_settings';
import { ProgressInline } from './index';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('ProgressInline', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx
index 10b769e2a791c3..e403963cbbe201 100644
--- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx
@@ -7,23 +7,16 @@
import { mount } from 'enzyme';
import React from 'react';
-import { FilterManager, SearchBar } from '../../../../../../../src/plugins/data/public';
-import { uiSettingsServiceMock } from '../../../../../../../src/core/public/ui_settings/ui_settings_service.mock';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
import { TestProviders, mockIndexPattern } from '../../mock';
-import { QueryBar, QueryBarComponentProps } from '.';
+import { createKibanaCoreStartMock } from '../../mock/kibana_core';
import { DEFAULT_FROM, DEFAULT_TO } from '../../../common/constants';
-import { mockUiSettings } from '../../mock/ui_settings';
+import { FilterManager, SearchBar } from '../../../../../../../src/plugins/data/public';
+import { QueryBar, QueryBarComponentProps } from '.';
+import { createKibanaContextProviderMock } from '../../mock/kibana_react';
-jest.mock('ui/new_platform');
+jest.mock('../../lib/kibana');
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-const mockUiSettingsForFilterManager = uiSettingsServiceMock.createSetupContract();
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
- savedObjects: {},
-}));
+const mockUiSettingsForFilterManager = createKibanaCoreStartMock().uiSettings;
describe('QueryBar ', () => {
// We are doing that because we need to wrapped this component with redux
@@ -196,9 +189,13 @@ describe('QueryBar ', () => {
describe('#onQueryChange', () => {
test(' is the only reference that changed when filterQueryDraft props get updated', () => {
+ const KibanaWithStorageProvider = createKibanaContextProviderMock();
+
const Proxy = (props: QueryBarComponentProps) => (
-
+
+
+
);
diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx
index 9f706790bec672..b2843348cc2e30 100644
--- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx
@@ -6,7 +6,6 @@
import { isEqual } from 'lodash/fp';
import React, { memo, useState, useEffect, useMemo, useCallback } from 'react';
-import { IndexPattern } from 'ui/index_patterns';
import {
esFilters,
@@ -118,7 +117,7 @@ export const QueryBar = memo(
);
const CustomButton = <>{null}>;
- const indexPatterns = useMemo(() => [indexPattern as IndexPattern], [indexPattern]);
+ const indexPatterns = useMemo(() => [indexPattern], [indexPattern]);
const searchBarProps = savedQuery != null ? { savedQuery } : {};
diff --git a/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx
index 3d02cff7b72e87..089bade4a4144f 100644
--- a/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx
@@ -10,7 +10,6 @@ import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { Subscription } from 'rxjs';
import styled from 'styled-components';
-import { IndexPattern } from 'ui/index_patterns';
import { IIndexPattern } from 'src/plugins/data/public';
import { SavedQuery } from 'src/legacy/core_plugins/data/public';
@@ -254,7 +253,7 @@ const SearchBarComponent = memo [indexPattern as IndexPattern], [indexPattern]);
+ const indexPatterns = useMemo(() => [indexPattern], [indexPattern]);
return (
(
{
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/subtitle/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/subtitle/index.test.tsx
index b54f3133de4726..3424c05f32d637 100644
--- a/x-pack/legacy/plugins/siem/public/components/subtitle/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/subtitle/index.test.tsx
@@ -8,12 +8,9 @@ import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
-import '../../mock/ui_settings';
import { TestProviders } from '../../mock';
import { Subtitle } from './index';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('Subtitle', () => {
test('it renders', () => {
const wrapper = shallow();
diff --git a/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.test.tsx
index 011e2ddcdbde7a..013104da7c6128 100644
--- a/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.test.tsx
@@ -8,13 +8,69 @@ import { mount } from 'enzyme';
import * as React from 'react';
import { Provider as ReduxStoreProvider } from 'react-redux';
+import { useUiSetting$ } from '../../lib/kibana';
import { apolloClientObservable, mockGlobalState } from '../../mock';
+import { createUseUiSetting$Mock } from '../../mock/kibana_react';
import { createStore, State } from '../../store';
import { SuperDatePicker, makeMapStateToProps } from '.';
import { cloneDeep } from 'lodash/fp';
-
-jest.mock('../../lib/settings/use_kibana_ui_setting');
+import { DEFAULT_TIMEPICKER_QUICK_RANGES } from '../../../common/constants';
+
+jest.mock('../../lib/kibana');
+const mockUseUiSetting$ = useUiSetting$ as jest.Mock;
+const timepickerRanges = [
+ {
+ from: 'now/d',
+ to: 'now/d',
+ display: 'Today',
+ },
+ {
+ from: 'now/w',
+ to: 'now/w',
+ display: 'This week',
+ },
+ {
+ from: 'now-15m',
+ to: 'now',
+ display: 'Last 15 minutes',
+ },
+ {
+ from: 'now-30m',
+ to: 'now',
+ display: 'Last 30 minutes',
+ },
+ {
+ from: 'now-1h',
+ to: 'now',
+ display: 'Last 1 hour',
+ },
+ {
+ from: 'now-24h',
+ to: 'now',
+ display: 'Last 24 hours',
+ },
+ {
+ from: 'now-7d',
+ to: 'now',
+ display: 'Last 7 days',
+ },
+ {
+ from: 'now-30d',
+ to: 'now',
+ display: 'Last 30 days',
+ },
+ {
+ from: 'now-90d',
+ to: 'now',
+ display: 'Last 90 days',
+ },
+ {
+ from: 'now-1y',
+ to: 'now',
+ display: 'Last 1 year',
+ },
+];
describe('SIEM Super Date Picker', () => {
describe('#SuperDatePicker', () => {
@@ -24,6 +80,13 @@ describe('SIEM Super Date Picker', () => {
beforeEach(() => {
jest.clearAllMocks();
store = createStore(state, apolloClientObservable);
+ mockUseUiSetting$.mockImplementation((key, defaultValue) => {
+ const useUiSetting$Mock = createUseUiSetting$Mock();
+
+ return key === DEFAULT_TIMEPICKER_QUICK_RANGES
+ ? [timepickerRanges, jest.fn()]
+ : useUiSetting$Mock(key, defaultValue);
+ });
});
describe('Pick Relative Date', () => {
diff --git a/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.tsx b/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.tsx
index a2e190da0f7bc0..0877906c721ce6 100644
--- a/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/super_date_picker/index.tsx
@@ -18,7 +18,7 @@ import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { DEFAULT_TIMEPICKER_QUICK_RANGES } from '../../../common/constants';
-import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../lib/kibana';
import { inputsModel, State } from '../../store';
import { inputsActions, timelineActions } from '../../store/actions';
import { InputsModelId } from '../../store/inputs/constants';
@@ -38,6 +38,12 @@ import { InputsRange, Policy } from '../../store/inputs/model';
const MAX_RECENTLY_USED_RANGES = 9;
+interface Range {
+ from: string;
+ to: string;
+ display: string;
+}
+
interface SuperDatePickerStateRedux {
duration: number;
end: number;
@@ -196,10 +202,10 @@ export const SuperDatePickerComponent = React.memo(
const endDate = kind === 'relative' ? toStr : new Date(end).toISOString();
const startDate = kind === 'relative' ? fromStr : new Date(start).toISOString();
- const [quickRanges] = useKibanaUiSetting(DEFAULT_TIMEPICKER_QUICK_RANGES);
+ const [quickRanges] = useUiSetting$(DEFAULT_TIMEPICKER_QUICK_RANGES);
const commonlyUsedRanges = isEmpty(quickRanges)
? []
- : quickRanges.map(({ from, to, display }: { from: string; to: string; display: string }) => ({
+ : quickRanges.map(({ from, to, display }) => ({
start: from,
end: to,
label: display,
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/index.test.tsx
index d3eaedb3ef23e1..5c6a0872ce3406 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/body/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/index.test.tsx
@@ -17,8 +17,6 @@ import { Sort } from './sort';
import { wait } from '../../../lib/helpers';
import { useMountAppended } from '../../../utils/use_mount_appended';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
const testBodyHeight = 700;
const mockGetNotesByIds = (eventId: string[]) => [];
const mockSort: Sort = {
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.test.tsx
index 3f27abfd2176c0..5c54e5be3374ca 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/formatted_field.test.tsx
@@ -18,7 +18,7 @@ import { useMountAppended } from '../../../../utils/use_mount_appended';
import { FormattedFieldValue } from './formatted_field';
import { HOST_NAME_FIELD_NAME } from './constants';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../../lib/kibana');
describe('Events', () => {
const theme = () => ({ eui: euiDarkVars, darkMode: true });
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/netflow/netflow_row_renderer.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/netflow/netflow_row_renderer.test.tsx
index 9f73d86dec4020..6ba8f3f28dae85 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/netflow/netflow_row_renderer.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/netflow/netflow_row_renderer.test.tsx
@@ -25,8 +25,6 @@ export const justIdAndTimestamp: Ecs = {
timestamp: '2018-11-12T19:03:25.936Z',
};
-jest.mock('../../../../../lib/settings/use_kibana_ui_setting');
-
describe('netflowRowRenderer', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.test.tsx
index 96865fd928216b..008885b5264c88 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.test.tsx
@@ -18,7 +18,7 @@ import { useMountAppended } from '../../../../utils/use_mount_appended';
import { plainColumnRenderer } from './plain_column_renderer';
import { getValues, deleteItemIdx, findItem } from './helpers';
-jest.mock('../../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../../lib/kibana');
const mockFramework = mockFrameworks.default_UTC;
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx
index 3727e82c1d2a03..b2dbdb6b0e45cb 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx
@@ -49,7 +49,7 @@ import {
} from './generic_row_renderer';
import * as i18n from './translations';
-jest.mock('../../../../../lib/settings/use_kibana_ui_setting');
+jest.mock('../../../../../lib/kibana');
describe('GenericRowRenderer', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/header/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/header/index.test.tsx
index 977764803acbb1..4527e39128f890 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/header/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/header/index.test.tsx
@@ -9,21 +9,14 @@ import toJson from 'enzyme-to-json';
import * as React from 'react';
import { Direction } from '../../../graphql/types';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
import { mockIndexPattern } from '../../../mock';
import { TestProviders } from '../../../mock/test_providers';
-import { mockUiSettings } from '../../../mock/ui_settings';
import { mockDataProviders } from '../data_providers/mock/mock_data_providers';
import { useMountAppended } from '../../../utils/use_mount_appended';
import { TimelineHeaderComponent } from '.';
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
- savedObjects: {},
-}));
+jest.mock('../../../lib/kibana');
describe('Header', () => {
const indexPattern = mockIndexPattern;
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.test.tsx
index eb82241b04124c..bc05204cc47fe2 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.test.tsx
@@ -8,22 +8,12 @@ import { mount } from 'enzyme';
import * as React from 'react';
import { Provider as ReduxStoreProvider } from 'react-redux';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
import { mockGlobalState, apolloClientObservable } from '../../../mock';
-import { mockUiSettings } from '../../../mock/ui_settings';
import { createStore, State } from '../../../store';
import { Properties, showDescriptionThreshold, showNotesThreshold } from '.';
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
-
-jest.mock('ui/vis/lib/timezone', () => ({
- timezoneProvider: () => () => 'America/New_York',
-}));
+jest.mock('../../../lib/kibana');
describe('Properties', () => {
const usersViewing = ['elastic'];
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx
index b78691fabdcbf1..b978ef3d478d80 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx
@@ -9,22 +9,15 @@ import React from 'react';
import { DEFAULT_FROM, DEFAULT_TO } from '../../../../common/constants';
import { mockBrowserFields } from '../../../containers/source/mock';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
import { convertKueryToElasticSearchQuery } from '../../../lib/keury';
import { mockIndexPattern, TestProviders } from '../../../mock';
-import { mockUiSettings } from '../../../mock/ui_settings';
import { QueryBar } from '../../query_bar';
import { mockDataProviders } from '../data_providers/mock/mock_data_providers';
import { buildGlobalQuery } from '../helpers';
import { QueryBarTimeline, QueryBarTimelineComponentProps, getDataProviderFilter } from './index';
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
- savedObjects: {},
-}));
+jest.mock('../../../lib/kibana');
describe('Timeline QueryBar ', () => {
// We are doing that because we need to wrapped this component with redux
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx
index c55ead5e2d5d5c..c3b46c6cd0f729 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx
@@ -19,7 +19,7 @@ import {
import { BrowserFields } from '../../../containers/source';
import { convertKueryToElasticSearchQuery } from '../../../lib/keury';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
+import { useKibana } from '../../../lib/kibana';
import { KueryFilterQuery, KueryFilterQueryKind } from '../../../store';
import { KqlMode } from '../../../store/timeline/model';
import { useSavedQueryServices } from '../../../utils/saved_query_services';
@@ -92,8 +92,8 @@ export const QueryBarTimeline = memo(
const [dataProvidersDsl, setDataProvidersDsl] = useState(
convertKueryToElasticSearchQuery(buildGlobalQuery(dataProviders, browserFields), indexPattern)
);
- const core = useKibanaCore();
- const [filterManager] = useState(new FilterManager(core.uiSettings));
+ const kibana = useKibana();
+ const [filterManager] = useState(new FilterManager(kibana.services.uiSettings));
const savedQueryServices = useSavedQueryServices();
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx
index 180af88f21e4d7..bb500de239da71 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.test.tsx
@@ -12,10 +12,8 @@ import { MockedProvider } from 'react-apollo/test-utils';
import { timelineQuery } from '../../containers/timeline/index.gql_query';
import { mockBrowserFields } from '../../containers/source/mock';
import { Direction } from '../../graphql/types';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
import { defaultHeaders, mockTimelineData, mockIndexPattern } from '../../mock';
import { TestProviders } from '../../mock/test_providers';
-import { mockUiSettings } from '../../mock/ui_settings';
import { flyoutHeaderHeight } from '../flyout';
import {
@@ -30,12 +28,7 @@ import { useMountAppended } from '../../utils/use_mount_appended';
const testFlyoutHeight = 980;
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
- savedObjects: {},
-}));
+jest.mock('../../lib/kibana');
describe('Timeline', () => {
const sort: Sort = {
diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx
index ec7d10d2373d49..5646b26428bf86 100644
--- a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx
@@ -12,7 +12,7 @@ import styled from 'styled-components';
import { BrowserFields } from '../../containers/source';
import { TimelineQuery } from '../../containers/timeline';
import { Direction } from '../../graphql/types';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
+import { useKibana } from '../../lib/kibana';
import { KqlMode } from '../../store/timeline/model';
import { AutoSizer } from '../auto_sizer';
import { ColumnHeader } from './body/column_headers/column_header';
@@ -113,9 +113,9 @@ export const TimelineComponent = ({
sort,
toggleColumn,
}: Props) => {
- const core = useKibanaCore();
+ const kibana = useKibana();
const combinedQueries = combineQueries({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
dataProviders,
indexPattern,
browserFields,
diff --git a/x-pack/legacy/plugins/siem/public/components/wrapper_page/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/wrapper_page/index.test.tsx
index 3ea243fe5cfe76..5d73e9bcf8e71c 100644
--- a/x-pack/legacy/plugins/siem/public/components/wrapper_page/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/components/wrapper_page/index.test.tsx
@@ -9,11 +9,8 @@ import toJson from 'enzyme-to-json';
import React from 'react';
import { TestProviders } from '../../mock';
-import '../../mock/ui_settings';
import { WrapperPage } from './index';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
describe('WrapperPage', () => {
test('it renders', () => {
const wrapper = shallow(
diff --git a/x-pack/legacy/plugins/siem/public/containers/alerts/alerts_over_time/index.tsx b/x-pack/legacy/plugins/siem/public/containers/alerts/alerts_over_time/index.tsx
index 98dcef51292ae3..9541e6d39d6691 100644
--- a/x-pack/legacy/plugins/siem/public/containers/alerts/alerts_over_time/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/alerts/alerts_over_time/index.tsx
@@ -8,10 +8,11 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { inputsModel, State, inputsSelectors, hostsModel } from '../../../store';
+import { withKibana, WithKibanaProps } from '../../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
import { QueryTemplate, QueryTemplateProps } from '../../query_template';
@@ -40,7 +41,7 @@ export interface AlertsOverTimeComponentReduxProps {
isInspected: boolean;
}
-type AlertsOverTimeProps = OwnProps & AlertsOverTimeComponentReduxProps;
+type AlertsOverTimeProps = OwnProps & AlertsOverTimeComponentReduxProps & WithKibanaProps;
class AlertsOverTimeComponentQuery extends QueryTemplate<
AlertsOverTimeProps,
@@ -54,6 +55,7 @@ class AlertsOverTimeComponentQuery extends QueryTemplate<
filterQuery,
id = ID,
isInspected,
+ kibana,
sourceId,
startDate,
} = this.props;
@@ -70,7 +72,7 @@ class AlertsOverTimeComponentQuery extends QueryTemplate<
from: startDate!,
to: endDate!,
},
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
@@ -105,4 +107,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const AlertsOverTimeQuery = connect(makeMapStateToProps)(AlertsOverTimeComponentQuery);
+export const AlertsOverTimeQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(AlertsOverTimeComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx
index 917f4dbcc211bb..f2c00cbae1a74c 100644
--- a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx
@@ -12,7 +12,7 @@ import { AnomaliesOverTimeHistogram } from '../../../components/anomalies_over_t
import { AnomaliesOverTimeQuery } from '../anomalies_over_time';
import { getAnomaliesFilterQuery } from './utils';
import { useSiemJobs } from '../../../components/ml_popover/hooks/use_siem_jobs';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_ANOMALY_SCORE } from '../../../../common/constants';
const AnomaliesOverTimeManage = manageQuery(AnomaliesOverTimeHistogram);
@@ -33,7 +33,7 @@ export const AnomaliesQueryTabBody = ({
ip,
}: AnomaliesQueryTabBodyProps) => {
const [siemJobsLoading, siemJobs] = useSiemJobs(true);
- const [anomalyScore] = useKibanaUiSetting(DEFAULT_ANOMALY_SCORE);
+ const [anomalyScore] = useUiSetting$(DEFAULT_ANOMALY_SCORE);
const mergedFilterQuery = getAnomaliesFilterQuery(
filterQuery,
diff --git a/x-pack/legacy/plugins/siem/public/containers/authentications/authentications_over_time/index.tsx b/x-pack/legacy/plugins/siem/public/containers/authentications/authentications_over_time/index.tsx
index 1d6d96869b6a93..8f363d49f18515 100644
--- a/x-pack/legacy/plugins/siem/public/containers/authentications/authentications_over_time/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/authentications/authentications_over_time/index.tsx
@@ -8,10 +8,11 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { inputsModel, State, inputsSelectors, hostsModel } from '../../../store';
+import { withKibana, WithKibanaProps } from '../../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
import { QueryTemplate, QueryTemplateProps } from '../../query_template';
@@ -43,7 +44,9 @@ export interface AuthenticationsOverTimeComponentReduxProps {
isInspected: boolean;
}
-type AuthenticationsOverTimeProps = OwnProps & AuthenticationsOverTimeComponentReduxProps;
+type AuthenticationsOverTimeProps = OwnProps &
+ AuthenticationsOverTimeComponentReduxProps &
+ WithKibanaProps;
class AuthenticationsOverTimeComponentQuery extends QueryTemplate<
AuthenticationsOverTimeProps,
@@ -56,6 +59,7 @@ class AuthenticationsOverTimeComponentQuery extends QueryTemplate<
filterQuery,
id = ID,
isInspected,
+ kibana,
sourceId,
startDate,
endDate,
@@ -73,7 +77,7 @@ class AuthenticationsOverTimeComponentQuery extends QueryTemplate<
from: startDate!,
to: endDate!,
},
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
@@ -108,6 +112,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const AuthenticationsOverTimeQuery = connect(makeMapStateToProps)(
- AuthenticationsOverTimeComponentQuery
-);
+export const AuthenticationsOverTimeQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(AuthenticationsOverTimeComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx b/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx
index 6f896cfd95901d..6d4a88c45a7681 100644
--- a/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx
@@ -8,8 +8,8 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
AuthenticationsEdges,
@@ -19,6 +19,7 @@ import {
import { hostsModel, hostsSelectors, inputsModel, State, inputsSelectors } from '../../store';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
import { authenticationsQuery } from './index.gql_query';
@@ -48,7 +49,7 @@ export interface AuthenticationsComponentReduxProps {
limit: number;
}
-type AuthenticationsProps = OwnProps & AuthenticationsComponentReduxProps;
+type AuthenticationsProps = OwnProps & AuthenticationsComponentReduxProps & WithKibanaProps;
class AuthenticationsComponentQuery extends QueryTemplatePaginated<
AuthenticationsProps,
@@ -63,6 +64,7 @@ class AuthenticationsComponentQuery extends QueryTemplatePaginated<
filterQuery,
id = ID,
isInspected,
+ kibana,
limit,
skip,
sourceId,
@@ -77,7 +79,7 @@ class AuthenticationsComponentQuery extends QueryTemplatePaginated<
},
pagination: generateTablePaginationOptions(activePage, limit),
filterQuery: createFilter(filterQuery),
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
inspect: isInspected,
};
return (
@@ -142,4 +144,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const AuthenticationsQuery = connect(makeMapStateToProps)(AuthenticationsComponentQuery);
+export const AuthenticationsQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(AuthenticationsComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/persist_rule.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/persist_rule.tsx
index 371d28aebf7f7b..82490991236de5 100644
--- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/persist_rule.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/persist_rule.tsx
@@ -6,7 +6,7 @@
import { useEffect, useState, Dispatch } from 'react';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import { useStateToaster } from '../../../components/toasters';
import { errorToToaster } from '../../../components/ml/api/error_to_toaster';
@@ -26,7 +26,7 @@ export const usePersistRule = (): Return => {
const [rule, setRule] = useState(null);
const [isSaved, setIsSaved] = useState(false);
const [isLoading, setIsLoading] = useState(false);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
useEffect(() => {
diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule.tsx
index 8ba59a86a2b85a..ad0b87385ee790 100644
--- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule.tsx
@@ -6,7 +6,7 @@
import { useEffect, useState } from 'react';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import { useStateToaster } from '../../../components/toasters';
import { errorToToaster } from '../../../components/ml/api/error_to_toaster';
@@ -25,7 +25,7 @@ type Return = [boolean, Rule | null];
export const useRule = (id: string | undefined): Return => {
const [rule, setRule] = useState(null);
const [loading, setLoading] = useState(true);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
useEffect(() => {
diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rules.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rules.tsx
index 2b8bb986a296a4..66285c804aa283 100644
--- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rules.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rules.tsx
@@ -6,7 +6,7 @@
import { useEffect, useState } from 'react';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import { FetchRulesResponse, FilterOptions, PaginationOptions } from './types';
import { useStateToaster } from '../../../components/toasters';
@@ -35,7 +35,7 @@ export const useRules = (
data: [],
});
const [loading, setLoading] = useState(true);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
useEffect(() => {
diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx
index a1b3907e2b31b0..d8656252885504 100644
--- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/use_query.tsx
@@ -6,7 +6,7 @@
import { useEffect, useState } from 'react';
-import { useKibanaUiSetting } from '../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_KBN_VERSION } from '../../../../common/constants';
import { errorToToaster } from '../../../components/ml/api/error_to_toaster';
import { useStateToaster } from '../../../components/toasters';
@@ -26,7 +26,7 @@ type Return = [boolean, SignalSearchResponse | null];
export const useQuerySignals = (query: string): Return => {
const [signals, setSignals] = useState | null>(null);
const [loading, setLoading] = useState(true);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
useEffect(() => {
diff --git a/x-pack/legacy/plugins/siem/public/containers/events/events_over_time/index.tsx b/x-pack/legacy/plugins/siem/public/containers/events/events_over_time/index.tsx
index 77ce98e180ab0c..e102cd11f108e2 100644
--- a/x-pack/legacy/plugins/siem/public/containers/events/events_over_time/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/events/events_over_time/index.tsx
@@ -8,12 +8,13 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { inputsModel, State, inputsSelectors, hostsModel } from '../../../store';
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
import { QueryTemplate, QueryTemplateProps } from '../../query_template';
+import { withKibana, WithKibanaProps } from '../../../lib/kibana';
import { EventsOverTimeGqlQuery } from './events_over_time.gql_query';
import { GetEventsOverTimeQuery, MatrixOverTimeHistogramData } from '../../../graphql/types';
@@ -40,7 +41,7 @@ export interface EventsOverTimeComponentReduxProps {
isInspected: boolean;
}
-type EventsOverTimeProps = OwnProps & EventsOverTimeComponentReduxProps;
+type EventsOverTimeProps = OwnProps & EventsOverTimeComponentReduxProps & WithKibanaProps;
class EventsOverTimeComponentQuery extends QueryTemplate<
EventsOverTimeProps,
@@ -54,6 +55,7 @@ class EventsOverTimeComponentQuery extends QueryTemplate<
filterQuery,
id = ID,
isInspected,
+ kibana,
sourceId,
startDate,
} = this.props;
@@ -70,7 +72,7 @@ class EventsOverTimeComponentQuery extends QueryTemplate<
from: startDate!,
to: endDate!,
},
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
@@ -105,4 +107,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const EventsOverTimeQuery = connect(makeMapStateToProps)(EventsOverTimeComponentQuery);
+export const EventsOverTimeQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(EventsOverTimeComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts b/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts
index 3bfdbae8d30f76..9cae503d309408 100644
--- a/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts
+++ b/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts
@@ -7,11 +7,11 @@
import { get } from 'lodash/fp';
import React, { useEffect, useState } from 'react';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { GetLastEventTimeQuery, LastEventIndexKey, LastTimeDetails } from '../../../graphql/types';
import { inputsModel } from '../../../store';
import { QueryTemplateProps } from '../../query_template';
+import { useUiSetting$ } from '../../../lib/kibana';
import { LastEventTimeGqlQuery } from './last_event_time.gql_query';
import { useApolloClient } from '../../../utils/apollo_context';
@@ -38,6 +38,7 @@ export function useLastEventTimeQuery(
const [lastSeen, updateLastSeen] = useState(null);
const [errorMessage, updateErrorMessage] = useState(null);
const [currentIndexKey, updateCurrentIndexKey] = useState(null);
+ const [defaultIndex] = useUiSetting$(DEFAULT_INDEX_KEY);
const apolloClient = useApolloClient();
async function fetchLastEventTime(signal: AbortSignal) {
updateLoading(true);
@@ -50,7 +51,7 @@ export function useLastEventTimeQuery(
sourceId,
indexKey,
details,
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex,
},
context: {
fetchOptions: {
diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts b/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts
index 042de56fbd99d9..e36da5bfbe4ee3 100644
--- a/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts
+++ b/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts
@@ -8,7 +8,7 @@ import ApolloClient from 'apollo-client';
import { get } from 'lodash/fp';
import React, { useEffect, useState } from 'react';
-import chrome from 'ui/chrome';
+import { useUiSetting$ } from '../../../lib/kibana';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { GetHostFirstLastSeenQuery } from '../../../graphql/types';
import { inputsModel } from '../../../store';
@@ -39,6 +39,7 @@ export function useFirstLastSeenHostQuery(
const [firstSeen, updateFirstSeen] = useState(null);
const [lastSeen, updateLastSeen] = useState(null);
const [errorMessage, updateErrorMessage] = useState(null);
+ const [defaultIndex] = useUiSetting$(DEFAULT_INDEX_KEY);
async function fetchFirstLastSeenHost(signal: AbortSignal) {
updateLoading(true);
@@ -49,7 +50,7 @@ export function useFirstLastSeenHostQuery(
variables: {
sourceId,
hostName,
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex,
},
context: {
fetchOptions: {
diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx b/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx
index d2be29e3e9e296..733c2224d840a7 100644
--- a/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx
@@ -9,8 +9,8 @@ import memoizeOne from 'memoize-one';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
Direction,
@@ -22,6 +22,7 @@ import {
import { hostsModel, hostsSelectors, inputsModel, State, inputsSelectors } from '../../store';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { HostsTableQuery } from './hosts_table.gql_query';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
@@ -57,7 +58,7 @@ export interface HostsComponentReduxProps {
direction: Direction;
}
-type HostsProps = OwnProps & HostsComponentReduxProps;
+type HostsProps = OwnProps & HostsComponentReduxProps & WithKibanaProps;
class HostsComponentQuery extends QueryTemplatePaginated<
HostsProps,
@@ -83,12 +84,14 @@ class HostsComponentQuery extends QueryTemplatePaginated<
direction,
filterQuery,
endDate,
+ kibana,
limit,
startDate,
skip,
sourceId,
sortField,
} = this.props;
+ const defaultIndex = kibana.services.uiSettings.get(DEFAULT_INDEX_KEY);
const variables: GetHostsTableQuery.Variables = {
sourceId,
@@ -103,7 +106,7 @@ class HostsComponentQuery extends QueryTemplatePaginated<
},
pagination: generateTablePaginationOptions(activePage, limit),
filterQuery: createFilter(filterQuery),
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex,
inspect: isInspected,
};
return (
@@ -174,4 +177,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const HostsQuery = connect(makeMapStateToProps)(HostsComponentQuery);
+export const HostsQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(HostsComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx b/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx
index a9223143462fd0..5057e872b53131 100644
--- a/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx
@@ -7,12 +7,14 @@
import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
-import chrome from 'ui/chrome';
import { connect } from 'react-redux';
+import { compose } from 'redux';
+
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { inputsModel, inputsSelectors, State } from '../../../store';
import { getDefaultFetchPolicy } from '../../helpers';
import { QueryTemplate, QueryTemplateProps } from '../../query_template';
+import { withKibana, WithKibanaProps } from '../../../lib/kibana';
import { HostOverviewQuery } from './host_overview.gql_query';
import { GetHostOverviewQuery, HostItem } from '../../../graphql/types';
@@ -40,8 +42,10 @@ export interface OwnProps extends QueryTemplateProps {
endDate: number;
}
+type HostsOverViewProps = OwnProps & HostOverviewReduxProps & WithKibanaProps;
+
class HostOverviewByNameComponentQuery extends QueryTemplate<
- OwnProps & HostOverviewReduxProps,
+ HostsOverViewProps,
GetHostOverviewQuery.Query,
GetHostOverviewQuery.Variables
> {
@@ -51,6 +55,7 @@ class HostOverviewByNameComponentQuery extends QueryTemplate<
isInspected,
children,
hostName,
+ kibana,
skip,
sourceId,
startDate,
@@ -70,7 +75,7 @@ class HostOverviewByNameComponentQuery extends QueryTemplate<
from: startDate,
to: endDate,
},
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
@@ -102,6 +107,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const HostOverviewByNameQuery = connect(makeMapStateToProps)(
- HostOverviewByNameComponentQuery
-);
+export const HostOverviewByNameQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(HostOverviewByNameComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx b/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx
index 003032493fca25..9576c66c4c9a52 100644
--- a/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx
@@ -9,10 +9,10 @@ import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { GetIpOverviewQuery, IpOverviewData } from '../../graphql/types';
import { networkModel, inputsModel, inputsSelectors, State } from '../../store';
+import { useUiSetting } from '../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplateProps } from '../query_template';
@@ -49,7 +49,7 @@ const IpOverviewComponentQuery = React.memo(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
diff --git a/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx
index 20ed7fa991d158..501bc8472b5e21 100644
--- a/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx
@@ -8,11 +8,11 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { KpiHostDetailsData, GetKpiHostDetailsQuery } from '../../graphql/types';
import { inputsModel, inputsSelectors, State } from '../../store';
+import { useUiSetting } from '../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplateProps } from '../query_template';
@@ -51,7 +51,7 @@ const KpiHostDetailsComponentQuery = React.memo(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
diff --git a/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx
index f8aa8aa38e8e15..32472ba6deedf5 100644
--- a/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx
@@ -8,11 +8,11 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { GetKpiHostsQuery, KpiHostsData } from '../../graphql/types';
import { inputsModel, inputsSelectors, State } from '../../store';
+import { useUiSetting } from '../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplateProps } from '../query_template';
@@ -51,7 +51,7 @@ const KpiHostsComponentQuery = React.memo(
to: endDate!,
},
filterQuery: createFilter(filterQuery),
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: useUiSetting(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
diff --git a/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx
index 269c3593d4d73c..52b8814958ba01 100644
--- a/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx
@@ -8,11 +8,11 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { GetKpiNetworkQuery, KpiNetworkData } from '../../graphql/types';
import { inputsModel, inputsSelectors, State } from '../../store';
+import { useUiSetting } from '../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplateProps } from '../query_template';
@@ -51,7 +51,7 @@ const KpiNetworkComponentQuery = React.memo
to: endDate!,
},
filterQuery: createFilter(filterQuery),
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: useUiSetting(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
diff --git a/x-pack/legacy/plugins/siem/public/containers/kuery_autocompletion/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kuery_autocompletion/index.tsx
index d06f4f6fbbbfa4..6361f7abcf9770 100644
--- a/x-pack/legacy/plugins/siem/public/containers/kuery_autocompletion/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/kuery_autocompletion/index.tsx
@@ -9,7 +9,7 @@ import {
AutocompleteSuggestion,
IIndexPattern,
} from '../../../../../../../src/plugins/data/public';
-import { useKibanaPlugins } from '../../lib/compose/kibana_plugins';
+import { useKibana } from '../../lib/kibana';
type RendererResult = React.ReactElement | null;
type RendererFunction = (args: RenderArgs) => Result;
@@ -34,13 +34,13 @@ export const KueryAutocompletion = React.memo
null
);
const [suggestions, setSuggestions] = useState([]);
- const plugins = useKibanaPlugins();
+ const kibana = useKibana();
const loadSuggestions = async (
expression: string,
cursorPosition: number,
maxSuggestions?: number
) => {
- const autocompletionProvider = plugins.data.autocomplete.getProvider('kuery');
+ const autocompletionProvider = kibana.services.data.autocomplete.getProvider('kuery');
const config = {
get: () => true,
};
diff --git a/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx
index 592fe43b9873f9..b5ebf3deacd0a9 100644
--- a/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx
@@ -8,8 +8,8 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
GetNetworkDnsQuery,
@@ -19,6 +19,7 @@ import {
MatrixOverOrdinalHistogramData,
} from '../../graphql/types';
import { inputsModel, networkModel, networkSelectors, State, inputsSelectors } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
@@ -53,7 +54,7 @@ export interface NetworkDnsComponentReduxProps {
limit: number;
}
-type NetworkDnsProps = OwnProps & NetworkDnsComponentReduxProps;
+type NetworkDnsProps = OwnProps & NetworkDnsComponentReduxProps & WithKibanaProps;
export class NetworkDnsComponentQuery extends QueryTemplatePaginated<
NetworkDnsProps,
@@ -70,13 +71,14 @@ export class NetworkDnsComponentQuery extends QueryTemplatePaginated<
id = ID,
isInspected,
isPtrIncluded,
+ kibana,
limit,
skip,
sourceId,
startDate,
} = this.props;
const variables: GetNetworkDnsQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
inspect: isInspected,
isPtrIncluded,
@@ -172,7 +174,12 @@ const makeMapHistogramStateToProps = () => {
return mapStateToProps;
};
-export const NetworkDnsQuery = connect(makeMapStateToProps)(NetworkDnsComponentQuery);
-export const NetworkDnsHistogramQuery = connect(makeMapHistogramStateToProps)(
- NetworkDnsComponentQuery
-);
+export const NetworkDnsQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(NetworkDnsComponentQuery);
+
+export const NetworkDnsHistogramQuery = compose>(
+ connect(makeMapHistogramStateToProps),
+ withKibana
+)(NetworkDnsComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx
index d76ab53b2de3a9..bf4e64f63d5599 100644
--- a/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx
@@ -9,7 +9,6 @@ import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
@@ -19,6 +18,7 @@ import {
PageInfoPaginated,
} from '../../graphql/types';
import { inputsModel, inputsSelectors, networkModel, networkSelectors, State } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
@@ -52,7 +52,7 @@ export interface NetworkHttpComponentReduxProps {
sort: NetworkHttpSortField;
}
-type NetworkHttpProps = OwnProps & NetworkHttpComponentReduxProps;
+type NetworkHttpProps = OwnProps & NetworkHttpComponentReduxProps & WithKibanaProps;
class NetworkHttpComponentQuery extends QueryTemplatePaginated<
NetworkHttpProps,
@@ -68,6 +68,7 @@ class NetworkHttpComponentQuery extends QueryTemplatePaginated<
id = ID,
ip,
isInspected,
+ kibana,
limit,
skip,
sourceId,
@@ -75,7 +76,7 @@ class NetworkHttpComponentQuery extends QueryTemplatePaginated<
startDate,
} = this.props;
const variables: GetNetworkHttpQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
inspect: isInspected,
ip,
@@ -150,5 +151,6 @@ const makeMapStateToProps = () => {
};
export const NetworkHttpQuery = compose>(
- connect(makeMapStateToProps)
+ connect(makeMapStateToProps),
+ withKibana
)(NetworkHttpComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx
index b179745dafa511..bd1e1a002bbcdc 100644
--- a/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx
@@ -10,7 +10,6 @@ import { Query } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
FlowTargetSourceDest,
@@ -20,6 +19,7 @@ import {
PageInfoPaginated,
} from '../../graphql/types';
import { inputsModel, inputsSelectors, networkModel, networkSelectors, State } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
@@ -54,7 +54,7 @@ export interface NetworkTopCountriesComponentReduxProps {
sort: NetworkTopTablesSortField;
}
-type NetworkTopCountriesProps = OwnProps & NetworkTopCountriesComponentReduxProps;
+type NetworkTopCountriesProps = OwnProps & NetworkTopCountriesComponentReduxProps & WithKibanaProps;
class NetworkTopCountriesComponentQuery extends QueryTemplatePaginated<
NetworkTopCountriesProps,
@@ -68,6 +68,7 @@ class NetworkTopCountriesComponentQuery extends QueryTemplatePaginated<
endDate,
flowTarget,
filterQuery,
+ kibana,
id = `${ID}-${flowTarget}`,
ip,
isInspected,
@@ -78,7 +79,7 @@ class NetworkTopCountriesComponentQuery extends QueryTemplatePaginated<
sort,
} = this.props;
const variables: GetNetworkTopCountriesQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
flowTarget,
inspect: isInspected,
@@ -154,5 +155,6 @@ const makeMapStateToProps = () => {
};
export const NetworkTopCountriesQuery = compose>(
- connect(makeMapStateToProps)
+ connect(makeMapStateToProps),
+ withKibana
)(NetworkTopCountriesComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx
index 239576a48c49fc..f0f1f8257f29f1 100644
--- a/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx
@@ -9,7 +9,6 @@ import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
@@ -19,6 +18,7 @@ import {
NetworkTopTablesSortField,
PageInfoPaginated,
} from '../../graphql/types';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { inputsModel, inputsSelectors, networkModel, networkSelectors, State } from '../../store';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
@@ -54,7 +54,7 @@ export interface NetworkTopNFlowComponentReduxProps {
sort: NetworkTopTablesSortField;
}
-type NetworkTopNFlowProps = OwnProps & NetworkTopNFlowComponentReduxProps;
+type NetworkTopNFlowProps = OwnProps & NetworkTopNFlowComponentReduxProps & WithKibanaProps;
class NetworkTopNFlowComponentQuery extends QueryTemplatePaginated<
NetworkTopNFlowProps,
@@ -68,6 +68,7 @@ class NetworkTopNFlowComponentQuery extends QueryTemplatePaginated<
endDate,
flowTarget,
filterQuery,
+ kibana,
id = `${ID}-${flowTarget}`,
ip,
isInspected,
@@ -78,7 +79,7 @@ class NetworkTopNFlowComponentQuery extends QueryTemplatePaginated<
sort,
} = this.props;
const variables: GetNetworkTopNFlowQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
flowTarget,
inspect: isInspected,
@@ -154,5 +155,6 @@ const makeMapStateToProps = () => {
};
export const NetworkTopNFlowQuery = compose>(
- connect(makeMapStateToProps)
+ connect(makeMapStateToProps),
+ withKibana
)(NetworkTopNFlowComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx b/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx
index 6ef0ee7b33589c..36cadd7872cc84 100644
--- a/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx
@@ -8,10 +8,10 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { GetOverviewHostQuery, OverviewHostData } from '../../../graphql/types';
+import { useUiSetting } from '../../../lib/kibana';
import { inputsModel, inputsSelectors } from '../../../store/inputs';
import { State } from '../../../store';
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
@@ -53,7 +53,7 @@ const OverviewHostComponentQuery = React.memo(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
diff --git a/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx b/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx
index 677d96c10eee29..9e7d59de0e5466 100644
--- a/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx
@@ -9,9 +9,9 @@ import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { GetOverviewNetworkQuery, OverviewNetworkData } from '../../../graphql/types';
+import { useUiSetting } from '../../../lib/kibana';
import { State } from '../../../store';
import { inputsModel, inputsSelectors } from '../../../store/inputs';
import { createFilter, getDefaultFetchPolicy } from '../../helpers';
@@ -55,7 +55,7 @@ export const OverviewNetworkComponentQuery = React.memo<
to: endDate,
},
filterQuery: createFilter(filterQuery),
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: useUiSetting(DEFAULT_INDEX_KEY),
inspect: isInspected,
}}
>
diff --git a/x-pack/legacy/plugins/siem/public/containers/source/index.test.tsx b/x-pack/legacy/plugins/siem/public/containers/source/index.test.tsx
index 7d6ac73357b153..d1a183a402e371 100644
--- a/x-pack/legacy/plugins/siem/public/containers/source/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/source/index.test.tsx
@@ -11,11 +11,11 @@ import { MockedProvider } from 'react-apollo/test-utils';
import { wait } from '../../lib/helpers';
-import '../../mock/ui_settings';
-
import { WithSource, indicesExistOrDataTemporarilyUnavailable } from '.';
import { mockBrowserFields, mockIndexFields, mocksSource } from './mock';
+jest.mock('../../lib/kibana');
+
describe('Index Fields & Browser Fields', () => {
test('Index Fields', async () => {
mount(
diff --git a/x-pack/legacy/plugins/siem/public/containers/source/index.tsx b/x-pack/legacy/plugins/siem/public/containers/source/index.tsx
index 8bddbd14a367c1..94524dedbcd596 100644
--- a/x-pack/legacy/plugins/siem/public/containers/source/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/source/index.tsx
@@ -10,7 +10,7 @@ import { Query } from 'react-apollo';
import React, { useEffect, useState } from 'react';
import memoizeOne from 'memoize-one';
import { IIndexPattern } from 'src/plugins/data/public';
-import chrome from 'ui/chrome';
+import { useUiSetting$ } from '../../lib/kibana';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import { IndexField, SourceQuery } from '../../graphql/types';
@@ -82,6 +82,7 @@ export const getBrowserFields = memoizeOne(
);
export const WithSource = React.memo(({ children, sourceId }) => {
+ const [defaultIndex] = useUiSetting$(DEFAULT_INDEX_KEY);
return (
query={sourceQuery}
@@ -89,20 +90,14 @@ export const WithSource = React.memo(({ children, sourceId }) =
notifyOnNetworkStatusChange
variables={{
sourceId,
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex,
}}
>
{({ data }) =>
children({
indicesExist: get('source.status.indicesExist', data),
browserFields: getBrowserFields(get('source.status.indexFields', data)),
- indexPattern: getIndexFields(
- chrome
- .getUiSettingsClient()
- .get(DEFAULT_INDEX_KEY)
- .join(),
- get('source.status.indexFields', data)
- ),
+ indexPattern: getIndexFields(defaultIndex.join(), get('source.status.indexFields', data)),
})
}
diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx b/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx
index cfb3f8bd8dc774..721cfefe01780a 100644
--- a/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx
@@ -8,10 +8,10 @@ import { getOr } from 'lodash/fp';
import memoizeOne from 'memoize-one';
import React from 'react';
import { Query } from 'react-apollo';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
import { DetailItem, GetTimelineDetailsQuery } from '../../../graphql/types';
+import { useUiSetting } from '../../../lib/kibana';
import { timelineDetailsQuery } from './index.gql_query';
@@ -38,7 +38,7 @@ export const TimelineDetailsComponentQuery = React.memo(
sourceId,
indexName,
eventId,
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: useUiSetting(DEFAULT_INDEX_KEY),
};
return executeQuery ? (
diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx
index 40ed3b3747c105..f7c2d067a29f57 100644
--- a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx
@@ -8,9 +8,9 @@ import { getOr } from 'lodash/fp';
import memoizeOne from 'memoize-one';
import React from 'react';
import { Query } from 'react-apollo';
-
-import chrome from 'ui/chrome';
+import { compose } from 'redux';
import { connect } from 'react-redux';
+
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
GetTimelineQuery,
@@ -20,6 +20,7 @@ import {
TimelineItem,
} from '../../graphql/types';
import { inputsModel, inputsSelectors, State } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { createFilter } from '../helpers';
import { QueryTemplate, QueryTemplateProps } from '../query_template';
@@ -50,7 +51,7 @@ export interface OwnProps extends QueryTemplateProps {
sortField: SortField;
fields: string[];
}
-type TimelineQueryProps = OwnProps & TimelineQueryReduxProps;
+type TimelineQueryProps = OwnProps & TimelineQueryReduxProps & WithKibanaProps;
class TimelineQueryComponent extends QueryTemplate<
TimelineQueryProps,
@@ -71,6 +72,7 @@ class TimelineQueryComponent extends QueryTemplate<
id,
indexPattern,
isInspected,
+ kibana,
limit,
fields,
filterQuery,
@@ -84,7 +86,8 @@ class TimelineQueryComponent extends QueryTemplate<
pagination: { limit, cursor: null, tiebreaker: null },
sortField,
defaultIndex:
- indexPattern?.title.split(',') ?? chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ indexPattern?.title.split(',') ??
+ kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
inspect: isInspected,
};
return (
@@ -158,4 +161,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const TimelineQuery = connect(makeMapStateToProps)(TimelineQueryComponent);
+export const TimelineQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(TimelineQueryComponent);
diff --git a/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx b/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx
index 7abe14ae745c5a..3738355c8846eb 100644
--- a/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx
@@ -10,7 +10,6 @@ import { Query } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
PageInfoPaginated,
@@ -20,6 +19,7 @@ import {
FlowTargetSourceDest,
} from '../../graphql/types';
import { inputsModel, networkModel, networkSelectors, State, inputsSelectors } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
@@ -53,7 +53,7 @@ export interface TlsComponentReduxProps {
sort: TlsSortField;
}
-type TlsProps = OwnProps & TlsComponentReduxProps;
+type TlsProps = OwnProps & TlsComponentReduxProps & WithKibanaProps;
class TlsComponentQuery extends QueryTemplatePaginated<
TlsProps,
@@ -70,6 +70,7 @@ class TlsComponentQuery extends QueryTemplatePaginated<
id = ID,
ip,
isInspected,
+ kibana,
limit,
skip,
sourceId,
@@ -77,7 +78,7 @@ class TlsComponentQuery extends QueryTemplatePaginated<
sort,
} = this.props;
const variables: GetTlsQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
flowTarget,
inspect: isInspected,
@@ -152,6 +153,7 @@ const makeMapStateToProps = () => {
};
};
-export const TlsQuery = compose>(connect(makeMapStateToProps))(
- TlsComponentQuery
-);
+export const TlsQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(TlsComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx b/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx
index e623110fb71788..520ade954eb5c1 100644
--- a/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx
@@ -8,8 +8,8 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
GetUncommonProcessesQuery,
@@ -17,6 +17,7 @@ import {
UncommonProcessesEdges,
} from '../../graphql/types';
import { hostsModel, hostsSelectors, inputsModel, State, inputsSelectors } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
@@ -48,7 +49,7 @@ export interface UncommonProcessesComponentReduxProps {
limit: number;
}
-type UncommonProcessesProps = OwnProps & UncommonProcessesComponentReduxProps;
+type UncommonProcessesProps = OwnProps & UncommonProcessesComponentReduxProps & WithKibanaProps;
class UncommonProcessesComponentQuery extends QueryTemplatePaginated<
UncommonProcessesProps,
@@ -63,13 +64,14 @@ class UncommonProcessesComponentQuery extends QueryTemplatePaginated<
filterQuery,
id = ID,
isInspected,
+ kibana,
limit,
skip,
sourceId,
startDate,
} = this.props;
const variables: GetUncommonProcessesQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
inspect: isInspected,
pagination: generateTablePaginationOptions(activePage, limit),
@@ -142,4 +144,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const UncommonProcessesQuery = connect(makeMapStateToProps)(UncommonProcessesComponentQuery);
+export const UncommonProcessesQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(UncommonProcessesComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/containers/users/index.tsx b/x-pack/legacy/plugins/siem/public/containers/users/index.tsx
index ea6453b5c5dd49..ece73b7b10ff00 100644
--- a/x-pack/legacy/plugins/siem/public/containers/users/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/containers/users/index.tsx
@@ -8,8 +8,8 @@ import { getOr } from 'lodash/fp';
import React from 'react';
import { Query } from 'react-apollo';
import { connect } from 'react-redux';
+import { compose } from 'redux';
-import chrome from 'ui/chrome';
import { DEFAULT_INDEX_KEY } from '../../../common/constants';
import {
GetUsersQuery,
@@ -19,6 +19,7 @@ import {
UsersSortField,
} from '../../graphql/types';
import { inputsModel, networkModel, networkSelectors, State, inputsSelectors } from '../../store';
+import { withKibana, WithKibanaProps } from '../../lib/kibana';
import { createFilter, getDefaultFetchPolicy } from '../helpers';
import { generateTablePaginationOptions } from '../../components/paginated_table/helpers';
import { QueryTemplatePaginated, QueryTemplatePaginatedProps } from '../query_template_paginated';
@@ -53,7 +54,7 @@ export interface UsersComponentReduxProps {
sort: UsersSortField;
}
-type UsersProps = OwnProps & UsersComponentReduxProps;
+type UsersProps = OwnProps & UsersComponentReduxProps & WithKibanaProps;
class UsersComponentQuery extends QueryTemplatePaginated<
UsersProps,
@@ -70,6 +71,7 @@ class UsersComponentQuery extends QueryTemplatePaginated<
id = ID,
ip,
isInspected,
+ kibana,
limit,
skip,
sourceId,
@@ -77,7 +79,7 @@ class UsersComponentQuery extends QueryTemplatePaginated<
sort,
} = this.props;
const variables: GetUsersQuery.Variables = {
- defaultIndex: chrome.getUiSettingsClient().get(DEFAULT_INDEX_KEY),
+ defaultIndex: kibana.services.uiSettings.get(DEFAULT_INDEX_KEY),
filterQuery: createFilter(filterQuery),
flowTarget,
inspect: isInspected,
@@ -154,4 +156,7 @@ const makeMapStateToProps = () => {
return mapStateToProps;
};
-export const UsersQuery = connect(makeMapStateToProps)(UsersComponentQuery);
+export const UsersQuery = compose>(
+ connect(makeMapStateToProps),
+ withKibana
+)(UsersComponentQuery);
diff --git a/x-pack/legacy/plugins/siem/public/hooks/use_index_patterns.tsx b/x-pack/legacy/plugins/siem/public/hooks/use_index_patterns.tsx
index 091315df314d90..f5b595b0d01c61 100644
--- a/x-pack/legacy/plugins/siem/public/hooks/use_index_patterns.tsx
+++ b/x-pack/legacy/plugins/siem/public/hooks/use_index_patterns.tsx
@@ -10,7 +10,7 @@ import { DEFAULT_KBN_VERSION } from '../../common/constants';
import { useStateToaster } from '../components/toasters';
import { errorToToaster } from '../components/ml/api/error_to_toaster';
import { IndexPatternSavedObject } from '../components/ml_popover/types';
-import { useKibanaUiSetting } from '../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../lib/kibana';
import { getIndexPatterns } from './api/api';
import * as i18n from './translations';
@@ -21,7 +21,7 @@ export const useIndexPatterns = (refreshToggle = false): Return => {
const [indexPatterns, setIndexPatterns] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const [, dispatchToaster] = useStateToaster();
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
useEffect(() => {
let isSubscribed = true;
diff --git a/x-pack/legacy/plugins/siem/public/lib/compose/__mocks__/kibana_core.ts b/x-pack/legacy/plugins/siem/public/lib/compose/__mocks__/kibana_core.ts
deleted file mode 100644
index 7511f65dfb3092..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/compose/__mocks__/kibana_core.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
-
-const npStart = createUiNewPlatformMock().npStart;
-
-export function useKibanaCore() {
- return npStart.core;
-}
diff --git a/x-pack/legacy/plugins/siem/public/lib/compose/__mocks__/kibana_plugins.ts b/x-pack/legacy/plugins/siem/public/lib/compose/__mocks__/kibana_plugins.ts
deleted file mode 100644
index ab255f7c73a062..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/compose/__mocks__/kibana_plugins.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
-
-const npStart = createUiNewPlatformMock().npStart;
-
-export function useKibanaPlugins() {
- return npStart.plugins;
-}
diff --git a/x-pack/legacy/plugins/siem/public/lib/compose/kibana_core.tsx b/x-pack/legacy/plugins/siem/public/lib/compose/kibana_core.tsx
deleted file mode 100644
index f2fa261bf3eb47..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/compose/kibana_core.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import React, { createContext, useContext } from 'react';
-import { LegacyCoreStart } from 'src/core/public';
-
-interface CoreMountContext {
- core: LegacyCoreStart;
-}
-
-// TODO: Replace CoreStart/CoreSetup with AppMountContext
-// see: https://github.com/elastic/kibana/pull/41007
-
-export const KibanaCoreContext = createContext({} as CoreMountContext['core']);
-
-export const KibanaCoreContextProvider: React.FC<{ core: CoreMountContext['core'] }> = props => (
-
-);
-
-export function useKibanaCore() {
- return useContext(KibanaCoreContext);
-}
diff --git a/x-pack/legacy/plugins/siem/public/lib/compose/kibana_plugins.tsx b/x-pack/legacy/plugins/siem/public/lib/compose/kibana_plugins.tsx
deleted file mode 100644
index 7d1f1bc01edd32..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/compose/kibana_plugins.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import React, { createContext, useContext } from 'react';
-import { PluginsStart } from 'ui/new_platform/new_platform';
-
-interface PluginsMountContext {
- plugins: PluginsStart;
-}
-
-// TODO: Replace CoreStart/CoreSetup with AppMountContext
-// see: https://github.com/elastic/kibana/pull/41007
-
-export const KibanaPluginsContext = createContext({} as PluginsMountContext['plugins']);
-
-export const KibanaPluginsContextProvider: React.FC<{
- plugins: PluginsMountContext['plugins'];
-}> = props => (
-
-);
-
-export function useKibanaPlugins() {
- return useContext(KibanaPluginsContext);
-}
diff --git a/x-pack/legacy/plugins/siem/public/lib/kibana/__mocks__/index.ts b/x-pack/legacy/plugins/siem/public/lib/kibana/__mocks__/index.ts
new file mode 100644
index 00000000000000..93fd37c4d14cbd
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/public/lib/kibana/__mocks__/index.ts
@@ -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;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import {
+ createKibanaContextProviderMock,
+ createUseUiSettingMock,
+ createUseUiSetting$Mock,
+ createUseKibanaMock,
+ createWithKibanaMock,
+} from '../../../mock/kibana_react';
+
+export const useKibana = jest.fn(createUseKibanaMock());
+export const useUiSetting = jest.fn(createUseUiSettingMock());
+export const useUiSetting$ = jest.fn(createUseUiSetting$Mock());
+export const withKibana = jest.fn(createWithKibanaMock());
+export const KibanaContextProvider = jest.fn(createKibanaContextProviderMock());
diff --git a/x-pack/legacy/plugins/siem/public/lib/kibana/index.ts b/x-pack/legacy/plugins/siem/public/lib/kibana/index.ts
new file mode 100644
index 00000000000000..96d9c8330d265d
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/public/lib/kibana/index.ts
@@ -0,0 +1,31 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import {
+ KibanaContextProvider,
+ KibanaReactContextValue,
+ useKibana,
+ useUiSetting,
+ useUiSetting$,
+ withKibana,
+} from '../../../../../../../src/plugins/kibana_react/public';
+import { StartServices } from '../../apps/plugin';
+
+export type KibanaContext = KibanaReactContextValue;
+export interface WithKibanaProps {
+ kibana: KibanaContext;
+}
+
+// eslint-disable-next-line react-hooks/rules-of-hooks
+const typedUseKibana = () => useKibana();
+
+export {
+ KibanaContextProvider,
+ typedUseKibana as useKibana,
+ useUiSetting,
+ useUiSetting$,
+ withKibana,
+};
diff --git a/x-pack/legacy/plugins/siem/public/lib/settings/__mocks__/use_kibana_ui_setting.ts b/x-pack/legacy/plugins/siem/public/lib/settings/__mocks__/use_kibana_ui_setting.ts
deleted file mode 100644
index 9f5639ce19997a..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/settings/__mocks__/use_kibana_ui_setting.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { mockFrameworks, getMockKibanaUiSetting } from '../../../mock';
-
-type GenericValue = string | boolean | number;
-
-export const useKibanaUiSetting = (key: string, defaultValue?: GenericValue) => {
- return getMockKibanaUiSetting(mockFrameworks.default_UTC)(key);
-};
diff --git a/x-pack/legacy/plugins/siem/public/lib/settings/use_kibana_ui_setting.ts b/x-pack/legacy/plugins/siem/public/lib/settings/use_kibana_ui_setting.ts
deleted file mode 100644
index 0a89edb85e6ea3..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/settings/use_kibana_ui_setting.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { useCallback, useMemo } from 'react';
-// @ts-ignore: path dynamic for kibana
-import { timezoneProvider } from 'ui/vis/lib/timezone';
-
-import { DEFAULT_KBN_VERSION, DEFAULT_TIMEZONE_BROWSER } from '../../../common/constants';
-import { useKibanaCore } from '../compose/kibana_core';
-import { useObservable } from './use_observable';
-
-type GenericValue = string | boolean | number;
-
-/**
- * This hook behaves like a `useState` hook in that it provides a requested
- * setting value (with an optional default) from the Kibana UI settings (also
- * known as "advanced settings") and a setter to change that setting:
- *
- * ```
- * const [darkMode, setDarkMode] = useKibanaUiSetting('theme:darkMode');
- * ```
- *
- * This is not just a static consumption of the value, but will reactively
- * update when the underlying setting subscription of the `UiSettingsClient`
- * notifies of a change.
- *
- * Unlike the `useState`, it doesn't give type guarantees for the value,
- * because the underlying `UiSettingsClient` doesn't support that.
- */
-export const useKibanaUiSetting = (key: string, defaultValue?: GenericValue) => {
- const core = useKibanaCore();
- const uiSettingsClient = core.uiSettings;
- const uiInjectedMetadata = core.injectedMetadata;
-
- if (key === DEFAULT_KBN_VERSION) {
- return [uiInjectedMetadata.getKibanaVersion()];
- }
-
- /* eslint-disable react-hooks/rules-of-hooks */
- if (key === DEFAULT_TIMEZONE_BROWSER) {
- return [useMemo(() => timezoneProvider(uiSettingsClient)(), [uiSettingsClient])];
- }
-
- const uiSetting$ = useMemo(() => uiSettingsClient.get$(key, defaultValue), [uiSettingsClient]);
- const uiSetting = useObservable(uiSetting$);
- const setUiSetting = useCallback((value: GenericValue) => uiSettingsClient.set(key, value), [
- uiSettingsClient,
- ]);
- /* eslint-enable react-hooks/rules-of-hooks */
-
- return [uiSetting, setUiSetting];
-};
diff --git a/x-pack/legacy/plugins/siem/public/lib/settings/use_kibana_ui_settings.test.tsx b/x-pack/legacy/plugins/siem/public/lib/settings/use_kibana_ui_settings.test.tsx
deleted file mode 100644
index 9af4759b256088..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/settings/use_kibana_ui_settings.test.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import * as React from 'react';
-
-import { DEFAULT_KBN_VERSION, DEFAULT_TIMEZONE_BROWSER } from '../../../common/constants';
-import { HookWrapper } from '../../mock/hook_wrapper';
-import { useKibanaCore } from '../compose/kibana_core';
-import { useKibanaUiSetting } from './use_kibana_ui_setting';
-import { mount } from 'enzyme';
-
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- injectedMetadata: {
- getKibanaVersion: () => '8.0.0',
- },
- uiSettings: {
- get$: () => 'world',
- },
-}));
-
-jest.mock('ui/vis/lib/timezone', () => ({
- timezoneProvider: () => () => 'America/New_York',
-}));
-
-jest.mock('./use_observable', () => ({
- useObservable: (val: string) => val,
-}));
-
-describe('useKibanaUiSetting', () => {
- test('getKibanaVersion', () => {
- const wrapper = mount( useKibanaUiSetting(DEFAULT_KBN_VERSION)} />);
- expect(wrapper.text()).toEqual('["8.0.0"]');
- });
-
- test('getTimezone', () => {
- const wrapper = mount(
- useKibanaUiSetting(DEFAULT_TIMEZONE_BROWSER)} />
- );
- expect(wrapper.text()).toEqual('["America/New_York"]');
- });
-
- test('get any ui settings', () => {
- const wrapper = mount( useKibanaUiSetting('hello')} />);
- expect(wrapper.text()).toEqual('["world",null]');
- });
-});
diff --git a/x-pack/legacy/plugins/siem/public/lib/settings/use_observable.ts b/x-pack/legacy/plugins/siem/public/lib/settings/use_observable.ts
deleted file mode 100644
index 536b6b2723ae04..00000000000000
--- a/x-pack/legacy/plugins/siem/public/lib/settings/use_observable.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { useEffect, useState } from 'react';
-import { Observable } from 'rxjs';
-
-export function useObservable(observable$: Observable): T | undefined;
-export function useObservable(observable$: Observable, initialValue: T): T;
-export function useObservable(observable$: Observable, initialValue?: T): T | undefined {
- const [value, update] = useState(initialValue);
-
- useEffect(() => {
- const s = observable$.subscribe(update);
- return () => s.unsubscribe();
- }, [observable$]);
-
- return value;
-}
diff --git a/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx b/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx
index b1defcb34066d8..1696001203bc87 100644
--- a/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx
+++ b/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx
@@ -8,9 +8,9 @@ import darkTheme from '@elastic/eui/dist/eui_theme_dark.json';
import lightTheme from '@elastic/eui/dist/eui_theme_light.json';
import { DEFAULT_DARK_MODE } from '../../../common/constants';
-import { useKibanaUiSetting } from '../settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../kibana';
export const useEuiTheme = () => {
- const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE);
+ const [darkMode] = useUiSetting$(DEFAULT_DARK_MODE);
return darkMode ? darkTheme : lightTheme;
};
diff --git a/x-pack/legacy/plugins/siem/public/mock/kibana_core.ts b/x-pack/legacy/plugins/siem/public/mock/kibana_core.ts
new file mode 100644
index 00000000000000..cf3523a6260bbf
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/public/mock/kibana_core.ts
@@ -0,0 +1,13 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { createUiNewPlatformMock } from 'ui/new_platform/__mocks__/helpers';
+
+export const createKibanaCoreSetupMock = () => createUiNewPlatformMock().npSetup.core;
+export const createKibanaPluginsSetupMock = () => createUiNewPlatformMock().npSetup.plugins;
+
+export const createKibanaCoreStartMock = () => createUiNewPlatformMock().npStart.core;
+export const createKibanaPluginsStartMock = () => createUiNewPlatformMock().npStart.plugins;
diff --git a/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts b/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts
new file mode 100644
index 00000000000000..15944df1822b35
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts
@@ -0,0 +1,95 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import React from 'react';
+import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
+
+import {
+ DEFAULT_SIEM_TIME_RANGE,
+ DEFAULT_SIEM_REFRESH_INTERVAL,
+ DEFAULT_INDEX_KEY,
+ DEFAULT_DATE_FORMAT,
+ DEFAULT_DATE_FORMAT_TZ,
+ DEFAULT_DARK_MODE,
+ DEFAULT_TIME_RANGE,
+ DEFAULT_REFRESH_RATE_INTERVAL,
+ DEFAULT_FROM,
+ DEFAULT_TO,
+ DEFAULT_INTERVAL_PAUSE,
+ DEFAULT_INTERVAL_VALUE,
+ DEFAULT_TIMEZONE_BROWSER,
+} from '../../common/constants';
+import { defaultIndexPattern } from '../../default_index_pattern';
+import { createKibanaCoreStartMock, createKibanaPluginsStartMock } from './kibana_core';
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export const mockUiSettings: Record = {
+ [DEFAULT_TIME_RANGE]: { from: 'now-15m', to: 'now', mode: 'quick' },
+ [DEFAULT_REFRESH_RATE_INTERVAL]: { pause: false, value: 0 },
+ [DEFAULT_SIEM_TIME_RANGE]: {
+ from: DEFAULT_FROM,
+ to: DEFAULT_TO,
+ },
+ [DEFAULT_SIEM_REFRESH_INTERVAL]: {
+ pause: DEFAULT_INTERVAL_PAUSE,
+ value: DEFAULT_INTERVAL_VALUE,
+ },
+ [DEFAULT_INDEX_KEY]: defaultIndexPattern,
+ [DEFAULT_DATE_FORMAT_TZ]: 'UTC',
+ [DEFAULT_TIMEZONE_BROWSER]: 'America/New_York',
+ [DEFAULT_DATE_FORMAT]: 'MMM D, YYYY @ HH:mm:ss.SSS',
+ [DEFAULT_DARK_MODE]: false,
+};
+
+export const createUseUiSettingMock = () => (
+ key: string,
+ defaultValue?: T
+): T => {
+ const result = mockUiSettings[key];
+
+ if (typeof result != null) return result;
+
+ if (defaultValue != null) {
+ return defaultValue;
+ }
+
+ throw new Error(`Unexpected config key: ${key}`);
+};
+
+export const createUseUiSetting$Mock = () => {
+ const useUiSettingMock = createUseUiSettingMock();
+
+ return (
+ key: string,
+ defaultValue?: T
+ ): [T, () => void] | undefined => [useUiSettingMock(key, defaultValue), jest.fn()];
+};
+
+export const createUseKibanaMock = () => {
+ const services = { ...createKibanaCoreStartMock(), ...createKibanaPluginsStartMock() };
+
+ return () => ({ services });
+};
+
+export const createWithKibanaMock = () => {
+ const kibana = createUseKibanaMock()();
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return (Component: any) => (props: any) => {
+ return React.createElement(Component, { ...props, kibana });
+ };
+};
+
+export const createKibanaContextProviderMock = () => {
+ const kibana = createUseKibanaMock()();
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return ({ services, ...rest }: any) =>
+ React.createElement(KibanaContextProvider, {
+ ...rest,
+ services: { ...kibana.services, ...services },
+ });
+};
diff --git a/x-pack/legacy/plugins/siem/public/mock/test_providers.tsx b/x-pack/legacy/plugins/siem/public/mock/test_providers.tsx
index d4c06d998c5a20..6c0a85e3ef7783 100644
--- a/x-pack/legacy/plugins/siem/public/mock/test_providers.tsx
+++ b/x-pack/legacy/plugins/siem/public/mock/test_providers.tsx
@@ -17,12 +17,9 @@ import { Store } from 'redux';
import { BehaviorSubject } from 'rxjs';
import { ThemeProvider } from 'styled-components';
-import { CoreStart } from 'src/core/public';
-import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
-
import { createStore, State } from '../store';
import { mockGlobalState } from './global_state';
-import { mockUiSettings } from './ui_settings';
+import { createKibanaContextProviderMock } from './kibana_react';
jest.mock('ui/new_platform');
@@ -41,29 +38,6 @@ export const apolloClient = new ApolloClient({
export const apolloClientObservable = new BehaviorSubject(apolloClient);
-const services = {
- uiSettings: mockUiSettings,
- savedObjects: {} as CoreStart['savedObjects'],
- notifications: {} as CoreStart['notifications'],
- docLinks: {
- links: {
- query: {
- kueryQuerySyntax: '',
- },
- },
- } as CoreStart['docLinks'],
- http: {} as CoreStart['http'],
- overlays: {} as CoreStart['overlays'],
- storage: {
- get: () => {},
- },
- data: {
- query: {
- savedQueries: {},
- },
- },
-};
-
const localStorageMock = () => {
let store: Record = {};
@@ -84,11 +58,13 @@ Object.defineProperty(window, 'localStorage', {
value: localStorageMock(),
});
+const MockKibanaContextProvider = createKibanaContextProviderMock();
+
/** A utility for wrapping children in the providers required to run most tests */
export const TestProviders = React.memo(
({ children, store = createStore(state, apolloClientObservable), onDragEnd = jest.fn() }) => (
-
+
({ eui: euiDarkVars, darkMode: true })}>
@@ -96,7 +72,7 @@ export const TestProviders = React.memo(
-
+
)
);
diff --git a/x-pack/legacy/plugins/siem/public/mock/ui_settings.ts b/x-pack/legacy/plugins/siem/public/mock/ui_settings.ts
deleted file mode 100644
index 6c6411c6bda533..00000000000000
--- a/x-pack/legacy/plugins/siem/public/mock/ui_settings.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import chrome from 'ui/chrome';
-import {
- DEFAULT_SIEM_TIME_RANGE,
- DEFAULT_SIEM_REFRESH_INTERVAL,
- DEFAULT_INDEX_KEY,
- DEFAULT_DATE_FORMAT,
- DEFAULT_DATE_FORMAT_TZ,
- DEFAULT_DARK_MODE,
- DEFAULT_TIME_RANGE,
- DEFAULT_REFRESH_RATE_INTERVAL,
- DEFAULT_FROM,
- DEFAULT_TO,
- DEFAULT_INTERVAL_PAUSE,
- DEFAULT_INTERVAL_VALUE,
-} from '../../common/constants';
-import { defaultIndexPattern } from '../../default_index_pattern';
-
-chrome.getUiSettingsClient().get.mockImplementation((key: string) => {
- switch (key) {
- case DEFAULT_TIME_RANGE:
- return { from: 'now-15m', to: 'now', mode: 'quick' };
- case DEFAULT_REFRESH_RATE_INTERVAL:
- return { pause: false, value: 0 };
- case DEFAULT_SIEM_TIME_RANGE:
- return {
- from: DEFAULT_FROM,
- to: DEFAULT_TO,
- };
- case DEFAULT_SIEM_REFRESH_INTERVAL:
- return {
- pause: DEFAULT_INTERVAL_PAUSE,
- value: DEFAULT_INTERVAL_VALUE,
- };
- case DEFAULT_INDEX_KEY:
- return defaultIndexPattern;
- case DEFAULT_DATE_FORMAT_TZ:
- return 'Asia/Taipei';
- case DEFAULT_DATE_FORMAT:
- return 'MMM D, YYYY @ HH:mm:ss.SSS';
- case DEFAULT_DARK_MODE:
- return false;
- default:
- throw new Error(`Unexpected config key: ${key}`);
- }
-});
-
-export interface MockNpSetUp {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- core: { uiSettings: any };
-}
-
-type Config =
- | 'query:allowLeadingWildcards'
- | 'query:queryString:options'
- | 'courier:ignoreFilterIfFieldNotInIndex'
- | 'dateFormat:tz';
-
-export const mockUiSettings = {
- get: (item: Config) => {
- return mockUiSettings[item];
- },
- get$: () => ({
- subscribe: jest.fn(),
- }),
- 'query:allowLeadingWildcards': true,
- 'query:queryString:options': {},
- 'courier:ignoreFilterIfFieldNotInIndex': true,
- 'dateFormat:tz': 'Browser',
-};
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx
index 599870117890d6..aeb5e677374fc2 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/index.tsx
@@ -25,7 +25,7 @@ import {
SignalFilterOption,
SignalsTableFilterGroup,
} from './signals_filter_group';
-import { useKibanaUiSetting } from '../../../../lib/settings/use_kibana_ui_setting';
+import { useKibana, useUiSetting$ } from '../../../../lib/kibana';
import { DEFAULT_KBN_VERSION, DEFAULT_SIGNALS_INDEX } from '../../../../../common/constants';
import { defaultHeaders } from '../../../../components/timeline/body/column_headers/default_headers';
import { ColumnHeader } from '../../../../components/timeline/body/column_headers/column_header';
@@ -43,7 +43,6 @@ import {
} from './types';
import { inputsActions } from '../../../../store/inputs';
import { combineQueries } from '../../../../components/timeline/helpers';
-import { useKibanaCore } from '../../../../lib/compose/kibana_core';
import { useFetchIndexPatterns } from '../../../../containers/detection_engine/rules/fetch_index_patterns';
import { InputsRange } from '../../../../store/inputs/model';
import { Query } from '../../../../../../../../../src/plugins/data/common/query';
@@ -122,13 +121,13 @@ export const SignalsTableComponent = React.memo(
const [{ browserFields, indexPatterns }] = useFetchIndexPatterns([
`${DEFAULT_SIGNALS_INDEX}-default`,
]); // TODO Get from new FrankInspired XavierHook
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
- const core = useKibanaCore();
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
+ const kibana = useKibana();
const getGlobalQuery = useCallback(() => {
if (browserFields != null && indexPatterns != null) {
return combineQueries({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
dataProviders: [],
indexPattern: indexPatterns,
browserFields,
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx
index 8d754eb1d3e1b0..72b250470d19b0 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx
@@ -16,7 +16,7 @@ import {
} from '../../../../../components/detection_engine/utility_bar';
import * as i18n from './translations';
import { getBatchItems } from './batch_actions';
-import { useKibanaUiSetting } from '../../../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../../../lib/kibana';
import { DEFAULT_NUMBER_FORMAT } from '../../../../../../common/constants';
import { TimelineNonEcsData } from '../../../../../graphql/types';
import { SendSignalsToTimeline, UpdateSignalsStatus } from '../types';
@@ -45,7 +45,7 @@ export const SignalsUtilityBar = React.memo(
updateSignalsStatus,
sendSignalsToTimeline,
}) => {
- const [defaultNumberFormat] = useKibanaUiSetting(DEFAULT_NUMBER_FORMAT);
+ const [defaultNumberFormat] = useUiSetting$(DEFAULT_NUMBER_FORMAT);
const getBatchItemsPopoverContent = useCallback(
(closePopover: () => void) => (
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine_empty_page.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine_empty_page.tsx
index cb3e690615395d..a217fd6a737e70 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine_empty_page.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/detection_engine_empty_page.tsx
@@ -6,8 +6,8 @@
import React from 'react';
import chrome from 'ui/chrome';
-import { documentationLinks } from 'ui/documentation_links';
+import { useKibana } from '../../lib/kibana';
import { EmptyPage } from '../../components/empty_page';
import * as i18n from './translations';
@@ -21,7 +21,7 @@ export const DetectionEngineEmptyPage = React.memo(() => (
actionSecondaryIcon="popout"
actionSecondaryLabel={i18n.EMPTY_ACTION_SECONDARY}
actionSecondaryTarget="_blank"
- actionSecondaryUrl={documentationLinks.siem}
+ actionSecondaryUrl={useKibana().services.docLinks.links.siem}
data-test-subj="empty-page"
title={i18n.EMPTY_TITLE}
/>
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx
index 4497474b387b1e..442360bbf14846 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx
@@ -31,7 +31,7 @@ import { getBatchItems } from './batch_actions';
import { EuiBasicTableOnChange, TableData } from '../types';
import { allRulesReducer, State } from './reducer';
import * as i18n from '../translations';
-import { useKibanaUiSetting } from '../../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../../lib/kibana';
import { DEFAULT_KBN_VERSION } from '../../../../../common/constants';
import { JSONDownloader } from '../components/json_downloader';
import { useStateToaster } from '../../../../components/toasters';
@@ -78,7 +78,7 @@ export const AllRules = React.memo<{ importCompleteToggle: boolean }>(importComp
const history = useHistory();
const [isInitialLoad, setIsInitialLoad] = useState(true);
const [isLoadingRules, rulesData] = useRules(pagination, filterOptions, refreshToggle);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
const getBatchItemsPopoverContent = useCallback(
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx
index f2fbd373cf4bc7..39c660a0079a6f 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/index.tsx
@@ -25,7 +25,7 @@ import {
FilterManager,
Query,
} from '../../../../../../../../../../src/plugins/data/public';
-import { useKibanaCore } from '../../../../../lib/compose/kibana_core';
+import { useKibana } from '../../../../../lib/kibana';
import { FilterLabel } from './filter_label';
import { FormSchema } from '../shared_imports';
import * as I18n from './translations';
@@ -70,8 +70,8 @@ const MyEuiTextArea = styled(EuiTextArea)`
export const StepRuleDescription = memo(
({ data, direction = 'row', indexPatterns, schema }) => {
- const core = useKibanaCore();
- const [filterManager] = useState(new FilterManager(core.uiSettings));
+ const kibana = useKibana();
+ const [filterManager] = useState(new FilterManager(kibana.services.uiSettings));
const keys = Object.keys(schema);
const listItems = keys.reduce(
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/import_rule_modal/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/import_rule_modal/index.test.tsx
index 8dcce36e1a4090..381a3138bf6179 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/import_rule_modal/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/import_rule_modal/index.test.tsx
@@ -8,20 +8,11 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as React from 'react';
import { ImportRuleModalComponent } from './index';
-import { useKibanaUiSetting } from '../../../../../lib/settings/use_kibana_ui_setting';
-import { getMockKibanaUiSetting, MockFrameworks } from '../../../../../mock';
-import { DEFAULT_KBN_VERSION } from '../../../../../../common/constants';
-const mockUseKibanaUiSetting: jest.Mock = useKibanaUiSetting as jest.Mock;
-jest.mock('../../../../../lib/settings/use_kibana_ui_setting', () => ({
- useKibanaUiSetting: jest.fn(),
-}));
+jest.mock('../../../../../lib/kibana');
describe('ImportRuleModal', () => {
test('renders correctly against snapshot', () => {
- mockUseKibanaUiSetting.mockImplementation(
- getMockKibanaUiSetting((DEFAULT_KBN_VERSION as unknown) as MockFrameworks)
- );
const wrapper = shallow(
{
const [selectedFiles, setSelectedFiles] = useState(null);
const [isImporting, setIsImporting] = useState(false);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const [, dispatchToaster] = useStateToaster();
const cleanupAndCloseModal = () => {
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/query_bar/index.tsx
index d8d77fcf8abffb..c294ec24c4cb70 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/query_bar/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/query_bar/index.tsx
@@ -20,7 +20,7 @@ import {
} from '../../../../../../../../../../src/plugins/data/public';
import { QueryBar } from '../../../../../components/query_bar';
-import { useKibanaCore } from '../../../../../lib/compose/kibana_core';
+import { useKibana } from '../../../../../lib/kibana';
import { useSavedQueryServices } from '../../../../../utils/saved_query_services';
import { FieldHook, getFieldValidityAndErrorMessage } from '../shared_imports';
@@ -68,8 +68,8 @@ export const QueryBarDefineRule = ({
const [queryDraft, setQueryDraft] = useState({ query: '', language: 'kuery' });
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);
- const core = useKibanaCore();
- const [filterManager] = useState(new FilterManager(core.uiSettings));
+ const kibana = useKibana();
+ const [filterManager] = useState(new FilterManager(kibana.services.uiSettings));
const savedQueryServices = useSavedQueryServices();
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.test.tsx
index 6809acd4b33f62..7a3a99b1839718 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.test.tsx
@@ -8,20 +8,8 @@ import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import * as React from 'react';
-import { useKibanaCore } from '../../../../../lib/compose/kibana_core';
-
import { RuleSwitchComponent } from './index';
-
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: {
- get$: () => 'world',
- },
- injectedMetadata: {
- getKibanaVersion: () => '8.0.0',
- },
-}));
+jest.mock('../../../../../lib/kibana');
describe('RuleSwitch', () => {
test('renders correctly against snapshot', () => {
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.tsx
index a5d983ec8e224d..54f0fc453830e1 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_switch/index.tsx
@@ -17,7 +17,7 @@ import React, { useCallback, useState, useEffect } from 'react';
import { DEFAULT_KBN_VERSION } from '../../../../../../common/constants';
import { enableRules } from '../../../../../containers/detection_engine/rules';
-import { useKibanaUiSetting } from '../../../../../lib/settings/use_kibana_ui_setting';
+import { useUiSetting$ } from '../../../../../lib/kibana';
import { enableRulesAction } from '../../all/actions';
import { Action } from '../../all/reducer';
@@ -50,7 +50,7 @@ export const RuleSwitchComponent = ({
}: RuleSwitchProps) => {
const [myIsLoading, setMyIsLoading] = useState(false);
const [myEnabled, setMyEnabled] = useState(enabled ?? false);
- const [kbnVersion] = useKibanaUiSetting(DEFAULT_KBN_VERSION);
+ const [kbnVersion] = useUiSetting$(DEFAULT_KBN_VERSION);
const onRuleStateChange = useCallback(
async (event: EuiSwitchEvent) => {
diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx
index b94e3c35f3ea08..cc4e959cc9c78b 100644
--- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx
@@ -9,9 +9,9 @@ import { isEqual, get } from 'lodash/fp';
import React, { memo, useCallback, useState, useEffect } from 'react';
import { IIndexPattern } from '../../../../../../../../../../src/plugins/data/public';
-import { useUiSetting$ } from '../../../../../../../../../../src/plugins/kibana_react/public';
import { useFetchIndexPatterns } from '../../../../../containers/detection_engine/rules';
import { DEFAULT_INDEX_KEY } from '../../../../../../common/constants';
+import { useUiSetting$ } from '../../../../../lib/kibana';
import * as RuleI18n from '../../translations';
import { DefineStepRule, RuleStep, RuleStepProps } from '../../types';
import { StepRuleDescription } from '../description_step';
diff --git a/x-pack/legacy/plugins/siem/public/pages/hosts/details/details_tabs.test.tsx b/x-pack/legacy/plugins/siem/public/pages/hosts/details/details_tabs.test.tsx
index 8d45bbbe34d33d..092c2463419d1c 100644
--- a/x-pack/legacy/plugins/siem/public/pages/hosts/details/details_tabs.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/hosts/details/details_tabs.test.tsx
@@ -10,21 +10,13 @@ import { MemoryRouter } from 'react-router-dom';
import { mockIndexPattern } from '../../../mock/index_pattern';
import { TestProviders } from '../../../mock/test_providers';
-import { mockUiSettings } from '../../../mock/ui_settings';
import { HostDetailsTabs } from './details_tabs';
import { SetAbsoluteRangeDatePicker } from './types';
import { hostDetailsPagePath } from '../types';
import { type } from './utils';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
import { useMountAppended } from '../../../utils/use_mount_appended';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
+jest.mock('../../../lib/kibana');
jest.mock('../../../containers/source', () => ({
indicesExistOrDataTemporarilyUnavailable: () => true,
diff --git a/x-pack/legacy/plugins/siem/public/pages/hosts/details/index.tsx b/x-pack/legacy/plugins/siem/public/pages/hosts/details/index.tsx
index e062e65bde4966..b548d91615d198 100644
--- a/x-pack/legacy/plugins/siem/public/pages/hosts/details/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/hosts/details/index.tsx
@@ -28,7 +28,7 @@ import { HostOverviewByNameQuery } from '../../../containers/hosts/overview';
import { KpiHostDetailsQuery } from '../../../containers/kpi_host_details';
import { indicesExistOrDataTemporarilyUnavailable, WithSource } from '../../../containers/source';
import { LastEventIndexKey } from '../../../graphql/types';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
+import { useKibana } from '../../../lib/kibana';
import { convertToBuildEsQuery } from '../../../lib/keury';
import { inputsSelectors, State } from '../../../store';
import { setHostDetailsTablesActivePageToZero as dispatchHostDetailsTablesActivePageToZero } from '../../../store/hosts/actions';
@@ -63,7 +63,7 @@ const HostDetailsComponent = React.memo(
setHostDetailsTablesActivePageToZero(null);
}, [setHostDetailsTablesActivePageToZero, detailName]);
const capabilities = useContext(MlCapabilitiesContext);
- const core = useKibanaCore();
+ const kibana = useKibana();
const hostDetailsPageFilters: esFilters.Filter[] = [
{
meta: {
@@ -100,7 +100,7 @@ const HostDetailsComponent = React.memo(
{({ indicesExist, indexPattern }) => {
const filterQuery = convertToBuildEsQuery({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
indexPattern,
queries: [query],
filters: getFilters(),
diff --git a/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.test.tsx b/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.test.tsx
index f08cee824afa7b..00dcb5908a98bc 100644
--- a/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.test.tsx
@@ -12,30 +12,15 @@ import { MockedProvider } from 'react-apollo/test-utils';
import { ActionCreator } from 'typescript-fsa';
import '../../mock/match_media';
-
-import { SiemNavigation } from '../../components/navigation';
import { mocksSource } from '../../containers/source/mock';
import { wait } from '../../lib/helpers';
import { TestProviders } from '../../mock';
-import { mockUiSettings } from '../../mock/ui_settings';
import { InputsModelId } from '../../store/inputs/constants';
+import { SiemNavigation } from '../../components/navigation';
import { HostsComponentProps } from './types';
import { Hosts } from './hosts';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
-
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
-
-jest.mock('ui/documentation_links', () => ({
- documentationLinks: {
- kibana: 'http://www.example.com',
- },
-}));
+jest.mock('../../lib/kibana');
// Test will fail because we will to need to mock some core services to make the test work
// For now let's forget about SiemSearchBar and QueryBar
diff --git a/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.tsx b/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.tsx
index 6d217a9301884b..6b69f06b97b833 100644
--- a/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/hosts/hosts.tsx
@@ -25,7 +25,7 @@ import { GlobalTimeArgs } from '../../containers/global_time';
import { KpiHostsQuery } from '../../containers/kpi_hosts';
import { indicesExistOrDataTemporarilyUnavailable, WithSource } from '../../containers/source';
import { LastEventIndexKey } from '../../graphql/types';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
+import { useKibana } from '../../lib/kibana';
import { convertToBuildEsQuery } from '../../lib/keury';
import { inputsSelectors, State, hostsModel } from '../../store';
import { setAbsoluteRangeDatePicker as dispatchSetAbsoluteRangeDatePicker } from '../../store/inputs/actions';
@@ -54,7 +54,7 @@ const HostsComponent = React.memo(
hostsPagePath,
}) => {
const capabilities = React.useContext(MlCapabilitiesContext);
- const core = useKibanaCore();
+ const kibana = useKibana();
const { tabName } = useParams();
const hostsFilters = React.useMemo(() => {
@@ -75,7 +75,7 @@ const HostsComponent = React.memo(
{({ indicesExist, indexPattern }) => {
const filterQuery = convertToBuildEsQuery({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
indexPattern,
queries: [query],
filters: hostsFilters,
diff --git a/x-pack/legacy/plugins/siem/public/pages/hosts/hosts_empty_page.tsx b/x-pack/legacy/plugins/siem/public/pages/hosts/hosts_empty_page.tsx
index ecd1e4f378cc57..1d2a3f83e8808d 100644
--- a/x-pack/legacy/plugins/siem/public/pages/hosts/hosts_empty_page.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/hosts/hosts_empty_page.tsx
@@ -6,26 +6,30 @@
import React from 'react';
import chrome from 'ui/chrome';
-import { documentationLinks } from 'ui/documentation_links';
import { EmptyPage } from '../../components/empty_page';
+import { useKibana } from '../../lib/kibana';
import * as i18n from './translations';
const basePath = chrome.getBasePath();
-export const HostsEmptyPage = React.memo(() => (
-
-));
+export const HostsEmptyPage = React.memo(() => {
+ const docLinks = useKibana().services.docLinks;
+
+ return (
+
+ );
+});
HostsEmptyPage.displayName = 'HostsEmptyPage';
diff --git a/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.test.tsx
index 72f78588476498..d624631c1feae4 100644
--- a/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.test.tsx
@@ -16,27 +16,19 @@ import '../../../mock/match_media';
import { mocksSource } from '../../../containers/source/mock';
import { FlowTarget } from '../../../graphql/types';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
import { apolloClientObservable, mockGlobalState, TestProviders } from '../../../mock';
import { useMountAppended } from '../../../utils/use_mount_appended';
-import { mockUiSettings } from '../../../mock/ui_settings';
import { createStore, State } from '../../../store';
import { InputsModelId } from '../../../store/inputs/constants';
import { IPDetailsComponent, IPDetails } from './index';
-jest.mock('../../../lib/settings/use_kibana_ui_setting');
-
type Action = 'PUSH' | 'POP' | 'REPLACE';
const pop: Action = 'POP';
type GlobalWithFetch = NodeJS.Global & { fetch: jest.Mock };
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
+jest.mock('../../../lib/kibana');
// Test will fail because we will to need to mock some core services to make the test work
// For now let's forget about SiemSearchBar and QueryBar
@@ -106,12 +98,6 @@ const getMockProps = (ip: string) => ({
setIpDetailsTablesActivePageToZero: (jest.fn() as unknown) as ActionCreator,
});
-jest.mock('ui/documentation_links', () => ({
- documentationLinks: {
- siem: 'http://www.example.com',
- },
-}));
-
describe('Ip Details', () => {
const mount = useMountAppended();
diff --git a/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.tsx b/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.tsx
index 97db422b539e84..99ca12292a52c0 100644
--- a/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/network/ip_details/index.tsx
@@ -24,7 +24,7 @@ import { WrapperPage } from '../../../components/wrapper_page';
import { IpOverviewQuery } from '../../../containers/ip_overview';
import { indicesExistOrDataTemporarilyUnavailable, WithSource } from '../../../containers/source';
import { FlowTargetSourceDest, LastEventIndexKey } from '../../../graphql/types';
-import { useKibanaCore } from '../../../lib/compose/kibana_core';
+import { useKibana } from '../../../lib/kibana';
import { decodeIpv6 } from '../../../lib/helpers';
import { convertToBuildEsQuery } from '../../../lib/keury';
import { ConditionalFlexGroup } from '../../../pages/network/navigation/conditional_flex_group';
@@ -70,7 +70,7 @@ export const IPDetailsComponent = ({
},
[setAbsoluteRangeDatePicker]
);
- const core = useKibanaCore();
+ const kibana = useKibana();
useEffect(() => {
setIpDetailsTablesActivePageToZero(null);
@@ -82,7 +82,7 @@ export const IPDetailsComponent = ({
{({ indicesExist, indexPattern }) => {
const ip = decodeIpv6(detailName);
const filterQuery = convertToBuildEsQuery({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
indexPattern,
queries: [query],
filters,
diff --git a/x-pack/legacy/plugins/siem/public/pages/network/network.test.tsx b/x-pack/legacy/plugins/siem/public/pages/network/network.test.tsx
index 327b0fb4c1e5b8..335bb62c5c8526 100644
--- a/x-pack/legacy/plugins/siem/public/pages/network/network.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/network/network.test.tsx
@@ -13,24 +13,10 @@ import { MockedProvider } from 'react-apollo/test-utils';
import '../../mock/match_media';
import { mocksSource } from '../../containers/source/mock';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
import { TestProviders } from '../../mock';
-import { mockUiSettings } from '../../mock/ui_settings';
import { Network } from './network';
-jest.mock('../../lib/settings/use_kibana_ui_setting');
-
-jest.mock('ui/documentation_links', () => ({
- documentationLinks: {
- kibana: 'http://www.example.com',
- },
-}));
-
-const mockUseKibanaCore = useKibanaCore as jest.Mock;
-jest.mock('../../lib/compose/kibana_core');
-mockUseKibanaCore.mockImplementation(() => ({
- uiSettings: mockUiSettings,
-}));
+jest.mock('../../lib/kibana');
// Test will fail because we will to need to mock some core services to make the test work
// For now let's forget about SiemSearchBar and QueryBar
diff --git a/x-pack/legacy/plugins/siem/public/pages/network/network.tsx b/x-pack/legacy/plugins/siem/public/pages/network/network.tsx
index 0d8d3a6753c59f..c39935742a2e01 100644
--- a/x-pack/legacy/plugins/siem/public/pages/network/network.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/network/network.tsx
@@ -23,7 +23,7 @@ import { WrapperPage } from '../../components/wrapper_page';
import { KpiNetworkQuery } from '../../containers/kpi_network';
import { indicesExistOrDataTemporarilyUnavailable, WithSource } from '../../containers/source';
import { LastEventIndexKey } from '../../graphql/types';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
+import { useKibana } from '../../lib/kibana';
import { convertToBuildEsQuery } from '../../lib/keury';
import { networkModel, State, inputsSelectors } from '../../store';
import { setAbsoluteRangeDatePicker as dispatchSetAbsoluteRangeDatePicker } from '../../store/inputs/actions';
@@ -51,7 +51,7 @@ const NetworkComponent = React.memo(
hasMlUserPermissions,
capabilitiesFetched,
}) => {
- const core = useKibanaCore();
+ const kibana = useKibana();
const { tabName } = useParams();
const networkFilters = useMemo(() => {
@@ -72,7 +72,7 @@ const NetworkComponent = React.memo(
{({ indicesExist, indexPattern }) => {
const filterQuery = convertToBuildEsQuery({
- config: esQuery.getEsQueryConfig(core.uiSettings),
+ config: esQuery.getEsQueryConfig(kibana.services.uiSettings),
indexPattern,
queries: [query],
filters: networkFilters,
diff --git a/x-pack/legacy/plugins/siem/public/pages/network/network_empty_page.tsx b/x-pack/legacy/plugins/siem/public/pages/network/network_empty_page.tsx
index 34e7f49bd9bd58..e22802fd29d49e 100644
--- a/x-pack/legacy/plugins/siem/public/pages/network/network_empty_page.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/network/network_empty_page.tsx
@@ -6,26 +6,29 @@
import React from 'react';
import chrome from 'ui/chrome';
-import { documentationLinks } from 'ui/documentation_links';
+import { useKibana } from '../../lib/kibana';
import { EmptyPage } from '../../components/empty_page';
-
import * as i18n from './translations';
const basePath = chrome.getBasePath();
-export const NetworkEmptyPage = React.memo(() => (
-
-));
+export const NetworkEmptyPage = React.memo(() => {
+ const docLinks = useKibana().services.docLinks;
+
+ return (
+
+ );
+});
NetworkEmptyPage.displayName = 'NetworkEmptyPage';
diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/overview.test.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/overview.test.tsx
index 833030e0dc8a15..300df4a742adf2 100644
--- a/x-pack/legacy/plugins/siem/public/pages/overview/overview.test.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/overview/overview.test.tsx
@@ -10,17 +10,11 @@ import * as React from 'react';
import { MockedProvider } from 'react-apollo/test-utils';
import { MemoryRouter } from 'react-router-dom';
-import { Overview } from './index';
-
-import '../../mock/ui_settings';
-import { mocksSource } from '../../containers/source/mock';
import { TestProviders } from '../../mock';
+import { mocksSource } from '../../containers/source/mock';
+import { Overview } from './index';
-jest.mock('ui/documentation_links', () => ({
- documentationLinks: {
- kibana: 'http://www.example.com',
- },
-}));
+jest.mock('../../lib/kibana');
let localSource: Array<{
request: {};
diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx
index de976b1a5c5a37..a0e94431054cca 100644
--- a/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx
@@ -8,8 +8,8 @@ import { EuiFlexGroup } from '@elastic/eui';
import moment from 'moment';
import React from 'react';
import chrome from 'ui/chrome';
-import { documentationLinks } from 'ui/documentation_links';
+import { useKibana } from '../../lib/kibana';
import { EmptyPage } from '../../components/empty_page';
import { HeaderPage } from '../../components/header_page';
import { OverviewHost } from '../../components/page/overview/overview_host';
@@ -24,6 +24,7 @@ import * as i18n from './translations';
const basePath = chrome.getBasePath();
export const OverviewComponent = React.memo(() => {
+ const docLinks = useKibana().services.docLinks;
const dateEnd = Date.now();
const dateRange = moment.duration(24, 'hours').asMilliseconds();
const dateStart = dateEnd - dateRange;
@@ -62,7 +63,7 @@ export const OverviewComponent = React.memo(() => {
actionSecondaryIcon="popout"
actionSecondaryLabel={i18n.EMPTY_ACTION_SECONDARY}
actionSecondaryTarget="_blank"
- actionSecondaryUrl={documentationLinks.siem}
+ actionSecondaryUrl={docLinks.links.siem}
data-test-subj="empty-page"
title={i18n.EMPTY_TITLE}
/>
diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/summary.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/summary.tsx
index 7fd8f84129d893..51cfcbe9374ab9 100644
--- a/x-pack/legacy/plugins/siem/public/pages/overview/summary.tsx
+++ b/x-pack/legacy/plugins/siem/public/pages/overview/summary.tsx
@@ -4,73 +4,81 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import React from 'react';
import { EuiFlexItem, EuiLink, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import React from 'react';
-import { documentationLinks } from 'ui/documentation_links';
-export const Summary = React.memo(() => (
-
-
-
-
-
+import { useKibana } from '../../lib/kibana';
+
+export const Summary = React.memo(() => {
+ const docLinks = useKibana().services.docLinks;
+
+ return (
+
+
+
+
+
-
-
-
-
- ),
- data: (
-
-
-
- ),
- siemSolution: (
-
-
-
- ),
- }}
- />
-
+
+
+
+
+ ),
+ data: (
+
+
+
+ ),
+ siemSolution: (
+
+
+
+ ),
+ }}
+ />
+
-
-
-
+
+
+
-
-
-
-
- ),
- }}
- />
-
-
-
-));
+
+
+
+
+ ),
+ }}
+ />
+
+
+
+ );
+});
Summary.displayName = 'Summary';
diff --git a/x-pack/legacy/plugins/siem/public/utils/saved_query_services/index.tsx b/x-pack/legacy/plugins/siem/public/utils/saved_query_services/index.tsx
index cda6882fe17143..a8ee10ba2b8014 100644
--- a/x-pack/legacy/plugins/siem/public/utils/saved_query_services/index.tsx
+++ b/x-pack/legacy/plugins/siem/public/utils/saved_query_services/index.tsx
@@ -10,16 +10,18 @@ import {
createSavedQueryService,
} from '../../../../../../../src/plugins/data/public';
-import { useKibanaCore } from '../../lib/compose/kibana_core';
+import { useKibana } from '../../lib/kibana';
export const useSavedQueryServices = () => {
- const core = useKibanaCore();
+ const kibana = useKibana();
+ const client = kibana.services.savedObjects.client;
+
const [savedQueryService, setSavedQueryService] = useState(
- createSavedQueryService(core.savedObjects.client)
+ createSavedQueryService(client)
);
useEffect(() => {
- setSavedQueryService(createSavedQueryService(core.savedObjects.client));
- }, [core.savedObjects.client]);
+ setSavedQueryService(createSavedQueryService(client));
+ }, [client]);
return savedQueryService;
};
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts
index 69fc9a26e921a7..4e370bfdc5bc9f 100644
--- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts
@@ -41,189 +41,248 @@ import rule31 from './eql_audio_capture_via_powershell.json';
import rule32 from './eql_unusual_parentchild_relationship.json';
import rule33 from './eql_modification_of_boot_configuration.json';
import rule34 from './eql_volume_shadow_copy_deletion_via_vssadmin.json';
-import rule35 from './suricata_category_large_scale_information_leak.json';
-import rule36 from './suricata_category_attempted_information_leak.json';
-import rule37 from './suricata_category_not_suspicious_traffic.json';
-import rule38 from './suricata_category_potentially_bad_traffic.json';
-import rule39 from './suricata_category_information_leak.json';
-import rule40 from './suricata_category_unknown_traffic.json';
-import rule41 from './suricata_category_successful_administrator_privilege_gain.json';
-import rule42 from './suricata_category_attempted_administrator_privilege_gain.json';
-import rule43 from './suricata_category_unsuccessful_user_privilege_gain.json';
-import rule44 from './suricata_category_successful_user_privilege_gain.json';
-import rule45 from './suricata_category_attempted_user_privilege_gain.json';
-import rule46 from './suricata_category_attempted_denial_of_service.json';
-import rule47 from './suricata_category_decode_of_an_rpc_query.json';
-import rule48 from './suricata_category_denial_of_service.json';
-import rule49 from './suricata_category_attempted_login_with_suspicious_username.json';
-import rule50 from './suricata_category_client_using_unusual_port.json';
-import rule51 from './suricata_category_suspicious_filename_detected.json';
-import rule52 from './suricata_category_a_suspicious_string_was_detected.json';
-import rule53 from './suricata_category_tcp_connection_detected.json';
-import rule54 from './suricata_category_executable_code_was_detected.json';
-import rule55 from './suricata_category_network_trojan_detected.json';
-import rule56 from './suricata_category_system_call_detected.json';
-import rule57 from './suricata_category_potentially_vulnerable_web_application_access.json';
-import rule58 from './suricata_category_nonstandard_protocol_or_event.json';
-import rule59 from './suricata_category_denial_of_service_attack.json';
-import rule60 from './suricata_category_generic_protocol_command_decode.json';
-import rule61 from './suricata_category_network_scan_detected.json';
-import rule62 from './suricata_category_web_application_attack.json';
-import rule63 from './suricata_category_generic_icmp_event.json';
-import rule64 from './suricata_category_misc_attack.json';
-import rule65 from './suricata_category_default_username_and_password_login_attempt.json';
-import rule66 from './suricata_category_external_ip_address_retrieval.json';
-import rule67 from './suricata_category_potential_corporate_privacy_violation.json';
-import rule68 from './suricata_category_targeted_malicious_activity.json';
-import rule69 from './suricata_category_observed_c2_domain.json';
-import rule70 from './suricata_category_exploit_kit_activity.json';
-import rule71 from './suricata_category_possibly_unwanted_program.json';
-import rule72 from './suricata_category_successful_credential_theft.json';
-import rule73 from './suricata_category_possible_social_engineering_attempted.json';
-import rule74 from './suricata_category_crypto_currency_mining_activity.json';
-import rule75 from './suricata_category_malware_command_and_control_activity.json';
-import rule76 from './suricata_category_misc_activity.json';
-import rule77 from './windows_powershell_connecting_to_the_internet.json';
-import rule78 from './windows_net_user_command_activity.json';
-import rule79 from './windows_image_load_from_a_temp_directory.json';
-import rule80 from './network_ssh_secure_shell_to_the_internet.json';
-import rule81 from './suricata_nonhttp_traffic_on_tcp_port_80.json';
-import rule82 from './windows_misc_lolbin_connecting_to_the_internet.json';
-import rule83 from './linux_strace_activity.json';
-import rule84 from './suricata_directory_reversal_characters_in_an_http_request.json';
-import rule85 from './suricata_dns_traffic_on_unusual_udp_port.json';
-import rule86 from './network_telnet_port_activity.json';
-import rule87 from './suricata_directory_traversal_in_downloaded_zip_file.json';
-import rule88 from './windows_execution_via_microsoft_html_application_hta.json';
-import rule89 from './windows_credential_dumping_commands.json';
-import rule90 from './windows_net_command_activity_by_the_system_account.json';
-import rule91 from './windows_register_server_program_connecting_to_the_internet.json';
-import rule92 from './linux_java_process_connecting_to_the_internet.json';
-import rule93 from './suricata_imap_traffic_on_unusual_port_internet_destination.json';
-import rule94 from './suricata_double_encoded_characters_in_a_uri.json';
-import rule95 from './network_tor_activity_to_the_internet.json';
-import rule96 from './windows_registry_query_local.json';
-import rule97 from './linux_netcat_network_connection.json';
-import rule98 from './windows_defense_evasion_via_filter_manager.json';
-import rule99 from './suricata_nondns_traffic_on_udp_port_53.json';
-import rule100 from './suricata_double_encoded_characters_in_an_http_post.json';
-import rule101 from './command_shell_started_by_internet_explorer.json';
-import rule102 from './network_vnc_virtual_network_computing_from_the_internet.json';
-import rule103 from './windows_nmap_activity.json';
-import rule104 from './suspicious_process_started_by_a_script.json';
-import rule105 from './windows_network_anomalous_windows_process_using_https_ports.json';
-import rule106 from './powershell_network_connection.json';
-import rule107 from './windows_signed_binary_proxy_execution.json';
-import rule108 from './linux_kernel_module_activity.json';
-import rule109 from './network_vnc_virtual_network_computing_to_the_internet.json';
-import rule110 from './suricata_mimikatz_string_detected_in_http_response.json';
-import rule111 from './command_shell_started_by_svchost.json';
-import rule112 from './linux_tcpdump_activity.json';
-import rule113 from './process_started_by_ms_office_program_possible_payload.json';
-import rule114 from './windows_signed_binary_proxy_execution_download.json';
-import rule115 from './suricata_base64_encoded_startprocess_powershell_execution.json';
-import rule116 from './suricata_base64_encoded_invokecommand_powershell_execution.json';
-import rule117 from './suricata_directory_traversal_characters_in_http_response.json';
-import rule118 from './windows_microsoft_html_application_hta_connecting_to_the_internet.json';
-import rule119 from './suricata_tls_traffic_on_unusual_port_internet_destination.json';
-import rule120 from './process_started_by_acrobat_reader_possible_payload.json';
-import rule121 from './suricata_http_traffic_on_unusual_port_internet_destination.json';
-import rule122 from './windows_persistence_via_modification_of_existing_service.json';
-import rule123 from './windows_defense_evasion_or_persistence_via_hidden_files.json';
-import rule124 from './windows_execution_via_compiled_html_file.json';
-import rule125 from './linux_ptrace_activity.json';
-import rule126 from './suricata_nonimap_traffic_on_port_1443_imap.json';
-import rule127 from './windows_scheduled_task_activity.json';
-import rule128 from './suricata_ftp_traffic_on_unusual_port_internet_destination.json';
-import rule129 from './windows_wireshark_activity.json';
-import rule130 from './windows_execution_via_trusted_developer_utilities.json';
-import rule131 from './suricata_rpc_traffic_on_http_ports.json';
-import rule132 from './windows_process_discovery_via_tasklist_command.json';
-import rule133 from './suricata_cobaltstrike_artifact_in_an_dns_request.json';
-import rule134 from './suricata_serialized_php_detected.json';
-import rule135 from './windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json';
-import rule136 from './windows_registry_query_network.json';
-import rule137 from './windows_persistence_via_application_shimming.json';
-import rule138 from './network_proxy_port_activity_to_the_internet.json';
-import rule139 from './windows_whoami_command_activity.json';
-import rule140 from './suricata_shell_exec_php_function_in_an_http_post.json';
-import rule141 from './windump_activity.json';
-import rule142 from './windows_management_instrumentation_wmi_execution.json';
-import rule143 from './network_rdp_remote_desktop_protocol_from_the_internet.json';
-import rule144 from './windows_priv_escalation_via_accessibility_features.json';
-import rule145 from './psexec_activity.json';
-import rule146 from './linux_rawshark_activity.json';
-import rule147 from './suricata_nonftp_traffic_on_port_21.json';
-import rule148 from './network_ftp_file_transfer_protocol_activity_to_the_internet.json';
-import rule149 from './windows_certutil_connecting_to_the_internet.json';
-import rule150 from './suricata_nonsmb_traffic_on_tcp_port_139_smb.json';
-import rule151 from './network_rdp_remote_desktop_protocol_to_the_internet.json';
-import rule152 from './linux_whoami_commmand.json';
-import rule153 from './windows_persistence_or_priv_escalation_via_hooking.json';
-import rule154 from './linux_lzop_activity_possible_julianrunnels.json';
-import rule155 from './suricata_nontls_on_tls_port.json';
-import rule156 from './network_irc_internet_relay_chat_protocol_activity_to_the_internet.json';
-import rule157 from './linux_network_anomalous_process_using_https_ports.json';
-import rule158 from './windows_credential_dumping_via_registry_save.json';
-import rule159 from './network_rpc_remote_procedure_call_from_the_internet.json';
-import rule160 from './windows_credential_dumping_via_imageload.json';
-import rule161 from './windows_burp_ce_activity.json';
-import rule162 from './linux_hping_activity.json';
-import rule163 from './windows_command_prompt_connecting_to_the_internet.json';
-import rule164 from './network_nat_traversal_port_activity.json';
-import rule165 from './network_rpc_remote_procedure_call_to_the_internet.json';
-import rule166 from './suricata_possible_cobalt_strike_malleable_c2_null_response.json';
-import rule167 from './windows_remote_management_execution.json';
-import rule168 from './suricata_lazagne_artifact_in_an_http_post.json';
-import rule169 from './windows_netcat_network_activity.json';
-import rule170 from './windows_iodine_activity.json';
-import rule171 from './network_port_26_activity.json';
-import rule172 from './windows_execution_via_connection_manager.json';
-import rule173 from './linux_process_started_in_temp_directory.json';
-import rule174 from './suricata_eval_php_function_in_an_http_request.json';
-import rule175 from './linux_web_download.json';
-import rule176 from './suricata_ssh_traffic_not_on_port_22_internet_destination.json';
-import rule177 from './network_port_8000_activity.json';
-import rule178 from './windows_process_started_by_the_java_runtime.json';
-import rule179 from './suricata_possible_sql_injection_sql_commands_in_http_transactions.json';
-import rule180 from './network_smb_windows_file_sharing_activity_to_the_internet.json';
-import rule181 from './network_port_8000_activity_to_the_internet.json';
-import rule182 from './command_shell_started_by_powershell.json';
-import rule183 from './linux_nmap_activity.json';
-import rule184 from './search_windows_10.json';
-import rule185 from './network_smtp_to_the_internet.json';
-import rule186 from './windows_payload_obfuscation_via_certutil.json';
-import rule187 from './network_pptp_point_to_point_tunneling_protocol_activity.json';
-import rule188 from './linux_unusual_shell_activity.json';
-import rule189 from './linux_mknod_activity.json';
-import rule190 from './network_sql_server_port_activity_to_the_internet.json';
-import rule191 from './suricata_commonly_abused_dns_domain_detected.json';
-import rule192 from './linux_iodine_activity.json';
-import rule193 from './suricata_mimikatz_artifacts_in_an_http_post.json';
-import rule194 from './windows_execution_via_net_com_assemblies.json';
-import rule195 from './suricata_dns_traffic_on_unusual_tcp_port.json';
-import rule196 from './suricata_base64_encoded_newobject_powershell_execution.json';
-import rule197 from './windows_netcat_activity.json';
-import rule198 from './windows_persistence_via_bits_jobs.json';
-import rule199 from './linux_nping_activity.json';
-import rule200 from './windows_execution_via_regsvr32.json';
-import rule201 from './process_started_by_windows_defender.json';
-import rule202 from './windows_indirect_command_execution.json';
-import rule203 from './network_ssh_secure_shell_from_the_internet.json';
-import rule204 from './windows_html_help_executable_program_connecting_to_the_internet.json';
-import rule205 from './suricata_windows_executable_served_by_jpeg_web_content.json';
-import rule206 from './network_dns_directly_to_the_internet.json';
-import rule207 from './windows_defense_evasion_via_windows_event_log_tools.json';
-import rule208 from './suricata_nondns_traffic_on_tcp_port_53.json';
-import rule209 from './windows_persistence_via_netshell_helper_dll.json';
-import rule210 from './windows_script_interpreter_connecting_to_the_internet.json';
-import rule211 from './windows_defense_evasion_decoding_using_certutil.json';
-import rule212 from './linux_shell_activity_by_web_server.json';
-import rule213 from './linux_ldso_process_activity.json';
-import rule214 from './windows_mimikatz_activity.json';
-import rule215 from './suricata_nonssh_traffic_on_port_22.json';
-import rule216 from './windows_data_compression_using_powershell.json';
-import rule217 from './windows_nmap_scan_activity.json';
+import rule35 from './zeek_notice_signaturesmultiple_sig_responders.json';
+import rule36 from './zeek_notice_packetfiltercompile_failure.json';
+import rule37 from './zeek_notice_signaturescount_signature.json';
+import rule38 from './zeek_notice_signaturesmultiple_signatures.json';
+import rule39 from './zeek_notice_signaturessignature_summary.json';
+import rule40 from './zeek_notice_signaturessensitive_signature.json';
+import rule41 from './zeek_notice_packetfilterinstall_failure.json';
+import rule42 from './zeek_notice_weirdactivity.json';
+import rule43 from './zeek_notice_noticetally.json';
+import rule44 from './zeek_notice_packetfilterno_more_conn_shunts_available.json';
+import rule45 from './zeek_notice_packetfiltercannot_bpf_shunt_conn.json';
+import rule46 from './zeek_notice_teamcymrumalwarehashregistrymatch.json';
+import rule47 from './zeek_notice_softwaresoftware_version_change.json';
+import rule48 from './zeek_notice_protocoldetectorserver_found.json';
+import rule49 from './zeek_notice_packetfiltertoo_long_to_compile_filter.json';
+import rule50 from './zeek_notice_protocoldetectorprotocol_found.json';
+import rule51 from './zeek_notice_intelnotice.json';
+import rule52 from './zeek_notice_packetfilterdropped_packets.json';
+import rule53 from './zeek_notice_scanaddress_scan.json';
+import rule54 from './zeek_notice_ftpbruteforcing.json';
+import rule55 from './zeek_notice_scanport_scan.json';
+import rule56 from './zeek_notice_dnsexternal_name.json';
+import rule57 from './zeek_notice_capturelosstoo_much_loss.json';
+import rule58 from './zeek_notice_softwarevulnerable_version.json';
+import rule59 from './zeek_notice_connretransmission_inconsistency.json';
+import rule60 from './zeek_notice_traceroutedetected.json';
+import rule61 from './zeek_notice_conncontent_gap.json';
+import rule62 from './zeek_notice_smtpblocklist_blocked_host.json';
+import rule63 from './zeek_notice_httpsql_injection_victim.json';
+import rule64 from './zeek_notice_sshlogin_by_password_guesser.json';
+import rule65 from './zeek_notice_sshpassword_guessing.json';
+import rule66 from './zeek_notice_sshwatched_country_login.json';
+import rule67 from './zeek_notice_ftpsite_exec_success.json';
+import rule68 from './zeek_notice_smtpsuspicious_origination.json';
+import rule69 from './zeek_notice_httpsql_injection_attacker.json';
+import rule70 from './zeek_notice_smtpblocklist_error_message.json';
+import rule71 from './zeek_notice_sshinteresting_hostname_login.json';
+import rule72 from './zeek_notice_sslinvalid_server_cert.json';
+import rule73 from './zeek_notice_heartbleedssl_heartbeat_many_requests.json';
+import rule74 from './zeek_notice_heartbleedssl_heartbeat_odd_length.json';
+import rule75 from './zeek_notice_sslcertificate_expired.json';
+import rule76 from './zeek_notice_sslcertificate_expires_soon.json';
+import rule77 from './zeek_notice_heartbleedssl_heartbeat_attack_success.json';
+import rule78 from './zeek_notice_sslcertificate_not_valid_yet.json';
+import rule79 from './zeek_notice_heartbleedssl_heartbeat_attack.json';
+import rule80 from './zeek_notice_sslinvalid_ocsp_response.json';
+import rule81 from './zeek_notice_sslweak_key.json';
+import rule82 from './zeek_notice_sslold_version.json';
+import rule83 from './zeek_notice_sslweak_cipher.json';
+import rule84 from './suricata_category_large_scale_information_leak.json';
+import rule85 from './suricata_category_attempted_information_leak.json';
+import rule86 from './suricata_category_not_suspicious_traffic.json';
+import rule87 from './suricata_category_potentially_bad_traffic.json';
+import rule88 from './suricata_category_information_leak.json';
+import rule89 from './suricata_category_unknown_traffic.json';
+import rule90 from './suricata_category_successful_administrator_privilege_gain.json';
+import rule91 from './suricata_category_attempted_administrator_privilege_gain.json';
+import rule92 from './suricata_category_unsuccessful_user_privilege_gain.json';
+import rule93 from './suricata_category_successful_user_privilege_gain.json';
+import rule94 from './suricata_category_attempted_user_privilege_gain.json';
+import rule95 from './suricata_category_attempted_denial_of_service.json';
+import rule96 from './suricata_category_decode_of_an_rpc_query.json';
+import rule97 from './suricata_category_denial_of_service.json';
+import rule98 from './suricata_category_attempted_login_with_suspicious_username.json';
+import rule99 from './suricata_category_client_using_unusual_port.json';
+import rule100 from './suricata_category_suspicious_filename_detected.json';
+import rule101 from './suricata_category_a_suspicious_string_was_detected.json';
+import rule102 from './suricata_category_tcp_connection_detected.json';
+import rule103 from './suricata_category_executable_code_was_detected.json';
+import rule104 from './suricata_category_network_trojan_detected.json';
+import rule105 from './suricata_category_system_call_detected.json';
+import rule106 from './suricata_category_potentially_vulnerable_web_application_access.json';
+import rule107 from './suricata_category_nonstandard_protocol_or_event.json';
+import rule108 from './suricata_category_denial_of_service_attack.json';
+import rule109 from './suricata_category_generic_protocol_command_decode.json';
+import rule110 from './suricata_category_network_scan_detected.json';
+import rule111 from './suricata_category_web_application_attack.json';
+import rule112 from './suricata_category_generic_icmp_event.json';
+import rule113 from './suricata_category_misc_attack.json';
+import rule114 from './suricata_category_default_username_and_password_login_attempt.json';
+import rule115 from './suricata_category_external_ip_address_retrieval.json';
+import rule116 from './suricata_category_potential_corporate_privacy_violation.json';
+import rule117 from './suricata_category_targeted_malicious_activity.json';
+import rule118 from './suricata_category_observed_c2_domain.json';
+import rule119 from './suricata_category_exploit_kit_activity.json';
+import rule120 from './suricata_category_possibly_unwanted_program.json';
+import rule121 from './suricata_category_successful_credential_theft.json';
+import rule122 from './suricata_category_possible_social_engineering_attempted.json';
+import rule123 from './suricata_category_crypto_currency_mining_activity.json';
+import rule124 from './suricata_category_malware_command_and_control_activity.json';
+import rule125 from './suricata_category_misc_activity.json';
+import rule126 from './windows_powershell_connecting_to_the_internet.json';
+import rule127 from './windows_net_user_command_activity.json';
+import rule128 from './windows_image_load_from_a_temp_directory.json';
+import rule129 from './network_ssh_secure_shell_to_the_internet.json';
+import rule130 from './suricata_nonhttp_traffic_on_tcp_port_80.json';
+import rule131 from './windows_misc_lolbin_connecting_to_the_internet.json';
+import rule132 from './linux_strace_activity.json';
+import rule133 from './suricata_directory_reversal_characters_in_an_http_request.json';
+import rule134 from './suricata_dns_traffic_on_unusual_udp_port.json';
+import rule135 from './network_telnet_port_activity.json';
+import rule136 from './suricata_directory_traversal_in_downloaded_zip_file.json';
+import rule137 from './windows_execution_via_microsoft_html_application_hta.json';
+import rule138 from './windows_credential_dumping_commands.json';
+import rule139 from './windows_net_command_activity_by_the_system_account.json';
+import rule140 from './windows_register_server_program_connecting_to_the_internet.json';
+import rule141 from './linux_java_process_connecting_to_the_internet.json';
+import rule142 from './suricata_imap_traffic_on_unusual_port_internet_destination.json';
+import rule143 from './suricata_double_encoded_characters_in_a_uri.json';
+import rule144 from './network_tor_activity_to_the_internet.json';
+import rule145 from './windows_registry_query_local.json';
+import rule146 from './linux_netcat_network_connection.json';
+import rule147 from './windows_defense_evasion_via_filter_manager.json';
+import rule148 from './suricata_nondns_traffic_on_udp_port_53.json';
+import rule149 from './suricata_double_encoded_characters_in_an_http_post.json';
+import rule150 from './command_shell_started_by_internet_explorer.json';
+import rule151 from './network_vnc_virtual_network_computing_from_the_internet.json';
+import rule152 from './windows_nmap_activity.json';
+import rule153 from './suspicious_process_started_by_a_script.json';
+import rule154 from './windows_network_anomalous_windows_process_using_https_ports.json';
+import rule155 from './powershell_network_connection.json';
+import rule156 from './windows_signed_binary_proxy_execution.json';
+import rule157 from './linux_kernel_module_activity.json';
+import rule158 from './network_vnc_virtual_network_computing_to_the_internet.json';
+import rule159 from './suricata_mimikatz_string_detected_in_http_response.json';
+import rule160 from './command_shell_started_by_svchost.json';
+import rule161 from './linux_tcpdump_activity.json';
+import rule162 from './process_started_by_ms_office_program_possible_payload.json';
+import rule163 from './windows_signed_binary_proxy_execution_download.json';
+import rule164 from './suricata_base64_encoded_startprocess_powershell_execution.json';
+import rule165 from './suricata_base64_encoded_invokecommand_powershell_execution.json';
+import rule166 from './suricata_directory_traversal_characters_in_http_response.json';
+import rule167 from './windows_microsoft_html_application_hta_connecting_to_the_internet.json';
+import rule168 from './suricata_tls_traffic_on_unusual_port_internet_destination.json';
+import rule169 from './process_started_by_acrobat_reader_possible_payload.json';
+import rule170 from './suricata_http_traffic_on_unusual_port_internet_destination.json';
+import rule171 from './windows_persistence_via_modification_of_existing_service.json';
+import rule172 from './windows_defense_evasion_or_persistence_via_hidden_files.json';
+import rule173 from './windows_execution_via_compiled_html_file.json';
+import rule174 from './linux_ptrace_activity.json';
+import rule175 from './suricata_nonimap_traffic_on_port_1443_imap.json';
+import rule176 from './windows_scheduled_task_activity.json';
+import rule177 from './suricata_ftp_traffic_on_unusual_port_internet_destination.json';
+import rule178 from './windows_wireshark_activity.json';
+import rule179 from './windows_execution_via_trusted_developer_utilities.json';
+import rule180 from './suricata_rpc_traffic_on_http_ports.json';
+import rule181 from './windows_process_discovery_via_tasklist_command.json';
+import rule182 from './suricata_cobaltstrike_artifact_in_an_dns_request.json';
+import rule183 from './suricata_serialized_php_detected.json';
+import rule184 from './windows_background_intelligent_transfer_service_bits_connecting_to_the_internet.json';
+import rule185 from './windows_registry_query_network.json';
+import rule186 from './windows_persistence_via_application_shimming.json';
+import rule187 from './network_proxy_port_activity_to_the_internet.json';
+import rule188 from './windows_whoami_command_activity.json';
+import rule189 from './suricata_shell_exec_php_function_in_an_http_post.json';
+import rule190 from './windump_activity.json';
+import rule191 from './windows_management_instrumentation_wmi_execution.json';
+import rule192 from './network_rdp_remote_desktop_protocol_from_the_internet.json';
+import rule193 from './windows_priv_escalation_via_accessibility_features.json';
+import rule194 from './psexec_activity.json';
+import rule195 from './linux_rawshark_activity.json';
+import rule196 from './suricata_nonftp_traffic_on_port_21.json';
+import rule197 from './network_ftp_file_transfer_protocol_activity_to_the_internet.json';
+import rule198 from './windows_certutil_connecting_to_the_internet.json';
+import rule199 from './suricata_nonsmb_traffic_on_tcp_port_139_smb.json';
+import rule200 from './network_rdp_remote_desktop_protocol_to_the_internet.json';
+import rule201 from './linux_whoami_commmand.json';
+import rule202 from './windows_persistence_or_priv_escalation_via_hooking.json';
+import rule203 from './linux_lzop_activity_possible_julianrunnels.json';
+import rule204 from './suricata_nontls_on_tls_port.json';
+import rule205 from './network_irc_internet_relay_chat_protocol_activity_to_the_internet.json';
+import rule206 from './linux_network_anomalous_process_using_https_ports.json';
+import rule207 from './windows_credential_dumping_via_registry_save.json';
+import rule208 from './network_rpc_remote_procedure_call_from_the_internet.json';
+import rule209 from './windows_credential_dumping_via_imageload.json';
+import rule210 from './windows_burp_ce_activity.json';
+import rule211 from './linux_hping_activity.json';
+import rule212 from './windows_command_prompt_connecting_to_the_internet.json';
+import rule213 from './network_nat_traversal_port_activity.json';
+import rule214 from './network_rpc_remote_procedure_call_to_the_internet.json';
+import rule215 from './suricata_possible_cobalt_strike_malleable_c2_null_response.json';
+import rule216 from './windows_remote_management_execution.json';
+import rule217 from './suricata_lazagne_artifact_in_an_http_post.json';
+import rule218 from './windows_netcat_network_activity.json';
+import rule219 from './windows_iodine_activity.json';
+import rule220 from './network_port_26_activity.json';
+import rule221 from './windows_execution_via_connection_manager.json';
+import rule222 from './linux_process_started_in_temp_directory.json';
+import rule223 from './suricata_eval_php_function_in_an_http_request.json';
+import rule224 from './linux_web_download.json';
+import rule225 from './suricata_ssh_traffic_not_on_port_22_internet_destination.json';
+import rule226 from './network_port_8000_activity.json';
+import rule227 from './windows_process_started_by_the_java_runtime.json';
+import rule228 from './suricata_possible_sql_injection_sql_commands_in_http_transactions.json';
+import rule229 from './network_smb_windows_file_sharing_activity_to_the_internet.json';
+import rule230 from './network_port_8000_activity_to_the_internet.json';
+import rule231 from './command_shell_started_by_powershell.json';
+import rule232 from './linux_nmap_activity.json';
+import rule233 from './search_windows_10.json';
+import rule234 from './network_smtp_to_the_internet.json';
+import rule235 from './windows_payload_obfuscation_via_certutil.json';
+import rule236 from './network_pptp_point_to_point_tunneling_protocol_activity.json';
+import rule237 from './linux_unusual_shell_activity.json';
+import rule238 from './linux_mknod_activity.json';
+import rule239 from './network_sql_server_port_activity_to_the_internet.json';
+import rule240 from './suricata_commonly_abused_dns_domain_detected.json';
+import rule241 from './linux_iodine_activity.json';
+import rule242 from './suricata_mimikatz_artifacts_in_an_http_post.json';
+import rule243 from './windows_execution_via_net_com_assemblies.json';
+import rule244 from './suricata_dns_traffic_on_unusual_tcp_port.json';
+import rule245 from './suricata_base64_encoded_newobject_powershell_execution.json';
+import rule246 from './windows_netcat_activity.json';
+import rule247 from './windows_persistence_via_bits_jobs.json';
+import rule248 from './linux_nping_activity.json';
+import rule249 from './windows_execution_via_regsvr32.json';
+import rule250 from './process_started_by_windows_defender.json';
+import rule251 from './windows_indirect_command_execution.json';
+import rule252 from './network_ssh_secure_shell_from_the_internet.json';
+import rule253 from './windows_html_help_executable_program_connecting_to_the_internet.json';
+import rule254 from './suricata_windows_executable_served_by_jpeg_web_content.json';
+import rule255 from './network_dns_directly_to_the_internet.json';
+import rule256 from './windows_defense_evasion_via_windows_event_log_tools.json';
+import rule257 from './suricata_nondns_traffic_on_tcp_port_53.json';
+import rule258 from './windows_persistence_via_netshell_helper_dll.json';
+import rule259 from './windows_script_interpreter_connecting_to_the_internet.json';
+import rule260 from './windows_defense_evasion_decoding_using_certutil.json';
+import rule261 from './linux_shell_activity_by_web_server.json';
+import rule262 from './linux_ldso_process_activity.json';
+import rule263 from './windows_mimikatz_activity.json';
+import rule264 from './suricata_nonssh_traffic_on_port_22.json';
+import rule265 from './windows_data_compression_using_powershell.json';
+import rule266 from './windows_nmap_scan_activity.json';
+import rule267 from './splunk_windows_event_log_cleared.json';
+import rule268 from './splunk_detect_long_dns_txt_record_response.json';
+import rule269 from './splunk_processes_launching_netsh.json';
+import rule270 from './splunk_detect_large_outbound_icmp_packets.json';
+import rule271 from './splunk_detect_new_local_admin_account.json';
+import rule272 from './splunk_protocols_passing_authentication_in_cleartext.json';
+import rule273 from './splunk_detect_use_of_cmdexe_to_launch_script_interpreters.json';
+import rule274 from './splunk_child_processes_of_spoolsvexe.json';
+import rule275 from './splunk_detect_psexec_with_accepteula_flag.json';
+import rule276 from './splunk_processes_created_by_netsh.json';
export const rawRules = [
rule1,
@@ -443,4 +502,63 @@ export const rawRules = [
rule215,
rule216,
rule217,
+ rule218,
+ rule219,
+ rule220,
+ rule221,
+ rule222,
+ rule223,
+ rule224,
+ rule225,
+ rule226,
+ rule227,
+ rule228,
+ rule229,
+ rule230,
+ rule231,
+ rule232,
+ rule233,
+ rule234,
+ rule235,
+ rule236,
+ rule237,
+ rule238,
+ rule239,
+ rule240,
+ rule241,
+ rule242,
+ rule243,
+ rule244,
+ rule245,
+ rule246,
+ rule247,
+ rule248,
+ rule249,
+ rule250,
+ rule251,
+ rule252,
+ rule253,
+ rule254,
+ rule255,
+ rule256,
+ rule257,
+ rule258,
+ rule259,
+ rule260,
+ rule261,
+ rule262,
+ rule263,
+ rule264,
+ rule265,
+ rule266,
+ rule267,
+ rule268,
+ rule269,
+ rule270,
+ rule271,
+ rule272,
+ rule273,
+ rule274,
+ rule275,
+ rule276,
];
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_child_processes_of_spoolsvexe.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_child_processes_of_spoolsvexe.json
new file mode 100644
index 00000000000000..554ddb1468d0ba
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_child_processes_of_spoolsvexe.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "2f026c73-bb63-455e-abdf-f11f463acf0d",
+ "risk_score": 50,
+ "description": "Splunk - Child Processes of Spoolsv.exe",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Child Processes of Spoolsv.exe",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "process.parent.name:spoolsv.exe and not process.name:regsvr32.exe ",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_large_outbound_icmp_packets.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_large_outbound_icmp_packets.json
new file mode 100644
index 00000000000000..30dd0023b44914
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_large_outbound_icmp_packets.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "e108c0c6-5ee8-47a0-8c23-ec47ba3a9b00",
+ "risk_score": 50,
+ "description": "Splunk - Detect Large Outbound ICMP Packets",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Detect Large Outbound ICMP Packets",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "network.transport:icmp and network.bytes>1000 and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_long_dns_txt_record_response.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_long_dns_txt_record_response.json
new file mode 100644
index 00000000000000..8ae0c57d6aeaae
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_long_dns_txt_record_response.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "2cdf84be-1c9c-4184-9880-75b9a6ddeaba",
+ "risk_score": 50,
+ "description": "Splunk - Detect Long DNS TXT Record Response",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Detect Long DNS TXT Record Response",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "network.protocol:dns and server.bytes>100 and not destination.ip:10.0.0.0/8 and not destination.ip:172.16.0.0/12 and not destination.ip:192.168.0.0/16 and not destination.ip:169.254.169.254 and not destination.ip:127.0.0.53",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_new_local_admin_account.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_new_local_admin_account.json
new file mode 100644
index 00000000000000..39cb60d130a690
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_new_local_admin_account.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "030fc8e4-2c5f-4cc9-a6bd-2b6b7b98ae16",
+ "risk_score": 50,
+ "description": "Splunk - Detect New Local Admin account",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Detect New Local Admin account",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.code:(4720 or 4732) and winlog.event_data.TargetUserName:Administrators",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_psexec_with_accepteula_flag.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_psexec_with_accepteula_flag.json
new file mode 100644
index 00000000000000..b8b4d5f34037d0
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_psexec_with_accepteula_flag.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "4b63cf13-9043-41e3-84ec-6e39eb0d407e",
+ "risk_score": 50,
+ "description": "Splunk - Detect PsExec With accepteula Flag",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Detect PsExec With accepteula Flag",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "process.name:PsExec.exe and process.args:\"-accepteula\"",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_use_of_cmdexe_to_launch_script_interpreters.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_use_of_cmdexe_to_launch_script_interpreters.json
new file mode 100644
index 00000000000000..1cd29886f3cd04
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_detect_use_of_cmdexe_to_launch_script_interpreters.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "f4388e4c-ec3d-41b3-be5c-27c11f61473c",
+ "risk_score": 50,
+ "description": "Splunk - Detect Use of cmd.exe to Launch Script Interpreters",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Detect Use of cmd.exe to Launch Script Interpreters",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.action:\"Process Create (rule: ProcessCreate)\" and process.name:(\"wscript.exe\" or \"cscript.exe\") and process.parent.name:\"cmd.exe\"",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_processes_created_by_netsh.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_processes_created_by_netsh.json
new file mode 100644
index 00000000000000..cbedcb655990f4
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_processes_created_by_netsh.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "ce7a0bde-7406-4729-a075-a215f4571ff6",
+ "risk_score": 50,
+ "description": "Splunk - Processes created by netsh",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Processes created by netsh",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "process.parent.name:netsh.exe",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_processes_launching_netsh.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_processes_launching_netsh.json
new file mode 100644
index 00000000000000..c25e6211a3bb98
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_processes_launching_netsh.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "600dba95-f1c6-4a4d-aae1-c79cbd8a5ddd",
+ "risk_score": 50,
+ "description": "Splunk - Processes launching netsh",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Processes launching netsh",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "process.name:netsh.exe and event.action:\"Process Create (rule: ProcessCreate)\" ",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_protocols_passing_authentication_in_cleartext.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_protocols_passing_authentication_in_cleartext.json
new file mode 100644
index 00000000000000..12eafea8d88c9a
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_protocols_passing_authentication_in_cleartext.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "f4442e7f-856a-4a4a-851b-c1f9b97b0d39",
+ "risk_score": 50,
+ "description": "Splunk - Protocols passing authentication in cleartext",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Protocols passing authentication in cleartext",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "destination.port:(21 or 23 or 110 or 143) and network.transport:tcp",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_windows_event_log_cleared.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_windows_event_log_cleared.json
new file mode 100644
index 00000000000000..7317f491d1a9d4
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/splunk_windows_event_log_cleared.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "c0747553-4652-4e74-bc86-898f2daa2bde",
+ "risk_score": 50,
+ "description": "Splunk - Windows Event Log Cleared",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Splunk - Windows Event Log Cleared",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.code:(1102 or 1100)",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_capturelosstoo_much_loss.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_capturelosstoo_much_loss.json
new file mode 100644
index 00000000000000..32d722ce42bab6
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_capturelosstoo_much_loss.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "c115a407-799b-45d6-962e-a639bb764c06",
+ "risk_score": 50,
+ "description": "Detected Zeek capture loss exceeds the percentage threshold",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice CaptureLoss::Too_Much_Loss",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"CaptureLoss::Too_Much_Loss\" or rule.name: \"CaptureLoss::Too_Much_Loss\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_conncontent_gap.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_conncontent_gap.json
new file mode 100644
index 00000000000000..a707c4647b1ea8
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_conncontent_gap.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "22d12b64-33f4-40ce-ad57-49dd870bc8e5",
+ "risk_score": 50,
+ "description": "Data has sequence hole; perhaps due to filtering.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Conn::Content_Gap",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Conn::Content_Gap\" or rule.name: \"Conn::Content_Gap\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_connretransmission_inconsistency.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_connretransmission_inconsistency.json
new file mode 100644
index 00000000000000..06f413ce93787e
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_connretransmission_inconsistency.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "53719624-55f0-4541-8370-f27f6766fb9e",
+ "risk_score": 50,
+ "description": "Possible evasion; usually just chud.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Conn::Retransmission_Inconsistency",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Conn::Retransmission_Inconsistency\" or rule.name: \"Conn::Retransmission_Inconsistency\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_dnsexternal_name.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_dnsexternal_name.json
new file mode 100644
index 00000000000000..a664b1314fb36a
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_dnsexternal_name.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "39c40c5a-110c-45b1-876f-969212e8814b",
+ "risk_score": 50,
+ "description": "Raised when a non-local name is found to be pointing at a local host.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice DNS::External_Name",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"DNS::External_Name\" or rule.name: \"DNS::External_Name\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_ftpbruteforcing.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_ftpbruteforcing.json
new file mode 100644
index 00000000000000..73c78ee4354e23
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_ftpbruteforcing.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "7e069475-817e-4e89-9245-1dfaa3083b11",
+ "risk_score": 50,
+ "description": "Indicates a host bruteforcing FTP logins by watching for too many rejected usernames or failed passwords.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice FTP::Bruteforcing",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"FTP::Bruteforcing\" or rule.name: \"FTP::Bruteforcing\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_ftpsite_exec_success.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_ftpsite_exec_success.json
new file mode 100644
index 00000000000000..69e2087c8800e5
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_ftpsite_exec_success.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "4b9cb3e9-e26a-4bd2-bd1f-8d451b49838f",
+ "risk_score": 50,
+ "description": "Indicates that a successful response to a “SITE EXEC” command/arg pair was seen.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice FTP::Site_Exec_Success",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"FTP::Site_Exec_Success\" or rule.name: \"FTP::Site_Exec_Success\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_attack.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_attack.json
new file mode 100644
index 00000000000000..b14eabc3352b0e
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_attack.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "68a33102-3680-4581-a48a-210b23925905",
+ "risk_score": 50,
+ "description": "Indicates that a host performed a heartbleed attack or scan.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Heartbleed::SSL_Heartbeat_Attack",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Heartbleed::SSL_Heartbeat_Attack\" or rule.name: \"Heartbleed::SSL_Heartbeat_Attack\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_attack_success.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_attack_success.json
new file mode 100644
index 00000000000000..160f2728cdd507
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_attack_success.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "241a61ae-b385-4f36-96c4-b2fb5446cc43",
+ "risk_score": 50,
+ "description": "Indicates that a host performing a heartbleed attack was probably successful.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Heartbleed::SSL_Heartbeat_Attack_Success",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Heartbleed::SSL_Heartbeat_Attack_Success\" or rule.name: \"Heartbleed::SSL_Heartbeat_Attack_Success\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_many_requests.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_many_requests.json
new file mode 100644
index 00000000000000..cfee3959893766
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_many_requests.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "59d6a32c-753e-4c19-bb77-1befdc6e0e6a",
+ "risk_score": 50,
+ "description": "Indicates we saw many heartbeat requests without a reply. Might be an attack.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Heartbleed::SSL_Heartbeat_Many_Requests",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Heartbleed::SSL_Heartbeat_Many_Requests\" or rule.name: \"Heartbleed::SSL_Heartbeat_Many_Requests\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_odd_length.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_odd_length.json
new file mode 100644
index 00000000000000..a6456e63a3ec00
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_heartbleedssl_heartbeat_odd_length.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "0c6e7be4-6cab-4ee1-ad51-7c1ffd0e9002",
+ "risk_score": 50,
+ "description": "Indicates we saw heartbeat requests with odd length. Probably an attack or scan.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Heartbleed::SSL_Heartbeat_Odd_Length",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Heartbleed::SSL_Heartbeat_Odd_Length\" or rule.name: \"Heartbleed::SSL_Heartbeat_Odd_Length\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_httpsql_injection_attacker.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_httpsql_injection_attacker.json
new file mode 100644
index 00000000000000..517a03834d57e2
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_httpsql_injection_attacker.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "4ca9ef93-7e7e-40a4-8d71-9130204d86e6",
+ "risk_score": 50,
+ "description": "Indicates that a host performing SQL injection attacks was detected.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice HTTP::SQL_Injection_Attacker",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"HTTP::SQL_Injection_Attacker\" or rule.name: \"HTTP::SQL_Injection_Attacker\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_httpsql_injection_victim.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_httpsql_injection_victim.json
new file mode 100644
index 00000000000000..b00e49c89e402c
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_httpsql_injection_victim.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "dda43d7f-69bc-487f-b05c-2b518e9db622",
+ "risk_score": 50,
+ "description": "Indicates that a host was seen to have SQL injection attacks against it. This is tracked by IP address as opposed to hostname.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice HTTP::SQL_Injection_Victim",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"HTTP::SQL_Injection_Victim\" or rule.name: \"HTTP::SQL_Injection_Victim\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_intelnotice.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_intelnotice.json
new file mode 100644
index 00000000000000..27cfe2036744ec
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_intelnotice.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "122e153a-78f3-4e7e-a5b5-cfe0b917f109",
+ "risk_score": 50,
+ "description": "This notice is generated when an intelligence indicator is denoted to be notice-worthy.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Intel::Notice",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Intel::Notice\" or rule.name: \"Intel::Notice\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_noticetally.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_noticetally.json
new file mode 100644
index 00000000000000..16e22585d6e13f
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_noticetally.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "7581fd81-25e8-489e-bcf3-69db068b7a6c",
+ "risk_score": 50,
+ "description": "Zeek notice reporting a count of how often a notice occurred.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Notice::Tally",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Notice::Tally\" or rule.name: \"Notice::Tally\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltercannot_bpf_shunt_conn.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltercannot_bpf_shunt_conn.json
new file mode 100644
index 00000000000000..3e8704dee917a8
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltercannot_bpf_shunt_conn.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "0031d83e-1fb4-4dd6-b938-97ae7044b051",
+ "risk_score": 50,
+ "description": "Limitations in BPF make shunting some connections with BPF impossible. This notice encompasses those various cases.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice PacketFilter::Cannot_BPF_Shunt_Conn",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"PacketFilter::Cannot_BPF_Shunt_Conn\" or rule.name: \"PacketFilter::Cannot_BPF_Shunt_Conn\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltercompile_failure.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltercompile_failure.json
new file mode 100644
index 00000000000000..63567a6ebbd90d
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltercompile_failure.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "335b2ddc-f806-46e8-8ffa-114d613aac92",
+ "risk_score": 50,
+ "description": "This notice is generated if a packet filter cannot be compiled.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice PacketFilter::Compile_Failure",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"PacketFilter::Compile_Failure\" or rule.name: \"PacketFilter::Compile_Failure\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterdropped_packets.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterdropped_packets.json
new file mode 100644
index 00000000000000..78b664f573b6bb
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterdropped_packets.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "4f212278-329b-4088-ae59-9091003dff22",
+ "risk_score": 50,
+ "description": "Indicates packets were dropped by the packet filter.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice PacketFilter::Dropped_Packets",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"PacketFilter::Dropped_Packets\" or rule.name: \"PacketFilter::Dropped_Packets\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterinstall_failure.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterinstall_failure.json
new file mode 100644
index 00000000000000..7fec89f251e80f
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterinstall_failure.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "235988ec-d037-4f5f-a211-74106512b36d",
+ "risk_score": 50,
+ "description": "Generated if a packet filter fails to install.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice PacketFilter::Install_Failure",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"PacketFilter::Install_Failure\" or rule.name: \"PacketFilter::Install_Failure\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterno_more_conn_shunts_available.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterno_more_conn_shunts_available.json
new file mode 100644
index 00000000000000..176c4373e8e961
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfilterno_more_conn_shunts_available.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "de4016de-3374-41a0-a678-21d36c70af9a",
+ "risk_score": 50,
+ "description": "Indicative that PacketFilter::max_bpf_shunts connections are already being shunted with BPF filters and no more are allowed.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice PacketFilter::No_More_Conn_Shunts_Available",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"PacketFilter::No_More_Conn_Shunts_Available\" or rule.name: \"PacketFilter::No_More_Conn_Shunts_Available\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltertoo_long_to_compile_filter.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltertoo_long_to_compile_filter.json
new file mode 100644
index 00000000000000..6077e494779e39
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_packetfiltertoo_long_to_compile_filter.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "71e93c42-7990-4233-a8a5-2631193df7db",
+ "risk_score": 50,
+ "description": "Generated when a notice takes too long to compile.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice PacketFilter::Too_Long_To_Compile_Filter",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"PacketFilter::Too_Long_To_Compile_Filter\" or rule.name: \"PacketFilter::Too_Long_To_Compile_Filter\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_protocoldetectorprotocol_found.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_protocoldetectorprotocol_found.json
new file mode 100644
index 00000000000000..2375fce0cf2b10
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_protocoldetectorprotocol_found.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "777586b6-4757-489e-a6e8-676b7df70b39",
+ "risk_score": 50,
+ "description": "Indicates a protocol was detected on a non-standard port.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice ProtocolDetector::Protocol_Found",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"ProtocolDetector::Protocol_Found\" or rule.name: \"ProtocolDetector::Protocol_Found\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_protocoldetectorserver_found.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_protocoldetectorserver_found.json
new file mode 100644
index 00000000000000..6fd75bd7591219
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_protocoldetectorserver_found.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "7d7f7635-6900-4f63-b14b-477a909ea90a",
+ "risk_score": 50,
+ "description": "Indicates a server was detected on a non-standard port for the protocol.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice ProtocolDetector::Server_Found",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"ProtocolDetector::Server_Found\" or rule.name: \"ProtocolDetector::Server_Found\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_scanaddress_scan.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_scanaddress_scan.json
new file mode 100644
index 00000000000000..fe0508f08ab1dd
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_scanaddress_scan.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "9d320fca-4ec1-4511-bdbc-7edf9673c07d",
+ "risk_score": 50,
+ "description": "Address scans detect that a host appears to be scanning some number of destinations on a single port.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Scan::Address_Scan",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Scan::Address_Scan\" or rule.name: \"Scan::Address_Scan\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_scanport_scan.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_scanport_scan.json
new file mode 100644
index 00000000000000..007e5fd94ae5fc
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_scanport_scan.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "d09fbf7a-47a7-4130-8dd7-b386cca81a42",
+ "risk_score": 50,
+ "description": "Port scans detect that an attacking host appears to be scanning a single victim host on several ports.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Scan::Port_Scan",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Scan::Port_Scan\" or rule.name: \"Scan::Port_Scan\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturescount_signature.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturescount_signature.json
new file mode 100644
index 00000000000000..f5b708dce484f3
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturescount_signature.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "a704589c-8ba9-4a3c-8e39-ab9360cade17",
+ "risk_score": 50,
+ "description": "The same signature has triggered multiple times for a host.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Signatures::Count_Signature",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Signatures::Count_Signature\" or rule.name: \"Signatures::Count_Signature\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturesmultiple_sig_responders.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturesmultiple_sig_responders.json
new file mode 100644
index 00000000000000..8e8b9ae8793ae9
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturesmultiple_sig_responders.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "4f313ae8-cbc6-4082-9599-526f8ccb7303",
+ "risk_score": 50,
+ "description": "Host has triggered the same signature on multiple hosts.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Signatures::Multiple_Sig_Responders",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Signatures::Multiple_Sig_Responders\" or rule.name: \"Signatures::Multiple_Sig_Responders\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturesmultiple_signatures.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturesmultiple_signatures.json
new file mode 100644
index 00000000000000..0d24f030472c61
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturesmultiple_signatures.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "ab90d81c-79e1-4f62-a61e-484c4bedb2b0",
+ "risk_score": 50,
+ "description": "Host has triggered many signatures on the same host.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Signatures::Multiple_Signatures",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Signatures::Multiple_Signatures\" or rule.name: \"Signatures::Multiple_Signatures\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturessensitive_signature.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturessensitive_signature.json
new file mode 100644
index 00000000000000..545c6536904937
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturessensitive_signature.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "ac394dec-67e8-417f-bb06-ae0bd75556b0",
+ "risk_score": 50,
+ "description": "Generic notice type for notice-worthy signature matches.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Signatures::Sensitive_Signature",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Signatures::Sensitive_Signature\" or rule.name: \"Signatures::Sensitive_Signature\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturessignature_summary.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturessignature_summary.json
new file mode 100644
index 00000000000000..76fb44b6bd24a8
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_signaturessignature_summary.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "d17fe857-eb67-4843-ab63-bf4852e49396",
+ "risk_score": 50,
+ "description": "Summarize the number of times a host triggered a signature.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Signatures::Signature_Summary",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Signatures::Signature_Summary\" or rule.name: \"Signatures::Signature_Summary\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpblocklist_blocked_host.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpblocklist_blocked_host.json
new file mode 100644
index 00000000000000..b1b52dc6c08f2e
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpblocklist_blocked_host.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "402d5f78-82cd-4320-8b69-3185e44daf07",
+ "risk_score": 50,
+ "description": "The originator’s address is seen in the block list error message. This is useful to detect local hosts sending SPAM with a high positive rate.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SMTP::Blocklist_Blocked_Host",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SMTP::Blocklist_Blocked_Host\" or rule.name: \"SMTP::Blocklist_Blocked_Host\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpblocklist_error_message.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpblocklist_error_message.json
new file mode 100644
index 00000000000000..69adf95592dd72
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpblocklist_error_message.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "b9bb4a93-8c5c-4942-9193-e2dc97230034",
+ "risk_score": 50,
+ "description": "An SMTP server sent a reply mentioning an SMTP block list.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SMTP::Blocklist_Error_Message",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SMTP::Blocklist_Error_Message\" or rule.name: \"SMTP::Blocklist_Error_Message\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpsuspicious_origination.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpsuspicious_origination.json
new file mode 100644
index 00000000000000..2414a8a7669a47
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_smtpsuspicious_origination.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "cc6e9fef-d936-4faf-8936-e576c089d8b2",
+ "risk_score": 50,
+ "description": "SMTP message orignated from country or network configured to be suspicious.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SMTP::Suspicious_Origination",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SMTP::Suspicious_Origination\" or rule.name: \"SMTP::Suspicious_Origination\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_softwaresoftware_version_change.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_softwaresoftware_version_change.json
new file mode 100644
index 00000000000000..87f1472a0420db
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_softwaresoftware_version_change.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "ea1d2c1b-ecfe-42a5-bd0b-56c7a1bd8075",
+ "risk_score": 50,
+ "description": "Indicates that an interesting software application changed versions on a host.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Software::Software_Version_Change",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Software::Software_Version_Change\" or rule.name: \"Software::Software_Version_Change\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_softwarevulnerable_version.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_softwarevulnerable_version.json
new file mode 100644
index 00000000000000..24b803e654fcf5
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_softwarevulnerable_version.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "97b4d80c-7671-4301-85a6-954aa0ba96ce",
+ "risk_score": 50,
+ "description": "Indicates that a vulnerable version of software was detected.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Software::Vulnerable_Version",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Software::Vulnerable_Version\" or rule.name: \"Software::Vulnerable_Version\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshinteresting_hostname_login.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshinteresting_hostname_login.json
new file mode 100644
index 00000000000000..70e20f85d9b49d
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshinteresting_hostname_login.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "6a7f2b0a-3f24-4d58-aa84-243f1f0556d9",
+ "risk_score": 50,
+ "description": "Generated if a login originates or responds with a host where the reverse hostname lookup resolves to a name matched by the SSH::interesting_hostnames regular expression.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSH::Interesting_Hostname_Login",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSH::Interesting_Hostname_Login\" or rule.name: \"SSH::Interesting_Hostname_Login\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshlogin_by_password_guesser.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshlogin_by_password_guesser.json
new file mode 100644
index 00000000000000..7d9402f7a1ec49
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshlogin_by_password_guesser.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "5600ad95-2244-43db-8a7d-77eea95f80db",
+ "risk_score": 50,
+ "description": "Indicates that a host previously identified as a \"password guesser\" has now had a successful login attempt.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSH::Login_By_Password_Guesser",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSH::Login_By_Password_Guesser\" or rule.name: \"SSH::Login_By_Password_Guesser\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshpassword_guessing.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshpassword_guessing.json
new file mode 100644
index 00000000000000..00c346bc0ecc7f
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshpassword_guessing.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "e278142a-4ee7-4443-9b1f-421174b0dabf",
+ "risk_score": 50,
+ "description": "Indicates that a host has been identified as crossing the SSH::password_guesses_limit threshold with failed logins.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSH::Password_Guessing",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSH::Password_Guessing\" or rule.name: \"SSH::Password_Guessing\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshwatched_country_login.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshwatched_country_login.json
new file mode 100644
index 00000000000000..943f56b7c93684
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sshwatched_country_login.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "983f4b7e-38cd-4d7f-8be6-40447431561e",
+ "risk_score": 50,
+ "description": "SSH login was seen to or from a \"watched\" country based on the SSH::watched_countries variable",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSH::Watched_Country_Login",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSH::Watched_Country_Login\" or rule.name: \"SSH::Watched_Country_Login\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_expired.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_expired.json
new file mode 100644
index 00000000000000..030b56cc577827
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_expired.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "3981f48e-49a5-4a3e-9b44-900a0887526c",
+ "risk_score": 50,
+ "description": "Indicates that a certificate’s NotValidAfter date has lapsed and the certificate is now invalid.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Certificate_Expired",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Certificate_Expired\" or rule.name: \"SSL::Certificate_Expired\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_expires_soon.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_expires_soon.json
new file mode 100644
index 00000000000000..702724abcfa643
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_expires_soon.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "e8207172-3478-4b2c-85b7-6f13d97fff43",
+ "risk_score": 50,
+ "description": "Indicates that a certificate is going to expire within SSL::notify_when_cert_expiring_in.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Certificate_Expires_Soon",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Certificate_Expires_Soon\" or rule.name: \"SSL::Certificate_Expires_Soon\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_not_valid_yet.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_not_valid_yet.json
new file mode 100644
index 00000000000000..258fb0cf78b604
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslcertificate_not_valid_yet.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "45586490-99f6-4e11-8228-2229d727a3b4",
+ "risk_score": 50,
+ "description": "Indicates that a certificate’s NotValidBefore date is future dated.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Certificate_Not_Valid_Yet",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Certificate_Not_Valid_Yet\" or rule.name: \"SSL::Certificate_Not_Valid_Yet\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslinvalid_ocsp_response.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslinvalid_ocsp_response.json
new file mode 100644
index 00000000000000..43c4b46e36c076
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslinvalid_ocsp_response.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "eb17fcbb-de22-4aa0-81aa-1c059bdd4f2b",
+ "risk_score": 50,
+ "description": "This indicates that the OCSP response was not deemed to be valid.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Invalid_Ocsp_Response",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Invalid_Ocsp_Response\" or rule.name: \"SSL::Invalid_Ocsp_Response\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslinvalid_server_cert.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslinvalid_server_cert.json
new file mode 100644
index 00000000000000..8c473f00076241
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslinvalid_server_cert.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "13f51fe0-fc74-4c45-90f3-6fb1cd26ec66",
+ "risk_score": 50,
+ "description": "This notice indicates that the result of validating the certificate along with its full certificate chain was invalid.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Invalid_Server_Cert",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Invalid_Server_Cert\" or rule.name: \"SSL::Invalid_Server_Cert\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslold_version.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslold_version.json
new file mode 100644
index 00000000000000..ba60fa82a5baea
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslold_version.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "260b680e-c3d6-4c03-90cd-03c86e9f8ec1",
+ "risk_score": 50,
+ "description": "Indicates that a server is using a potentially unsafe version",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Old_Version",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Old_Version\" or rule.name: \"SSL::Old_Version\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslweak_cipher.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslweak_cipher.json
new file mode 100644
index 00000000000000..786b42cb8db50d
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslweak_cipher.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "25886074-6ae1-41c0-8546-e8cf55ed1b4b",
+ "risk_score": 50,
+ "description": "Indicates that a server is using a potentially unsafe cipher",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Weak_Cipher",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Weak_Cipher\" or rule.name: \"SSL::Weak_Cipher\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslweak_key.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslweak_key.json
new file mode 100644
index 00000000000000..7120cfe5e81ad0
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_sslweak_key.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "e020f504-c0e5-4768-8e1f-1e2ec7bac961",
+ "risk_score": 50,
+ "description": "Indicates that a server is using a potentially unsafe key.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice SSL::Weak_Key",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"SSL::Weak_Key\" or rule.name: \"SSL::Weak_Key\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_teamcymrumalwarehashregistrymatch.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_teamcymrumalwarehashregistrymatch.json
new file mode 100644
index 00000000000000..47817a05ea5707
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_teamcymrumalwarehashregistrymatch.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "a130a0ba-b083-4630-b0ea-cceb80d7720b",
+ "risk_score": 50,
+ "description": "The hash value of a file transferred over HTTP matched in the malware hash registry.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice TeamCymruMalwareHashRegistry::Match",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"TeamCymruMalwareHashRegistry::Match\" or rule.name: \"TeamCymruMalwareHashRegistry::Match\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_traceroutedetected.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_traceroutedetected.json
new file mode 100644
index 00000000000000..c676c84347cb55
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_traceroutedetected.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "aeefe077-f05d-44a7-b757-272fc51c334c",
+ "risk_score": 50,
+ "description": "Indicates that a host was seen running traceroutes.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Traceroute::Detected",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Traceroute::Detected\" or rule.name: \"Traceroute::Detected\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_weirdactivity.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_weirdactivity.json
new file mode 100644
index 00000000000000..fc1da9e414cc5c
--- /dev/null
+++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/zeek_notice_weirdactivity.json
@@ -0,0 +1,17 @@
+{
+ "rule_id": "d5ad39d0-8421-4f79-ad93-8ddbf7f553b3",
+ "risk_score": 50,
+ "description": "Generic unusual but notice-worthy weird activity.",
+ "immutable": true,
+ "interval": "5m",
+ "name": "Zeek Notice Weird::Activity",
+ "severity": "low",
+ "type": "query",
+ "from": "now-6m",
+ "to": "now",
+ "query": "event.module: zeek and event.dataset: zeek.notice and (zeek.notice.note: \"Weird::Activity\" or rule.name: \"Weird::Activity\")",
+ "language": "kuery",
+ "filters": [],
+ "enabled": false,
+ "version": 1
+}
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index b7bac7dd170ed2..54ae975849c29e 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -261,24 +261,6 @@
"common.ui.aggTypes.timeInterval.scaledHelpText": "現在 {bucketDescription} にスケーリングされています",
"common.ui.aggTypes.timeInterval.selectIntervalPlaceholder": "間隔を選択",
"common.ui.aggTypes.timeInterval.selectOptionHelpText": "オプションを選択するかカスタム値を作成します。例30s、20m、24h、2d、1w、1M",
- "common.ui.courier.fetch.requestTimedOutNotificationMessage": "リクエストがタイムアウトしたため、データが不完全な可能性があります",
- "common.ui.courier.fetch.shardsFailedNotificationMessage": "{shardsTotal} 件中 {shardsFailed} 件のシャードでエラーが発生しました",
- "common.ui.courier.hitsDescription": "クエリにより返されたドキュメントの数です。",
- "common.ui.courier.hitsLabel": "ヒット数",
- "common.ui.courier.hitsTotalDescription": "クエリに一致するドキュメントの数です。",
- "common.ui.courier.hitsTotalLabel": "ヒット数 (合計)",
- "common.ui.courier.indexPatternDescription": "Elasticsearch インデックスに接続したインデックスパターンです。",
- "common.ui.courier.indexPatternIdDescription": "{kibanaIndexPattern} インデックス内の ID です。",
- "common.ui.courier.indexPatternIdLabel": "インデックスパターン ID",
- "common.ui.courier.indexPatternLabel": "インデックスパターン",
- "common.ui.courier.noSearchStrategyRegisteredErrorMessageDescription": "検索リクエストの検索方法が見つかりませんでした",
- "common.ui.courier.noSearchStrategyRegisteredErrorMessageTitle": "検索方法が登録されていません",
- "common.ui.courier.queryTimeDescription": "クエリの処理の所要時間です。リクエストの送信やブラウザでのパースの時間は含まれません。",
- "common.ui.courier.queryTimeLabel": "クエリ時間",
- "common.ui.courier.queryTimeValue": "{queryTime}ms",
- "common.ui.courier.requestTimeDescription": "ブラウザから Elasticsearch にリクエストが送信され返されるまでの所要時間です。リクエストがキューで待機していた時間は含まれません。",
- "common.ui.courier.requestTimeLabel": "リクエスト時間",
- "common.ui.courier.requestTimeValue": "{requestTime}ms",
"common.ui.directives.fieldNameIcons.booleanAriaLabel": "ブールフィールド",
"common.ui.directives.fieldNameIcons.conflictFieldAriaLabel": "矛盾フィールド",
"common.ui.directives.fieldNameIcons.dateFieldAriaLabel": "日付フィールド",
@@ -472,14 +454,14 @@
"common.ui.notify.toaster.unavailableServerErrorMessage": "HTTP リクエストが接続に失敗しました。Kibana サーバーが実行されていて、ご使用のブラウザの接続が正常に動作していることを確認するか、システム管理者にお問い合わせください。",
"common.ui.paginateControls.pageSizeLabel": "ページサイズ",
"common.ui.paginateControls.scrollTopButtonLabel": "最上部に移動",
- "common.ui.savedObjectFinder.addNewItemButtonLabel": "新規 {item} を追加",
- "common.ui.savedObjectFinder.manageItemsButtonLabel": "{items} の管理",
- "common.ui.savedObjectFinder.noMatchesFoundDescription": "一致する {items} が見つかりません。",
- "common.ui.savedObjectFinder.pageItemsFromHitCountDescription": "{hitCount} 件中 {pageFirstItem}-{pageLastItem} 件目",
- "common.ui.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "昇順",
- "common.ui.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降順",
- "common.ui.savedObjectFinder.sortByButtonLabel": "名前",
- "common.ui.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "並べ替え基準",
+ "timelion.savedObjectFinder.addNewItemButtonLabel": "新規 {item} を追加",
+ "timelion.savedObjectFinder.manageItemsButtonLabel": "{items} の管理",
+ "timelion.savedObjectFinder.noMatchesFoundDescription": "一致する {items} が見つかりません。",
+ "timelion.savedObjectFinder.pageItemsFromHitCountDescription": "{hitCount} 件中 {pageFirstItem}-{pageLastItem} 件目",
+ "timelion.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "昇順",
+ "timelion.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降順",
+ "timelion.savedObjectFinder.sortByButtonLabel": "名前",
+ "timelion.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "並べ替え基準",
"common.ui.savedObjects.confirmModal.overwriteButtonLabel": "上書き",
"common.ui.savedObjects.confirmModal.overwriteConfirmationMessage": "{title} を上書きしてよろしいですか?",
"common.ui.savedObjects.confirmModal.overwriteTitle": "{name} を上書きしますか?",
@@ -541,20 +523,6 @@
"common.ui.visualize.queryGeohashBounds.unableToGetBoundErrorTitle": "バウンドを取得できませんでした",
"common.ui.welcomeErrorMessage": "Kibana が正常に読み込まれませんでした。詳細はサーバーアウトプットを確認してください。",
"common.ui.welcomeMessage": "Kibana を読み込み中",
- "common.ui.courier.fetch.shardsFailedModal.close": "閉じる",
- "common.ui.courier.fetch.shardsFailedModal.copyToClipboard": "応答をクリップボードにコピー",
- "common.ui.courier.fetch.shardsFailedModal.failureHeader": "{failureName} で {failureDetails}",
- "common.ui.courier.fetch.shardsFailedModal.showDetails": "詳細を表示",
- "common.ui.courier.fetch.shardsFailedModal.tabHeaderRequest": "リクエスト",
- "common.ui.courier.fetch.shardsFailedModal.tabHeaderResponse": "応答",
- "common.ui.courier.fetch.shardsFailedModal.tabHeaderShardFailures": "シャードエラー",
- "common.ui.courier.fetch.shardsFailedModal.tableColIndex": "インデックス",
- "common.ui.courier.fetch.shardsFailedModal.tableColNode": "ノード",
- "common.ui.courier.fetch.shardsFailedModal.tableColReason": "理由",
- "common.ui.courier.fetch.shardsFailedModal.tableColShard": "シャード",
- "common.ui.courier.fetch.shardsFailedModal.tableRowCollapse": "{rowDescription} を折りたたむ",
- "common.ui.courier.fetch.shardsFailedModal.tableRowExpand": "{rowDescription} を展開する",
- "common.ui.courier.fetch.shardsFailedNotificationDescription": "表示されているデータは不完全か誤りの可能性があります。",
"common.ui.directives.fieldNameIcons.geoShapeFieldAriaLabel": "地理情報図形",
"common.ui.vis.editors.agg.errorsAriaLabel": "集約にエラーがあります",
"common.ui.vislib.heatmap.maxBucketsText": "定義された数列が多すぎます ({nr}).構成されている最高値は {max} です。",
@@ -873,6 +841,38 @@
"data.search.searchBar.savedQueryPopoverSavedQueryListItemDescriptionAriaLabel": "{savedQueryName} の説明",
"data.search.searchBar.savedQueryPopoverSavedQueryListItemSelectedButtonAriaLabel": "選択されたクエリボタン {savedQueryName} を保存しました。変更を破棄するには押してください。",
"data.search.searchBar.savedQueryPopoverTitleText": "保存されたクエリ",
+ "data.search.searchSource.fetch.shardsFailedModal.close": "閉じる",
+ "data.search.searchSource.fetch.shardsFailedModal.copyToClipboard": "応答をクリップボードにコピー",
+ "data.search.searchSource.fetch.shardsFailedModal.failureHeader": "{failureName} で {failureDetails}",
+ "data.search.searchSource.fetch.shardsFailedModal.showDetails": "詳細を表示",
+ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderRequest": "リクエスト",
+ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse": "応答",
+ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures": "シャードエラー",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColIndex": "インデックス",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColNode": "ノード",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColReason": "理由",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColShard": "シャード",
+ "data.search.searchSource.fetch.shardsFailedModal.tableRowCollapse": "{rowDescription} を折りたたむ",
+ "data.search.searchSource.fetch.shardsFailedModal.tableRowExpand": "{rowDescription} を展開する",
+ "data.search.searchSource.fetch.shardsFailedNotificationDescription": "表示されているデータは不完全か誤りの可能性があります。",
+ "data.search.searchSource.fetch.requestTimedOutNotificationMessage": "リクエストがタイムアウトしたため、データが不完全な可能性があります",
+ "data.search.searchSource.fetch.shardsFailedNotificationMessage": "{shardsTotal} 件中 {shardsFailed} 件のシャードでエラーが発生しました",
+ "data.search.searchSource.hitsDescription": "クエリにより返されたドキュメントの数です。",
+ "data.search.searchSource.hitsLabel": "ヒット数",
+ "data.search.searchSource.hitsTotalDescription": "クエリに一致するドキュメントの数です。",
+ "data.search.searchSource.hitsTotalLabel": "ヒット数 (合計)",
+ "data.search.searchSource.indexPatternDescription": "Elasticsearch インデックスに接続したインデックスパターンです。",
+ "data.search.searchSource.indexPatternIdDescription": "{kibanaIndexPattern} インデックス内の ID です。",
+ "data.search.searchSource.indexPatternIdLabel": "インデックスパターン ID",
+ "data.search.searchSource.indexPatternLabel": "インデックスパターン",
+ "data.search.searchSource.noSearchStrategyRegisteredErrorMessageDescription": "検索リクエストの検索方法が見つかりませんでした",
+ "data.search.searchSource.noSearchStrategyRegisteredErrorMessageTitle": "検索方法が登録されていません",
+ "data.search.searchSource.queryTimeDescription": "クエリの処理の所要時間です。リクエストの送信やブラウザでのパースの時間は含まれません。",
+ "data.search.searchSource.queryTimeLabel": "クエリ時間",
+ "data.search.searchSource.queryTimeValue": "{queryTime}ms",
+ "data.search.searchSource.requestTimeDescription": "ブラウザから Elasticsearch にリクエストが送信され返されるまでの所要時間です。リクエストがキューで待機していた時間は含まれません。",
+ "data.search.searchSource.requestTimeLabel": "リクエスト時間",
+ "data.search.searchSource.requestTimeValue": "{requestTime}ms",
"data.filter.filterEditor.operatorSelectPlaceholderSelect": "選択してください",
"data.filter.filterEditor.operatorSelectPlaceholderWaiting": "待機中",
"data.filter.filterEditor.rangeInputLabel": "範囲",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 7ade936ba10445..b63a8feeae02ba 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -261,24 +261,6 @@
"common.ui.aggTypes.timeInterval.scaledHelpText": "当前缩放至 {bucketDescription}",
"common.ui.aggTypes.timeInterval.selectIntervalPlaceholder": "选择时间间隔",
"common.ui.aggTypes.timeInterval.selectOptionHelpText": "选择选项或创建定制值示例:30s、20m、24h、2d、1w、1M",
- "common.ui.courier.fetch.requestTimedOutNotificationMessage": "由于您的请求超时,因此数据可能不完整",
- "common.ui.courier.fetch.shardsFailedNotificationMessage": "{shardsTotal} 个分片有 {shardsFailed} 个失败",
- "common.ui.courier.hitsDescription": "查询返回的文档数目。",
- "common.ui.courier.hitsLabel": "命中",
- "common.ui.courier.hitsTotalDescription": "匹配查询的文档数目。",
- "common.ui.courier.hitsTotalLabel": "命中(总计)",
- "common.ui.courier.indexPatternDescription": "连接到 Elasticsearch 索引的索引模式。",
- "common.ui.courier.indexPatternIdDescription": "{kibanaIndexPattern} 索引中的 ID。",
- "common.ui.courier.indexPatternIdLabel": "索引模式 ID",
- "common.ui.courier.indexPatternLabel": "索引模式",
- "common.ui.courier.noSearchStrategyRegisteredErrorMessageDescription": "无法为该搜索请求找到搜索策略",
- "common.ui.courier.noSearchStrategyRegisteredErrorMessageTitle": "未注册任何搜索策略",
- "common.ui.courier.queryTimeDescription": "处理查询所花费的时间。不包括发送请求或在浏览器中解析它的时间。",
- "common.ui.courier.queryTimeLabel": "查询时间",
- "common.ui.courier.queryTimeValue": "{queryTime}ms",
- "common.ui.courier.requestTimeDescription": "请求从浏览器到 Elasticsearch 以及返回的时间。不包括请求在队列中等候的时间。",
- "common.ui.courier.requestTimeLabel": "请求时间",
- "common.ui.courier.requestTimeValue": "{requestTime}ms",
"common.ui.directives.fieldNameIcons.booleanAriaLabel": "布尔字段",
"common.ui.directives.fieldNameIcons.conflictFieldAriaLabel": "冲突字段",
"common.ui.directives.fieldNameIcons.dateFieldAriaLabel": "日期字段",
@@ -472,14 +454,14 @@
"common.ui.notify.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。",
"common.ui.paginateControls.pageSizeLabel": "页面大小",
"common.ui.paginateControls.scrollTopButtonLabel": "滚动至顶部",
- "common.ui.savedObjectFinder.addNewItemButtonLabel": "添加新的 {item}",
- "common.ui.savedObjectFinder.manageItemsButtonLabel": "管理 {items}",
- "common.ui.savedObjectFinder.noMatchesFoundDescription": "未找到任何匹配的 {items}。",
- "common.ui.savedObjectFinder.pageItemsFromHitCountDescription": "{pageFirstItem}-{pageLastItem} 页,共 {hitCount} 页",
- "common.ui.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "升序",
- "common.ui.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降序",
- "common.ui.savedObjectFinder.sortByButtonLabel": "名称",
- "common.ui.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "排序依据",
+ "timelion.savedObjectFinder.addNewItemButtonLabel": "添加新的 {item}",
+ "timelion.savedObjectFinder.manageItemsButtonLabel": "管理 {items}",
+ "timelion.savedObjectFinder.noMatchesFoundDescription": "未找到任何匹配的 {items}。",
+ "timelion.savedObjectFinder.pageItemsFromHitCountDescription": "{pageFirstItem}-{pageLastItem} 页,共 {hitCount} 页",
+ "timelion.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "升序",
+ "timelion.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降序",
+ "timelion.savedObjectFinder.sortByButtonLabel": "名称",
+ "timelion.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "排序依据",
"common.ui.savedObjects.confirmModal.overwriteButtonLabel": "覆盖",
"common.ui.savedObjects.confirmModal.overwriteConfirmationMessage": "确定要覆盖 “{title}”?",
"common.ui.savedObjects.confirmModal.overwriteTitle": "覆盖“{name}”?",
@@ -542,20 +524,6 @@
"common.ui.visualize.queryGeohashBounds.unableToGetBoundErrorTitle": "无法获取边界",
"common.ui.welcomeErrorMessage": "Kibana 未正确加载。检查服务器输出以了解详情。",
"common.ui.welcomeMessage": "正在加载 Kibana",
- "common.ui.courier.fetch.shardsFailedModal.close": "关闭",
- "common.ui.courier.fetch.shardsFailedModal.copyToClipboard": "将响应复制到剪贴板",
- "common.ui.courier.fetch.shardsFailedModal.failureHeader": "{failureDetails} 时为 {failureName}",
- "common.ui.courier.fetch.shardsFailedModal.showDetails": "显示详情",
- "common.ui.courier.fetch.shardsFailedModal.tabHeaderRequest": "请求",
- "common.ui.courier.fetch.shardsFailedModal.tabHeaderResponse": "响应",
- "common.ui.courier.fetch.shardsFailedModal.tabHeaderShardFailures": "分片错误",
- "common.ui.courier.fetch.shardsFailedModal.tableColIndex": "索引",
- "common.ui.courier.fetch.shardsFailedModal.tableColNode": "节点",
- "common.ui.courier.fetch.shardsFailedModal.tableColReason": "原因",
- "common.ui.courier.fetch.shardsFailedModal.tableColShard": "分片",
- "common.ui.courier.fetch.shardsFailedModal.tableRowCollapse": "折叠 {rowDescription}",
- "common.ui.courier.fetch.shardsFailedModal.tableRowExpand": "展开 {rowDescription}",
- "common.ui.courier.fetch.shardsFailedNotificationDescription": "您正在查看的数据可能不完整或有错误。",
"common.ui.directives.fieldNameIcons.geoShapeFieldAriaLabel": "几何形状字段",
"common.ui.vis.editors.agg.errorsAriaLabel": "聚合有错误",
"common.ui.vislib.heatmap.maxBucketsText": "定义了过多的序列 ({nr})。配置的最大值为 {max}。",
@@ -874,6 +842,38 @@
"data.search.searchBar.savedQueryPopoverSavedQueryListItemDescriptionAriaLabel": "{savedQueryName} 描述",
"data.search.searchBar.savedQueryPopoverSavedQueryListItemSelectedButtonAriaLabel": "已保存查询按钮已选择 {savedQueryName}。按下可清除任何更改。",
"data.search.searchBar.savedQueryPopoverTitleText": "已保存查询",
+ "data.search.searchSource.fetch.shardsFailedModal.close": "关闭",
+ "data.search.searchSource.fetch.shardsFailedModal.copyToClipboard": "将响应复制到剪贴板",
+ "data.search.searchSource.fetch.shardsFailedModal.failureHeader": "{failureDetails} 时为 {failureName}",
+ "data.search.searchSource.fetch.shardsFailedModal.showDetails": "显示详情",
+ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderRequest": "请求",
+ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse": "响应",
+ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures": "分片错误",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColIndex": "索引",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColNode": "节点",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColReason": "原因",
+ "data.search.searchSource.fetch.shardsFailedModal.tableColShard": "分片",
+ "data.search.searchSource.fetch.shardsFailedModal.tableRowCollapse": "折叠 {rowDescription}",
+ "data.search.searchSource.fetch.shardsFailedModal.tableRowExpand": "展开 {rowDescription}",
+ "data.search.searchSource.fetch.shardsFailedNotificationDescription": "您正在查看的数据可能不完整或有错误。",
+ "data.search.searchSource.fetch.requestTimedOutNotificationMessage": "由于您的请求超时,因此数据可能不完整",
+ "data.search.searchSource.fetch.shardsFailedNotificationMessage": "{shardsTotal} 个分片有 {shardsFailed} 个失败",
+ "data.search.searchSource.hitsDescription": "查询返回的文档数目。",
+ "data.search.searchSource.hitsLabel": "命中",
+ "data.search.searchSource.hitsTotalDescription": "匹配查询的文档数目。",
+ "data.search.searchSource.hitsTotalLabel": "命中(总计)",
+ "data.search.searchSource.indexPatternDescription": "连接到 Elasticsearch 索引的索引模式。",
+ "data.search.searchSource.indexPatternIdDescription": "{kibanaIndexPattern} 索引中的 ID。",
+ "data.search.searchSource.indexPatternIdLabel": "索引模式 ID",
+ "data.search.searchSource.indexPatternLabel": "索引模式",
+ "data.search.searchSource.noSearchStrategyRegisteredErrorMessageDescription": "无法为该搜索请求找到搜索策略",
+ "data.search.searchSource.noSearchStrategyRegisteredErrorMessageTitle": "未注册任何搜索策略",
+ "data.search.searchSource.queryTimeDescription": "处理查询所花费的时间。不包括发送请求或在浏览器中解析它的时间。",
+ "data.search.searchSource.queryTimeLabel": "查询时间",
+ "data.search.searchSource.queryTimeValue": "{queryTime}ms",
+ "data.search.searchSource.requestTimeDescription": "请求从浏览器到 Elasticsearch 以及返回的时间。不包括请求在队列中等候的时间。",
+ "data.search.searchSource.requestTimeLabel": "请求时间",
+ "data.search.searchSource.requestTimeValue": "{requestTime}ms",
"data.filter.filterEditor.operatorSelectPlaceholderSelect": "选择",
"data.filter.filterEditor.operatorSelectPlaceholderWaiting": "正在等候",
"data.filter.filterEditor.rangeInputLabel": "范围",