diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9cba1ee909f6d..e559177586f48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,11 +55,9 @@ Granted that you share your thoughts, we might even be able to come up with crea First of all, **sorry about that!** We want you to have a great time with Kibana. -Hosting meaningful discussions on GitHub can be challenging. For that reason, we'll sometimes ask that you join us on IRC _([#kibana](https://kiwiirc.com/client/irc.freenode.net/?#kibana) on freenode)_ to chat about your issues. You may also experience **faster response times** when engaging us via IRC. - There's hundreds of open issues and prioritizing what to work on is an important aspect of our daily jobs. We prioritize issues according to impact and difficulty, so some issues can be neglected while we work on more pressing issues. -Feel free to bump your issues if you think they've been neglected for a prolonged period, or just jump on IRC and let us have it! +Feel free to bump your issues if you think they've been neglected for a prolonged period. ### "I want to help!" diff --git a/package.json b/package.json index e4fdaf32a014a..04dc5edb6fd99 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "@kbn/ui-framework": "1.0.0", "@kbn/ui-shared-deps": "1.0.0", "JSONStream": "1.3.5", - "abort-controller": "^3.0.0", + "abortcontroller-polyfill": "^1.4.0", "angular": "^1.7.9", "angular-aria": "^1.7.9", "angular-elastic": "^2.5.1", diff --git a/packages/kbn-optimizer/package.json b/packages/kbn-optimizer/package.json index e8bb31f1e365d..219b9aaa7f8f2 100644 --- a/packages/kbn-optimizer/package.json +++ b/packages/kbn-optimizer/package.json @@ -31,6 +31,7 @@ "node-sass": "^4.13.0", "postcss-loader": "^3.0.0", "raw-loader": "^3.1.0", + "resolve-url-loader": "^3.1.1", "rxjs": "^6.5.3", "sass-loader": "^8.0.2", "style-loader": "^1.1.3", diff --git a/packages/kbn-optimizer/src/worker/webpack.config.ts b/packages/kbn-optimizer/src/worker/webpack.config.ts index 1e87b8a5a7f7b..22b927d4638d7 100644 --- a/packages/kbn-optimizer/src/worker/webpack.config.ts +++ b/packages/kbn-optimizer/src/worker/webpack.config.ts @@ -126,6 +126,27 @@ export function getWebpackConfig(bundle: Bundle, worker: WorkerConfig) { }, }, }, + { + loader: 'resolve-url-loader', + options: { + join: (_: string, __: any) => (uri: string, base?: string) => { + if (!base) { + return null; + } + + // manually force ui/* urls in legacy styles to resolve to ui/legacy/public + if (uri.startsWith('ui/') && base.split(Path.sep).includes('legacy')) { + return Path.resolve( + worker.repoRoot, + 'src/legacy/ui/public', + uri.replace('ui/', '') + ); + } + + return null; + }, + }, + }, { loader: 'sass-loader', options: { diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 2ccff3e9c3df2..451db9750ada7 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -43046,21 +43046,28 @@ module.exports = require("tty"); const os = __webpack_require__(11); const hasFlag = __webpack_require__(12); -const env = process.env; +const {env} = process; let forceColor; if (hasFlag('no-color') || hasFlag('no-colors') || - hasFlag('color=false')) { - forceColor = false; + hasFlag('color=false') || + hasFlag('color=never')) { + forceColor = 0; } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) { - forceColor = true; + forceColor = 1; } if ('FORCE_COLOR' in env) { - forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; + if (env.FORCE_COLOR === true || env.FORCE_COLOR === 'true') { + forceColor = 1; + } else if (env.FORCE_COLOR === false || env.FORCE_COLOR === 'false') { + forceColor = 0; + } else { + forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3); + } } function translateLevel(level) { @@ -43077,7 +43084,7 @@ function translateLevel(level) { } function supportsColor(stream) { - if (forceColor === false) { + if (forceColor === 0) { return 0; } @@ -43091,11 +43098,15 @@ function supportsColor(stream) { return 2; } - if (stream && !stream.isTTY && forceColor !== true) { + if (stream && !stream.isTTY && forceColor === undefined) { return 0; } - const min = forceColor ? 1 : 0; + const min = forceColor || 0; + + if (env.TERM === 'dumb') { + return min; + } if (process.platform === 'win32') { // Node.js 7.5.0 is the first version of Node.js to include a patch to @@ -43156,10 +43167,6 @@ function supportsColor(stream) { return 1; } - if (env.TERM === 'dumb') { - return min; - } - return min; } diff --git a/packages/kbn-ui-shared-deps/package.json b/packages/kbn-ui-shared-deps/package.json index 4b4db9d7f37f3..6795d363a9f1d 100644 --- a/packages/kbn-ui-shared-deps/package.json +++ b/packages/kbn-ui-shared-deps/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@elastic/charts": "^17.0.2", - "abort-controller": "^3.0.0", + "abortcontroller-polyfill": "^1.4.0", "@elastic/eui": "19.0.0", "@kbn/dev-utils": "1.0.0", "@kbn/i18n": "1.0.0", diff --git a/packages/kbn-ui-shared-deps/polyfills.js b/packages/kbn-ui-shared-deps/polyfills.js index 612fbb9a78b50..d2305d643e4d2 100644 --- a/packages/kbn-ui-shared-deps/polyfills.js +++ b/packages/kbn-ui-shared-deps/polyfills.js @@ -21,6 +21,6 @@ require('core-js/stable'); require('regenerator-runtime/runtime'); require('custom-event-polyfill'); require('whatwg-fetch'); -require('abort-controller/polyfill'); +require('abortcontroller-polyfill/dist/polyfill-patch-fetch'); require('./vendor/childnode_remove_polyfill'); require('symbol-observable'); diff --git a/packages/kbn-utility-types/README.md b/packages/kbn-utility-types/README.md index aafae4d3a5134..829fd21e14366 100644 --- a/packages/kbn-utility-types/README.md +++ b/packages/kbn-utility-types/README.md @@ -20,8 +20,12 @@ type B = UnwrapPromise; // string - `Ensure` — Makes sure `T` is of type `X`. - `ObservableLike` — Minimal interface for an object resembling an `Observable`. +- `PublicContract` — Returns an object with public keys only. +- `PublicKeys` — Returns public keys of an object. - `RecursiveReadonly` — Like `Readonly`, but freezes object recursively. - `ShallowPromise` — Same as `Promise` type, but it flat maps the wrapped type. +- `UnionToIntersection` — Converts a union of types into an intersection. - `UnwrapObservable` — Returns wrapped type of an observable. - `UnwrapPromise` — Returns wrapped type of a promise. - `UnwrapPromiseOrReturn` — Returns wrapped type of a promise or the type itself, if it isn't a promise. +- `Values` — Returns object or array value types. diff --git a/packages/kbn-utility-types/index.ts b/packages/kbn-utility-types/index.ts index ec81f7347b481..808935ed4cb5b 100644 --- a/packages/kbn-utility-types/index.ts +++ b/packages/kbn-utility-types/index.ts @@ -69,3 +69,31 @@ export type RecursiveReadonly = T extends (...args: any) => any : T extends object ? Readonly<{ [K in keyof T]: RecursiveReadonly }> : T; + +/** + * Returns types or array or object values. + */ +export type Values = T extends any[] ? T[number] : T extends object ? T[keyof T] : never; + +/** + * Utility type for converting a union of types into an intersection. + * + * This is a bit of "black magic" that will interpret a Union type as an Intersection + * type. This is necessary in the case of distinguishing one collection from + * another. + */ +export type UnionToIntersection = (U extends any +? (k: U) => void +: never) extends (k: infer I) => void + ? I + : never; + +/** + * Returns public keys of an object. + */ +export type PublicKeys = keyof T; + +/** + * Returns an object with public keys only. + */ +export type PublicContract = Pick>; diff --git a/packages/kbn-utility-types/test-d/public_contract.ts b/packages/kbn-utility-types/test-d/public_contract.ts new file mode 100644 index 0000000000000..b4429a60c758c --- /dev/null +++ b/packages/kbn-utility-types/test-d/public_contract.ts @@ -0,0 +1,33 @@ +/* + * 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 { expectType } from 'tsd'; +import { PublicContract } from '../index'; + +class Test { + public str: string = ''; + // @ts-ignore + private num: number = 0; +} + +type CONTRACT = PublicContract; + +expectType({ + str: 'foo', +}); diff --git a/packages/kbn-utility-types/test-d/public_keys.ts b/packages/kbn-utility-types/test-d/public_keys.ts new file mode 100644 index 0000000000000..66bf250a91547 --- /dev/null +++ b/packages/kbn-utility-types/test-d/public_keys.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. + */ + +import { expectType } from 'tsd'; +import { PublicKeys } from '../index'; + +class Test { + public str: string = ''; + // @ts-ignore + private num: number = 0; +} + +type KEYS = PublicKeys; + +expectType('str'); diff --git a/packages/kbn-utility-types/test-d/union_to_intersection.ts b/packages/kbn-utility-types/test-d/union_to_intersection.ts new file mode 100644 index 0000000000000..ba385268475e7 --- /dev/null +++ b/packages/kbn-utility-types/test-d/union_to_intersection.ts @@ -0,0 +1,28 @@ +/* + * 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 { expectType } from 'tsd'; +import { UnionToIntersection } from '../index'; + +type INTERSECTED = UnionToIntersection<{ foo: 'bar' } | { baz: 'qux' }>; + +expectType({ + foo: 'bar', + baz: 'qux', +}); diff --git a/packages/kbn-utility-types/test-d/values.ts b/packages/kbn-utility-types/test-d/values.ts new file mode 100644 index 0000000000000..9e50cfebde1db --- /dev/null +++ b/packages/kbn-utility-types/test-d/values.ts @@ -0,0 +1,38 @@ +/* + * 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 { expectType } from 'tsd'; +import { Values } from '../index'; + +// Arrays +type STRING = Values; +type ASDF_FOO = Values>; + +expectType('adf'); +expectType('asdf'); +expectType('foo'); + +// Objects +type STRING2 = Values>; +type FOO = Values>; +type BAR = Values<{ foo: 'bar' }>; + +expectType('adf'); +expectType('foo'); +expectType('bar'); diff --git a/src/dev/typescript/project.ts b/src/dev/typescript/project.ts index e0d882985bd7c..623c248144ff6 100644 --- a/src/dev/typescript/project.ts +++ b/src/dev/typescript/project.ts @@ -52,11 +52,15 @@ export class Project { public directory: string; public name: string; public config: any; + public disableTypeCheck: boolean; private readonly include: IMinimatch[]; private readonly exclude: IMinimatch[]; - constructor(public tsConfigPath: string, name?: string) { + constructor( + public tsConfigPath: string, + options: { name?: string; disableTypeCheck?: boolean } = {} + ) { this.config = parseTsConfig(tsConfigPath); const { files, include, exclude = [] } = this.config as { @@ -72,7 +76,8 @@ export class Project { } this.directory = dirname(this.tsConfigPath); - this.name = name || relative(REPO_ROOT, this.directory) || basename(this.directory); + this.disableTypeCheck = options.disableTypeCheck || false; + this.name = options.name || relative(REPO_ROOT, this.directory) || basename(this.directory); this.include = makeMatchers(this.directory, include); this.exclude = makeMatchers(this.directory, exclude); } diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts index 1920747b94d3b..fb35e5ce526ed 100644 --- a/src/dev/typescript/projects.ts +++ b/src/dev/typescript/projects.ts @@ -24,14 +24,16 @@ import { Project } from './project'; export const PROJECTS = [ new Project(resolve(REPO_ROOT, 'tsconfig.json')), - new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), 'kibana/test'), + new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }), new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')), - new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), 'x-pack/test'), - new Project( - resolve(REPO_ROOT, 'x-pack/legacy/plugins/siem/cypress/tsconfig.json'), - 'siem/cypress' - ), - new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/apm/cypress/tsconfig.json'), 'apm/cypress'), + new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }), + new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/siem/cypress/tsconfig.json'), { + name: 'siem/cypress', + }), + new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/apm/cypress/tsconfig.json'), { + name: 'apm/cypress', + disableTypeCheck: true, + }), // NOTE: using glob.sync rather than glob-all or globby // because it takes less than 10 ms, while the other modules diff --git a/src/dev/typescript/run_type_check_cli.ts b/src/dev/typescript/run_type_check_cli.ts index 3deebcc0c18f9..1f0e4b48b7b4b 100644 --- a/src/dev/typescript/run_type_check_cli.ts +++ b/src/dev/typescript/run_type_check_cli.ts @@ -80,7 +80,7 @@ export function runTypeCheckCli() { } const tscArgs = ['--noEmit', '--pretty', ...(opts['skip-lib-check'] ? ['--skipLibCheck'] : [])]; - const projects = filterProjectsByFlag(opts.project); + const projects = filterProjectsByFlag(opts.project).filter(p => !p.disableTypeCheck); if (!projects.length) { log.error(`Unable to find project at ${opts.project}`); diff --git a/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.js b/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.js index 68216b92840fc..0b8786f0c2841 100644 --- a/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.js +++ b/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.js @@ -17,7 +17,7 @@ * under the License. */ -import { AbortController } from 'abort-controller'; +import { AbortController } from 'abortcontroller-polyfill/dist/cjs-ponyfill'; /* * A simple utility for generating a handler that provides a signal to the handler that signals when diff --git a/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.test.js b/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.test.js index 1c154370d1674..d79dd4ae4e449 100644 --- a/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.test.js +++ b/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.test.js @@ -17,7 +17,7 @@ * under the License. */ -import { AbortSignal } from 'abort-controller'; +import { AbortSignal } from 'abortcontroller-polyfill/dist/cjs-ponyfill'; import { abortableRequestHandler } from './abortable_request_handler'; describe('abortableRequestHandler', () => { diff --git a/src/plugins/expressions/common/execution/types.ts b/src/plugins/expressions/common/execution/types.ts index ac0061c59c031..51538394cd125 100644 --- a/src/plugins/expressions/common/execution/types.ts +++ b/src/plugins/expressions/common/execution/types.ts @@ -20,6 +20,7 @@ import { ExpressionType } from '../expression_types'; import { DataAdapter, RequestAdapter } from '../../../inspector/common'; import { TimeRange, Query, Filter } from '../../../data/common'; +import { SavedObject, SavedObjectAttributes } from '../../../../core/public'; /** * `ExecutionContext` is an object available to all functions during a single execution; @@ -55,6 +56,20 @@ export interface ExecutionContext( + type: string, + id: string + ) => Promise>; } /** diff --git a/src/plugins/expressions/common/expression_functions/specs/index.ts b/src/plugins/expressions/common/expression_functions/specs/index.ts index 514068da8f10c..f7471a8fd9d75 100644 --- a/src/plugins/expressions/common/expression_functions/specs/index.ts +++ b/src/plugins/expressions/common/expression_functions/specs/index.ts @@ -20,6 +20,7 @@ import { clog } from './clog'; import { font } from './font'; import { kibana } from './kibana'; +import { kibanaContextFunction } from './kibana_context'; import { variableSet } from './var_set'; import { variable } from './var'; import { AnyExpressionFunctionDefinition } from '../types'; @@ -28,6 +29,7 @@ export const functionSpecs: AnyExpressionFunctionDefinition[] = [ clog, font, kibana, + kibanaContextFunction, variableSet, variable, ]; @@ -35,5 +37,6 @@ export const functionSpecs: AnyExpressionFunctionDefinition[] = [ export * from './clog'; export * from './font'; export * from './kibana'; +export * from './kibana_context'; export * from './var_set'; export * from './var'; diff --git a/src/plugins/expressions/public/expression_functions/kibana_context.ts b/src/plugins/expressions/common/expression_functions/specs/kibana_context.ts similarity index 83% rename from src/plugins/expressions/public/expression_functions/kibana_context.ts rename to src/plugins/expressions/common/expression_functions/specs/kibana_context.ts index f997972c33839..4092dfbba00d5 100644 --- a/src/plugins/expressions/public/expression_functions/kibana_context.ts +++ b/src/plugins/expressions/common/expression_functions/specs/kibana_context.ts @@ -18,9 +18,8 @@ */ import { i18n } from '@kbn/i18n'; -import { ExpressionFunctionDefinition } from '../../common'; -import { KibanaContext } from '../../common/expression_types'; -import { savedObjects } from '../services'; +import { ExpressionFunctionDefinition } from '../../expression_functions'; +import { KibanaContext } from '../../expression_types'; interface Arguments { q?: string | null; @@ -36,7 +35,7 @@ export type ExpressionFunctionKibanaContext = ExpressionFunctionDefinition< Promise >; -export const kibanaContext = (): ExpressionFunctionKibanaContext => ({ +export const kibanaContextFunction: ExpressionFunctionKibanaContext = { name: 'kibana_context', type: 'kibana_context', inputTypes: ['kibana_context', 'null'], @@ -74,13 +73,21 @@ export const kibanaContext = (): ExpressionFunctionKibanaContext => ({ }), }, }, - async fn(input, args) { + + async fn(input, args, { getSavedObject }) { const queryArg = args.q ? JSON.parse(args.q) : []; let queries = Array.isArray(queryArg) ? queryArg : [queryArg]; let filters = args.filters ? JSON.parse(args.filters) : []; if (args.savedSearchId) { - const obj = await savedObjects.get('search', args.savedSearchId); + if (typeof getSavedObject !== 'function') { + throw new Error( + '"getSavedObject" function not available in execution context. ' + + 'When you execute expression you need to add extra execution context ' + + 'as the third argument and provide "getSavedObject" implementation.' + ); + } + const obj = await getSavedObject('search', args.savedSearchId); const search = obj.attributes.kibanaSavedObjectMeta as { searchSourceJSON: string }; const data = JSON.parse(search.searchSourceJSON) as { query: string; filter: any[] }; queries = queries.concat(data.query); @@ -108,4 +115,4 @@ export const kibanaContext = (): ExpressionFunctionKibanaContext => ({ timeRange, }; }, -}); +}; diff --git a/src/plugins/expressions/public/plugin.test.ts b/src/plugins/expressions/public/plugin.test.ts index ac9a2f508e2db..08f7135f033f1 100644 --- a/src/plugins/expressions/public/plugin.test.ts +++ b/src/plugins/expressions/public/plugin.test.ts @@ -50,6 +50,14 @@ describe('ExpressionsPublicPlugin', () => { const bar = await setup.run('var_set name="foo" value="bar" | var name="foo"', null); expect(bar).toBe('bar'); }); + + test('kibana_context function is available', async () => { + const { setup } = await expressionsPluginMock.createPlugin(); + const result = await setup.run('kibana_context', null); + expect(result).toMatchObject({ + type: 'kibana_context', + }); + }); }); }); diff --git a/src/plugins/expressions/public/plugin.ts b/src/plugins/expressions/public/plugin.ts index aac429b365c48..4aa8003617652 100644 --- a/src/plugins/expressions/public/plugin.ts +++ b/src/plugins/expressions/public/plugin.ts @@ -27,6 +27,7 @@ import { ExpressionsService, ExpressionsServiceSetup, ExpressionsServiceStart, + ExecutionContext, } from '../common'; import { Setup as InspectorSetup, Start as InspectorStart } from '../../inspector/public'; import { BfetchPublicSetup, BfetchPublicStart } from '../../bfetch/public'; @@ -38,7 +39,6 @@ import { setNotifications, setExpressionsService, } from './services'; -import { kibanaContext as kibanaContextFunction } from './expression_functions/kibana_context'; import { ReactExpressionRenderer } from './react_expression_renderer'; import { ExpressionLoader, loader } from './loader'; import { render, ExpressionRenderHandler } from './render'; @@ -106,14 +106,25 @@ export class ExpressionsPublicPlugin constructor(initializerContext: PluginInitializerContext) {} - public setup(core: CoreSetup, { inspector, bfetch }: ExpressionsSetupDeps): ExpressionsSetup { - const { expressions } = this; - const { executor, renderers } = expressions; + private configureExecutor(core: CoreSetup) { + const { executor } = this.expressions; + + const getSavedObject: ExecutionContext['getSavedObject'] = async (type, id) => { + const [start] = await core.getStartServices(); + return start.savedObjects.client.get(type, id); + }; executor.extendContext({ environment: 'client', + getSavedObject, }); - executor.registerFunction(kibanaContextFunction()); + } + + public setup(core: CoreSetup, { inspector, bfetch }: ExpressionsSetupDeps): ExpressionsSetup { + this.configureExecutor(core); + + const { expressions } = this; + const { executor, renderers } = expressions; setRenderersRegistry(renderers); setExpressionsService(this.expressions); diff --git a/src/plugins/expressions/public/services.ts b/src/plugins/expressions/public/services.ts index 4fdff9b151ac2..a203e87414571 100644 --- a/src/plugins/expressions/public/services.ts +++ b/src/plugins/expressions/public/services.ts @@ -24,7 +24,7 @@ import { Start as IInspector } from '../../inspector/public'; import { ExpressionsSetup } from './plugin'; import { ExpressionsService } from '../common'; -export const { getCoreStart, setCoreStart, savedObjects } = createKibanaUtilsCore(); +export const { getCoreStart, setCoreStart } = createKibanaUtilsCore(); export const [getInspector, setInspector] = createGetterSetter('Inspector'); diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 347923670c413..f909852b0c936 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -192,6 +192,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo public async navigateToUrlWithBrowserHistory( appName: string, subUrl?: string, + search?: string, { basePath = '', ensureCurrentUrl = true, @@ -203,6 +204,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo const appConfig = { // subUrl following the basePath, assumes no hashes. Ex: 'app/endpoint/management' pathname: `${basePath}${config.get(['apps', appName]).pathname}${subUrl}`, + search, }; await this.navigate({ diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 140e3fd0c4014..f0b590f7ffd6c 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -17,7 +17,7 @@ "xpack.grokDebugger": "legacy/plugins/grokdebugger", "xpack.idxMgmt": "legacy/plugins/index_management", "xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management", - "xpack.infra": "legacy/plugins/infra", + "xpack.infra": "plugins/infra", "xpack.ingestManager": "plugins/ingest_manager", "xpack.data": "plugins/data_enhanced", "xpack.lens": "legacy/plugins/lens", diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx index a247390704e72..d79f2a4ed481d 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx @@ -25,7 +25,7 @@ import { DetailView } from './DetailView'; import { ErrorDistribution } from './Distribution'; import { useLocation } from '../../../hooks/useLocation'; import { useUrlParams } from '../../../hooks/useUrlParams'; -import { useTrackPageview } from '../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../plugins/observability/public'; const Titles = styled.div` margin-bottom: ${px(units.plus)}; diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx index 2daf5e55d4e72..9f7ff65d37d36 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx @@ -17,7 +17,7 @@ import { useFetcher } from '../../../hooks/useFetcher'; import { ErrorDistribution } from '../ErrorGroupDetails/Distribution'; import { ErrorGroupList } from './List'; import { useUrlParams } from '../../../hooks/useUrlParams'; -import { useTrackPageview } from '../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../plugins/observability/public'; import { PROJECTION } from '../../../../common/projections/typings'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx index b522736c80f9b..762c10c0f48a7 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx @@ -14,7 +14,7 @@ import { useFetcher } from '../../../hooks/useFetcher'; import { NoServicesMessage } from './NoServicesMessage'; import { ServiceList } from './ServiceList'; import { useUrlParams } from '../../../hooks/useUrlParams'; -import { useTrackPageview } from '../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../plugins/observability/public'; import { PROJECTION } from '../../../../common/projections/typings'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { useApmPluginContext } from '../../../hooks/useApmPluginContext'; diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx index 7243a86404f04..4f808b3b4b5d9 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx @@ -34,6 +34,7 @@ import { isRumAgentName } from '../../../../../../common/agent_name'; import { ALL_OPTION_VALUE } from '../../../../../../common/agent_configuration_constants'; import { saveConfig } from './saveConfig'; import { useApmPluginContext } from '../../../../../hooks/useApmPluginContext'; +import { useUiTracker } from '../../../../../../../../../plugins/observability/public'; const defaultSettings = { TRANSACTION_SAMPLE_RATE: '1.0', @@ -59,6 +60,9 @@ export function AddEditFlyout({ const callApmApiFromHook = useCallApmApi(); + // get a telemetry UI event tracker + const trackApmEvent = useUiTracker({ app: 'apm' }); + // config conditions (service) const [serviceName, setServiceName] = useState( selectedConfig ? selectedConfig.service.name || ALL_OPTION_VALUE : '' @@ -133,7 +137,8 @@ export function AddEditFlyout({ transactionMaxSpans, configurationId: selectedConfig ? selectedConfig.id : undefined, agentName, - toasts + toasts, + trackApmEvent }); setIsSaving(false); onSaved(); diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/saveConfig.ts b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/saveConfig.ts index 7ca221d642b08..a0c7c97e012a4 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/saveConfig.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/saveConfig.ts @@ -7,12 +7,12 @@ import { i18n } from '@kbn/i18n'; import { NotificationsStart } from 'kibana/public'; import { APMClient } from '../../../../../services/rest/createCallApmApi'; -import { trackEvent } from '../../../../../../../infra/public/hooks/use_track_metric'; import { isRumAgentName } from '../../../../../../common/agent_name'; import { getOptionLabel, omitAllOption } from '../../../../../../common/agent_configuration_constants'; +import { UiTracker } from '../../../../../../../../../plugins/observability/public'; interface Settings { transaction_sample_rate: number; @@ -29,7 +29,8 @@ export async function saveConfig({ transactionMaxSpans, configurationId, agentName, - toasts + toasts, + trackApmEvent }: { callApmApi: APMClient; serviceName: string; @@ -40,8 +41,9 @@ export async function saveConfig({ configurationId?: string; agentName?: string; toasts: NotificationsStart['toasts']; + trackApmEvent: UiTracker; }) { - trackEvent({ app: 'apm', name: 'save_agent_configuration' }); + trackApmEvent({ metric: 'save_agent_configuration' }); try { const settings: Settings = { diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx index 9e95cfd0fad7f..8812cccd2edaf 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx @@ -18,7 +18,7 @@ import { isEmpty } from 'lodash'; import { useFetcher } from '../../../../hooks/useFetcher'; import { AgentConfigurationListAPIResponse } from '../../../../../server/lib/settings/agent_configuration/list_configurations'; import { AgentConfigurationList } from './AgentConfigurationList'; -import { useTrackPageview } from '../../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../../plugins/observability/public'; import { AddEditFlyout } from './AddEditFlyout'; export type Config = AgentConfigurationListAPIResponse[0]; diff --git a/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx index dd3e2d13826dc..3bdcc3231cddc 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx @@ -9,7 +9,7 @@ import React, { useMemo } from 'react'; import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher'; import { TraceList } from './TraceList'; import { useUrlParams } from '../../../hooks/useUrlParams'; -import { useTrackPageview } from '../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../plugins/observability/public'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { PROJECTION } from '../../../../common/projections/typings'; diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx index 9d6639b000762..a6712becf7968 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx @@ -26,7 +26,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams'; import { FETCH_STATUS } from '../../../hooks/useFetcher'; import { TransactionBreakdown } from '../../shared/TransactionBreakdown'; import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext'; -import { useTrackPageview } from '../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../plugins/observability/public'; import { PROJECTION } from '../../../../common/projections/typings'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { HeightRetainer } from '../../shared/HeightRetainer'; diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx index 2cf01f8b40a09..73824f235ab02 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx @@ -27,7 +27,7 @@ import { getHasMLJob } from '../../../services/rest/ml'; import { history } from '../../../utils/history'; import { useLocation } from '../../../hooks/useLocation'; import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext'; -import { useTrackPageview } from '../../../../../infra/public'; +import { useTrackPageview } from '../../../../../../../plugins/observability/public'; import { fromQuery, toQuery } from '../../shared/Links/url_helpers'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { PROJECTION } from '../../../../common/projections/typings'; diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.test.tsx b/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.test.tsx index 42022a3741495..0b39aa9ada756 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.test.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.test.tsx @@ -11,13 +11,15 @@ import { InfraLink } from './InfraLink'; test('InfraLink produces the correct URL', async () => { const href = await getRenderedHref( - () => , + () => ( + + ), { search: '?rangeFrom=now-5h&rangeTo=now-2h' } as Location ); expect(href).toMatchInlineSnapshot( - `"/basepath/app/infra#/some/path?time=1554687198"` + `"/basepath/app/metrics/some/path?time=1554687198"` ); }); diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx b/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx index e4f3557a2ce51..7efe5cb96cfbd 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx @@ -5,12 +5,12 @@ */ import { EuiLink, EuiLinkAnchorProps } from '@elastic/eui'; -import { compact } from 'lodash'; import React from 'react'; import url from 'url'; import { fromQuery } from './url_helpers'; import { useApmPluginContext } from '../../../hooks/useApmPluginContext'; import { AppMountContextBasePath } from '../../../context/ApmPluginContext'; +import { InfraAppId } from '../../../../../../../plugins/infra/public'; interface InfraQueryParams { time?: number; @@ -20,29 +20,32 @@ interface InfraQueryParams { } interface Props extends EuiLinkAnchorProps { + app: InfraAppId; path?: string; query: InfraQueryParams; children?: React.ReactNode; } export const getInfraHref = ({ + app, basePath, query, path }: { + app: InfraAppId; basePath: AppMountContextBasePath; query: InfraQueryParams; path?: string; }) => { const nextSearch = fromQuery(query); return url.format({ - pathname: basePath.prepend('/app/infra'), - hash: compact([path, nextSearch]).join('?') + pathname: basePath.prepend(`/app/${app}${path || ''}`), + search: nextSearch }); }; -export function InfraLink({ path, query = {}, ...rest }: Props) { +export function InfraLink({ app, path, query = {}, ...rest }: Props) { const { core } = useApmPluginContext(); - const href = getInfraHref({ basePath: core.http.basePath, query, path }); + const href = getInfraHref({ app, basePath: core.http.basePath, query, path }); return ; } diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts index 52c2d27eabb82..9f07bd508c95c 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts @@ -10,7 +10,9 @@ import { AppMountContextBasePath } from '../../../../context/ApmPluginContext'; describe('Transaction action menu', () => { const basePath = ({ - prepend: jest.fn() + prepend: (url: string) => { + return `some-basepath${url}`; + } } as unknown) as AppMountContextBasePath; const date = '2020-02-06T11:00:00.000Z'; const timestamp = { us: new Date(date).getTime() }; @@ -40,7 +42,7 @@ describe('Transaction action menu', () => { key: 'traceLogs', label: 'Trace logs', href: - '#/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123', + 'some-basepath/app/logs/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123', condition: true } ] @@ -54,7 +56,7 @@ describe('Transaction action menu', () => { key: 'sampleDocument', label: 'View sample document', href: - '#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))', + 'some-basepath/app/kibana#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))', condition: true } ] @@ -89,14 +91,15 @@ describe('Transaction action menu', () => { { key: 'podLogs', label: 'Pod logs', - href: '#/link-to/pod-logs/123?time=1580986800', + href: + 'some-basepath/app/logs/link-to/pod-logs/123?time=1580986800', condition: true }, { key: 'podMetrics', label: 'Pod metrics', href: - '#/link-to/pod-detail/123?from=1580986500000&to=1580987100000', + 'some-basepath/app/metrics/link-to/pod-detail/123?from=1580986500000&to=1580987100000', condition: true } ] @@ -110,7 +113,7 @@ describe('Transaction action menu', () => { key: 'traceLogs', label: 'Trace logs', href: - '#/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123', + 'some-basepath/app/logs/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123', condition: true } ] @@ -124,7 +127,7 @@ describe('Transaction action menu', () => { key: 'sampleDocument', label: 'View sample document', href: - '#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))', + 'some-basepath/app/kibana#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))', condition: true } ] @@ -158,14 +161,15 @@ describe('Transaction action menu', () => { { key: 'hostLogs', label: 'Host logs', - href: '#/link-to/host-logs/foo?time=1580986800', + href: + 'some-basepath/app/logs/link-to/host-logs/foo?time=1580986800', condition: true }, { key: 'hostMetrics', label: 'Host metrics', href: - '#/link-to/host-detail/foo?from=1580986500000&to=1580987100000', + 'some-basepath/app/metrics/link-to/host-detail/foo?from=1580986500000&to=1580987100000', condition: true } ] @@ -179,7 +183,7 @@ describe('Transaction action menu', () => { key: 'traceLogs', label: 'Trace logs', href: - '#/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123', + 'some-basepath/app/logs/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123', condition: true } ] @@ -193,7 +197,7 @@ describe('Transaction action menu', () => { key: 'sampleDocument', label: 'View sample document', href: - '#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))', + 'some-basepath/app/kibana#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))', condition: true } ] diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts index 77445a2600960..31efdb6355563 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts @@ -82,6 +82,7 @@ export const getSections = ({ { defaultMessage: 'Pod logs' } ), href: getInfraHref({ + app: 'logs', basePath, path: `/link-to/pod-logs/${podId}`, query: { time } @@ -95,6 +96,7 @@ export const getSections = ({ { defaultMessage: 'Pod metrics' } ), href: getInfraHref({ + app: 'metrics', basePath, path: `/link-to/pod-detail/${podId}`, query: infraMetricsQuery @@ -111,6 +113,7 @@ export const getSections = ({ { defaultMessage: 'Container logs' } ), href: getInfraHref({ + app: 'logs', basePath, path: `/link-to/container-logs/${containerId}`, query: { time } @@ -124,6 +127,7 @@ export const getSections = ({ { defaultMessage: 'Container metrics' } ), href: getInfraHref({ + app: 'metrics', basePath, path: `/link-to/container-detail/${containerId}`, query: infraMetricsQuery @@ -140,6 +144,7 @@ export const getSections = ({ { defaultMessage: 'Host logs' } ), href: getInfraHref({ + app: 'logs', basePath, path: `/link-to/host-logs/${hostName}`, query: { time } @@ -153,6 +158,7 @@ export const getSections = ({ { defaultMessage: 'Host metrics' } ), href: getInfraHref({ + app: 'metrics', basePath, path: `/link-to/host-detail/${hostName}`, query: infraMetricsQuery @@ -169,6 +175,7 @@ export const getSections = ({ { defaultMessage: 'Trace logs' } ), href: getInfraHref({ + app: 'logs', basePath, path: `/link-to/logs`, query: { diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx index c4e7ed86df8b7..a964b425073b5 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { useMemo } from 'react'; import numeral from '@elastic/numeral'; import { throttle } from 'lodash'; import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n'; @@ -14,7 +14,7 @@ import { TransactionLineChart } from '../../charts/TransactionCharts/Transaction import { asPercent } from '../../../../utils/formatters'; import { unit } from '../../../../style/variables'; import { isValidCoordinateValue } from '../../../../utils/isValidCoordinateValue'; -import { trackEvent } from '../../../../../../infra/public/hooks/use_track_metric'; +import { useUiTracker } from '../../../../../../../../plugins/observability/public'; interface Props { timeseries: TimeSeries[]; @@ -30,13 +30,14 @@ const formatTooltipValue = (coordinate: Coordinate) => { : NOT_AVAILABLE_LABEL; }; -const trackHoverBreakdownChart = throttle( - () => trackEvent({ app: 'apm', name: 'hover_breakdown_chart' }), - 60000 -); - const TransactionBreakdownGraph: React.FC = props => { const { timeseries } = props; + const trackApmEvent = useUiTracker({ app: 'apm' }); + const handleHover = useMemo( + () => + throttle(() => trackApmEvent({ metric: 'hover_breakdown_chart' }), 60000), + [trackApmEvent] + ); return ( = props => { yMax={1} height={unit * 12} stacked={true} - onHover={trackHoverBreakdownChart} + onHover={handleHover} /> ); }; diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx index 0e31cfff9a295..91f5f4e0a7176 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx @@ -13,8 +13,10 @@ import { EuiIcon } from '@elastic/eui'; import styled from 'styled-components'; -import { InfraFormatterType } from '../../../../../infra/public/lib/lib'; -import { FORMATTERS } from '../../../../../infra/public/utils/formatters'; +import { + FORMATTERS, + InfraFormatterType +} from '../../../../../../../plugins/infra/public'; interface TransactionBreakdownKpi { name: string; diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx b/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx index d8b7c5059ec62..85f5f83fb920e 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx @@ -10,8 +10,8 @@ import { useTransactionBreakdown } from '../../../hooks/useTransactionBreakdown' import { TransactionBreakdownHeader } from './TransactionBreakdownHeader'; import { TransactionBreakdownKpiList } from './TransactionBreakdownKpiList'; import { TransactionBreakdownGraph } from './TransactionBreakdownGraph'; -import { trackEvent } from '../../../../../infra/public/hooks/use_track_metric'; import { FETCH_STATUS } from '../../../hooks/useFetcher'; +import { useUiTracker } from '../../../../../../../plugins/observability/public'; const emptyMessage = i18n.translate('xpack.apm.transactionBreakdown.noData', { defaultMessage: 'No data within this time range.' @@ -21,11 +21,9 @@ const TransactionBreakdown: React.FC<{ initialIsOpen?: boolean; }> = ({ initialIsOpen }) => { const [showChart, setShowChart] = useState(!!initialIsOpen); - const { data, status } = useTransactionBreakdown(); - + const trackApmEvent = useUiTracker({ app: 'apm' }); const { kpis, timeseries } = data; - const noHits = data.kpis.length === 0 && status === FETCH_STATUS.SUCCESS; const showEmptyMessage = noHits && !showChart; @@ -38,9 +36,9 @@ const TransactionBreakdown: React.FC<{ onToggleClick={() => { setShowChart(!showChart); if (showChart) { - trackEvent({ app: 'apm', name: 'hide_breakdown_chart' }); + trackApmEvent({ metric: 'hide_breakdown_chart' }); } else { - trackEvent({ app: 'apm', name: 'show_breakdown_chart' }); + trackApmEvent({ metric: 'show_breakdown_chart' }); } }} /> diff --git a/x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx b/x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx index 58a41014f2fe9..64deff9f1ae39 100644 --- a/x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx +++ b/x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx @@ -37,6 +37,7 @@ import { getConfigFromInjectedMetadata } from './getConfigFromInjectedMetadata'; import { setHelpExtension } from './setHelpExtension'; import { toggleAppLinkInNav } from './toggleAppLinkInNav'; import { setReadonlyBadge } from './updateBadge'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { Permission } from '../components/app/Permission'; export const REACT_APP_ROOT_ID = 'react-apm-root'; @@ -135,21 +136,23 @@ export class ApmPlugin ReactDOM.render( - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + , document.getElementById(REACT_APP_ROOT_ID) ); diff --git a/x-pack/legacy/plugins/canvas/i18n/functions/function_help.ts b/x-pack/legacy/plugins/canvas/i18n/functions/function_help.ts index 565cfa251e126..dbdadd09df67f 100644 --- a/x-pack/legacy/plugins/canvas/i18n/functions/function_help.ts +++ b/x-pack/legacy/plugins/canvas/i18n/functions/function_help.ts @@ -5,7 +5,8 @@ */ import { ExpressionFunctionDefinition } from 'src/plugins/expressions'; -import { UnionToIntersection, CanvasFunction } from '../../types'; +import { UnionToIntersection } from '@kbn/utility-types'; +import { CanvasFunction } from '../../types'; import { help as all } from './dict/all'; import { help as alterColumn } from './dict/alter_column'; diff --git a/x-pack/legacy/plugins/canvas/types/functions.ts b/x-pack/legacy/plugins/canvas/types/functions.ts index 27b2a04ebd6e3..3344f9b3ae9f2 100644 --- a/x-pack/legacy/plugins/canvas/types/functions.ts +++ b/x-pack/legacy/plugins/canvas/types/functions.ts @@ -10,22 +10,6 @@ import { functions as browserFunctions } from '../canvas_plugin_src/functions/br import { functions as serverFunctions } from '../canvas_plugin_src/functions/server'; import { clientFunctions } from '../public/functions'; -/** - * Utility type for converting a union of types into an intersection. - * - * This is a bit of "black magic" that will interpret a Union type as an Intersection - * type. This is necessary in this case of distiguishing one collection from - * another in `FunctionError` and `FunctionStrings`. - */ -// prettier-ignore -export type UnionToIntersection = - (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; - -/** - * Utility type: gathers values of a collection as a type for use as a type. - */ -export type ValuesOf = T[number]; - /** * A `ExpressionFunctionFactory` is a powerful type used for any function that produces * an `ExpressionFunction`. If it does not meet the signature for such a function, diff --git a/x-pack/legacy/plugins/infra/index.ts b/x-pack/legacy/plugins/infra/index.ts index 4ab2cde082498..6ef273924a346 100644 --- a/x-pack/legacy/plugins/infra/index.ts +++ b/x-pack/legacy/plugins/infra/index.ts @@ -3,115 +3,23 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - -import { i18n } from '@kbn/i18n'; -import JoiNamespace from 'joi'; -import { resolve } from 'path'; -import { PluginInitializerContext } from 'src/core/server'; -import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import KbnServer from 'src/legacy/server/kbn_server'; -import { getConfigSchema } from './server/kibana.index'; -import { savedObjectMappings } from './server/saved_objects'; -import { plugin, InfraServerPluginDeps } from './server/new_platform_index'; -import { InfraSetup } from '../../../plugins/infra/server'; -import { PluginSetupContract as FeaturesPluginSetup } from '../../../plugins/features/server'; -import { SpacesPluginSetup } from '../../../plugins/spaces/server'; -import { VisTypeTimeseriesSetup } from '../../../../src/plugins/vis_type_timeseries/server'; -import { APMPluginContract } from '../../../plugins/apm/server'; -import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils'; - -export const APP_ID = 'infra'; +import { Root } from 'joi'; +import { savedObjectMappings } from '../../../plugins/infra/server'; export function infra(kibana: any) { return new kibana.Plugin({ - id: APP_ID, + id: 'infra', configPrefix: 'xpack.infra', - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'metrics'], + require: ['kibana', 'elasticsearch'], uiExports: { - app: { - description: i18n.translate('xpack.infra.infrastructureDescription', { - defaultMessage: 'Explore your metrics', - }), - icon: 'plugins/infra/images/infra_mono_white.svg', - main: 'plugins/infra/app', - title: i18n.translate('xpack.infra.infrastructureTitle', { - defaultMessage: 'Metrics', - }), - listed: false, - url: `/app/${APP_ID}#/infrastructure`, - }, - styleSheetPaths: resolve(__dirname, 'public/index.scss'), - home: ['plugins/infra/legacy_register_feature'], - links: [ - { - description: i18n.translate('xpack.infra.linkInfrastructureDescription', { - defaultMessage: 'Explore your metrics', - }), - icon: 'plugins/infra/images/infra_mono_white.svg', - euiIconType: 'metricsApp', - id: 'infra:home', - order: 8000, - title: i18n.translate('xpack.infra.linkInfrastructureTitle', { - defaultMessage: 'Metrics', - }), - url: `/app/${APP_ID}#/infrastructure`, - category: DEFAULT_APP_CATEGORIES.observability, - }, - { - description: i18n.translate('xpack.infra.linkLogsDescription', { - defaultMessage: 'Explore your logs', - }), - icon: 'plugins/infra/images/logging_mono_white.svg', - euiIconType: 'logsApp', - id: 'infra:logs', - order: 8001, - title: i18n.translate('xpack.infra.linkLogsTitle', { - defaultMessage: 'Logs', - }), - url: `/app/${APP_ID}#/logs`, - category: DEFAULT_APP_CATEGORIES.observability, - }, - ], mappings: savedObjectMappings, }, - config(Joi: typeof JoiNamespace) { - return getConfigSchema(Joi); - }, - init(legacyServer: any) { - const { newPlatform } = legacyServer as KbnServer; - const { core, plugins } = newPlatform.setup; - - const infraSetup = (plugins.infra as unknown) as InfraSetup; // chef's kiss - - const initContext = ({ - config: infraSetup.__legacy.config, - } as unknown) as PluginInitializerContext; - // NP_TODO: Use real types from the other plugins as they are migrated - const pluginDeps: InfraServerPluginDeps = { - home: legacyServer.newPlatform.setup.plugins.home, - usageCollection: plugins.usageCollection as UsageCollectionSetup, - indexPatterns: { - indexPatternsServiceFactory: legacyServer.indexPatternsServiceFactory, - }, - metrics: plugins.metrics as VisTypeTimeseriesSetup, - spaces: plugins.spaces as SpacesPluginSetup, - features: plugins.features as FeaturesPluginSetup, - apm: plugins.apm as APMPluginContract, - }; - - const infraPluginInstance = plugin(initContext); - infraPluginInstance.setup(core, pluginDeps); - - // NP_TODO: EVERYTHING BELOW HERE IS LEGACY - - const libs = infraPluginInstance.getLibs(); - - // NP_NOTE: Left here for now for legacy plugins to consume - legacyServer.expose( - 'defineInternalSourceConfiguration', - libs.sources.defineInternalSourceConfiguration.bind(libs.sources) - ); + config(Joi: Root) { + return Joi.object({ + enabled: Joi.boolean().default(true), + }) + .unknown() + .default(); }, }); } diff --git a/x-pack/legacy/plugins/infra/package.json b/x-pack/legacy/plugins/infra/package.json deleted file mode 100644 index 7aa8cb9b5269a..0000000000000 --- a/x-pack/legacy/plugins/infra/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "author": "Elastic", - "name": "infra", - "version": "7.0.0", - "private": true, - "license": "Elastic-License", - "scripts": { - "build-graphql-types": "node scripts/generate_types_from_graphql.js" - }, - "devDependencies": { - "@types/boom": "7.2.1", - "@types/lodash": "^4.14.110" - }, - "dependencies": { - "@types/color": "^3.0.0", - "boom": "7.3.0", - "lodash": "^4.17.15" - } -} diff --git a/x-pack/legacy/plugins/infra/public/app.ts b/x-pack/legacy/plugins/infra/public/app.ts deleted file mode 100644 index 7a13d3a59cc0d..0000000000000 --- a/x-pack/legacy/plugins/infra/public/app.ts +++ /dev/null @@ -1,56 +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. - */ - -// NP_TODO: This app.ts layer is needed until we migrate 100% to the NP. -// This is so other plugins can import from our public/index file without trying to -// actually mount and run our application. Once in the NP this won't be an issue -// as the NP will look for an export named "plugin" and run that from the index file. - -import { npStart, npSetup } from 'ui/new_platform'; -import { PluginInitializerContext } from 'kibana/public'; -import chrome from 'ui/chrome'; -// @ts-ignore -import { uiModules } from 'ui/modules'; -import uiRoutes from 'ui/routes'; -// @ts-ignore -import { timezoneProvider } from 'ui/vis/lib/timezone'; -import { plugin } from './new_platform_index'; - -const ROOT_ELEMENT_ID = 'react-infra-root'; -export { ROOT_ELEMENT_ID }; - -const { core, plugins } = npStart; -const __LEGACY = { - uiModules, - uiRoutes, - timezoneProvider, -}; -// This will be moved to core.application.register when the new platform -// migration is complete. -// @ts-ignore -chrome.setRootTemplate(` -
-`); - -const checkForRoot = () => { - return new Promise(resolve => { - const ready = !!document.getElementById(ROOT_ELEMENT_ID); - if (ready) { - resolve(); - } else { - setTimeout(() => resolve(checkForRoot()), 10); - } - }); -}; - -checkForRoot().then(() => { - const pluginInstance = plugin({} as PluginInitializerContext); - pluginInstance.setup(npSetup.core, { home: npSetup.plugins.home }); - pluginInstance.start(core, plugins, __LEGACY); -}); diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_track_metric.tsx b/x-pack/legacy/plugins/infra/public/hooks/use_track_metric.tsx deleted file mode 100644 index c5945ab808202..0000000000000 --- a/x-pack/legacy/plugins/infra/public/hooks/use_track_metric.tsx +++ /dev/null @@ -1,89 +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 } from 'react'; -import { - createUiStatsReporter, - UiStatsMetricType, - METRIC_TYPE, -} from '../../../../../../src/legacy/core_plugins/ui_metric/public'; - -/** - * Note: The UI Metric plugin will take care of sending this data to the telemetry server. - * You can find these metrics stored at: - * stack_stats.kibana.plugins.ui_metric.{app}.{metric}(__delayed_{n}ms)? - * which will be an array of objects each containing a key, representing the metric, and - * a value, which will be a counter - */ - -type ObservabilityApp = 'infra_metrics' | 'infra_logs' | 'apm' | 'uptime'; - -const trackerCache = new Map>(); - -function getTrackerForApp(app: string) { - const cached = trackerCache.get(app); - if (cached) { - return cached; - } - - const tracker = createUiStatsReporter(app); - trackerCache.set(app, tracker); - - return tracker; -} - -interface TrackOptions { - app: ObservabilityApp; - metricType?: UiStatsMetricType; - delay?: number; // in ms -} -type EffectDeps = unknown[]; - -type TrackMetricOptions = TrackOptions & { metric: string }; - -export { METRIC_TYPE }; -export function useTrackMetric( - { app, metric, metricType = METRIC_TYPE.COUNT, delay = 0 }: TrackMetricOptions, - effectDependencies: EffectDeps = [] -) { - useEffect(() => { - let decoratedMetric = metric; - if (delay > 0) { - decoratedMetric += `__delayed_${delay}ms`; - } - const trackUiMetric = getTrackerForApp(app); - const id = setTimeout(() => trackUiMetric(metricType, decoratedMetric), Math.max(delay, 0)); - return () => clearTimeout(id); - - // the dependencies are managed externally - // eslint-disable-next-line react-hooks/exhaustive-deps - }, effectDependencies); -} - -/** - * useTrackPageview is a convenience wrapper for tracking a pageview - * Its metrics will be found at: - * stack_stats.kibana.plugins.ui_metric.{app}.pageview__{path}(__delayed_{n}ms)? - */ -type TrackPageviewProps = TrackOptions & { path: string }; - -export function useTrackPageview( - { path, ...rest }: TrackPageviewProps, - effectDependencies: EffectDeps = [] -) { - useTrackMetric({ ...rest, metric: `pageview__${path}` }, effectDependencies); -} - -interface TrackEventProps { - app: ObservabilityApp; - name: string; - metricType?: UiStatsMetricType; -} - -export function trackEvent({ app, name, metricType = METRIC_TYPE.CLICK }: TrackEventProps) { - const trackUiMetric = getTrackerForApp(app); - trackUiMetric(metricType, `event__${name}`); -} diff --git a/x-pack/legacy/plugins/infra/public/index.ts b/x-pack/legacy/plugins/infra/public/index.ts deleted file mode 100644 index 5e68ca85681fe..0000000000000 --- a/x-pack/legacy/plugins/infra/public/index.ts +++ /dev/null @@ -1,14 +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. - */ - -// NP_NOTE: Whilst we are in the transition period of the NP migration, this index file -// is exclusively for our static code exports that other plugins (e.g. APM) use. -// When we switch over to the real NP, and an export of "plugin" is expected and called, -// we can do away with the middle "app.ts" layer. The "app.ts" layer is needed for now, -// and needs to be situated differently to this index file, so that our code for setting the root template -// and attempting to start the app doesn't try to run just because another plugin is importing from this file. - -export { useTrackPageview } from './hooks/use_track_metric'; diff --git a/x-pack/legacy/plugins/infra/public/legacy_register_feature.ts b/x-pack/legacy/plugins/infra/public/legacy_register_feature.ts deleted file mode 100644 index 7b10a1e062f75..0000000000000 --- a/x-pack/legacy/plugins/infra/public/legacy_register_feature.ts +++ /dev/null @@ -1,15 +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 { npSetup } from 'ui/new_platform'; -import { featureCatalogueEntries } from './feature_catalogue_entry'; - -const { - plugins: { home }, -} = npSetup; - -home.featureCatalogue.register(featureCatalogueEntries.metrics); -home.featureCatalogue.register(featureCatalogueEntries.logs); diff --git a/x-pack/legacy/plugins/infra/public/new_platform_plugin.ts b/x-pack/legacy/plugins/infra/public/new_platform_plugin.ts deleted file mode 100644 index f438b65794653..0000000000000 --- a/x-pack/legacy/plugins/infra/public/new_platform_plugin.ts +++ /dev/null @@ -1,74 +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 { CoreStart, CoreSetup, PluginInitializerContext } from 'kibana/public'; -import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'; -import ApolloClient from 'apollo-client'; -import { ApolloLink } from 'apollo-link'; -import { HttpLink } from 'apollo-link-http'; -import { withClientState } from 'apollo-link-state'; -import { startApp } from './apps/start_app'; -import { InfraFrontendLibs } from './lib/lib'; -import introspectionQueryResultData from './graphql/introspection.json'; -import { InfraKibanaObservableApiAdapter } from './lib/adapters/observable_api/kibana_observable_api'; -import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public'; -import { featureCatalogueEntries } from './feature_catalogue_entry'; - -type ClientPlugins = any; -type LegacyDeps = any; -interface InfraPluginSetupDependencies { - home: HomePublicPluginSetup; -} - -export class Plugin { - constructor(context: PluginInitializerContext) {} - - setup(core: CoreSetup, { home }: InfraPluginSetupDependencies) { - home.featureCatalogue.register(featureCatalogueEntries.metrics); - home.featureCatalogue.register(featureCatalogueEntries.logs); - } - - start(core: CoreStart, plugins: ClientPlugins, __LEGACY: LegacyDeps) { - startApp(this.composeLibs(core, plugins, __LEGACY), core, plugins); - } - - composeLibs(core: CoreStart, plugins: ClientPlugins, legacy: LegacyDeps) { - const cache = new InMemoryCache({ - addTypename: false, - fragmentMatcher: new IntrospectionFragmentMatcher({ - introspectionQueryResultData, - }), - }); - - const observableApi = new InfraKibanaObservableApiAdapter({ - basePath: core.http.basePath.get(), - }); - - const graphQLOptions = { - cache, - link: ApolloLink.from([ - withClientState({ - cache, - resolvers: {}, - }), - new HttpLink({ - credentials: 'same-origin', - headers: { - 'kbn-xsrf': true, - }, - uri: `${core.http.basePath.get()}/api/infra/graphql`, - }), - ]), - }; - - const apolloClient = new ApolloClient(graphQLOptions); - - const libs: InfraFrontendLibs = { - apolloClient, - observableApi, - }; - return libs; - } -} diff --git a/x-pack/legacy/plugins/infra/public/routes.tsx b/x-pack/legacy/plugins/infra/public/routes.tsx deleted file mode 100644 index fd69c6e842448..0000000000000 --- a/x-pack/legacy/plugins/infra/public/routes.tsx +++ /dev/null @@ -1,66 +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 { History } from 'history'; -import React from 'react'; -import { Route, Router, Switch } from 'react-router-dom'; - -import { NotFoundPage } from './pages/404'; -import { InfrastructurePage } from './pages/infrastructure'; -import { LinkToPage } from './pages/link_to'; -import { LogsPage } from './pages/logs'; -import { MetricDetail } from './pages/metrics'; -import { RedirectWithQueryParams } from './utils/redirect_with_query_params'; -import { useKibana } from '../../../../../src/plugins/kibana_react/public'; - -interface RouterProps { - history: History; -} - -export const PageRouter: React.FC = ({ history }) => { - const uiCapabilities = useKibana().services.application?.capabilities; - return ( - - - {uiCapabilities?.infrastructure?.show && ( - - )} - {uiCapabilities?.infrastructure?.show && ( - - )} - {uiCapabilities?.infrastructure?.show && ( - - )} - {uiCapabilities?.infrastructure?.show && ( - - )} - {uiCapabilities?.infrastructure?.show && ( - - )} - {uiCapabilities?.infrastructure?.show && ( - - )} - {uiCapabilities?.logs?.show && ( - - )} - {uiCapabilities?.logs?.show && } - {uiCapabilities?.infrastructure?.show && ( - - )} - - - - - ); -}; diff --git a/x-pack/legacy/plugins/infra/public/utils/fetch.ts b/x-pack/legacy/plugins/infra/public/utils/fetch.ts deleted file mode 100644 index 50afc64bb5b78..0000000000000 --- a/x-pack/legacy/plugins/infra/public/utils/fetch.ts +++ /dev/null @@ -1,17 +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 axios from 'axios'; -const FETCH_TIMEOUT = 30000; - -export const fetch = axios.create({ - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - 'kbn-xsrf': 'professionally-crafted-string-of-text', - }, - timeout: FETCH_TIMEOUT, -}); diff --git a/x-pack/legacy/plugins/infra/public/utils/use_kibana_injected_var.ts b/x-pack/legacy/plugins/infra/public/utils/use_kibana_injected_var.ts deleted file mode 100644 index 4afcb4fd88430..0000000000000 --- a/x-pack/legacy/plugins/infra/public/utils/use_kibana_injected_var.ts +++ /dev/null @@ -1,18 +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 { npSetup } from 'ui/new_platform'; - -/** - * This hook provides access to the "injected variables" provided by the - * platform. While it doesn't need to be a hook right now, it has been written - * as one in order to keep the API stable despite the upcoming injection - * through the context after the new platform migration. - */ -export const useKibanaInjectedVar = (name: string, defaultValue?: unknown) => { - const injectedMetadata = npSetup.core.injectedMetadata; - return injectedMetadata.getInjectedVar(name, defaultValue); -}; diff --git a/x-pack/legacy/plugins/infra/server/new_platform_index.ts b/x-pack/legacy/plugins/infra/server/new_platform_index.ts deleted file mode 100644 index e59897a6b241d..0000000000000 --- a/x-pack/legacy/plugins/infra/server/new_platform_index.ts +++ /dev/null @@ -1,15 +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 { PluginInitializerContext } from 'src/core/server'; -import { InfraServerPlugin, InfraPluginSetup } from './new_platform_plugin'; -import { config, InfraConfig } from '../../../../plugins/infra/server'; -import { InfraServerPluginDeps } from './lib/adapters/framework'; -export { config, InfraConfig, InfraServerPluginDeps, InfraPluginSetup }; - -export function plugin(context: PluginInitializerContext) { - return new InfraServerPlugin(context); -} diff --git a/x-pack/legacy/plugins/infra/server/new_platform_plugin.ts b/x-pack/legacy/plugins/infra/server/new_platform_plugin.ts deleted file mode 100644 index d3c6f7a5f70a1..0000000000000 --- a/x-pack/legacy/plugins/infra/server/new_platform_plugin.ts +++ /dev/null @@ -1,137 +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 { CoreSetup, PluginInitializerContext } from 'src/core/server'; -import { i18n } from '@kbn/i18n'; -import { Server } from 'hapi'; -import { InfraConfig } from '../../../../plugins/infra/server'; -import { initInfraServer } from './infra_server'; -import { InfraBackendLibs, InfraDomainLibs } from './lib/infra_types'; -import { FrameworkFieldsAdapter } from './lib/adapters/fields/framework_fields_adapter'; -import { KibanaFramework } from './lib/adapters/framework/kibana_framework_adapter'; -import { InfraKibanaLogEntriesAdapter } from './lib/adapters/log_entries/kibana_log_entries_adapter'; -import { KibanaMetricsAdapter } from './lib/adapters/metrics/kibana_metrics_adapter'; -import { InfraElasticsearchSourceStatusAdapter } from './lib/adapters/source_status'; -import { InfraFieldsDomain } from './lib/domains/fields_domain'; -import { InfraLogEntriesDomain } from './lib/domains/log_entries_domain'; -import { InfraMetricsDomain } from './lib/domains/metrics_domain'; -import { LogEntryCategoriesAnalysis, LogEntryRateAnalysis } from './lib/log_analysis'; -import { InfraSnapshot } from './lib/snapshot'; -import { InfraSourceStatus } from './lib/source_status'; -import { InfraSources } from './lib/sources'; -import { InfraServerPluginDeps } from './lib/adapters/framework'; -import { METRICS_FEATURE, LOGS_FEATURE } from './features'; -import { UsageCollector } from './usage/usage_collector'; -import { APP_ID } from '../index'; -import { InfraStaticSourceConfiguration } from './lib/sources/types'; - -export interface KbnServer extends Server { - usage: any; -} - -const logsSampleDataLinkLabel = i18n.translate('xpack.infra.sampleDataLinkLabel', { - defaultMessage: 'Logs', -}); - -export interface InfraPluginSetup { - defineInternalSourceConfiguration: ( - sourceId: string, - sourceProperties: InfraStaticSourceConfiguration - ) => void; -} - -const DEFAULT_CONFIG: InfraConfig = { - enabled: true, - query: { - partitionSize: 75, - partitionFactor: 1.2, - }, -}; - -export class InfraServerPlugin { - public config: InfraConfig = DEFAULT_CONFIG; - public libs: InfraBackendLibs | undefined; - - constructor(context: PluginInitializerContext) { - const config$ = context.config.create(); - config$.subscribe(configValue => { - this.config = { - ...DEFAULT_CONFIG, - enabled: configValue.enabled, - query: { - ...DEFAULT_CONFIG.query, - ...configValue.query, - }, - }; - }); - } - - getLibs() { - if (!this.libs) { - throw new Error('libs not set up yet'); - } - return this.libs; - } - - setup(core: CoreSetup, plugins: InfraServerPluginDeps) { - const framework = new KibanaFramework(core, this.config, plugins); - const sources = new InfraSources({ - config: this.config, - }); - const sourceStatus = new InfraSourceStatus( - new InfraElasticsearchSourceStatusAdapter(framework), - { - sources, - } - ); - const snapshot = new InfraSnapshot({ sources, framework }); - const logEntryCategoriesAnalysis = new LogEntryCategoriesAnalysis({ framework }); - const logEntryRateAnalysis = new LogEntryRateAnalysis({ framework }); - - // TODO: separate these out individually and do away with "domains" as a temporary group - const domainLibs: InfraDomainLibs = { - fields: new InfraFieldsDomain(new FrameworkFieldsAdapter(framework), { - sources, - }), - logEntries: new InfraLogEntriesDomain(new InfraKibanaLogEntriesAdapter(framework), { - sources, - }), - metrics: new InfraMetricsDomain(new KibanaMetricsAdapter(framework)), - }; - - this.libs = { - configuration: this.config, - framework, - logEntryCategoriesAnalysis, - logEntryRateAnalysis, - snapshot, - sources, - sourceStatus, - ...domainLibs, - }; - - plugins.features.registerFeature(METRICS_FEATURE); - plugins.features.registerFeature(LOGS_FEATURE); - - plugins.home.sampleData.addAppLinksToSampleDataset('logs', [ - { - path: `/app/${APP_ID}#/logs`, - label: logsSampleDataLinkLabel, - icon: 'logsApp', - }, - ]); - - initInfraServer(this.libs); - - // Telemetry - UsageCollector.registerUsageCollector(plugins.usageCollection); - - return { - defineInternalSourceConfiguration(sourceId, sourceProperties) { - sources.defineInternalSourceConfiguration(sourceId, sourceProperties); - }, - } as InfraPluginSetup; - } -} diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/types.ts b/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/types.ts deleted file mode 100644 index f4c5e26c5c6d1..0000000000000 --- a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/types.ts +++ /dev/null @@ -1,36 +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 rt from 'io-ts'; -import { - metricsExplorerMetricRT, - metricsExplorerPageInfoRT, - metricsExplorerColumnRT, - metricsExplorerRowRT, - metricsExplorerSeriesRT, - metricsExplorerRequestBodyRT, - metricsExplorerResponseRT, - metricsExplorerAggregationRT, - metricsExplorerColumnTypeRT, -} from '../../../common/http_api'; - -export type MetricsExplorerAggregation = rt.TypeOf; - -export type MetricsExplorerColumnType = rt.TypeOf; - -export type MetricsExplorerMetric = rt.TypeOf; - -export type MetricsExplorerPageInfo = rt.TypeOf; - -export type MetricsExplorerColumn = rt.TypeOf; - -export type MetricsExplorerRow = rt.TypeOf; - -export type MetricsExplorerSeries = rt.TypeOf; - -export type MetricsExplorerRequestBody = rt.TypeOf; - -export type MetricsExplorerResponse = rt.TypeOf; diff --git a/x-pack/legacy/plugins/infra/tsconfig.json b/x-pack/legacy/plugins/infra/tsconfig.json deleted file mode 100644 index 0a26f297882e4..0000000000000 --- a/x-pack/legacy/plugins/infra/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../../tsconfig.json", -} \ No newline at end of file diff --git a/x-pack/legacy/plugins/infra/yarn.lock b/x-pack/legacy/plugins/infra/yarn.lock deleted file mode 120000 index 4b16253de2abe..0000000000000 --- a/x-pack/legacy/plugins/infra/yarn.lock +++ /dev/null @@ -1 +0,0 @@ -../../../../yarn.lock \ No newline at end of file diff --git a/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap b/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap index de02fb10a5937..a8eebdaf6aa39 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap +++ b/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap @@ -13,7 +13,7 @@ exports[`Logs should render a link to filter by cluster uuid 1`] = ` values={ Object { "link": Logs , @@ -37,7 +37,7 @@ exports[`Logs should render a link to filter by cluster uuid and index uuid 1`] values={ Object { "link": Logs , @@ -61,7 +61,7 @@ exports[`Logs should render a link to filter by cluster uuid and node uuid 1`] = values={ Object { "link": Logs , @@ -287,7 +287,7 @@ exports[`Logs should render normally 1`] = ` values={ Object { "link": Logs , diff --git a/x-pack/legacy/plugins/monitoring/public/components/logs/logs.js b/x-pack/legacy/plugins/monitoring/public/components/logs/logs.js index 744ebb5a7ceb4..3590199048352 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/logs/logs.js +++ b/x-pack/legacy/plugins/monitoring/public/components/logs/logs.js @@ -110,7 +110,7 @@ const clusterColumns = [ ]; function getLogsUiLink(clusterUuid, nodeId, indexUuid) { - const base = `${chrome.getBasePath()}/app/infra#/link-to/${INFRA_SOURCE_ID}/logs`; + const base = `${chrome.getBasePath()}/app/logs/link-to/${INFRA_SOURCE_ID}/logs`; const params = []; if (clusterUuid) { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts index d410a89cf0723..ccd6ae818c6cd 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts @@ -4,92 +4,66 @@ * you may not use this file except in compliance with the Elastic License. */ -import { drag, drop } from '../../lib/drag_n_drop/helpers'; -import { populateTimeline } from '../../lib/fields_browser/helpers'; -import { createNewTimeline, toggleFirstTimelineEventDetails } from '../../lib/timeline/helpers'; -import { HOSTS_PAGE } from '../../lib/urls'; -import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../lib/util/helpers'; +import { HOSTS_PAGE } from '../../../urls/navigation'; +import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login'; +import { + createNewTimeline, + populateTimeline, + expandFirstTimelineEventDetails, + uncheckTimestampToggleField, + checkIdToggleField, + dragAndDropIdToggleFieldToTimeline, +} from '../../../tasks/timeline/main'; +import { openTimeline } from '../../../tasks/siem_main'; +import { + TIMESTAMP_TOGGLE_FIELD, + ID_TOGGLE_FIELD, + TIMESTAMP_HEADER_FIELD, + ID_HEADER_FIELD, +} from '../../../screens/timeline/main'; describe('toggle column in timeline', () => { before(() => { loginAndWaitForPage(HOSTS_PAGE); }); + beforeEach(() => { + openTimeline(); + populateTimeline(); + }); + afterEach(() => { createNewTimeline(); }); - const timestampField = '@timestamp'; - const idField = '_id'; - it('displays a checked Toggle field checkbox for `@timestamp`, a default timeline column', () => { - populateTimeline(); - - toggleFirstTimelineEventDetails(); - - cy.get(`[data-test-subj="toggle-field-${timestampField}"]`).should('be.checked'); + expandFirstTimelineEventDetails(); + cy.get(TIMESTAMP_TOGGLE_FIELD).should('be.checked'); }); it('displays an Unchecked Toggle field checkbox for `_id`, because it is NOT a default timeline column', () => { - populateTimeline(); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="toggle-field-${idField}"]`).should( - 'not.be.checked' - ); + cy.get(ID_TOGGLE_FIELD).should('not.be.checked'); }); it('removes the @timestamp field from the timeline when the user un-checks the toggle', () => { - populateTimeline(); - - toggleFirstTimelineEventDetails(); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${timestampField}"]`).should( - 'exist' - ); + expandFirstTimelineEventDetails(); + uncheckTimestampToggleField(); - cy.get(`[data-test-subj="timeline"] [data-test-subj="toggle-field-${timestampField}"]`, { - timeout: DEFAULT_TIMEOUT, - }).uncheck({ force: true }); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${timestampField}"]`).should( - 'not.exist' - ); + cy.get(TIMESTAMP_HEADER_FIELD).should('not.exist'); }); it('adds the _id field to the timeline when the user checks the field', () => { - populateTimeline(); - - toggleFirstTimelineEventDetails(); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${idField}"]`).should( - 'not.exist' - ); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="toggle-field-${idField}"]`).check({ - force: true, - }); + expandFirstTimelineEventDetails(); + checkIdToggleField(); - cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${idField}"]`).should('exist'); + cy.get(ID_HEADER_FIELD).should('exist'); }); it('adds the _id field to the timeline via drag and drop', () => { - populateTimeline(); - - toggleFirstTimelineEventDetails(); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${idField}"]`).should( - 'not.exist' - ); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="field-name-${idField}"]`).then(field => - drag(field) - ); - - cy.get(`[data-test-subj="timeline"] [data-test-subj="headers-group"]`).then(headersDropArea => - drop(headersDropArea) - ); + expandFirstTimelineEventDetails(); + dragAndDropIdToggleFieldToTimeline(); - cy.get(`[data-test-subj="timeline"] [data-test-subj="header-text-${idField}"]`, { + cy.get(ID_HEADER_FIELD, { timeout: DEFAULT_TIMEOUT, }).should('exist'); }); diff --git a/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts b/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts index 4c722ffa5f215..7b47c159c4a0a 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts @@ -37,3 +37,15 @@ export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]'; export const TIMELINE_NOT_READY_TO_DROP_BUTTON = '[data-test-subj="flyout-button-not-ready-to-drop"]'; + +export const TOGGLE_TIMELINE_EXPAND_EVENT = '[data-test-subj="expand-event"]'; + +export const TIMESTAMP_TOGGLE_FIELD = '[data-test-subj="toggle-field-@timestamp"]'; + +export const ID_TOGGLE_FIELD = '[data-test-subj="toggle-field-_id"]'; + +export const TIMESTAMP_HEADER_FIELD = '[data-test-subj="header-text-@timestamp"]'; + +export const ID_HEADER_FIELD = '[data-test-subj="timeline"] [data-test-subj="header-text-_id"]'; + +export const ID_FIELD = '[data-test-subj="timeline"] [data-test-subj="field-name-_id"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts b/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts index f347c072a3584..d26c0f2911f75 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts @@ -14,12 +14,19 @@ import { TIMELINE_INSPECT_BUTTON, CREATE_NEW_TIMELINE, CLOSE_TIMELINE_BTN, + TOGGLE_TIMELINE_EXPAND_EVENT, + TIMESTAMP_TOGGLE_FIELD, + ID_TOGGLE_FIELD, + ID_HEADER_FIELD, + ID_FIELD, } from '../../screens/timeline/main'; +import { drag, drop } from '../../tasks/common'; + export const hostExistsQuery = 'host.name: *'; export const populateTimeline = () => { - cy.get(`${SEARCH_OR_FILTER_CONTAINER} input`).type(`${hostExistsQuery} {enter}`); + executeTimelineKQL(hostExistsQuery); cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) .invoke('text') .should('be.above', 0); @@ -47,3 +54,35 @@ export const createNewTimeline = () => { cy.get(CREATE_NEW_TIMELINE).click(); cy.get(CLOSE_TIMELINE_BTN).click({ force: true }); }; + +export const expandFirstTimelineEventDetails = () => { + cy.get(TOGGLE_TIMELINE_EXPAND_EVENT, { timeout: DEFAULT_TIMEOUT }) + .first() + .click({ force: true }); +}; + +export const uncheckTimestampToggleField = () => { + cy.get(TIMESTAMP_TOGGLE_FIELD).should('exist'); + + cy.get(TIMESTAMP_TOGGLE_FIELD, { + timeout: DEFAULT_TIMEOUT, + }).uncheck({ force: true }); +}; + +export const checkIdToggleField = () => { + cy.get(ID_TOGGLE_FIELD).should('not.exist'); + + cy.get(ID_TOGGLE_FIELD).check({ + force: true, + }); +}; + +export const dragAndDropIdToggleFieldToTimeline = () => { + cy.get(ID_HEADER_FIELD).should('not.exist'); + + cy.get(ID_FIELD).then(field => drag(field)); + + cy.get(`[data-test-subj="timeline"] [data-test-subj="headers-group"]`).then(headersDropArea => + drop(headersDropArea) + ); +}; diff --git a/x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js b/x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js index 7d76b1dd921aa..8ca61b2397d8b 100644 --- a/x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js +++ b/x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js @@ -21,8 +21,7 @@ run( ); const circularFound = result.circular(); - // We can only care about SIEM code, we should not be penalyze for others - if (circularFound.filter(cf => cf.includes('siem')).length !== 0) { + if (circularFound.length !== 0) { throw createFailError( `SIEM circular dependencies of imports has been found:\n - ${circularFound.join('\n - ')}` ); diff --git a/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts b/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts index af9a5ab765571..b12bd1b6c2a51 100644 --- a/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts +++ b/x-pack/legacy/plugins/siem/public/components/alerts_viewer/default_headers.ts @@ -4,12 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers'; -import { DEFAULT_COLUMN_MIN_WIDTH, DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; -import { timelineDefaults, SubsetTimelineModel } from '../../store/timeline/model'; +import { + DEFAULT_COLUMN_MIN_WIDTH, + DEFAULT_DATE_COLUMN_MIN_WIDTH, +} from '../timeline/body/constants'; +import { ColumnHeaderOptions, SubsetTimelineModel } from '../../store/timeline/model'; +import { timelineDefaults } from '../../store/timeline/defaults'; -export const alertsHeaders: ColumnHeader[] = [ +export const alertsHeaders: ColumnHeaderOptions[] = [ { columnHeaderType: defaultColumnHeaderType, id: '@timestamp', diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts index ae3a8828491e3..82ddd2c9f29d7 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts @@ -11,8 +11,8 @@ import { ActionCreator } from 'typescript-fsa'; import { BrowserFields, getAllFieldsByName } from '../../containers/source'; import { IdToDataProvider } from '../../store/drag_and_drop/model'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; -import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; +import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; import { DataProvider } from '../timeline/data_providers/data_provider'; import { dragAndDropActions, timelineActions } from '../../store/actions'; @@ -124,7 +124,7 @@ interface AddProviderToTimelineParams { interface AddFieldToTimelineColumnsParams { upsertColumn?: ActionCreator<{ - column: ColumnHeader; + column: ColumnHeaderOptions; id: string; index: number; }>; diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx index 1962850425baa..e9903ce66d799 100644 --- a/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx +++ b/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx @@ -22,6 +22,7 @@ import styled from 'styled-components'; import { BrowserFields } from '../../containers/source'; import { ToStringArray } from '../../graphql/types'; import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { DragEffects } from '../drag_and_drop/draggable_wrapper'; import { DroppableWrapper } from '../drag_and_drop/droppable_wrapper'; import { getDroppableId, getDraggableFieldId, DRAG_TYPE_FIELD } from '../drag_and_drop/helpers'; @@ -29,9 +30,8 @@ import { DraggableFieldBadge } from '../draggables/field_badge'; import { FieldName } from '../fields_browser/field_name'; import { SelectableText } from '../selectable_text'; import { OverflowField } from '../tables/helpers'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers'; -import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; import { MESSAGE_FIELD_NAME } from '../timeline/body/renderers/constants'; import { FormattedFieldValue } from '../timeline/body/renderers/formatted_field'; import { OnUpdateColumns } from '../timeline/events'; @@ -63,11 +63,11 @@ export const getColumns = ({ toggleColumn, }: { browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; eventId: string; onUpdateColumns: OnUpdateColumns; contextId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; }) => [ { field: 'field', diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/event_details.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/event_details.tsx index f77c703f064f6..9234fe44320f0 100644 --- a/x-pack/legacy/plugins/siem/public/components/event_details/event_details.tsx +++ b/x-pack/legacy/plugins/siem/public/components/event_details/event_details.tsx @@ -10,7 +10,7 @@ import styled from 'styled-components'; import { BrowserFields } from '../../containers/source'; import { DetailItem } from '../../graphql/types'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { OnUpdateColumns } from '../timeline/events'; import { EventFieldsBrowser } from './event_fields_browser'; import { JsonView } from './json_view'; @@ -20,14 +20,14 @@ export type View = 'table-view' | 'json-view'; interface Props { browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; data: DetailItem[]; id: string; view: View; onUpdateColumns: OnUpdateColumns; onViewSelected: (selected: View) => void; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } const Details = styled.div` diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.tsx index f4e9a2b789d71..9a842339cb62e 100644 --- a/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.tsx +++ b/x-pack/legacy/plugins/siem/public/components/event_details/event_fields_browser.tsx @@ -8,7 +8,7 @@ import { sortBy } from 'lodash'; import { EuiInMemoryTable } from '@elastic/eui'; import React, { useMemo } from 'react'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { BrowserFields, getAllFieldsByName } from '../../containers/source'; import { DetailItem } from '../../graphql/types'; import { OnUpdateColumns } from '../timeline/events'; @@ -18,12 +18,12 @@ import { search } from './helpers'; interface Props { browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; data: DetailItem[]; eventId: string; onUpdateColumns: OnUpdateColumns; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } /** Renders a table view or JSON view of the `ECS` `data` */ diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/helpers.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/helpers.tsx index a4ec8ff2c4907..5d9c9d82490bb 100644 --- a/x-pack/legacy/plugins/siem/public/components/event_details/helpers.tsx +++ b/x-pack/legacy/plugins/siem/public/components/event_details/helpers.tsx @@ -7,8 +7,11 @@ import { get, getOr, isEmpty, uniqBy } from 'lodash/fp'; import { BrowserField, BrowserFields } from '../../containers/source'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; -import { DEFAULT_DATE_COLUMN_MIN_WIDTH, DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; +import { + DEFAULT_DATE_COLUMN_MIN_WIDTH, + DEFAULT_COLUMN_MIN_WIDTH, +} from '../timeline/body/constants'; import { ToStringArray } from '../../graphql/types'; import * as i18n from './translations'; @@ -46,7 +49,7 @@ export const getColumnHeaderFromBrowserField = ({ }: { browserField: Partial; width?: number; -}): ColumnHeader => ({ +}): ColumnHeaderOptions => ({ category: browserField.category, columnHeaderType: 'not-filtered', description: browserField.description != null ? browserField.description : undefined, @@ -68,7 +71,7 @@ export const getColumnsWithTimestamp = ({ }: { browserFields: BrowserFields; category: string; -}): ColumnHeader[] => { +}): ColumnHeaderOptions[] => { const emptyFields: Record> = {}; const timestamp = get('base.fields.@timestamp', browserFields); const categoryFields: Array> = [ diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/stateful_event_details.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/stateful_event_details.tsx index c614fd52316bc..c79f02740253a 100644 --- a/x-pack/legacy/plugins/siem/public/components/event_details/stateful_event_details.tsx +++ b/x-pack/legacy/plugins/siem/public/components/event_details/stateful_event_details.tsx @@ -7,20 +7,20 @@ import React, { useCallback, useState } from 'react'; import { BrowserFields } from '../../containers/source'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { DetailItem } from '../../graphql/types'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { OnUpdateColumns } from '../timeline/events'; import { EventDetails, View } from './event_details'; interface Props { browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; data: DetailItem[]; id: string; onUpdateColumns: OnUpdateColumns; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } export const StatefulEventDetails = React.memo( diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/default_headers.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/default_headers.tsx index fed61c3bdd215..b97e0da5df078 100644 --- a/x-pack/legacy/plugins/siem/public/components/events_viewer/default_headers.tsx +++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/default_headers.tsx @@ -4,11 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers'; -import { DEFAULT_COLUMN_MIN_WIDTH, DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { + DEFAULT_COLUMN_MIN_WIDTH, + DEFAULT_DATE_COLUMN_MIN_WIDTH, +} from '../timeline/body/constants'; -export const defaultHeaders: ColumnHeader[] = [ +export const defaultHeaders: ColumnHeaderOptions[] = [ { columnHeaderType: defaultColumnHeaderType, id: '@timestamp', diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/default_model.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/default_model.tsx index ac385057406e2..59a9f6d061c8d 100644 --- a/x-pack/legacy/plugins/siem/public/components/events_viewer/default_model.tsx +++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/default_model.tsx @@ -5,7 +5,8 @@ */ import { defaultHeaders } from './default_headers'; -import { SubsetTimelineModel, timelineDefaults } from '../../store/timeline/model'; +import { SubsetTimelineModel } from '../../store/timeline/model'; +import { timelineDefaults } from '../../store/timeline/defaults'; export const eventsDefaultModel: SubsetTimelineModel = { ...timelineDefaults, 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 cbce1f635310a..b05529f9a497f 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 @@ -15,9 +15,8 @@ import { BrowserFields } from '../../containers/source'; import { TimelineQuery } from '../../containers/timeline'; import { Direction } from '../../graphql/types'; import { useKibana } from '../../lib/kibana'; -import { KqlMode } from '../../store/timeline/model'; +import { ColumnHeaderOptions, KqlMode } from '../../store/timeline/model'; import { HeaderSection } from '../header_section'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { defaultHeaders } from '../timeline/body/column_headers/default_headers'; import { Sort } from '../timeline/body/sort'; import { StatefulBody } from '../timeline/body/stateful_body'; @@ -50,7 +49,7 @@ const StyledEuiPanel = styled(EuiPanel)` interface Props { browserFields: BrowserFields; - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; dataProviders: DataProvider[]; deletedEventIds: Readonly; end: number; @@ -68,7 +67,7 @@ interface Props { start: number; sort: Sort; timelineTypeContext: TimelineTypeContextProps; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; utilityBar?: (refetch: inputsModel.Refetch, totalCount: number) => React.ReactNode; } 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 1e7c7fc2411bb..762ae8497dadb 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 @@ -7,10 +7,14 @@ import { isEqual } from 'lodash/fp'; import React, { useCallback, useMemo, useEffect } from 'react'; import { connect, ConnectedProps } from 'react-redux'; + import { inputsModel, inputsSelectors, State, timelineSelectors } from '../../store'; import { inputsActions, timelineActions } from '../../store/actions'; -import { SubsetTimelineModel, TimelineModel } from '../../store/timeline/model'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { + ColumnHeaderOptions, + SubsetTimelineModel, + TimelineModel, +} from '../../store/timeline/model'; import { OnChangeItemsPerPage } from '../timeline/events'; import { Filter } from '../../../../../../../src/plugins/data/public'; @@ -86,7 +90,7 @@ const StatefulEventsViewerComponent: React.FC = ({ ); const toggleColumn = useCallback( - (column: ColumnHeader) => { + (column: ColumnHeaderOptions) => { const exists = columns.findIndex(c => c.id === column.id) !== -1; if (!exists && upsertColumn != null) { diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_browser.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_browser.tsx index c8a0eb9da688b..02aeab74f8bab 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_browser.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_browser.tsx @@ -10,7 +10,7 @@ import { noop } from 'lodash/fp'; import styled from 'styled-components'; import { BrowserFields } from '../../containers/source'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { CategoriesPane } from './categories_pane'; import { FieldsPane } from './fields_pane'; import { Header } from './header'; @@ -57,7 +57,7 @@ type Props = Pick< /** * The current timeline column headers */ - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; /** * A map of categoryId -> metadata about the fields in that category, * filtered such that the name of every field in the category includes @@ -95,7 +95,7 @@ type Props = Pick< /** * Invoked to add or remove a column from the timeline */ - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; }; /** diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.test.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.test.tsx index 4d0c707c46910..226b56dad8c4f 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.test.tsx @@ -9,9 +9,9 @@ import React from 'react'; import { mockBrowserFields } from '../../containers/source/mock'; import { TestProviders } from '../../mock'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers'; -import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; import { Category } from './category'; import { getFieldColumns, getFieldItems } from './field_items'; @@ -21,7 +21,7 @@ import { useMountAppended } from '../../utils/use_mount_appended'; const selectedCategoryId = 'base'; const selectedCategoryFields = mockBrowserFields[selectedCategoryId].fields; const timestampFieldId = '@timestamp'; -const columnHeaders: ColumnHeader[] = [ +const columnHeaders: ColumnHeaderOptions[] = [ { category: 'base', columnHeaderType: defaultColumnHeaderType, diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.tsx index 778e9d3d3c744..990c2678b1006 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_items.tsx @@ -13,6 +13,7 @@ import { Draggable } from 'react-beautiful-dnd'; import styled from 'styled-components'; import { BrowserField, BrowserFields } from '../../containers/source'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { DragEffects } from '../drag_and_drop/draggable_wrapper'; import { DroppableWrapper } from '../drag_and_drop/droppable_wrapper'; import { getDraggableFieldId, getDroppableId, DRAG_TYPE_FIELD } from '../drag_and_drop/helpers'; @@ -20,9 +21,8 @@ import { DraggableFieldBadge } from '../draggables/field_badge'; import { getEmptyValue } from '../empty_value'; import { getColumnsWithTimestamp, getExampleText, getIconFromType } from '../event_details/helpers'; import { SelectableText } from '../selectable_text'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers'; -import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; import { OnUpdateColumns } from '../timeline/events'; import { TruncatableText } from '../truncatable_text'; import { FieldName } from './field_name'; @@ -68,10 +68,10 @@ export const getFieldItems = ({ browserFields: BrowserFields; category: Partial; categoryId: string; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; highlight?: string; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; onUpdateColumns: OnUpdateColumns; }): FieldItem[] => uniqBy('name', [ diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx index b8fbe46baa9c5..fe434a6ad63ce 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx @@ -18,7 +18,7 @@ import React, { useContext } from 'react'; import styled from 'styled-components'; import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { OnUpdateColumns } from '../timeline/events'; import { TimelineContext } from '../timeline/timeline_context'; import { WithHoverActions } from '../with_hover_actions'; @@ -107,7 +107,7 @@ ViewCategoryIcon.displayName = 'ViewCategoryIcon'; interface ToolTipProps { categoryId: string; onUpdateColumns: OnUpdateColumns; - categoryColumns: ColumnHeader[]; + categoryColumns: ColumnHeaderOptions[]; } const ViewCategory = React.memo( @@ -138,7 +138,7 @@ ViewCategory.displayName = 'ViewCategory'; /** Renders a field name in it's non-dragging state */ export const FieldName = React.memo<{ categoryId: string; - categoryColumns: ColumnHeader[]; + categoryColumns: ColumnHeaderOptions[]; fieldId: string; highlight?: string; onUpdateColumns: OnUpdateColumns; diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/fields_pane.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/fields_pane.tsx index fba6e22e4b21f..354b2ae5e5eb8 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/fields_pane.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/fields_pane.tsx @@ -9,7 +9,7 @@ import React from 'react'; import styled from 'styled-components'; import { BrowserFields } from '../../containers/source'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { Category } from './category'; import { FieldBrowserProps } from './types'; @@ -33,7 +33,7 @@ const NoFieldsFlexGroup = styled(EuiFlexGroup)` NoFieldsFlexGroup.displayName = 'NoFieldsFlexGroup'; type Props = Pick & { - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; /** * A map of categoryId -> metadata about the fields in that category, * filtered such that the name of every field in the category includes @@ -56,7 +56,7 @@ type Props = Pick void; + toggleColumn: (column: ColumnHeaderOptions) => void; }; export const FieldsPane = React.memo( ({ diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/index.test.tsx index cf9e4f57d67b7..9e513b890e722 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/index.test.tsx @@ -10,11 +10,11 @@ import { ActionCreator } from 'typescript-fsa'; import { mockBrowserFields } from '../../containers/source/mock'; import { TestProviders } from '../../mock'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { FIELD_BROWSER_HEIGHT, FIELD_BROWSER_WIDTH } from './helpers'; import { StatefulFieldsBrowserComponent } from '.'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; // Suppress warnings about "react-beautiful-dnd" until we migrate to @testing-library/react /* eslint-disable no-console */ @@ -35,7 +35,7 @@ const removeColumnMock = (jest.fn() as unknown) as ActionCreator<{ }>; const upsertColumnMock = (jest.fn() as unknown) as ActionCreator<{ - column: ColumnHeader; + column: ColumnHeaderOptions; id: string; index: number; }>; diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/index.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/index.tsx index b545c6890bd41..3e19ba383b4ec 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/index.tsx @@ -12,7 +12,7 @@ import styled from 'styled-components'; import { BrowserFields } from '../../containers/source'; import { timelineActions } from '../../store/actions'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { DEFAULT_CATEGORY_NAME } from '../timeline/body/column_headers/default_headers'; import { FieldsBrowser } from './field_browser'; import { filterBrowserFieldsByFieldName, mergeBrowserFieldsWithDefaultCategory } from './helpers'; @@ -124,7 +124,7 @@ export const StatefulFieldsBrowserComponent = React.memo { + const updateColumnsAndSelectCategoryId = useCallback((columns: ColumnHeaderOptions[]) => { onUpdateColumns(columns); // show the category columns in the timeline }, []); diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/types.ts b/x-pack/legacy/plugins/siem/public/components/fields_browser/types.ts index 21d2d65168fa4..d6b1936fcc52f 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/types.ts +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/types.ts @@ -5,15 +5,15 @@ */ import { BrowserFields } from '../../containers/source'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { OnUpdateColumns } from '../timeline/events'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; export type OnFieldSelected = (fieldId: string) => void; export type OnHideFieldBrowser = () => void; export interface FieldBrowserProps { /** The timeline's current column headers */ - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; /** A map of categoryId -> metadata about the fields in that category */ browserFields: BrowserFields; /** The height of the field browser */ @@ -31,7 +31,7 @@ export interface FieldBrowserProps { /** The timeline associated with this field browser */ timelineId: string; /** Adds or removes a column to / from the timeline */ - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; /** The width of the field browser */ width: number; } diff --git a/x-pack/legacy/plugins/siem/public/components/flyout/header/index.tsx b/x-pack/legacy/plugins/siem/public/components/flyout/header/index.tsx index 901f7afd1ed48..06e77b51787be 100644 --- a/x-pack/legacy/plugins/siem/public/components/flyout/header/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/flyout/header/index.tsx @@ -23,8 +23,9 @@ import { Properties } from '../../timeline/properties'; import { appActions } from '../../../store/app'; import { inputsActions } from '../../../store/inputs'; import { timelineActions } from '../../../store/actions'; -import { timelineDefaults, TimelineModel } from '../../../store/timeline/model'; -import { DEFAULT_TIMELINE_WIDTH } from '../../timeline/body/helpers'; +import { TimelineModel } from '../../../store/timeline/model'; +import { timelineDefaults } from '../../../store/timeline/defaults'; +import { DEFAULT_TIMELINE_WIDTH } from '../../timeline/body/constants'; import { InputsModelId } from '../../../store/inputs/constants'; interface OwnProps { diff --git a/x-pack/legacy/plugins/siem/public/components/flyout/index.tsx b/x-pack/legacy/plugins/siem/public/components/flyout/index.tsx index d18c22e44ce94..eb41773bb21c8 100644 --- a/x-pack/legacy/plugins/siem/public/components/flyout/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/flyout/index.tsx @@ -15,7 +15,7 @@ import { DataProvider } from '../timeline/data_providers/data_provider'; import { FlyoutButton } from './button'; import { Pane } from './pane'; import { timelineActions } from '../../store/actions'; -import { DEFAULT_TIMELINE_WIDTH } from '../timeline/body/helpers'; +import { DEFAULT_TIMELINE_WIDTH } from '../timeline/body/constants'; /** The height in pixels of the flyout header, exported for use in height calculations */ export const flyoutHeaderHeight: number = 60; diff --git a/x-pack/legacy/plugins/siem/public/components/navigation/helpers.ts b/x-pack/legacy/plugins/siem/public/components/navigation/helpers.ts index f010cd67c10bc..9a95d93a2df70 100644 --- a/x-pack/legacy/plugins/siem/public/components/navigation/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/navigation/helpers.ts @@ -8,8 +8,9 @@ import { isEmpty } from 'lodash/fp'; import { Location } from 'history'; import { UrlInputsModel } from '../../store/inputs/model'; +import { TimelineUrl } from '../../store/timeline/model'; import { CONSTANTS } from '../url_state/constants'; -import { URL_STATE_KEYS, KeyUrlState, Timeline } from '../url_state/types'; +import { URL_STATE_KEYS, KeyUrlState } from '../url_state/types'; import { replaceQueryStringInLocation, replaceStateKeyInQueryString, @@ -24,7 +25,7 @@ export const getSearch = (tab: SearchNavTab, urlState: TabNavigationProps): stri if (tab && tab.urlKey != null && URL_STATE_KEYS[tab.urlKey] != null) { return URL_STATE_KEYS[tab.urlKey].reduce( (myLocation: Location, urlKey: KeyUrlState) => { - let urlStateToReplace: UrlInputsModel | Query | Filter[] | Timeline | string = ''; + let urlStateToReplace: UrlInputsModel | Query | Filter[] | TimelineUrl | string = ''; if (urlKey === CONSTANTS.appQuery && urlState.query != null) { if (urlState.query.query === '') { diff --git a/x-pack/legacy/plugins/siem/public/components/navigation/tab_navigation/types.ts b/x-pack/legacy/plugins/siem/public/components/navigation/tab_navigation/types.ts index bf8e036ad5ce4..fe701ad115d17 100644 --- a/x-pack/legacy/plugins/siem/public/components/navigation/tab_navigation/types.ts +++ b/x-pack/legacy/plugins/siem/public/components/navigation/tab_navigation/types.ts @@ -6,8 +6,8 @@ import { UrlInputsModel } from '../../../store/inputs/model'; import { CONSTANTS } from '../../url_state/constants'; -import { Timeline } from '../../url_state/types'; import { HostsTableType } from '../../../store/hosts/model'; +import { TimelineUrl } from '../../../store/timeline/model'; import { Filter, Query } from '../../../../../../../../src/plugins/data/public'; import { SiemNavigationProps } from '../types'; @@ -20,7 +20,7 @@ export interface TabNavigationProps extends SiemNavigationProps { [CONSTANTS.filters]?: Filter[]; [CONSTANTS.savedQuery]?: string; [CONSTANTS.timerange]: UrlInputsModel; - [CONSTANTS.timeline]: Timeline; + [CONSTANTS.timeline]: TimelineUrl; } export interface TabNavigationItemProps { diff --git a/x-pack/legacy/plugins/siem/public/components/navigation/types.ts b/x-pack/legacy/plugins/siem/public/components/navigation/types.ts index cc60c470e21f3..96a70e0bc70cc 100644 --- a/x-pack/legacy/plugins/siem/public/components/navigation/types.ts +++ b/x-pack/legacy/plugins/siem/public/components/navigation/types.ts @@ -7,8 +7,8 @@ import { Filter, Query } from '../../../../../../../src/plugins/data/public'; import { HostsTableType } from '../../store/hosts/model'; import { UrlInputsModel } from '../../store/inputs/model'; +import { TimelineUrl } from '../../store/timeline/model'; import { CONSTANTS, UrlStateType } from '../url_state/constants'; -import { Timeline } from '../url_state/types'; export interface SiemNavigationProps { display?: 'default' | 'condensed'; @@ -24,7 +24,7 @@ export interface SiemNavigationComponentProps { [CONSTANTS.filters]?: Filter[]; [CONSTANTS.savedQuery]?: string; [CONSTANTS.timerange]: UrlInputsModel; - [CONSTANTS.timeline]: Timeline; + [CONSTANTS.timeline]: TimelineUrl; }; } diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts b/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts index 2228ee4262400..120d644b3b33a 100644 --- a/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts +++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts @@ -6,7 +6,7 @@ import { cloneDeep, omit } from 'lodash/fp'; import { mockTimelineResults } from '../../mock/timeline_results'; -import { timelineDefaults } from '../../store/timeline/model'; +import { timelineDefaults } from '../../store/timeline/defaults'; import { defaultTimelineToTimelineModel, getNotesCount, diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.ts b/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.ts index 61c3d9f73e0d0..4f7d6cd64f1d9 100644 --- a/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.ts @@ -19,13 +19,16 @@ import { addTimeline as dispatchAddTimeline, } from '../../store/timeline/actions'; -import { TimelineModel, timelineDefaults } from '../../store/timeline/model'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions, TimelineModel } from '../../store/timeline/model'; +import { timelineDefaults } from '../../store/timeline/defaults'; import { defaultColumnHeaderType, defaultHeaders, } from '../timeline/body/column_headers/default_headers'; -import { DEFAULT_DATE_COLUMN_MIN_WIDTH, DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/helpers'; +import { + DEFAULT_DATE_COLUMN_MIN_WIDTH, + DEFAULT_COLUMN_MIN_WIDTH, +} from '../timeline/body/constants'; import { OpenTimelineResult, UpdateTimeline, DispatchUpdateTimeline } from './types'; import { getTimeRangeSettings } from '../../utils/default_date_settings'; @@ -78,7 +81,7 @@ export const defaultTimelineToTimelineModel = ( columns: timeline.columns != null ? timeline.columns.map(col => { - const timelineCols: ColumnHeader = { + const timelineCols: ColumnHeaderOptions = { ...col, columnHeaderType: defaultColumnHeaderType, id: col.id != null ? col.id : 'unknown', diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx b/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx index daa64f9f16c83..26a7487fee52b 100644 --- a/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/index.tsx @@ -15,12 +15,12 @@ import { AllTimelinesVariables, AllTimelinesQuery } from '../../containers/timel import { allTimelinesQuery } from '../../containers/timeline/all/index.gql_query'; import { DeleteTimelineMutation, SortFieldTimeline, Direction } from '../../graphql/types'; import { State, timelineSelectors } from '../../store'; -import { timelineDefaults, TimelineModel } from '../../store/timeline/model'; +import { ColumnHeaderOptions, TimelineModel } from '../../store/timeline/model'; +import { timelineDefaults } from '../../store/timeline/defaults'; import { createTimeline as dispatchCreateNewTimeline, updateIsLoading as dispatchUpdateIsLoading, } from '../../store/timeline/actions'; -import { ColumnHeader } from '../timeline/body/column_headers/column_header'; import { OpenTimeline } from './open_timeline'; import { OPEN_TIMELINE_CLASS_NAME, queryTimelineById, dispatchUpdateTimeline } from './helpers'; import { OpenTimelineModalBody } from './open_timeline_modal/open_timeline_modal_body'; @@ -335,7 +335,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ show, }: { id: string; - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; show?: boolean; }) => dispatch(dispatchCreateNewTimeline({ id, columns, show })), updateIsLoading: ({ id, isLoading }: { id: string; isLoading: boolean }) => diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/actions/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/actions/index.test.tsx index 9351fddd90dd5..6055745e9378e 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/actions/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/actions/index.test.tsx @@ -7,7 +7,7 @@ import { mount } from 'enzyme'; import React from 'react'; import { TestProviders } from '../../../../mock'; -import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../helpers'; +import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../constants'; import { Actions } from '.'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/actions/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/actions/index.tsx index 64e8aa3c7e7b7..d9e04ad873537 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/actions/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/actions/index.tsx @@ -7,15 +7,16 @@ import { EuiButtonIcon } from '@elastic/eui'; import React from 'react'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { OnColumnRemoved } from '../../../events'; import { EventsHeadingExtra, EventsLoading } from '../../../styles'; import { useTimelineContext } from '../../../timeline_context'; import { Sort } from '../../sort'; -import { ColumnHeader } from '../column_header'; + import * as i18n from '../translations'; interface Props { - header: ColumnHeader; + header: ColumnHeaderOptions; onColumnRemoved: OnColumnRemoved; sort: Sort; } diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/column_header.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/column_header.tsx index 9df805bddcc82..c3f28fd513d08 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/column_header.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/column_header.tsx @@ -7,6 +7,8 @@ import React from 'react'; import { Draggable } from 'react-beautiful-dnd'; import { Resizable, ResizeCallback } from 're-resizable'; + +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { DragEffects } from '../../../drag_and_drop/draggable_wrapper'; import { getDraggableFieldId, DRAG_TYPE_FIELD } from '../../../drag_and_drop/helpers'; import { DraggableFieldBadge } from '../../../draggables/field_badge'; @@ -16,29 +18,10 @@ import { Sort } from '../sort'; import { DraggingContainer } from './common/dragging_container'; import { Header } from './header'; -import { ColumnId } from '../column_id'; - -export type ColumnHeaderType = 'not-filtered' | 'text-filter'; - -/** The specification of a column header */ -export interface ColumnHeader { - aggregatable?: boolean; - category?: string; - columnHeaderType: ColumnHeaderType; - description?: string; - example?: string; - format?: string; - id: ColumnId; - label?: string; - linkField?: string; - placeholder?: string; - type?: string; - width: number; -} interface ColumneHeaderProps { draggableIndex: number; - header: ColumnHeader; + header: ColumnHeaderOptions; onColumnRemoved: OnColumnRemoved; onColumnSorted: OnColumnSorted; onColumnResized: OnColumnResized; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/default_headers.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/default_headers.ts index 4280ad684e8e0..082b5103a7d86 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/default_headers.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/default_headers.ts @@ -4,13 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_COLUMN_MIN_WIDTH, DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../helpers'; - -import { ColumnHeader, ColumnHeaderType } from './column_header'; +import { ColumnHeaderOptions, ColumnHeaderType } from '../../../../store/timeline/model'; +import { DEFAULT_COLUMN_MIN_WIDTH, DEFAULT_DATE_COLUMN_MIN_WIDTH } from '../constants'; export const defaultColumnHeaderType: ColumnHeaderType = 'not-filtered'; -export const defaultHeaders: ColumnHeader[] = [ +export const defaultHeaders: ColumnHeaderOptions[] = [ { columnHeaderType: defaultColumnHeaderType, id: '@timestamp', diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.test.tsx index b9cfee395bafb..f0f6ce8d0ed6f 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.test.tsx @@ -7,7 +7,7 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; -import { ColumnHeaderType } from '../column_header'; +import { ColumnHeaderType } from '../../../../../store/timeline/model'; import { defaultHeaders } from '../default_headers'; import { Filter } from '.'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.tsx index 0b5247e7da678..911a309edfd98 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/filter/index.tsx @@ -8,11 +8,11 @@ import { noop } from 'lodash/fp'; import React from 'react'; import { OnFilterChange } from '../../../events'; -import { ColumnHeader } from '../column_header'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { TextFilter } from '../text_filter'; interface Props { - header: ColumnHeader; + header: ColumnHeaderOptions; onFilterChange?: OnFilterChange; } diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx index c38ae26050c93..84781e6a24300 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx @@ -8,18 +8,18 @@ import { EuiToolTip } from '@elastic/eui'; import { noop } from 'lodash/fp'; import React from 'react'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { TruncatableText } from '../../../../truncatable_text'; import { EventsHeading, EventsHeadingTitleButton, EventsHeadingTitleSpan } from '../../../styles'; import { useTimelineContext } from '../../../timeline_context'; import { Sort } from '../../sort'; import { SortIndicator } from '../../sort/sort_indicator'; -import { ColumnHeader } from '../column_header'; import { HeaderToolTipContent } from '../header_tooltip_content'; import { getSortDirection } from './helpers'; interface HeaderContentProps { children: React.ReactNode; - header: ColumnHeader; + header: ColumnHeaderOptions; isResizing: boolean; onClick: () => void; sort: Sort; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/helpers.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/helpers.ts index 93cb9de7c8355..47ce21e4c9637 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/helpers.ts @@ -6,11 +6,11 @@ import { Direction } from '../../../../../graphql/types'; import { assertUnreachable } from '../../../../../lib/helpers'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { Sort, SortDirection } from '../../sort'; -import { ColumnHeader } from '../column_header'; interface GetNewSortDirectionOnClickParams { - clickedHeader: ColumnHeader; + clickedHeader: ColumnHeaderOptions; currentSort: Sort; } @@ -36,7 +36,7 @@ export const getNextSortDirection = (currentSort: Sort): Direction => { }; interface GetSortDirectionParams { - header: ColumnHeader; + header: ColumnHeaderOptions; sort: Sort; } diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.test.tsx index fab2e7ee872bf..80ae2aab0a19c 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.test.tsx @@ -9,9 +9,9 @@ import React from 'react'; import { Direction } from '../../../../../graphql/types'; import { TestProviders } from '../../../../../mock'; +import { ColumnHeaderType } from '../../../../../store/timeline/model'; import { Sort } from '../../sort'; import { CloseButton } from '../actions'; -import { ColumnHeaderType } from '../column_header'; import { defaultHeaders } from '../default_headers'; import { HeaderComponent } from '.'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.tsx index c45b9ce425deb..82c5d7eb73f02 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/index.tsx @@ -7,16 +7,16 @@ import { noop } from 'lodash/fp'; import React, { useCallback } from 'react'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { OnColumnRemoved, OnColumnSorted, OnFilterChange } from '../../../events'; import { Sort } from '../../sort'; import { Actions } from '../actions'; -import { ColumnHeader } from '../column_header'; import { Filter } from '../filter'; import { getNewSortDirectionOnClick } from './helpers'; import { HeaderContent } from './header_content'; interface Props { - header: ColumnHeader; + header: ColumnHeaderOptions; onColumnRemoved: OnColumnRemoved; onColumnSorted: OnColumnSorted; onFilterChange?: OnFilterChange; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.test.tsx index 20c139ae1d050..9afc852373bc6 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.test.tsx @@ -8,13 +8,13 @@ import { mount, shallow } from 'enzyme'; import { cloneDeep } from 'lodash/fp'; import React from 'react'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { defaultHeaders } from '../../../../../mock'; -import { ColumnHeader } from '../column_header'; import { HeaderToolTipContent } from '.'; describe('HeaderToolTipContent', () => { - let header: ColumnHeader; + let header: ColumnHeaderOptions; beforeEach(() => { header = cloneDeep(defaultHeaders[0]); }); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.tsx index 5deb2c3e66376..bef4bcc42b0c7 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header_tooltip_content/index.tsx @@ -9,8 +9,8 @@ import { isEmpty } from 'lodash/fp'; import React from 'react'; import styled from 'styled-components'; +import { ColumnHeaderOptions } from '../../../../../store/timeline/model'; import { getIconFromType } from '../../../../event_details/helpers'; -import { ColumnHeader } from '../column_header'; import * as i18n from '../translations'; const IconType = styled(EuiIcon)` @@ -35,7 +35,7 @@ const ToolTipTableValue = styled.span` `; ToolTipTableValue.displayName = 'ToolTipTableValue'; -export const HeaderToolTipContent = React.memo<{ header: ColumnHeader }>(({ header }) => ( +export const HeaderToolTipContent = React.memo<{ header: ColumnHeaderOptions }>(({ header }) => ( <> {!isEmpty(header.category) && (

diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/helpers.test.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/helpers.test.ts new file mode 100644 index 0000000000000..d66b75538ef6f --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/helpers.test.ts @@ -0,0 +1,48 @@ +/* + * 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 { getActionsColumnWidth, getColumnWidthFromType } from './helpers'; +import { + DEFAULT_COLUMN_MIN_WIDTH, + DEFAULT_DATE_COLUMN_MIN_WIDTH, + DEFAULT_ACTIONS_COLUMN_WIDTH, + SHOW_CHECK_BOXES_COLUMN_WIDTH, + EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH, +} from '../constants'; + +describe('helpers', () => { + describe('getColumnWidthFromType', () => { + test('it returns the expected width for a non-date column', () => { + expect(getColumnWidthFromType('keyword')).toEqual(DEFAULT_COLUMN_MIN_WIDTH); + }); + + test('it returns the expected width for a date column', () => { + expect(getColumnWidthFromType('date')).toEqual(DEFAULT_DATE_COLUMN_MIN_WIDTH); + }); + }); + + describe('getActionsColumnWidth', () => { + test('returns the default actions column width when isEventViewer is false', () => { + expect(getActionsColumnWidth(false)).toEqual(DEFAULT_ACTIONS_COLUMN_WIDTH); + }); + + test('returns the default actions column width + checkbox width when isEventViewer is false and showCheckboxes is true', () => { + expect(getActionsColumnWidth(false, true)).toEqual( + DEFAULT_ACTIONS_COLUMN_WIDTH + SHOW_CHECK_BOXES_COLUMN_WIDTH + ); + }); + + test('returns the events viewer actions column width when isEventViewer is true', () => { + expect(getActionsColumnWidth(true)).toEqual(EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH); + }); + + test('returns the events viewer actions column width + checkbox width when isEventViewer is true and showCheckboxes is true', () => { + expect(getActionsColumnWidth(true, true)).toEqual( + EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH + SHOW_CHECK_BOXES_COLUMN_WIDTH + ); + }); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/helpers.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/helpers.ts new file mode 100644 index 0000000000000..6923831f9ef63 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/helpers.ts @@ -0,0 +1,48 @@ +/* + * 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 { get } from 'lodash/fp'; + +import { BrowserFields } from '../../../../containers/source'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; +import { + DEFAULT_COLUMN_MIN_WIDTH, + DEFAULT_DATE_COLUMN_MIN_WIDTH, + SHOW_CHECK_BOXES_COLUMN_WIDTH, + EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH, + DEFAULT_ACTIONS_COLUMN_WIDTH, +} from '../constants'; + +/** Enriches the column headers with field details from the specified browserFields */ +export const getColumnHeaders = ( + headers: ColumnHeaderOptions[], + browserFields: BrowserFields +): ColumnHeaderOptions[] => { + return headers.map(header => { + const splitHeader = header.id.split('.'); // source.geo.city_name -> [source, geo, city_name] + + return { + ...header, + ...get( + [splitHeader.length > 1 ? splitHeader[0] : 'base', 'fields', header.id], + browserFields + ), + }; + }); +}; + +export const getColumnWidthFromType = (type: string): number => + type !== 'date' ? DEFAULT_COLUMN_MIN_WIDTH : DEFAULT_DATE_COLUMN_MIN_WIDTH; + +/** Returns the (fixed) width of the Actions column */ +export const getActionsColumnWidth = ( + isEventViewer: boolean, + showCheckboxes = false, + additionalActionWidth = 0 +): number => + (showCheckboxes ? SHOW_CHECK_BOXES_COLUMN_WIDTH : 0) + + (isEventViewer ? EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH : DEFAULT_ACTIONS_COLUMN_WIDTH) + + additionalActionWidth; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.test.tsx index 4b97dd7573a45..4fafacfd01633 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.test.tsx @@ -7,7 +7,7 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../helpers'; +import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../constants'; import { defaultHeaders } from './default_headers'; import { Direction } from '../../../../graphql/types'; import { mockBrowserFields } from '../../../../../public/containers/source/mock'; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.tsx index 953ffb4d4932b..ab8dc629dd577 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/index.tsx @@ -10,6 +10,7 @@ import React from 'react'; import { Droppable } from 'react-beautiful-dnd'; import { BrowserFields } from '../../../../containers/source'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { DRAG_TYPE_FIELD, droppableTimelineColumnsPrefix } from '../../../drag_and_drop/helpers'; import { StatefulFieldsBrowser } from '../../../fields_browser'; import { FIELD_BROWSER_HEIGHT, FIELD_BROWSER_WIDTH } from '../../../fields_browser/helpers'; @@ -30,13 +31,13 @@ import { EventsTrHeader, } from '../../styles'; import { Sort } from '../sort'; -import { ColumnHeader } from './column_header'; import { EventsSelect } from './events_select'; +import { ColumnHeader } from './column_header'; interface Props { actionsColumnWidth: number; browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; isEventViewer?: boolean; isSelectAllChecked: boolean; onColumnRemoved: OnColumnRemoved; @@ -49,7 +50,7 @@ interface Props { showSelectAllCheckbox: boolean; sort: Sort; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } /** Renders the timeline header columns */ diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/constants.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/constants.ts new file mode 100644 index 0000000000000..2aeb033c50d6f --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/constants.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + +/** The (fixed) width of the Actions column */ +export const DEFAULT_ACTIONS_COLUMN_WIDTH = 115; // px; +/** + * The (fixed) width of the Actions column when the timeline body is used as + * an events viewer, which has fewer actions than a regular events viewer + */ +export const EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH = 32; // px; +/** Additional column width to include when checkboxes are shown **/ +export const SHOW_CHECK_BOXES_COLUMN_WIDTH = 32; // px; +/** The default minimum width of a column (when a width for the column type is not specified) */ +export const DEFAULT_COLUMN_MIN_WIDTH = 180; // px +/** The default minimum width of a column of type `date` */ +export const DEFAULT_DATE_COLUMN_MIN_WIDTH = 190; // px + +export const DEFAULT_TIMELINE_WIDTH = 1100; // px diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/data_driven_columns/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/data_driven_columns/index.tsx index 416c72cfbc255..af32c4632b019 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/data_driven_columns/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/data_driven_columns/index.tsx @@ -5,18 +5,18 @@ */ import React from 'react'; - import { getOr } from 'lodash/fp'; + import { Ecs, TimelineNonEcsData } from '../../../../graphql/types'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { OnColumnResized } from '../../events'; import { EventsTd, EventsTdContent, EventsTdGroupData } from '../../styles'; -import { ColumnHeader } from '../column_headers/column_header'; import { ColumnRenderer } from '../renderers/column_renderer'; import { getColumnRenderer } from '../renderers/get_column_renderer'; interface Props { _id: string; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; columnRenderers: ColumnRenderer[]; data: TimelineNonEcsData[]; ecsData: Ecs; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/event_column_view.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/event_column_view.tsx index 74476c3dc1d61..daf9c3d8b1f96 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/event_column_view.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/event_column_view.tsx @@ -9,11 +9,11 @@ import uuid from 'uuid'; import { TimelineNonEcsData, Ecs } from '../../../../graphql/types'; import { Note } from '../../../../lib/note'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { AssociateNote, UpdateNote } from '../../../notes/helpers'; import { OnColumnResized, OnPinEvent, OnRowSelected, OnUnPinEvent } from '../../events'; import { EventsTdContent, EventsTrData } from '../../styles'; import { Actions } from '../actions'; -import { ColumnHeader } from '../column_headers/column_header'; import { DataDrivenColumns } from '../data_driven_columns'; import { eventHasNotes, getPinOnClick } from '../helpers'; import { ColumnRenderer } from '../renderers/column_renderer'; @@ -23,7 +23,7 @@ interface Props { id: string; actionsColumnWidth: number; associateNote: AssociateNote; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; columnRenderers: ColumnRenderer[]; data: TimelineNonEcsData[]; ecsData: Ecs; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/index.tsx index 6b2e105ad0566..84c4253076dc9 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/index.tsx @@ -8,6 +8,7 @@ import React from 'react'; import { BrowserFields } from '../../../../containers/source'; import { TimelineItem, TimelineNonEcsData } from '../../../../graphql/types'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { maxDelay } from '../../../../lib/helpers/scheduler'; import { Note } from '../../../../lib/note'; import { AddNoteToEvent, UpdateNote } from '../../../notes/helpers'; @@ -19,7 +20,6 @@ import { OnUpdateColumns, } from '../../events'; import { EventsTbody } from '../../styles'; -import { ColumnHeader } from '../column_headers/column_header'; import { ColumnRenderer } from '../renderers/column_renderer'; import { RowRenderer } from '../renderers/row_renderer'; import { StatefulEvent } from './stateful_event'; @@ -29,7 +29,7 @@ interface Props { actionsColumnWidth: number; addNoteToEvent: AddNoteToEvent; browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; columnRenderers: ColumnRenderer[]; containerElementRef: HTMLDivElement; data: TimelineItem[]; @@ -47,7 +47,7 @@ interface Props { rowRenderers: RowRenderer[]; selectedEventIds: Readonly>; showCheckboxes: boolean; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; updateNote: UpdateNote; } diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx index 5704b6030e7d1..1f09ae4337c42 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx @@ -13,6 +13,7 @@ import { TimelineDetailsQuery } from '../../../../containers/timeline/details'; import { TimelineItem, DetailItem, TimelineNonEcsData } from '../../../../graphql/types'; import { requestIdleCallbackViaScheduler } from '../../../../lib/helpers/scheduler'; import { Note } from '../../../../lib/note'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { AddNoteToEvent, UpdateNote } from '../../../notes/helpers'; import { SkeletonRow } from '../../../skeleton_row'; import { @@ -26,7 +27,6 @@ import { ExpandableEvent } from '../../expandable_event'; import { STATEFUL_EVENT_CSS_CLASS_NAME } from '../../helpers'; import { EventsTrGroup, EventsTrSupplement, OFFSET_SCROLLBAR } from '../../styles'; import { useTimelineWidthContext } from '../../timeline_context'; -import { ColumnHeader } from '../column_headers/column_header'; import { ColumnRenderer } from '../renderers/column_renderer'; import { getRowRenderer } from '../renderers/get_row_renderer'; import { RowRenderer } from '../renderers/row_renderer'; @@ -38,7 +38,7 @@ interface Props { containerElementRef: HTMLDivElement; addNoteToEvent: AddNoteToEvent; browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; columnRenderers: ColumnRenderer[]; event: TimelineItem; eventIdToNoteIds: Readonly>; @@ -56,7 +56,7 @@ interface Props { selectedEventIds: Readonly>; showCheckboxes: boolean; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; updateNote: UpdateNote; } diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event_child.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event_child.tsx index 16f89ca916d81..04f4ddf2a6eab 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event_child.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event_child.tsx @@ -9,12 +9,12 @@ import uuid from 'uuid'; import { TimelineNonEcsData, Ecs } from '../../../../graphql/types'; import { Note } from '../../../../lib/note'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { AddNoteToEvent, UpdateNote } from '../../../notes/helpers'; import { NoteCards } from '../../../notes/note_cards'; import { OnPinEvent, OnColumnResized, OnUnPinEvent, OnRowSelected } from '../../events'; import { EventsTrSupplement, OFFSET_SCROLLBAR } from '../../styles'; import { useTimelineWidthContext } from '../../timeline_context'; -import { ColumnHeader } from '../column_headers/column_header'; import { ColumnRenderer } from '../renderers/column_renderer'; import { EventColumnView } from './event_column_view'; @@ -23,7 +23,7 @@ interface Props { actionsColumnWidth: number; addNoteToEvent: AddNoteToEvent; onPinEvent: OnPinEvent; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; columnRenderers: ColumnRenderer[]; data: TimelineNonEcsData[]; ecsData: Ecs; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.test.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.test.ts index 602b88b7ae6d6..f021bf38b56c2 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.test.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.test.ts @@ -6,19 +6,7 @@ import { Ecs } from '../../../graphql/types'; -import { - DEFAULT_ACTIONS_COLUMN_WIDTH, - DEFAULT_COLUMN_MIN_WIDTH, - DEFAULT_DATE_COLUMN_MIN_WIDTH, - EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH, - eventHasNotes, - eventIsPinned, - getActionsColumnWidth, - getColumnWidthFromType, - getPinTooltip, - stringifyEvent, - SHOW_CHECK_BOXES_COLUMN_WIDTH, -} from './helpers'; +import { eventHasNotes, eventIsPinned, getPinTooltip, stringifyEvent } from './helpers'; describe('helpers', () => { describe('stringifyEvent', () => { @@ -237,36 +225,4 @@ describe('helpers', () => { expect(eventIsPinned({ eventId, pinnedEventIds })).toEqual(false); }); }); - - describe('getColumnWidthFromType', () => { - test('it returns the expected width for a non-date column', () => { - expect(getColumnWidthFromType('keyword')).toEqual(DEFAULT_COLUMN_MIN_WIDTH); - }); - - test('it returns the expected width for a date column', () => { - expect(getColumnWidthFromType('date')).toEqual(DEFAULT_DATE_COLUMN_MIN_WIDTH); - }); - }); - - describe('getActionsColumnWidth', () => { - test('returns the default actions column width when isEventViewer is false', () => { - expect(getActionsColumnWidth(false)).toEqual(DEFAULT_ACTIONS_COLUMN_WIDTH); - }); - - test('returns the default actions column width + checkbox width when isEventViewer is false and showCheckboxes is true', () => { - expect(getActionsColumnWidth(false, true)).toEqual( - DEFAULT_ACTIONS_COLUMN_WIDTH + SHOW_CHECK_BOXES_COLUMN_WIDTH - ); - }); - - test('returns the events viewer actions column width when isEventViewer is true', () => { - expect(getActionsColumnWidth(true)).toEqual(EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH); - }); - - test('returns the events viewer actions column width + checkbox width when isEventViewer is true and showCheckboxes is true', () => { - expect(getActionsColumnWidth(true, true)).toEqual( - EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH + SHOW_CHECK_BOXES_COLUMN_WIDTH - ); - }); - }); }); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.ts index 4b1d72a3af7b0..3d1d165ef4fa6 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/helpers.ts @@ -3,30 +3,13 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { get, isEmpty, noop } from 'lodash/fp'; +import { isEmpty, noop } from 'lodash/fp'; -import { BrowserFields } from '../../../containers/source'; import { Ecs, TimelineItem, TimelineNonEcsData } from '../../../graphql/types'; import { EventType } from '../../../store/timeline/model'; import { OnPinEvent, OnUnPinEvent } from '../events'; -import { ColumnHeader } from './column_headers/column_header'; -import * as i18n from './translations'; - -/** The (fixed) width of the Actions column */ -export const DEFAULT_ACTIONS_COLUMN_WIDTH = 115; // px; -/** - * The (fixed) width of the Actions column when the timeline body is used as - * an events viewer, which has fewer actions than a regular events viewer - */ -export const EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH = 32; // px; -/** Additional column width to include when checkboxes are shown **/ -export const SHOW_CHECK_BOXES_COLUMN_WIDTH = 32; // px; -/** The default minimum width of a column (when a width for the column type is not specified) */ -export const DEFAULT_COLUMN_MIN_WIDTH = 180; // px -/** The default minimum width of a column of type `date` */ -export const DEFAULT_DATE_COLUMN_MIN_WIDTH = 190; // px -export const DEFAULT_TIMELINE_WIDTH = 1100; // px +import * as i18n from './translations'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export const omitTypenameAndEmpty = (k: string, v: any): any | undefined => @@ -74,37 +57,6 @@ export const getPinOnClick = ({ return isEventPinned ? () => onUnPinEvent(eventId) : () => onPinEvent(eventId); }; -export const getColumnWidthFromType = (type: string): number => - type !== 'date' ? DEFAULT_COLUMN_MIN_WIDTH : DEFAULT_DATE_COLUMN_MIN_WIDTH; - -/** Enriches the column headers with field details from the specified browserFields */ -export const getColumnHeaders = ( - headers: ColumnHeader[], - browserFields: BrowserFields -): ColumnHeader[] => { - return headers.map(header => { - const splitHeader = header.id.split('.'); // source.geo.city_name -> [source, geo, city_name] - - return { - ...header, - ...get( - [splitHeader.length > 1 ? splitHeader[0] : 'base', 'fields', header.id], - browserFields - ), - }; - }); -}; - -/** Returns the (fixed) width of the Actions column */ -export const getActionsColumnWidth = ( - isEventViewer: boolean, - showCheckboxes = false, - additionalActionWidth = 0 -): number => - (showCheckboxes ? SHOW_CHECK_BOXES_COLUMN_WIDTH : 0) + - (isEventViewer ? EVENTS_VIEWER_ACTIONS_COLUMN_WIDTH : DEFAULT_ACTIONS_COLUMN_WIDTH) + - additionalActionWidth; - /** * Creates mapping of eventID -> fieldData for given fieldsToKeep. Used to store additional field * data necessary for custom timeline actions in conjunction with selection state diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/index.tsx index 7f689a877c6b7..ea80d3351408a 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/index.tsx @@ -9,6 +9,7 @@ import React, { useMemo, useRef } from 'react'; import { BrowserFields } from '../../../containers/source'; import { TimelineItem, TimelineNonEcsData } from '../../../graphql/types'; import { Note } from '../../../lib/note'; +import { ColumnHeaderOptions } from '../../../store/timeline/model'; import { AddNoteToEvent, UpdateNote } from '../../notes/helpers'; import { OnColumnRemoved, @@ -23,9 +24,8 @@ import { } from '../events'; import { EventsTable, TimelineBody, TimelineBodyGlobalStyle } from '../styles'; import { ColumnHeaders } from './column_headers'; -import { ColumnHeader } from './column_headers/column_header'; +import { getActionsColumnWidth } from './column_headers/helpers'; import { Events } from './events'; -import { getActionsColumnWidth } from './helpers'; import { ColumnRenderer } from './renderers/column_renderer'; import { RowRenderer } from './renderers/row_renderer'; import { Sort } from './sort'; @@ -34,7 +34,7 @@ import { useTimelineTypeContext } from '../timeline_context'; export interface BodyProps { addNoteToEvent: AddNoteToEvent; browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; columnRenderers: ColumnRenderer[]; data: TimelineItem[]; getNotesByIds: (noteIds: string[]) => Note[]; @@ -58,7 +58,7 @@ export interface BodyProps { selectedEventIds: Readonly>; showCheckboxes: boolean; sort: Sort; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; updateNote: UpdateNote; } diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/column_renderer.ts b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/column_renderer.ts index d1807c82d188e..a13de90e7aed3 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/column_renderer.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/column_renderer.ts @@ -5,7 +5,7 @@ */ import { TimelineNonEcsData } from '../../../../graphql/types'; -import { ColumnHeader } from '../column_headers/column_header'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; export interface ColumnRenderer { isInstance: (columnName: string, data: TimelineNonEcsData[]) => boolean; @@ -20,7 +20,7 @@ export interface ColumnRenderer { }: { columnName: string; eventId: string; - field: ColumnHeader; + field: ColumnHeaderOptions; timelineId: string; truncate?: boolean; values: string[] | null | undefined; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/empty_column_renderer.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/empty_column_renderer.tsx index 7e2346ced8785..45ef46616718d 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/empty_column_renderer.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/empty_column_renderer.tsx @@ -9,12 +9,12 @@ import React from 'react'; import { TimelineNonEcsData } from '../../../../graphql/types'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { DraggableWrapper, DragEffects } from '../../../drag_and_drop/draggable_wrapper'; import { escapeDataProviderId } from '../../../drag_and_drop/helpers'; import { getEmptyValue } from '../../../empty_value'; import { EXISTS_OPERATOR } from '../../data_providers/data_provider'; import { Provider } from '../../data_providers/provider'; -import { ColumnHeader } from '../column_headers/column_header'; import { ColumnRenderer } from './column_renderer'; import { parseQueryValue } from './parse_query_value'; @@ -33,7 +33,7 @@ export const emptyColumnRenderer: ColumnRenderer = { }: { columnName: string; eventId: string; - field: ColumnHeader; + field: ColumnHeaderOptions; timelineId: string; truncate?: boolean; }) => ( diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.tsx index deeec05bc0707..f6a61889c501b 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/plain_column_renderer.tsx @@ -8,8 +8,8 @@ import { head } from 'lodash/fp'; import React from 'react'; import { TimelineNonEcsData } from '../../../../graphql/types'; +import { ColumnHeaderOptions } from '../../../../store/timeline/model'; import { getEmptyTagValue } from '../../../empty_value'; -import { ColumnHeader } from '../column_headers/column_header'; import { ColumnRenderer } from './column_renderer'; import { FormattedFieldValue } from './formatted_field'; import { parseValue } from './parse_value'; @@ -32,7 +32,7 @@ export const plainColumnRenderer: ColumnRenderer = { }: { columnName: string; eventId: string; - field: ColumnHeader; + field: ColumnHeaderOptions; timelineId: string; truncate?: boolean; values: string[] | undefined | null; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.test.tsx index ce59ae8d45048..4945939ac2bdc 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.test.tsx @@ -7,7 +7,7 @@ import { mockBrowserFields } from '../../../containers/source/mock'; import { defaultHeaders } from './column_headers/default_headers'; -import { getColumnHeaders } from './helpers'; +import { getColumnHeaders } from './column_headers/helpers'; describe('stateful_body', () => { describe('getColumnHeaders', () => { diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.tsx index ffb5f2a206f4d..d06dcbb84ad78 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/stateful_body.tsx @@ -13,6 +13,9 @@ import { BrowserFields } from '../../../containers/source'; import { TimelineItem } from '../../../graphql/types'; import { Note } from '../../../lib/note'; import { appSelectors, State, timelineSelectors } from '../../../store'; +import { timelineActions, appActions } from '../../../store/actions'; +import { ColumnHeaderOptions, TimelineModel } from '../../../store/timeline/model'; +import { timelineDefaults } from '../../../store/timeline/defaults'; import { AddNoteToEvent, UpdateNote } from '../../notes/helpers'; import { OnColumnRemoved, @@ -24,16 +27,13 @@ import { OnUnPinEvent, OnUpdateColumns, } from '../events'; - -import { ColumnHeader } from './column_headers/column_header'; -import { getColumnHeaders, getEventIdToDataMapping } from './helpers'; +import { useTimelineTypeContext } from '../timeline_context'; +import { getColumnHeaders } from './column_headers/helpers'; +import { getEventIdToDataMapping } from './helpers'; import { Body } from './index'; import { columnRenderers, rowRenderers } from './renderers'; import { Sort } from './sort'; -import { timelineActions, appActions } from '../../../store/actions'; -import { timelineDefaults, TimelineModel } from '../../../store/timeline/model'; import { plainRowRenderer } from './renderers/plain_row_renderer'; -import { useTimelineTypeContext } from '../timeline_context'; interface OwnProps { browserFields: BrowserFields; @@ -42,12 +42,12 @@ interface OwnProps { isEventViewer?: boolean; height: number; sort: Sort; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } type StatefulBodyComponentProps = OwnProps & PropsFromRedux; -export const emptyColumnHeaders: ColumnHeader[] = []; +export const emptyColumnHeaders: ColumnHeaderOptions[] = []; const StatefulBodyComponent = React.memo( ({ @@ -214,9 +214,9 @@ StatefulBodyComponent.displayName = 'StatefulBodyComponent'; const makeMapStateToProps = () => { const memoizedColumnHeaders: ( - headers: ColumnHeader[], + headers: ColumnHeaderOptions[], browserFields: BrowserFields - ) => ColumnHeader[] = memoizeOne(getColumnHeaders); + ) => ColumnHeaderOptions[] = memoizeOne(getColumnHeaders); const getTimeline = timelineSelectors.getTimelineByIdSelector(); const getNotesByIds = appSelectors.notesByIdsSelector(); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/events.ts b/x-pack/legacy/plugins/siem/public/components/timeline/events.ts index b54ed52bb9f18..f977c03ed3053 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/events.ts +++ b/x-pack/legacy/plugins/siem/public/components/timeline/events.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ColumnHeader } from './body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../store/timeline/model'; import { ColumnId } from './body/column_id'; import { SortDirection } from './body/sort'; import { QueryOperator } from './data_providers/data_provider'; @@ -85,7 +85,7 @@ export type OnRowSelected = ({ export type OnSelectAll = ({ isSelected }: { isSelected: boolean }) => void; /** Invoked when columns are updated */ -export type OnUpdateColumns = (columns: ColumnHeader[]) => void; +export type OnUpdateColumns = (columns: ColumnHeaderOptions[]) => void; /** Invoked when a user unpins an event */ export type OnUnPinEvent = (eventId: string) => void; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/expandable_event/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/expandable_event/index.tsx index 1c5df9d220a62..77cf50342b78b 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/expandable_event/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/expandable_event/index.tsx @@ -8,7 +8,7 @@ import React from 'react'; import styled from 'styled-components'; import { BrowserFields } from '../../../containers/source'; -import { ColumnHeader } from '../body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../../../store/timeline/model'; import { DetailItem } from '../../../graphql/types'; import { StatefulEventDetails } from '../../event_details/stateful_event_details'; import { LazyAccordion } from '../../lazy_accordion'; @@ -30,14 +30,14 @@ ExpandableDetails.displayName = 'ExpandableDetails'; interface Props { browserFields: BrowserFields; - columnHeaders: ColumnHeader[]; + columnHeaders: ColumnHeaderOptions[]; id: string; event: DetailItem[]; forceExpand?: boolean; hideExpandButton?: boolean; onUpdateColumns: OnUpdateColumns; timelineId: string; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } export const ExpandableEvent = React.memo( diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/index.tsx index 34f760e411ed4..d782d0366f041 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/index.tsx @@ -9,12 +9,11 @@ import React, { useEffect, useCallback, useMemo } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { WithSource } from '../../containers/source'; +import { useSignalIndex } from '../../containers/detection_engine/signals/use_signal_index'; import { inputsModel, inputsSelectors, State, timelineSelectors } from '../../store'; import { timelineActions } from '../../store/actions'; -import { timelineDefaults, TimelineModel } from '../../store/timeline/model'; -import { useSignalIndex } from '../../containers/detection_engine/signals/use_signal_index'; - -import { ColumnHeader } from './body/column_headers/column_header'; +import { ColumnHeaderOptions, TimelineModel } from '../../store/timeline/model'; +import { timelineDefaults } from '../../store/timeline/defaults'; import { defaultHeaders } from './body/column_headers/default_headers'; import { OnChangeDataProviderKqlQuery, @@ -137,7 +136,7 @@ const StatefulTimelineComponent = React.memo( ); const toggleColumn = useCallback( - (column: ColumnHeader) => { + (column: ColumnHeaderOptions) => { const exists = columns.findIndex(c => c.id === column.id) !== -1; if (!exists && upsertColumn != null) { diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx index 2b139d3948fe1..d1904fd5d9aac 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx @@ -21,7 +21,8 @@ import { inputsSelectors, } from '../../../store'; import { timelineActions } from '../../../store/actions'; -import { KqlMode, timelineDefaults, TimelineModel, EventType } from '../../../store/timeline/model'; +import { KqlMode, TimelineModel, EventType } from '../../../store/timeline/model'; +import { timelineDefaults } from '../../../store/timeline/defaults'; import { dispatchUpdateReduxTime } from '../../super_date_picker'; import { SearchOrFilter } from './search_or_filter'; 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 4b7331ab14c7e..e6aa6cc18f018 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx @@ -14,8 +14,7 @@ import { BrowserFields } from '../../containers/source'; import { TimelineQuery } from '../../containers/timeline'; import { Direction } from '../../graphql/types'; import { useKibana } from '../../lib/kibana'; -import { KqlMode, EventType } from '../../store/timeline/model'; -import { ColumnHeader } from './body/column_headers/column_header'; +import { ColumnHeaderOptions, KqlMode, EventType } from '../../store/timeline/model'; import { defaultHeaders } from './body/column_headers/default_headers'; import { Sort } from './body/sort'; import { StatefulBody } from './body/stateful_body'; @@ -57,7 +56,7 @@ export const isCompactFooter = (width: number): boolean => width < 600; interface Props { browserFields: BrowserFields; - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; dataProviders: DataProvider[]; end: number; eventType?: EventType; @@ -84,7 +83,7 @@ interface Props { showCallOutUnauthorizedMsg: boolean; start: number; sort: Sort; - toggleColumn: (column: ColumnHeader) => void; + toggleColumn: (column: ColumnHeaderOptions) => void; } /** The parent Timeline component */ diff --git a/x-pack/legacy/plugins/siem/public/components/url_state/helpers.ts b/x-pack/legacy/plugins/siem/public/components/url_state/helpers.ts index 05329621aa97a..d085af91da1f0 100644 --- a/x-pack/legacy/plugins/siem/public/components/url_state/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/url_state/helpers.ts @@ -4,15 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ +import { isEmpty } from 'lodash/fp'; import { parse, stringify } from 'query-string'; import { decode, encode } from 'rison-node'; import * as H from 'history'; -import { Query, Filter } from 'src/plugins/data/public'; -import { isEmpty } from 'lodash/fp'; +import { Query, Filter } from '../../../../../../../src/plugins/data/public'; +import { url } from '../../../../../../../src/plugins/kibana_utils/public'; + import { SiemPageName } from '../../pages/home/types'; import { inputsSelectors, State, timelineSelectors } from '../../store'; import { UrlInputsModel } from '../../store/inputs/model'; +import { TimelineUrl } from '../../store/timeline/model'; import { formatDate } from '../super_date_picker'; import { NavTab } from '../navigation/types'; import { CONSTANTS, UrlStateType } from './constants'; @@ -20,12 +23,9 @@ import { LocationTypes, UrlStateContainerPropTypes, ReplaceStateInLocation, - Timeline, UpdateUrlStateString, } from './types'; -import { url } from '../../../../../../../src/plugins/kibana_utils/public'; - export const decodeRisonUrlState = (value: string | undefined): T | null => { try { return value ? ((decode(value) as unknown) as T) : null; @@ -257,7 +257,7 @@ export const updateUrlStateString = ({ }); } } else if (urlKey === CONSTANTS.timeline) { - const queryState = decodeRisonUrlState(newUrlStateString); + const queryState = decodeRisonUrlState(newUrlStateString); if (queryState != null && queryState.id === '') { return replaceStateInLocation({ history, diff --git a/x-pack/legacy/plugins/siem/public/components/url_state/initialize_redux_by_url.tsx b/x-pack/legacy/plugins/siem/public/components/url_state/initialize_redux_by_url.tsx index 772afac6f8ba4..4838fb4499b87 100644 --- a/x-pack/legacy/plugins/siem/public/components/url_state/initialize_redux_by_url.tsx +++ b/x-pack/legacy/plugins/siem/public/components/url_state/initialize_redux_by_url.tsx @@ -6,8 +6,8 @@ import { get, isEmpty } from 'lodash/fp'; import { Dispatch } from 'redux'; -import { Query, Filter } from 'src/plugins/data/public'; +import { Query, Filter } from '../../../../../../../src/plugins/data/public'; import { inputsActions } from '../../store/actions'; import { InputsModelId, TimeRangeKinds } from '../../store/inputs/constants'; import { @@ -16,11 +16,11 @@ import { AbsoluteTimeRange, RelativeTimeRange, } from '../../store/inputs/model'; - +import { TimelineUrl } from '../../store/timeline/model'; import { CONSTANTS } from './constants'; import { decodeRisonUrlState } from './helpers'; import { normalizeTimeRange } from './normalize_time_range'; -import { DispatchSetInitialStateFromUrl, SetInitialStateFromUrl, Timeline } from './types'; +import { DispatchSetInitialStateFromUrl, SetInitialStateFromUrl } from './types'; import { queryTimelineById } from '../open_timeline/helpers'; export const dispatchSetInitialStateFromUrl = ( @@ -76,7 +76,7 @@ export const dispatchSetInitialStateFromUrl = ( } if (urlKey === CONSTANTS.timeline) { - const timeline = decodeRisonUrlState(newUrlStateString); + const timeline = decodeRisonUrlState(newUrlStateString); if (timeline != null && timeline.id !== '') { queryTimelineById({ apolloClient, diff --git a/x-pack/legacy/plugins/siem/public/components/url_state/types.ts b/x-pack/legacy/plugins/siem/public/components/url_state/types.ts index 97979e514aeaf..2cb1b0c96ad79 100644 --- a/x-pack/legacy/plugins/siem/public/components/url_state/types.ts +++ b/x-pack/legacy/plugins/siem/public/components/url_state/types.ts @@ -16,6 +16,7 @@ import { } from 'src/plugins/data/public'; import { UrlInputsModel } from '../../store/inputs/model'; +import { TimelineUrl } from '../../store/timeline/model'; import { RouteSpyState } from '../../utils/route/types'; import { DispatchUpdateTimeline } from '../open_timeline/types'; import { NavTab } from '../navigation/types'; @@ -75,17 +76,12 @@ export type LocationTypes = | CONSTANTS.timelinePage | CONSTANTS.unknown; -export interface Timeline { - id: string; - isOpen: boolean; -} - export interface UrlState { [CONSTANTS.appQuery]?: Query; [CONSTANTS.filters]?: Filter[]; [CONSTANTS.savedQuery]?: string; [CONSTANTS.timerange]: UrlInputsModel; - [CONSTANTS.timeline]: Timeline; + [CONSTANTS.timeline]: TimelineUrl; } export type KeyUrlState = keyof UrlState; diff --git a/x-pack/legacy/plugins/siem/public/mock/global_state.ts b/x-pack/legacy/plugins/siem/public/mock/global_state.ts index 31e203d080322..6678c3043a3da 100644 --- a/x-pack/legacy/plugins/siem/public/mock/global_state.ts +++ b/x-pack/legacy/plugins/siem/public/mock/global_state.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_TIMELINE_WIDTH } from '../components/timeline/body/helpers'; +import { DEFAULT_TIMELINE_WIDTH } from '../components/timeline/body/constants'; import { Direction, FlowTarget, diff --git a/x-pack/legacy/plugins/siem/public/mock/header.ts b/x-pack/legacy/plugins/siem/public/mock/header.ts index 387e16ebeb3d6..61af5a5f098b5 100644 --- a/x-pack/legacy/plugins/siem/public/mock/header.ts +++ b/x-pack/legacy/plugins/siem/public/mock/header.ts @@ -3,15 +3,14 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - -import { ColumnHeader } from '../components/timeline/body/column_headers/column_header'; +import { ColumnHeaderOptions } from '../store/timeline/model'; import { defaultColumnHeaderType } from '../components/timeline/body/column_headers/default_headers'; import { DEFAULT_COLUMN_MIN_WIDTH, DEFAULT_DATE_COLUMN_MIN_WIDTH, -} from '../components/timeline/body/helpers'; +} from '../components/timeline/body/constants'; -export const defaultHeaders: ColumnHeader[] = [ +export const defaultHeaders: ColumnHeaderOptions[] = [ { category: 'base', columnHeaderType: defaultColumnHeaderType, diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/columns.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/columns.tsx index 2ad37960d0423..78315d3ba79d4 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/columns.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/columns.tsx @@ -15,7 +15,7 @@ import { } from '@elastic/eui'; import React from 'react'; import { getEmptyTagValue } from '../../../../components/empty_value'; -import { ColumnTypes } from './index'; +import { ColumnTypes } from './types'; const actions: EuiTableActionsColumnType['actions'] = [ { diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/index.tsx index 5f017a3a1f67f..4c7cfac33c546 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/index.tsx @@ -15,30 +15,7 @@ import { UtilityBarText, } from '../../../../components/detection_engine/utility_bar'; import { columns } from './columns'; - -export interface RuleTypes { - href: string; - name: string; -} - -export interface ColumnTypes { - id: number; - rule: RuleTypes; - ran: string; - lookedBackTo: string; - status: string; - response?: string | undefined; -} - -export interface PageTypes { - index: number; - size: number; -} - -export interface SortTypes { - field: keyof ColumnTypes; - direction: 'asc' | 'desc'; -} +import { ColumnTypes, PageTypes, SortTypes } from './types'; export const ActivityMonitor = React.memo(() => { const sampleTableData: ColumnTypes[] = [ diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/types.ts b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/types.ts new file mode 100644 index 0000000000000..816992ff940dd --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/activity_monitor/types.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export interface RuleTypes { + href: string; + name: string; +} + +export interface ColumnTypes { + id: number; + rule: RuleTypes; + ran: string; + lookedBackTo: string; + status: string; + response?: string | undefined; +} + +export interface PageTypes { + index: number; + size: number; +} + +export interface SortTypes { + field: keyof ColumnTypes; + direction: 'asc' | 'desc'; +} diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/actions.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/actions.tsx index 003d2baa53dbc..b23b051e8b2e8 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/actions.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/actions.tsx @@ -17,7 +17,7 @@ import { formatTimelineResultToModel, } from '../../../../components/open_timeline/helpers'; import { convertKueryToElasticSearchQuery } from '../../../../lib/keury'; -import { timelineDefaults } from '../../../../store/timeline/model'; +import { timelineDefaults } from '../../../../store/timeline/defaults'; import { replaceTemplateFieldFromQuery, replaceTemplateFieldFromMatchFilters, diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx index a0d24f53c6b4e..44c48b1879e89 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/default_config.tsx @@ -11,14 +11,14 @@ import ApolloClient from 'apollo-client'; import React from 'react'; import { Filter } from '../../../../../../../../../src/plugins/data/common/es_query'; -import { ColumnHeader } from '../../../../components/timeline/body/column_headers/column_header'; import { TimelineAction, TimelineActionProps } from '../../../../components/timeline/body/actions'; import { defaultColumnHeaderType } from '../../../../components/timeline/body/column_headers/default_headers'; import { DEFAULT_COLUMN_MIN_WIDTH, DEFAULT_DATE_COLUMN_MIN_WIDTH, -} from '../../../../components/timeline/body/helpers'; -import { SubsetTimelineModel, timelineDefaults } from '../../../../store/timeline/model'; +} from '../../../../components/timeline/body/constants'; +import { ColumnHeaderOptions, SubsetTimelineModel } from '../../../../store/timeline/model'; +import { timelineDefaults } from '../../../../store/timeline/defaults'; import { FILTER_OPEN } from './signals_filter_group'; import { sendSignalToTimelineAction, updateSignalStatusAction } from './actions'; @@ -85,7 +85,7 @@ export const buildSignalsRuleIdFilter = (ruleId: string): Filter[] => [ }, ]; -export const signalsHeaders: ColumnHeader[] = [ +export const signalsHeaders: ColumnHeaderOptions[] = [ { columnHeaderType: defaultColumnHeaderType, id: '@timestamp', 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 aacc6d951f4c9..7cd26ac0cc41b 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 @@ -18,7 +18,8 @@ import { combineQueries } from '../../../../components/timeline/helpers'; import { useKibana } from '../../../../lib/kibana'; import { inputsSelectors, State, inputsModel } from '../../../../store'; import { timelineActions, timelineSelectors } from '../../../../store/timeline'; -import { timelineDefaults, TimelineModel } from '../../../../store/timeline/model'; +import { TimelineModel } from '../../../../store/timeline/model'; +import { timelineDefaults } from '../../../../store/timeline/defaults'; import { useApolloClient } from '../../../../utils/apollo_context'; import { updateSignalStatusAction } from './actions'; diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/actions.ts b/x-pack/legacy/plugins/siem/public/store/timeline/actions.ts index f05512787f0f7..51043b999c27e 100644 --- a/x-pack/legacy/plugins/siem/public/store/timeline/actions.ts +++ b/x-pack/legacy/plugins/siem/public/store/timeline/actions.ts @@ -7,7 +7,6 @@ import actionCreatorFactory from 'typescript-fsa'; import { Filter } from '../../../../../../../src/plugins/data/public'; -import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; import { Sort } from '../../components/timeline/body/sort'; import { DataProvider, @@ -15,7 +14,7 @@ import { } from '../../components/timeline/data_providers/data_provider'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; -import { EventType, KqlMode, TimelineModel } from './model'; +import { EventType, KqlMode, TimelineModel, ColumnHeaderOptions } from './model'; import { TimelineNonEcsData } from '../../graphql/types'; const actionCreator = actionCreatorFactory('x-pack/siem/local/timeline'); @@ -28,9 +27,11 @@ export const addNoteToEvent = actionCreator<{ id: string; noteId: string; eventI 'ADD_NOTE_TO_EVENT' ); -export const upsertColumn = actionCreator<{ column: ColumnHeader; id: string; index: number }>( - 'UPSERT_COLUMN' -); +export const upsertColumn = actionCreator<{ + column: ColumnHeaderOptions; + id: string; + index: number; +}>('UPSERT_COLUMN'); export const addProvider = actionCreator<{ id: string; provider: DataProvider }>('ADD_PROVIDER'); @@ -56,7 +57,7 @@ export const createTimeline = actionCreator<{ end: number; }; filters?: Filter[]; - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; itemsPerPage?: number; kqlQuery?: { filterQuery: SerializedFilterQuery | null; @@ -110,7 +111,7 @@ export const updateIsLoading = actionCreator<{ export const updateColumns = actionCreator<{ id: string; - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; }>('UPDATE_COLUMNS'); export const updateDataProviderEnabled = actionCreator<{ diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/defaults.ts b/x-pack/legacy/plugins/siem/public/store/timeline/defaults.ts new file mode 100644 index 0000000000000..bbaf2a3fb6e30 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/store/timeline/defaults.ts @@ -0,0 +1,54 @@ +/* + * 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 { Direction } from '../../graphql/types'; +import { DEFAULT_TIMELINE_WIDTH } from '../../components/timeline/body/constants'; +import { defaultHeaders } from '../../components/timeline/body/column_headers/default_headers'; +import { SubsetTimelineModel, TimelineModel } from './model'; + +export const timelineDefaults: SubsetTimelineModel & Pick = { + columns: defaultHeaders, + dataProviders: [], + deletedEventIds: [], + description: '', + eventType: 'raw', + eventIdToNoteIds: {}, + highlightedDropAndProviderId: '', + historyIds: [], + filters: [], + isFavorite: false, + isLive: false, + isSelectAllChecked: false, + isLoading: false, + isSaving: false, + itemsPerPage: 25, + itemsPerPageOptions: [10, 25, 50, 100], + kqlMode: 'filter', + kqlQuery: { + filterQuery: null, + filterQueryDraft: null, + }, + loadingEventIds: [], + title: '', + noteIds: [], + pinnedEventIds: {}, + pinnedEventsSaveObject: {}, + dateRange: { + start: 0, + end: 0, + }, + savedObjectId: null, + selectedEventIds: {}, + show: false, + showCheckboxes: false, + showRowRenderers: true, + sort: { + columnId: '@timestamp', + sortDirection: Direction.desc, + }, + width: DEFAULT_TIMELINE_WIDTH, + version: null, +}; diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/epic.ts b/x-pack/legacy/plugins/siem/public/store/timeline/epic.ts index c243221a1b8c7..e6acff8736492 100644 --- a/x-pack/legacy/plugins/siem/public/store/timeline/epic.ts +++ b/x-pack/legacy/plugins/siem/public/store/timeline/epic.ts @@ -29,7 +29,6 @@ import { } from 'rxjs/operators'; import { esFilters, Filter, MatchAllFilter } from '../../../../../../../src/plugins/data/public'; -import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; import { persistTimelineMutation } from '../../containers/timeline/persist.gql_query'; import { PersistTimelineMutation, @@ -70,7 +69,7 @@ import { addTimeline, showCallOutUnauthorizedMsg, } from './actions'; -import { TimelineModel } from './model'; +import { ColumnHeaderOptions, TimelineModel } from './model'; import { epicPersistNote, timelineNoteActionsType } from './epic_note'; import { epicPersistPinnedEvent, timelinePinnedEventActionsType } from './epic_pinned_event'; import { epicPersistTimelineFavorite, timelineFavoriteActionsType } from './epic_favorite'; @@ -273,7 +272,7 @@ export const convertTimelineAsInput = ( } else if (key === 'columns' && get(key, timeline) != null) { return set( key, - get(key, timeline).map((col: ColumnHeader) => omit(['width', '__typename'], col)), + get(key, timeline).map((col: ColumnHeaderOptions) => omit(['width', '__typename'], col)), acc ); } else if (key === 'filters' && get(key, timeline) != null) { diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/helpers.ts b/x-pack/legacy/plugins/siem/public/store/timeline/helpers.ts index 4155e25a67688..f56bbc34ce165 100644 --- a/x-pack/legacy/plugins/siem/public/store/timeline/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/store/timeline/helpers.ts @@ -7,8 +7,7 @@ import { getOr, omit, uniq, isEmpty, isEqualWith, union } from 'lodash/fp'; import { Filter } from '../../../../../../../src/plugins/data/public'; -import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; -import { getColumnWidthFromType } from '../../components/timeline/body/helpers'; +import { getColumnWidthFromType } from '../../components/timeline/body/column_headers/helpers'; import { Sort } from '../../components/timeline/body/sort'; import { DataProvider, @@ -17,7 +16,8 @@ import { } from '../../components/timeline/data_providers/data_provider'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; -import { KqlMode, timelineDefaults, TimelineModel, EventType } from './model'; +import { timelineDefaults } from './defaults'; +import { ColumnHeaderOptions, KqlMode, TimelineModel, EventType } from './model'; import { TimelineById, TimelineState } from './types'; import { TimelineNonEcsData } from '../../graphql/types'; @@ -129,7 +129,7 @@ export const addTimelineToStore = ({ }); interface AddNewTimelineParams { - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; dataProviders?: DataProvider[]; dateRange?: { start: number; @@ -353,7 +353,7 @@ const addProviderToTimeline = ( }; interface AddTimelineColumnParams { - column: ColumnHeader; + column: ColumnHeaderOptions; id: string; index: number; timelineById: TimelineById; @@ -566,7 +566,7 @@ export const updateKqlFilterQueryDraft = ({ interface UpdateTimelineColumnsParams { id: string; - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; timelineById: TimelineById; } diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/model.ts b/x-pack/legacy/plugins/siem/public/store/timeline/model.ts index 1c54031dfe3fd..ef46a8d061c2e 100644 --- a/x-pack/legacy/plugins/siem/public/store/timeline/model.ts +++ b/x-pack/legacy/plugins/siem/public/store/timeline/model.ts @@ -5,20 +5,39 @@ */ import { Filter } from '../../../../../../../src/plugins/data/public'; -import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; import { DataProvider } from '../../components/timeline/data_providers/data_provider'; -import { DEFAULT_TIMELINE_WIDTH } from '../../components/timeline/body/helpers'; -import { defaultHeaders } from '../../components/timeline/body/column_headers/default_headers'; import { Sort } from '../../components/timeline/body/sort'; -import { Direction, PinnedEvent, TimelineNonEcsData } from '../../graphql/types'; +import { PinnedEvent, TimelineNonEcsData } from '../../graphql/types'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; export const DEFAULT_PAGE_COUNT = 2; // Eui Pager will not render unless this is a minimum of 2 pages export type KqlMode = 'filter' | 'search'; export type EventType = 'all' | 'raw' | 'signal'; + +export type ColumnHeaderType = 'not-filtered' | 'text-filter'; + +/** Uniquely identifies a column */ +export type ColumnId = string; + +/** The specification of a column header */ +export interface ColumnHeaderOptions { + aggregatable?: boolean; + category?: string; + columnHeaderType: ColumnHeaderType; + description?: string; + example?: string; + format?: string; + id: ColumnId; + label?: string; + linkField?: string; + placeholder?: string; + type?: string; + width: number; +} + export interface TimelineModel { /** The columns displayed in the timeline */ - columns: ColumnHeader[]; + columns: ColumnHeaderOptions[]; /** The sources of the event data shown in the timeline */ dataProviders: DataProvider[]; /** Events to not be rendered **/ @@ -124,46 +143,7 @@ export type SubsetTimelineModel = Readonly< > >; -export const timelineDefaults: SubsetTimelineModel & Pick = { - columns: defaultHeaders, - dataProviders: [], - deletedEventIds: [], - description: '', - eventType: 'raw', - eventIdToNoteIds: {}, - highlightedDropAndProviderId: '', - historyIds: [], - filters: [], - isFavorite: false, - isLive: false, - isSelectAllChecked: false, - isLoading: false, - isSaving: false, - itemsPerPage: 25, - itemsPerPageOptions: [10, 25, 50, 100], - kqlMode: 'filter', - kqlQuery: { - filterQuery: null, - filterQueryDraft: null, - }, - loadingEventIds: [], - title: '', - noteIds: [], - pinnedEventIds: {}, - pinnedEventsSaveObject: {}, - dateRange: { - start: 0, - end: 0, - }, - savedObjectId: null, - selectedEventIds: {}, - show: false, - showCheckboxes: false, - showRowRenderers: true, - sort: { - columnId: '@timestamp', - sortDirection: Direction.desc, - }, - width: DEFAULT_TIMELINE_WIDTH, - version: null, -}; +export interface TimelineUrl { + id: string; + isOpen: boolean; +} diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/reducer.test.ts b/x-pack/legacy/plugins/siem/public/store/timeline/reducer.test.ts index 0b82bab3dbb8e..58fc1c7e1e3df 100644 --- a/x-pack/legacy/plugins/siem/public/store/timeline/reducer.test.ts +++ b/x-pack/legacy/plugins/siem/public/store/timeline/reducer.test.ts @@ -6,7 +6,6 @@ import { cloneDeep, set } from 'lodash/fp'; -import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; import { IS_OPERATOR, DataProvider, @@ -15,9 +14,9 @@ import { import { defaultColumnHeaderType } from '../../components/timeline/body/column_headers/default_headers'; import { DEFAULT_COLUMN_MIN_WIDTH, - getColumnWidthFromType, DEFAULT_TIMELINE_WIDTH, -} from '../../components/timeline/body/helpers'; +} from '../../components/timeline/body/constants'; +import { getColumnWidthFromType } from '../../components/timeline/body/column_headers/helpers'; import { Direction } from '../../graphql/types'; import { defaultHeaders } from '../../mock'; @@ -41,7 +40,8 @@ import { updateTimelineTitle, upsertTimelineColumn, } from './helpers'; -import { timelineDefaults } from './model'; +import { ColumnHeaderOptions } from './model'; +import { timelineDefaults } from './defaults'; import { TimelineById } from './types'; const timelineByIdMock: TimelineById = { @@ -101,7 +101,11 @@ const timelineByIdMock: TimelineById = { }, }; -const columnsMock: ColumnHeader[] = [defaultHeaders[0], defaultHeaders[1], defaultHeaders[2]]; +const columnsMock: ColumnHeaderOptions[] = [ + defaultHeaders[0], + defaultHeaders[1], + defaultHeaders[2], +]; describe('Timeline', () => { describe('#add saved object Timeline to store ', () => { @@ -183,8 +187,8 @@ describe('Timeline', () => { describe('#upsertTimelineColumn', () => { let timelineById: TimelineById = {}; - let columns: ColumnHeader[] = []; - let columnToAdd: ColumnHeader; + let columns: ColumnHeaderOptions[] = []; + let columnToAdd: ColumnHeaderOptions; beforeEach(() => { timelineById = cloneDeep(timelineByIdMock); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap index 5094aab1226a1..e79eb50d384a8 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap @@ -1,19 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`getInfraHref getInfraContainerHref creates a link for valid parameters 1`] = `"foo/app/infra#/link-to/container-detail/test-container-id"`; +exports[`getInfraHref getInfraContainerHref creates a link for valid parameters 1`] = `"foo/app/metrics/link-to/container-detail/test-container-id"`; -exports[`getInfraHref getInfraContainerHref does not specify a base path when none is available 1`] = `"/app/infra#/link-to/container-detail/test-container-id"`; +exports[`getInfraHref getInfraContainerHref does not specify a base path when none is available 1`] = `"/app/metrics/link-to/container-detail/test-container-id"`; -exports[`getInfraHref getInfraContainerHref returns the first item when multiple container ids are supplied 1`] = `"bar/app/infra#/link-to/container-detail/test-container-id"`; +exports[`getInfraHref getInfraContainerHref returns the first item when multiple container ids are supplied 1`] = `"bar/app/metrics/link-to/container-detail/test-container-id"`; -exports[`getInfraHref getInfraIpHref creates a link for valid parameters 1`] = `"bar/app/infra#/infrastructure/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; +exports[`getInfraHref getInfraIpHref creates a link for valid parameters 1`] = `"bar/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; -exports[`getInfraHref getInfraIpHref does not specify a base path when none is available 1`] = `"/app/infra#/infrastructure/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; +exports[`getInfraHref getInfraIpHref does not specify a base path when none is available 1`] = `"/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; -exports[`getInfraHref getInfraIpHref returns a url for ors between multiple ips 1`] = `"foo/app/infra#/infrastructure/inventory?waffleFilter=(expression:'host.ip%20%3A%20152.151.23.192%20or%20host.ip%20%3A%20151.101.202.217',kind:kuery)"`; +exports[`getInfraHref getInfraIpHref returns a url for ors between multiple ips 1`] = `"foo/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20152.151.23.192%20or%20host.ip%20%3A%20151.101.202.217',kind:kuery)"`; -exports[`getInfraHref getInfraKubernetesHref creates a link for valid parameters 1`] = `"foo/app/infra#/link-to/pod-detail/test-pod-uid"`; +exports[`getInfraHref getInfraKubernetesHref creates a link for valid parameters 1`] = `"foo/app/metrics/link-to/pod-detail/test-pod-uid"`; -exports[`getInfraHref getInfraKubernetesHref does not specify a base path when none is available 1`] = `"/app/infra#/link-to/pod-detail/test-pod-uid"`; +exports[`getInfraHref getInfraKubernetesHref does not specify a base path when none is available 1`] = `"/app/metrics/link-to/pod-detail/test-pod-uid"`; -exports[`getInfraHref getInfraKubernetesHref selects the first pod uid when there are multiple 1`] = `"/app/infra#/link-to/pod-detail/test-pod-uid"`; +exports[`getInfraHref getInfraKubernetesHref selects the first pod uid when there are multiple 1`] = `"/app/metrics/link-to/pod-detail/test-pod-uid"`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap index 67402d16d9a27..cfac6ce133c8a 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap @@ -1,13 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`getLoggingHref creates a container href with base path when present 1`] = `"bar/app/infra#/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"`; +exports[`getLoggingHref creates a container href with base path when present 1`] = `"bar/app/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"`; -exports[`getLoggingHref creates a container href without a base path if it's an empty string 1`] = `"/app/infra#/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"`; +exports[`getLoggingHref creates a container href without a base path if it's an empty string 1`] = `"/app/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"`; -exports[`getLoggingHref creates a pod href with base path when present 1`] = `"bar/app/infra#/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; +exports[`getLoggingHref creates a pod href with base path when present 1`] = `"bar/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; -exports[`getLoggingHref creates a pod href without a base path when it's an empty string 1`] = `"/app/infra#/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; +exports[`getLoggingHref creates a pod href without a base path when it's an empty string 1`] = `"/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; -exports[`getLoggingHref creates an ip href with base path when present 1`] = `"bar/app/infra#/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; +exports[`getLoggingHref creates an ip href with base path when present 1`] = `"bar/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; -exports[`getLoggingHref creates an ip href without a base path when it's an empty string 1`] = `"/app/infra#/logs?logFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; +exports[`getLoggingHref creates an ip href without a base path when it's an empty string 1`] = `"/app/logs?logFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts index 12b51bbad0074..73065be395c76 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts @@ -17,7 +17,10 @@ export const getInfraContainerHref = ( return undefined; } const ret = !Array.isArray(value) ? value : value[0]; - return addBasePath(basePath, `/app/infra#/link-to/container-detail/${encodeURIComponent(ret)}`); + return addBasePath( + basePath, + `/app/metrics/link-to/container-detail/${encodeURIComponent(ret)}` + ); }; return buildHref(summary.state.checks || [], 'container.id', getHref); }; @@ -31,7 +34,7 @@ export const getInfraKubernetesHref = ( return undefined; } const ret = !Array.isArray(value) ? value : value[0]; - return addBasePath(basePath, `/app/infra#/link-to/pod-detail/${encodeURIComponent(ret)}`); + return addBasePath(basePath, `/app/metrics/link-to/pod-detail/${encodeURIComponent(ret)}`); }; return buildHref(summary.state.checks || [], 'kubernetes.pod.uid', getHref); @@ -46,7 +49,7 @@ export const getInfraIpHref = (summary: MonitorSummary, basePath: string) => { const expression = encodeURIComponent(`host.ip : ${value}`); return addBasePath( basePath, - `/app/infra#/infrastructure/inventory?waffleFilter=(expression:'${expression}',kind:kuery)` + `/app/metrics/inventory?waffleFilter=(expression:'${expression}',kind:kuery)` ); } const ips = value.reduce( @@ -57,9 +60,7 @@ export const getInfraIpHref = (summary: MonitorSummary, basePath: string) => { ? undefined : addBasePath( basePath, - `/app/infra#/infrastructure/inventory?waffleFilter=(expression:'${encodeURIComponent( - ips - )}',kind:kuery)` + `/app/metrics/inventory?waffleFilter=(expression:'${encodeURIComponent(ips)}',kind:kuery)` ); }; return buildHref(summary.state.checks || [], 'monitor.ip', getHref); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts index b2235231028fc..b97b5a34855fb 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts @@ -19,7 +19,7 @@ export const getLoggingContainerHref = ( const ret = !Array.isArray(value) ? value : value[0]; return addBasePath( basePath, - `/app/infra#/logs?logFilter=${encodeURI(`(expression:'container.id : ${ret}',kind:kuery)`)}` + `/app/logs?logFilter=${encodeURI(`(expression:'container.id : ${ret}',kind:kuery)`)}` ); }; return buildHref(summary.state.checks || [], 'container.id', getHref); @@ -33,7 +33,7 @@ export const getLoggingKubernetesHref = (summary: MonitorSummary, basePath: stri const ret = !Array.isArray(value) ? value : value[0]; return addBasePath( basePath, - `/app/infra#/logs?logFilter=${encodeURI(`(expression:'pod.uid : ${ret}',kind:kuery)`)}` + `/app/logs?logFilter=${encodeURI(`(expression:'pod.uid : ${ret}',kind:kuery)`)}` ); }; return buildHref(summary.state.checks || [], 'kubernetes.pod.uid', getHref); @@ -47,9 +47,7 @@ export const getLoggingIpHref = (summary: MonitorSummary, basePath: string) => { const ret = !Array.isArray(value) ? value : value[0]; return addBasePath( basePath, - `/app/infra#/logs?logFilter=(expression:'${encodeURIComponent( - `host.ip : ${ret}` - )}',kind:kuery)` + `/app/logs?logFilter=(expression:'${encodeURIComponent(`host.ip : ${ret}`)}',kind:kuery)` ); }; return buildHref(summary.state.checks || [], 'monitor.ip', getHref); diff --git a/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx b/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx index 1d45c7b7ab99b..380cc041ae87e 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx @@ -10,7 +10,7 @@ import { useParams } from 'react-router-dom'; import { MonitorCharts, PingList } from '../components/functional'; import { UptimeRefreshContext, UptimeThemeContext } from '../contexts'; import { useUptimeTelemetry, useUrlParams, UptimePage } from '../hooks'; -import { useTrackPageview } from '../../../infra/public'; +import { useTrackPageview } from '../../../../../plugins/observability/public'; import { MonitorStatusDetails } from '../components/connected'; export const MonitorPage = () => { diff --git a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx index 5360d66f87e99..cf3631eda042a 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx @@ -15,7 +15,7 @@ import { } from '../components/functional'; import { useUrlParams, useUptimeTelemetry, UptimePage } from '../hooks'; import { stringifyUrlParams } from '../lib/helper/stringify_url_params'; -import { useTrackPageview } from '../../../infra/public'; +import { useTrackPageview } from '../../../../../plugins/observability/public'; import { DataPublicPluginSetup, IIndexPattern } from '../../../../../../src/plugins/data/public'; import { UptimeThemeContext } from '../contexts'; import { FilterGroup, KueryBar } from '../components/connected'; diff --git a/x-pack/plugins/endpoint/common/types.ts b/x-pack/plugins/endpoint/common/types.ts index 6fc4d8d79a1c5..f0fd9dc610e4e 100644 --- a/x-pack/plugins/endpoint/common/types.ts +++ b/x-pack/plugins/endpoint/common/types.ts @@ -25,6 +25,11 @@ export type ImmutableObject = { readonly [K in keyof T]: Immutable }; export class EndpointAppConstants { static ALERT_INDEX_NAME = 'my-index'; static ENDPOINT_INDEX_NAME = 'endpoint-agent*'; + static EVENT_INDEX_NAME = 'endpoint-events-*'; + /** + * Legacy events are stored in indices with endgame-* prefix + */ + static LEGACY_EVENT_INDEX_NAME = 'endgame-*'; } export interface AlertResultList { @@ -117,6 +122,43 @@ export interface EndpointMetadata { }; } +export interface LegacyEndpointEvent { + '@timestamp': Date; + endgame: { + event_type_full: string; + event_subtype_full: string; + unique_pid: number; + unique_ppid: number; + serial_event_id: number; + }; + agent: { + id: string; + type: string; + }; +} + +export interface EndpointEvent { + '@timestamp': Date; + event: { + category: string; + type: string; + id: string; + }; + endpoint: { + process: { + entity_id: string; + parent: { + entity_id: string; + }; + }; + }; + agent: { + type: string; + }; +} + +export type ResolverEvent = EndpointEvent | LegacyEndpointEvent; + /** * The PageId type is used for the payload when firing userNavigatedToPage actions */ diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 7bb3b13525914..8530d6206d398 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -8,20 +8,22 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { CoreStart, AppMountParameters } from 'kibana/public'; import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; -import { Route, BrowserRouter, Switch } from 'react-router-dom'; -import { Provider } from 'react-redux'; +import { Route, Switch, BrowserRouter, useLocation } from 'react-router-dom'; +import { Provider, useDispatch } from 'react-redux'; import { Store } from 'redux'; +import { memo } from 'react'; import { appStoreFactory } from './store'; import { AlertIndex } from './view/alerts'; import { ManagementList } from './view/managing'; import { PolicyList } from './view/policy'; +import { AppAction } from './store/action'; +import { EndpointAppLocation } from './types'; /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - const store = appStoreFactory(coreStart); ReactDOM.render(, element); @@ -31,6 +33,13 @@ export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMou }; } +const RouteCapture = memo(({ children }) => { + const location: EndpointAppLocation = useLocation(); + const dispatch: (action: AppAction) => unknown = useDispatch(); + dispatch({ type: 'userChangedUrl', payload: location }); + return <>{children}; +}); + interface RouterProps { basename: string; store: Store; @@ -40,25 +49,27 @@ const AppRoot: React.FunctionComponent = React.memo(({ basename, st - - ( -

- -

- )} - /> - - - - ( - - )} - /> - + + + ( +

+ +

+ )} + /> + + } /> + + ( + + )} + /> +
+
diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/action.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/action.ts index 464a04eff5ebd..a628a95003a7f 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/action.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/action.ts @@ -4,11 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Immutable } from '../../../../../common/types'; import { AlertListData } from '../../types'; interface ServerReturnedAlertsData { - type: 'serverReturnedAlertsData'; - payload: AlertListData; + readonly type: 'serverReturnedAlertsData'; + readonly payload: Immutable; } export type AlertAction = ServerReturnedAlertsData; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/alert_list.test.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/alert_list.test.ts new file mode 100644 index 0000000000000..6ba7a34ae81d1 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/alert_list.test.ts @@ -0,0 +1,85 @@ +/* + * 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 { Store, createStore, applyMiddleware } from 'redux'; +import { History } from 'history'; +import { alertListReducer } from './reducer'; +import { AlertListState } from '../../types'; +import { alertMiddlewareFactory } from './middleware'; +import { AppAction } from '../action'; +import { coreMock } from 'src/core/public/mocks'; +import { AlertResultList } from '../../../../../common/types'; +import { isOnAlertPage } from './selectors'; +import { createBrowserHistory } from 'history'; + +describe('alert list tests', () => { + let store: Store; + let coreStart: ReturnType; + let history: History; + beforeEach(() => { + coreStart = coreMock.createStart(); + history = createBrowserHistory(); + const middleware = alertMiddlewareFactory(coreStart); + store = createStore(alertListReducer, applyMiddleware(middleware)); + }); + describe('when the user navigates to the alert list page', () => { + beforeEach(() => { + coreStart.http.get.mockImplementation(async () => { + const response: AlertResultList = { + alerts: [ + { + '@timestamp': new Date(1542341895000), + agent: { + id: 'ced9c68e-b94a-4d66-bb4c-6106514f0a2f', + version: '3.0.0', + }, + event: { + action: 'open', + }, + file_classification: { + malware_classification: { + score: 3, + }, + }, + host: { + hostname: 'HD-c15-bc09190a', + ip: '10.179.244.14', + os: { + name: 'Windows', + }, + }, + thread: {}, + }, + ], + total: 1, + request_page_size: 10, + request_page_index: 0, + result_from_index: 0, + }; + return response; + }); + + // Simulates user navigating to the /alerts page + store.dispatch({ + type: 'userChangedUrl', + payload: { + ...history.location, + pathname: '/alerts', + }, + }); + }); + + it("should recognize it's on the alert list page", () => { + const actual = isOnAlertPage(store.getState()); + expect(actual).toBe(true); + }); + + it('should return alertListData', () => { + const actualResponseLength = store.getState().alerts.length; + expect(actualResponseLength).toEqual(1); + }); + }); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/alert_list_pagination.test.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/alert_list_pagination.test.ts new file mode 100644 index 0000000000000..77708a3c77e2b --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/alert_list_pagination.test.ts @@ -0,0 +1,98 @@ +/* + * 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 { Store, createStore, applyMiddleware } from 'redux'; +import { History } from 'history'; +import { alertListReducer } from './reducer'; +import { AlertListState } from '../../types'; +import { alertMiddlewareFactory } from './middleware'; +import { AppAction } from '../action'; +import { coreMock } from 'src/core/public/mocks'; +import { createBrowserHistory } from 'history'; +import { + urlFromNewPageSizeParam, + paginationDataFromUrl, + urlFromNewPageIndexParam, +} from './selectors'; + +describe('alert list pagination', () => { + let store: Store; + let coreStart: ReturnType; + let history: History; + beforeEach(() => { + coreStart = coreMock.createStart(); + history = createBrowserHistory(); + const middleware = alertMiddlewareFactory(coreStart); + store = createStore(alertListReducer, applyMiddleware(middleware)); + }); + describe('when the user navigates to the alert list page', () => { + describe('when a new page size is passed', () => { + beforeEach(() => { + const urlPageSizeSelector = urlFromNewPageSizeParam(store.getState()); + history.push(urlPageSizeSelector(1)); + store.dispatch({ type: 'userChangedUrl', payload: history.location }); + }); + it('should modify the url correctly', () => { + const actualPaginationQuery = paginationDataFromUrl(store.getState()); + expect(actualPaginationQuery).toMatchInlineSnapshot(` + Object { + "page_size": "1", + } + `); + }); + + describe('and then a new page index is passed', () => { + beforeEach(() => { + const urlPageIndexSelector = urlFromNewPageIndexParam(store.getState()); + history.push(urlPageIndexSelector(1)); + store.dispatch({ type: 'userChangedUrl', payload: history.location }); + }); + it('should modify the url in the correct order', () => { + const actualPaginationQuery = paginationDataFromUrl(store.getState()); + expect(actualPaginationQuery).toMatchInlineSnapshot(` + Object { + "page_index": "1", + "page_size": "1", + } + `); + }); + }); + }); + + describe('when a new page index is passed', () => { + beforeEach(() => { + const urlPageIndexSelector = urlFromNewPageIndexParam(store.getState()); + history.push(urlPageIndexSelector(1)); + store.dispatch({ type: 'userChangedUrl', payload: history.location }); + }); + it('should modify the url correctly', () => { + const actualPaginationQuery = paginationDataFromUrl(store.getState()); + expect(actualPaginationQuery).toMatchInlineSnapshot(` + Object { + "page_index": "1", + } + `); + }); + + describe('and then a new page size is passed', () => { + beforeEach(() => { + const urlPageSizeSelector = urlFromNewPageSizeParam(store.getState()); + history.push(urlPageSizeSelector(1)); + store.dispatch({ type: 'userChangedUrl', payload: history.location }); + }); + it('should modify the url correctly and reset index to `0`', () => { + const actualPaginationQuery = paginationDataFromUrl(store.getState()); + expect(actualPaginationQuery).toMatchInlineSnapshot(` + Object { + "page_index": "0", + "page_size": "1", + } + `); + }); + }); + }); + }); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts index 4a7fac147852b..059507c8f0658 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts @@ -4,19 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -import { parse } from 'query-string'; -import { HttpFetchQuery } from 'src/core/public'; +import { HttpFetchQuery } from 'kibana/public'; +import { AlertResultList } from '../../../../../common/types'; import { AppAction } from '../action'; -import { MiddlewareFactory, AlertListData } from '../../types'; - -export const alertMiddlewareFactory: MiddlewareFactory = coreStart => { - const qp = parse(window.location.search.slice(1), { sort: false }); +import { MiddlewareFactory, AlertListState } from '../../types'; +import { isOnAlertPage, paginationDataFromUrl } from './selectors'; +export const alertMiddlewareFactory: MiddlewareFactory = coreStart => { return api => next => async (action: AppAction) => { next(action); - if (action.type === 'userNavigatedToPage' && action.payload === 'alertsPage') { - const response: AlertListData = await coreStart.http.get('/api/endpoint/alerts', { - query: qp as HttpFetchQuery, + const state = api.getState(); + if (action.type === 'userChangedUrl' && isOnAlertPage(state)) { + const response: AlertResultList = await coreStart.http.get(`/api/endpoint/alerts`, { + query: paginationDataFromUrl(state) as HttpFetchQuery, }); api.dispatch({ type: 'serverReturnedAlertsData', payload: response }); } diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/reducer.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/reducer.ts index de79476245d29..6369bb9fb2d0d 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/reducer.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/reducer.ts @@ -15,6 +15,7 @@ const initialState = (): AlertListState => { request_page_index: 0, result_from_index: 0, total: 0, + location: undefined, }; }; @@ -27,6 +28,11 @@ export const alertListReducer: Reducer = ( ...state, ...action.payload, }; + } else if (action.type === 'userChangedUrl') { + return { + ...state, + location: action.payload, + }; } return state; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts index 51903a0a641e8..6ad053888729c 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts @@ -4,6 +4,76 @@ * you may not use this file except in compliance with the Elastic License. */ +import qs from 'querystring'; import { AlertListState } from '../../types'; +/** + * Returns the Alert Data array from state + */ export const alertListData = (state: AlertListState) => state.alerts; + +/** + * Returns the alert list pagination data from state + */ +export const alertListPagination = (state: AlertListState) => { + return { + pageIndex: state.request_page_index, + pageSize: state.request_page_size, + resultFromIndex: state.result_from_index, + total: state.total, + }; +}; + +/** + * Returns a boolean based on whether or not the user is on the alerts page + */ +export const isOnAlertPage = (state: AlertListState): boolean => { + return state.location ? state.location.pathname === '/alerts' : false; +}; + +/** + * Returns the query object received from parsing the URL query params + */ +export const paginationDataFromUrl = (state: AlertListState): qs.ParsedUrlQuery => { + if (state.location) { + // Removes the `?` from the beginning of query string if it exists + const query = qs.parse(state.location.search.slice(1)); + return { + ...(query.page_size ? { page_size: query.page_size } : {}), + ...(query.page_index ? { page_index: query.page_index } : {}), + }; + } else { + return {}; + } +}; + +/** + * Returns a function that takes in a new page size and returns a new query param string + */ +export const urlFromNewPageSizeParam: ( + state: AlertListState +) => (newPageSize: number) => string = state => { + return newPageSize => { + const urlPaginationData = paginationDataFromUrl(state); + urlPaginationData.page_size = newPageSize.toString(); + + // Only set the url back to page zero if the user has changed the page index already + if (urlPaginationData.page_index !== undefined) { + urlPaginationData.page_index = '0'; + } + return '?' + qs.stringify(urlPaginationData); + }; +}; + +/** + * Returns a function that takes in a new page index and returns a new query param string + */ +export const urlFromNewPageIndexParam: ( + state: AlertListState +) => (newPageIndex: number) => string = state => { + return newPageIndex => { + const urlPaginationData = paginationDataFromUrl(state); + urlPaginationData.page_index = newPageIndex.toString(); + return '?' + qs.stringify(urlPaginationData); + }; +}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts index 8fe61ae01d319..3aeeeaf1c09e2 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts @@ -53,7 +53,6 @@ export const appStoreFactory = (coreStart: CoreStart): Store => { appReducer, composeWithReduxDevTools( applyMiddleware( - alertMiddlewareFactory(coreStart), substateMiddlewareFactory( globalState => globalState.managementList, managementMiddlewareFactory(coreStart) @@ -61,6 +60,10 @@ export const appStoreFactory = (coreStart: CoreStart): Store => { substateMiddlewareFactory( globalState => globalState.policyList, policyListMiddlewareFactory(coreStart) + ), + substateMiddlewareFactory( + globalState => globalState.alertList, + alertMiddlewareFactory(coreStart) ) ) ) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/routing/action.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/routing/action.ts index 9080af8c91817..c7e9970e58c30 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/routing/action.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/routing/action.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PageId } from '../../../../../common/types'; +import { PageId, Immutable } from '../../../../../common/types'; +import { EndpointAppLocation } from '../alerts'; interface UserNavigatedToPage { readonly type: 'userNavigatedToPage'; @@ -16,4 +17,9 @@ interface UserNavigatedFromPage { readonly payload: PageId; } -export type RoutingAction = UserNavigatedToPage | UserNavigatedFromPage; +interface UserChangedUrl { + readonly type: 'userChangedUrl'; + readonly payload: Immutable; +} + +export type RoutingAction = UserNavigatedToPage | UserNavigatedFromPage | UserChangedUrl; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/selectors.ts deleted file mode 100644 index 2766707271cde..0000000000000 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/selectors.ts +++ /dev/null @@ -1,31 +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 { GlobalState } from '../types'; -import * as alertListSelectors from './alerts/selectors'; - -export const alertListData = composeSelectors( - alertListStateSelector, - alertListSelectors.alertListData -); - -/** - * Returns the alert list state from within Global State - */ -function alertListStateSelector(state: GlobalState) { - return state.alertList; -} - -/** - * Calls the `secondSelector` with the result of the `selector`. Use this when re-exporting a - * concern-specific selector. `selector` should return the concern-specific state. - */ -function composeSelectors( - selector: (state: OuterState) => InnerState, - secondSelector: (state: InnerState) => ReturnValue -): (state: OuterState) => ReturnValue { - return state => secondSelector(selector(state)); -} diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts index 6b20012592fd9..d07521d09a119 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts @@ -8,7 +8,7 @@ import { Dispatch, MiddlewareAPI } from 'redux'; import { CoreStart } from 'kibana/public'; import { EndpointMetadata } from '../../../common/types'; import { AppAction } from './store/action'; -import { AlertResultList } from '../../../common/types'; +import { AlertResultList, Immutable } from '../../../common/types'; export type MiddlewareFactory = ( coreStart: CoreStart @@ -63,8 +63,6 @@ export interface GlobalState { readonly policyList: PolicyListState; } -export type AlertListData = AlertResultList; -export type AlertListState = AlertResultList; export type CreateStructuredSelector = < SelectorMap extends { [key: string]: (...args: never[]) => unknown } >( @@ -74,3 +72,16 @@ export type CreateStructuredSelector = < ) => { [Key in keyof SelectorMap]: ReturnType; }; + +export interface EndpointAppLocation { + pathname: string; + search: string; + state: never; + hash: string; + key?: string; +} + +export type AlertListData = AlertResultList; +export type AlertListState = Immutable & { + readonly location?: Immutable; +}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/hooks/use_alerts_selector.ts b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/hooks/use_alerts_selector.ts new file mode 100644 index 0000000000000..d3962f908757c --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/hooks/use_alerts_selector.ts @@ -0,0 +1,12 @@ +/* + * 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 { useSelector } from 'react-redux'; +import { GlobalState, AlertListState } from '../../../types'; + +export function useAlertListSelector(selector: (state: AlertListState) => TSelected) { + return useSelector((state: GlobalState) => selector(state.alertList)); +} diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx index 8c32426dcc868..045b82200b11b 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx @@ -4,41 +4,94 @@ * you may not use this file except in compliance with the Elastic License. */ -import { memo, useState, useMemo } from 'react'; +import { memo, useState, useMemo, useCallback } from 'react'; import React from 'react'; -import { EuiDataGrid } from '@elastic/eui'; -import { useSelector } from 'react-redux'; +import { EuiDataGrid, EuiDataGridColumn, EuiPage, EuiPageBody, EuiPageContent } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import * as selectors from '../../store/selectors'; -import { usePageId } from '../use_page_id'; +import { useHistory } from 'react-router-dom'; +import * as selectors from '../../store/alerts/selectors'; +import { useAlertListSelector } from './hooks/use_alerts_selector'; export const AlertIndex = memo(() => { - usePageId('alertsPage'); + const history = useHistory(); - const columns: Array<{ id: string }> = useMemo(() => { + const columns: EuiDataGridColumn[] = useMemo(() => { return [ - { id: 'alert_type' }, - { id: 'event_type' }, - { id: 'os' }, - { id: 'ip_address' }, - { id: 'host_name' }, - { id: 'timestamp' }, - { id: 'archived' }, - { id: 'malware_score' }, + { + id: 'alert_type', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.alertType', { + defaultMessage: 'Alert Type', + }), + }, + { + id: 'event_type', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.eventType', { + defaultMessage: 'Event Type', + }), + }, + { + id: 'os', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.os', { + defaultMessage: 'OS', + }), + }, + { + id: 'ip_address', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.ipAddress', { + defaultMessage: 'IP Address', + }), + }, + { + id: 'host_name', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.hostName', { + defaultMessage: 'Host Name', + }), + }, + { + id: 'timestamp', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.timestamp', { + defaultMessage: 'Timestamp', + }), + }, + { + id: 'archived', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.archived', { + defaultMessage: 'Archived', + }), + }, + { + id: 'malware_score', + display: i18n.translate('xpack.endpoint.application.endpoint.alerts.malwareScore', { + defaultMessage: 'Malware Score', + }), + }, ]; }, []); - const [visibleColumns, setVisibleColumns] = useState(() => columns.map(({ id }) => id)); + const { pageIndex, pageSize, total } = useAlertListSelector(selectors.alertListPagination); + const urlFromNewPageSizeParam = useAlertListSelector(selectors.urlFromNewPageSizeParam); + const urlFromNewPageIndexParam = useAlertListSelector(selectors.urlFromNewPageIndexParam); + const alertListData = useAlertListSelector(selectors.alertListData); + + const onChangeItemsPerPage = useCallback( + newPageSize => history.push(urlFromNewPageSizeParam(newPageSize)), + [history, urlFromNewPageSizeParam] + ); + + const onChangePage = useCallback( + newPageIndex => history.push(urlFromNewPageIndexParam(newPageIndex)), + [history, urlFromNewPageIndexParam] + ); - const json = useSelector(selectors.alertListData); + const [visibleColumns, setVisibleColumns] = useState(() => columns.map(({ id }) => id)); const renderCellValue = useMemo(() => { return ({ rowIndex, columnId }: { rowIndex: number; columnId: string }) => { - if (rowIndex > json.length) { + if (rowIndex > total) { return null; } - const row = json[rowIndex]; + const row = alertListData[rowIndex % pageSize]; if (columnId === 'alert_type') { return i18n.translate( @@ -64,23 +117,36 @@ export const AlertIndex = memo(() => { } return null; }; - }, [json]); + }, [alertListData, pageSize, total]); + + const pagination = useMemo(() => { + return { + pageIndex, + pageSize, + pageSizeOptions: [10, 20, 50], + onChangeItemsPerPage, + onChangePage, + }; + }, [onChangeItemsPerPage, onChangePage, pageIndex, pageSize]); return ( - + + + + + + + ); }); diff --git a/x-pack/plugins/endpoint/server/plugin.ts b/x-pack/plugins/endpoint/server/plugin.ts index 3fed4ca480b85..afed5199b7d72 100644 --- a/x-pack/plugins/endpoint/server/plugin.ts +++ b/x-pack/plugins/endpoint/server/plugin.ts @@ -5,12 +5,14 @@ */ import { Plugin, CoreSetup, PluginInitializerContext, Logger } from 'kibana/server'; import { first } from 'rxjs/operators'; -import { addRoutes } from './routes'; import { PluginSetupContract as FeaturesPluginSetupContract } from '../../features/server'; import { createConfig$, EndpointConfigType } from './config'; -import { registerEndpointRoutes } from './routes/endpoints'; import { EndpointAppContext } from './types'; + +import { addRoutes } from './routes'; +import { registerEndpointRoutes } from './routes/endpoints'; import { registerAlertRoutes } from './routes/alerts'; +import { registerResolverRoutes } from './routes/resolver'; export type EndpointPluginStart = void; export type EndpointPluginSetup = void; @@ -69,6 +71,7 @@ export class EndpointPlugin const router = core.http.createRouter(); addRoutes(router); registerEndpointRoutes(router, endpointContext); + registerResolverRoutes(router, endpointContext); registerAlertRoutes(router, endpointContext); } diff --git a/x-pack/plugins/endpoint/server/routes/resolver.ts b/x-pack/plugins/endpoint/server/routes/resolver.ts new file mode 100644 index 0000000000000..946ada51c40e9 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver.ts @@ -0,0 +1,42 @@ +/* + * 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 { IRouter } from 'kibana/server'; +import { EndpointAppContext } from '../types'; +import { handleRelatedEvents, validateRelatedEvents } from './resolver/related_events'; +import { handleChildren, validateChildren } from './resolver/children'; +import { handleLifecycle, validateLifecycle } from './resolver/lifecycle'; + +export function registerResolverRoutes(router: IRouter, endpointAppContext: EndpointAppContext) { + const log = endpointAppContext.logFactory.get('resolver'); + + router.get( + { + path: '/api/endpoint/resolver/{id}/related', + validate: validateRelatedEvents, + options: { authRequired: true }, + }, + handleRelatedEvents(log) + ); + + router.get( + { + path: '/api/endpoint/resolver/{id}/children', + validate: validateChildren, + options: { authRequired: true }, + }, + handleChildren(log) + ); + + router.get( + { + path: '/api/endpoint/resolver/{id}', + validate: validateLifecycle, + options: { authRequired: true }, + }, + handleLifecycle(log) + ); +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/children.ts b/x-pack/plugins/endpoint/server/routes/resolver/children.ts new file mode 100644 index 0000000000000..f97c742b18d67 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/children.ts @@ -0,0 +1,90 @@ +/* + * 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 _ from 'lodash'; +import { schema } from '@kbn/config-schema'; +import { RequestHandler, Logger } from 'kibana/server'; +import { extractEntityID } from './utils/normalize'; +import { getPaginationParams } from './utils/pagination'; +import { LifecycleQuery } from './queries/lifecycle'; +import { ChildrenQuery } from './queries/children'; + +interface ChildrenQueryParams { + after?: string; + limit: number; + /** + * legacyEndpointID is optional because there are two different types of identifiers: + * + * Legacy + * A legacy Entity ID is made up of the agent.id and unique_pid fields. The client will need to identify if + * it's looking at a legacy event and use those fields when making requests to the backend. The + * request would be /resolver/{id}?legacyEndpointID=and the {id} would be the unique_pid. + * + * Elastic Endpoint + * When interacting with the new form of data the client doesn't need the legacyEndpointID because it's already a + * part of the entityID in the new type of event. So for the same request the client would just hit resolver/{id} + * and the {id} would be entityID stored in the event's process.entity_id field. + */ + legacyEndpointID?: string; +} + +interface ChildrenPathParams { + id: string; +} + +export const validateChildren = { + params: schema.object({ id: schema.string() }), + query: schema.object({ + after: schema.maybe(schema.string()), + limit: schema.number({ defaultValue: 10, min: 1, max: 100 }), + legacyEndpointID: schema.maybe(schema.string()), + }), +}; + +export function handleChildren( + log: Logger +): RequestHandler { + return async (context, req, res) => { + const { + params: { id }, + query: { limit, after, legacyEndpointID }, + } = req; + try { + const pagination = getPaginationParams(limit, after); + + const client = context.core.elasticsearch.dataClient; + const childrenQuery = new ChildrenQuery(legacyEndpointID, pagination); + const lifecycleQuery = new LifecycleQuery(legacyEndpointID); + + // Retrieve the related child process events for a given process + const { total, results: events, nextCursor } = await childrenQuery.search(client, id); + const childIDs = events.map(extractEntityID); + + // Retrieve the lifecycle events for the child processes (e.g. started, terminated etc) + // this needs to fire after the above since we don't yet have the entity ids until we + // run the first query + const { results: lifecycleEvents } = await lifecycleQuery.search(client, ...childIDs); + + // group all of the lifecycle events by the child process id + const lifecycleGroups = Object.values(_.groupBy(lifecycleEvents, extractEntityID)); + const children = lifecycleGroups.map(group => ({ lifecycle: group })); + + return res.ok({ + body: { + children, + pagination: { + total, + next: nextCursor, + limit, + }, + }, + }); + } catch (err) { + log.warn(err); + return res.internalError({ body: err }); + } + }; +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts b/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts new file mode 100644 index 0000000000000..9895344174014 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts @@ -0,0 +1,94 @@ +/* + * 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 _ from 'lodash'; +import { schema } from '@kbn/config-schema'; +import { RequestHandler, Logger } from 'kibana/server'; +import { extractParentEntityID } from './utils/normalize'; +import { LifecycleQuery } from './queries/lifecycle'; +import { ResolverEvent } from '../../../common/types'; + +interface LifecycleQueryParams { + ancestors: number; + /** + * legacyEndpointID is optional because there are two different types of identifiers: + * + * Legacy + * A legacy Entity ID is made up of the agent.id and unique_pid fields. The client will need to identify if + * it's looking at a legacy event and use those fields when making requests to the backend. The + * request would be /resolver/{id}?legacyEndpointID=and the {id} would be the unique_pid. + * + * Elastic Endpoint + * When interacting with the new form of data the client doesn't need the legacyEndpointID because it's already a + * part of the entityID in the new type of event. So for the same request the client would just hit resolver/{id} + * and the {id} would be entityID stored in the event's process.entity_id field. + */ + legacyEndpointID?: string; +} + +interface LifecyclePathParams { + id: string; +} + +export const validateLifecycle = { + params: schema.object({ id: schema.string() }), + query: schema.object({ + ancestors: schema.number({ defaultValue: 0, min: 0, max: 10 }), + legacyEndpointID: schema.maybe(schema.string()), + }), +}; + +function getParentEntityID(results: ResolverEvent[]) { + return results.length === 0 ? undefined : extractParentEntityID(results[0]); +} + +export function handleLifecycle( + log: Logger +): RequestHandler { + return async (context, req, res) => { + const { + params: { id }, + query: { ancestors, legacyEndpointID }, + } = req; + try { + const ancestorLifecycles = []; + const client = context.core.elasticsearch.dataClient; + + const lifecycleQuery = new LifecycleQuery(legacyEndpointID); + const { results: processLifecycle } = await lifecycleQuery.search(client, id); + let nextParentID = getParentEntityID(processLifecycle); + + if (nextParentID) { + for (let i = 0; i < ancestors; i++) { + const { results: lifecycle } = await lifecycleQuery.search(client, nextParentID); + nextParentID = getParentEntityID(lifecycle); + + if (!nextParentID) { + break; + } + + ancestorLifecycles.push({ + lifecycle, + }); + } + } + + return res.ok({ + body: { + lifecycle: processLifecycle, + ancestors: ancestorLifecycles, + pagination: { + next: nextParentID || null, + ancestors, + }, + }, + }); + } catch (err) { + log.warn(err); + return res.internalError({ body: err }); + } + }; +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts new file mode 100644 index 0000000000000..be83efc39ca4c --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts @@ -0,0 +1,42 @@ +/* + * 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 { IScopedClusterClient } from 'kibana/server'; +import { EndpointAppConstants } from '../../../../common/types'; +import { paginate, paginatedResults, PaginationParams } from '../utils/pagination'; +import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public'; + +export abstract class ResolverQuery { + constructor( + private readonly endpointID?: string, + private readonly pagination?: PaginationParams + ) {} + + protected paginateBy(field: string, query: JsonObject) { + if (!this.pagination) { + return query; + } + return paginate(this.pagination, field, query); + } + + build(...ids: string[]) { + if (this.endpointID) { + return this.legacyQuery(this.endpointID, ids, EndpointAppConstants.LEGACY_EVENT_INDEX_NAME); + } + return this.query(ids, EndpointAppConstants.EVENT_INDEX_NAME); + } + + async search(client: IScopedClusterClient, ...ids: string[]) { + return paginatedResults(await client.callAsCurrentUser('search', this.build(...ids))); + } + + protected abstract legacyQuery( + endpointID: string, + uniquePIDs: string[], + index: string + ): JsonObject; + protected abstract query(entityIDs: string[], index: string): JsonObject; +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts new file mode 100644 index 0000000000000..2dd2e0c2d1d5f --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts @@ -0,0 +1,94 @@ +/* + * 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 { ChildrenQuery } from './children'; +import { EndpointAppConstants } from '../../../../common/types'; + +describe('children events query', () => { + it('generates the correct legacy queries', () => { + const timestamp = new Date(); + expect( + new ChildrenQuery('awesome-id', { size: 1, timestamp, eventID: 'foo' }).build('5') + ).toStrictEqual({ + body: { + query: { + bool: { + filter: [ + { + terms: { 'endgame.unique_ppid': ['5'] }, + }, + { + term: { 'agent.id': 'awesome-id' }, + }, + { + term: { 'event.category': 'process' }, + }, + { + term: { 'event.type': 'process_start' }, + }, + ], + }, + }, + aggs: { + total: { + value_count: { + field: 'endgame.serial_event_id', + }, + }, + }, + search_after: [timestamp.getTime(), 'foo'], + size: 1, + sort: [{ '@timestamp': 'asc' }, { 'endgame.serial_event_id': 'asc' }], + }, + index: EndpointAppConstants.LEGACY_EVENT_INDEX_NAME, + }); + }); + + it('generates the correct non-legacy queries', () => { + const timestamp = new Date(); + + expect( + new ChildrenQuery(undefined, { size: 1, timestamp, eventID: 'bar' }).build('baz') + ).toStrictEqual({ + body: { + query: { + bool: { + filter: [ + { + bool: { + should: [ + { + terms: { 'endpoint.process.parent.entity_id': ['baz'] }, + }, + { + terms: { 'process.parent.entity_id': ['baz'] }, + }, + ], + }, + }, + { + term: { 'event.category': 'process' }, + }, + { + term: { 'event.type': 'start' }, + }, + ], + }, + }, + aggs: { + total: { + value_count: { + field: 'event.id', + }, + }, + }, + search_after: [timestamp.getTime(), 'bar'], + size: 1, + sort: [{ '@timestamp': 'asc' }, { 'event.id': 'asc' }], + }, + index: EndpointAppConstants.EVENT_INDEX_NAME, + }); + }); +}); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/children.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/children.ts new file mode 100644 index 0000000000000..6d084a0cf20e5 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/children.ts @@ -0,0 +1,74 @@ +/* + * 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 { ResolverQuery } from './base'; + +export class ChildrenQuery extends ResolverQuery { + protected legacyQuery(endpointID: string, uniquePIDs: string[], index: string) { + return { + body: this.paginateBy('endgame.serial_event_id', { + query: { + bool: { + filter: [ + { + terms: { 'endgame.unique_ppid': uniquePIDs }, + }, + { + term: { 'agent.id': endpointID }, + }, + { + term: { 'event.category': 'process' }, + }, + { + // Corner case, we could only have a process_running or process_terminated + // so to solve this we'll probably want to either search for all of them and only return one if that's + // possible in elastic search or in memory pull out a single event to return + // https://github.com/elastic/endpoint-app-team/issues/168 + term: { 'event.type': 'process_start' }, + }, + ], + }, + }, + }), + index, + }; + } + + protected query(entityIDs: string[], index: string) { + return { + body: this.paginateBy('event.id', { + query: { + bool: { + filter: [ + { + bool: { + should: [ + { + terms: { 'endpoint.process.parent.entity_id': entityIDs }, + }, + { + terms: { 'process.parent.entity_id': entityIDs }, + }, + ], + }, + }, + { + term: { 'event.category': 'process' }, + }, + { + // Corner case, we could only have a process_running or process_terminated + // so to solve this we'll probably want to either search for all of them and only return one if that's + // possible in elastic search or in memory pull out a single event to return + // https://github.com/elastic/endpoint-app-team/issues/168 + term: { 'event.type': 'start' }, + }, + ], + }, + }, + }), + index, + }; + } +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts new file mode 100644 index 0000000000000..b1b47bfb9de7f --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts @@ -0,0 +1,63 @@ +/* + * 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 { EndpointAppConstants } from '../../../../common/types'; +import { LifecycleQuery } from './lifecycle'; + +describe('lifecycle query', () => { + it('generates the correct legacy queries', () => { + expect(new LifecycleQuery('awesome-id').build('5')).toStrictEqual({ + body: { + query: { + bool: { + filter: [ + { + terms: { 'endgame.unique_pid': ['5'] }, + }, + { + term: { 'agent.id': 'awesome-id' }, + }, + { + term: { 'event.category': 'process' }, + }, + ], + }, + }, + sort: [{ '@timestamp': 'asc' }], + }, + index: EndpointAppConstants.LEGACY_EVENT_INDEX_NAME, + }); + }); + + it('generates the correct non-legacy queries', () => { + expect(new LifecycleQuery().build('baz')).toStrictEqual({ + body: { + query: { + bool: { + filter: [ + { + bool: { + should: [ + { + terms: { 'endpoint.process.entity_id': ['baz'] }, + }, + { + terms: { 'process.entity_id': ['baz'] }, + }, + ], + }, + }, + { + term: { 'event.category': 'process' }, + }, + ], + }, + }, + sort: [{ '@timestamp': 'asc' }], + }, + index: EndpointAppConstants.EVENT_INDEX_NAME, + }); + }); +}); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.ts new file mode 100644 index 0000000000000..290c601e0e9d8 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.ts @@ -0,0 +1,64 @@ +/* + * 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 { ResolverQuery } from './base'; +import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public'; + +// consider limiting the response size to a reasonable value in case we have a bunch of lifecycle events +export class LifecycleQuery extends ResolverQuery { + protected legacyQuery(endpointID: string, uniquePIDs: string[], index: string): JsonObject { + return { + body: { + query: { + bool: { + filter: [ + { + terms: { 'endgame.unique_pid': uniquePIDs }, + }, + { + term: { 'agent.id': endpointID }, + }, + { + term: { 'event.category': 'process' }, + }, + ], + }, + }, + sort: [{ '@timestamp': 'asc' }], + }, + index, + }; + } + + protected query(entityIDs: string[], index: string): JsonObject { + return { + body: { + query: { + bool: { + filter: [ + { + bool: { + should: [ + { + terms: { 'endpoint.process.entity_id': entityIDs }, + }, + { + terms: { 'process.entity_id': entityIDs }, + }, + ], + }, + }, + { + term: { 'event.category': 'process' }, + }, + ], + }, + }, + sort: [{ '@timestamp': 'asc' }], + }, + index, + }; + } +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts new file mode 100644 index 0000000000000..8ef680a168310 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts @@ -0,0 +1,96 @@ +/* + * 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 { RelatedEventsQuery } from './related_events'; +import { EndpointAppConstants } from '../../../../common/types'; + +describe('related events query', () => { + it('generates the correct legacy queries', () => { + const timestamp = new Date(); + expect( + new RelatedEventsQuery('awesome-id', { size: 1, timestamp, eventID: 'foo' }).build('5') + ).toStrictEqual({ + body: { + query: { + bool: { + filter: [ + { + terms: { 'endgame.unique_pid': ['5'] }, + }, + { + term: { 'agent.id': 'awesome-id' }, + }, + { + bool: { + must_not: { + term: { 'event.category': 'process' }, + }, + }, + }, + ], + }, + }, + aggs: { + total: { + value_count: { + field: 'endgame.serial_event_id', + }, + }, + }, + search_after: [timestamp.getTime(), 'foo'], + size: 1, + sort: [{ '@timestamp': 'asc' }, { 'endgame.serial_event_id': 'asc' }], + }, + index: EndpointAppConstants.LEGACY_EVENT_INDEX_NAME, + }); + }); + + it('generates the correct non-legacy queries', () => { + const timestamp = new Date(); + + expect( + new RelatedEventsQuery(undefined, { size: 1, timestamp, eventID: 'bar' }).build('baz') + ).toStrictEqual({ + body: { + query: { + bool: { + filter: [ + { + bool: { + should: [ + { + terms: { 'endpoint.process.entity_id': ['baz'] }, + }, + { + terms: { 'process.entity_id': ['baz'] }, + }, + ], + }, + }, + { + bool: { + must_not: { + term: { 'event.category': 'process' }, + }, + }, + }, + ], + }, + }, + aggs: { + total: { + value_count: { + field: 'event.id', + }, + }, + }, + search_after: [timestamp.getTime(), 'bar'], + size: 1, + sort: [{ '@timestamp': 'asc' }, { 'event.id': 'asc' }], + }, + index: EndpointAppConstants.EVENT_INDEX_NAME, + }); + }); +}); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.ts new file mode 100644 index 0000000000000..cc5afe8face8d --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.ts @@ -0,0 +1,69 @@ +/* + * 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 { ResolverQuery } from './base'; +import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public'; + +export class RelatedEventsQuery extends ResolverQuery { + protected legacyQuery(endpointID: string, uniquePIDs: string[], index: string): JsonObject { + return { + body: this.paginateBy('endgame.serial_event_id', { + query: { + bool: { + filter: [ + { + terms: { 'endgame.unique_pid': uniquePIDs }, + }, + { + term: { 'agent.id': endpointID }, + }, + { + bool: { + must_not: { + term: { 'event.category': 'process' }, + }, + }, + }, + ], + }, + }, + }), + index, + }; + } + + protected query(entityIDs: string[], index: string): JsonObject { + return { + body: this.paginateBy('event.id', { + query: { + bool: { + filter: [ + { + bool: { + should: [ + { + terms: { 'endpoint.process.entity_id': entityIDs }, + }, + { + terms: { 'process.entity_id': entityIDs }, + }, + ], + }, + }, + { + bool: { + must_not: { + term: { 'event.category': 'process' }, + }, + }, + }, + ], + }, + }, + }), + index, + }; + } +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts b/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts new file mode 100644 index 0000000000000..804400522065c --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts @@ -0,0 +1,73 @@ +/* + * 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 { schema } from '@kbn/config-schema'; +import { RequestHandler, Logger } from 'kibana/server'; +import { getPaginationParams } from './utils/pagination'; +import { RelatedEventsQuery } from './queries/related_events'; + +interface RelatedEventsQueryParams { + after?: string; + limit: number; + /** + * legacyEndpointID is optional because there are two different types of identifiers: + * + * Legacy + * A legacy Entity ID is made up of the agent.id and unique_pid fields. The client will need to identify if + * it's looking at a legacy event and use those fields when making requests to the backend. The + * request would be /resolver/{id}?legacyEndpointID=and the {id} would be the unique_pid. + * + * Elastic Endpoint + * When interacting with the new form of data the client doesn't need the legacyEndpointID because it's already a + * part of the entityID in the new type of event. So for the same request the client would just hit resolver/{id} + * and the {id} would be entityID stored in the event's process.entity_id field. + */ + legacyEndpointID?: string; +} + +interface RelatedEventsPathParams { + id: string; +} + +export const validateRelatedEvents = { + params: schema.object({ id: schema.string() }), + query: schema.object({ + after: schema.maybe(schema.string()), + limit: schema.number({ defaultValue: 100, min: 1, max: 1000 }), + legacyEndpointID: schema.maybe(schema.string()), + }), +}; + +export function handleRelatedEvents( + log: Logger +): RequestHandler { + return async (context, req, res) => { + const { + params: { id }, + query: { limit, after, legacyEndpointID }, + } = req; + try { + const pagination = getPaginationParams(limit, after); + + const client = context.core.elasticsearch.dataClient; + // Retrieve the related non-process events for a given process + const relatedEventsQuery = new RelatedEventsQuery(legacyEndpointID, pagination); + const relatedEvents = await relatedEventsQuery.search(client, id); + + const { total, results: events, nextCursor } = relatedEvents; + + return res.ok({ + body: { + events, + pagination: { total, next: nextCursor, limit }, + }, + }); + } catch (err) { + log.warn(err); + return res.internalError({ body: err }); + } + }; +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/utils/normalize.ts b/x-pack/plugins/endpoint/server/routes/resolver/utils/normalize.ts new file mode 100644 index 0000000000000..86dd4c053e8fa --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/utils/normalize.ts @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ResolverEvent, LegacyEndpointEvent } from '../../../../common/types'; + +function isLegacyData(data: ResolverEvent): data is LegacyEndpointEvent { + return data.agent.type === 'endgame'; +} + +export function extractEventID(event: ResolverEvent) { + if (isLegacyData(event)) { + return String(event.endgame.serial_event_id); + } + return event.event.id; +} + +export function extractEntityID(event: ResolverEvent) { + if (isLegacyData(event)) { + return String(event.endgame.unique_pid); + } + return event.endpoint.process.entity_id; +} + +export function extractParentEntityID(event: ResolverEvent) { + if (isLegacyData(event)) { + const ppid = event.endgame.unique_ppid; + return ppid && String(ppid); // if unique_ppid is undefined return undefined + } + return event.endpoint.process.parent?.entity_id; +} diff --git a/x-pack/plugins/endpoint/server/routes/resolver/utils/pagination.ts b/x-pack/plugins/endpoint/server/routes/resolver/utils/pagination.ts new file mode 100644 index 0000000000000..33eb698479308 --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/resolver/utils/pagination.ts @@ -0,0 +1,91 @@ +/* + * 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 { SearchResponse } from 'elasticsearch'; +import { ResolverEvent } from '../../../../common/types'; +import { extractEventID } from './normalize'; +import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public'; + +export interface PaginationParams { + size: number; + timestamp?: Date; + eventID?: string; +} + +interface PaginationCursor { + timestamp: Date; + eventID: string; +} + +function urlEncodeCursor(data: PaginationCursor) { + const value = JSON.stringify(data); + return Buffer.from(value, 'utf8') + .toString('base64') + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=+$/g, ''); +} + +function urlDecodeCursor(value: string): PaginationCursor { + value = value.replace(/\-/g, '+').replace(/_/g, '/'); + const data = Buffer.from(value, 'base64').toString('utf8'); + const { timestamp, eventID } = JSON.parse(data); + // take some extra care to only grab the things we want + // convert the timestamp string to date object + return { timestamp: new Date(timestamp), eventID }; +} + +export function getPaginationParams(limit: number, after?: string): PaginationParams { + if (after) { + try { + const cursor = urlDecodeCursor(after); + if (cursor.timestamp && cursor.eventID) { + return { + size: limit, + timestamp: cursor.timestamp, + eventID: cursor.eventID, + }; + } + } catch (err) { + /* tslint:disable:no-empty */ + } // ignore invalid cursor values + } + return { size: limit }; +} + +export function paginate(pagination: PaginationParams, field: string, query: JsonObject) { + const { size, timestamp, eventID } = pagination; + query.sort = [{ '@timestamp': 'asc' }, { [field]: 'asc' }]; + query.aggs = { total: { value_count: { field } } }; + query.size = size; + if (timestamp && eventID) { + query.search_after = [timestamp.getTime(), eventID] as Array; + } + return query; +} + +export function paginatedResults( + response: SearchResponse +): { total: number; results: ResolverEvent[]; nextCursor: string | null } { + const total = response.aggregations?.total?.value || 0; + if (response.hits.hits.length === 0) { + return { total, results: [], nextCursor: null }; + } + + const results: ResolverEvent[] = []; + for (const hit of response.hits.hits) { + results.push(hit._source); + } + + // results will be at least 1 because of length check at the top of the function + const next = results[results.length - 1]; + const cursor = { + timestamp: next['@timestamp'], + eventID: extractEventID(next), + }; + + return { total, results, nextCursor: urlEncodeCursor(cursor) }; +} diff --git a/x-pack/legacy/plugins/infra/README.md b/x-pack/plugins/infra/README.md similarity index 100% rename from x-pack/legacy/plugins/infra/README.md rename to x-pack/plugins/infra/README.md diff --git a/x-pack/legacy/plugins/infra/common/color_palette.test.ts b/x-pack/plugins/infra/common/color_palette.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/color_palette.test.ts rename to x-pack/plugins/infra/common/color_palette.test.ts diff --git a/x-pack/legacy/plugins/infra/common/color_palette.ts b/x-pack/plugins/infra/common/color_palette.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/color_palette.ts rename to x-pack/plugins/infra/common/color_palette.ts diff --git a/x-pack/legacy/plugins/infra/common/ecs_allowed_list.test.ts b/x-pack/plugins/infra/common/ecs_allowed_list.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/ecs_allowed_list.test.ts rename to x-pack/plugins/infra/common/ecs_allowed_list.test.ts diff --git a/x-pack/legacy/plugins/infra/common/ecs_allowed_list.ts b/x-pack/plugins/infra/common/ecs_allowed_list.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/ecs_allowed_list.ts rename to x-pack/plugins/infra/common/ecs_allowed_list.ts diff --git a/x-pack/legacy/plugins/infra/common/errors/index.ts b/x-pack/plugins/infra/common/errors/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/errors/index.ts rename to x-pack/plugins/infra/common/errors/index.ts diff --git a/x-pack/legacy/plugins/infra/common/errors/metrics.ts b/x-pack/plugins/infra/common/errors/metrics.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/errors/metrics.ts rename to x-pack/plugins/infra/common/errors/metrics.ts diff --git a/x-pack/legacy/plugins/infra/common/graphql/root/index.ts b/x-pack/plugins/infra/common/graphql/root/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/graphql/root/index.ts rename to x-pack/plugins/infra/common/graphql/root/index.ts diff --git a/x-pack/legacy/plugins/infra/common/graphql/root/schema.gql.ts b/x-pack/plugins/infra/common/graphql/root/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/graphql/root/schema.gql.ts rename to x-pack/plugins/infra/common/graphql/root/schema.gql.ts diff --git a/x-pack/legacy/plugins/infra/common/graphql/shared/fragments.gql_query.ts b/x-pack/plugins/infra/common/graphql/shared/fragments.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/graphql/shared/fragments.gql_query.ts rename to x-pack/plugins/infra/common/graphql/shared/fragments.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/common/graphql/shared/index.ts b/x-pack/plugins/infra/common/graphql/shared/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/graphql/shared/index.ts rename to x-pack/plugins/infra/common/graphql/shared/index.ts diff --git a/x-pack/legacy/plugins/infra/common/graphql/shared/schema.gql.ts b/x-pack/plugins/infra/common/graphql/shared/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/graphql/shared/schema.gql.ts rename to x-pack/plugins/infra/common/graphql/shared/schema.gql.ts diff --git a/x-pack/legacy/plugins/infra/common/graphql/types.ts b/x-pack/plugins/infra/common/graphql/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/graphql/types.ts rename to x-pack/plugins/infra/common/graphql/types.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/index.ts b/x-pack/plugins/infra/common/http_api/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/index.ts rename to x-pack/plugins/infra/common/http_api/index.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/inventory_meta_api.ts b/x-pack/plugins/infra/common/http_api/inventory_meta_api.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/inventory_meta_api.ts rename to x-pack/plugins/infra/common/http_api/inventory_meta_api.ts diff --git a/x-pack/plugins/infra/common/http_api/ip_to_hostname/index.ts b/x-pack/plugins/infra/common/http_api/ip_to_hostname/index.ts new file mode 100644 index 0000000000000..4ebd5fdda6f99 --- /dev/null +++ b/x-pack/plugins/infra/common/http_api/ip_to_hostname/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export interface IpToHostResponse { + host: string; +} diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/index.ts b/x-pack/plugins/infra/common/http_api/log_analysis/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/index.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/index.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/index.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/index.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/results/index.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_categories.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_categories.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_categories.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_categories.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_category_datasets.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_category_datasets.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_category_datasets.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_category_datasets.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_rate.ts b/x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_rate.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_rate.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_rate.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/validation/index.ts b/x-pack/plugins/infra/common/http_api/log_analysis/validation/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/validation/index.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/validation/index.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_analysis/validation/log_entry_rate_indices.ts b/x-pack/plugins/infra/common/http_api/log_analysis/validation/log_entry_rate_indices.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_analysis/validation/log_entry_rate_indices.ts rename to x-pack/plugins/infra/common/http_api/log_analysis/validation/log_entry_rate_indices.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/common.ts b/x-pack/plugins/infra/common/http_api/log_entries/common.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/common.ts rename to x-pack/plugins/infra/common/http_api/log_entries/common.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/entries.ts b/x-pack/plugins/infra/common/http_api/log_entries/entries.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/entries.ts rename to x-pack/plugins/infra/common/http_api/log_entries/entries.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/highlights.ts b/x-pack/plugins/infra/common/http_api/log_entries/highlights.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/highlights.ts rename to x-pack/plugins/infra/common/http_api/log_entries/highlights.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/index.ts b/x-pack/plugins/infra/common/http_api/log_entries/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/index.ts rename to x-pack/plugins/infra/common/http_api/log_entries/index.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/item.ts b/x-pack/plugins/infra/common/http_api/log_entries/item.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/item.ts rename to x-pack/plugins/infra/common/http_api/log_entries/item.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/summary.ts b/x-pack/plugins/infra/common/http_api/log_entries/summary.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/summary.ts rename to x-pack/plugins/infra/common/http_api/log_entries/summary.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/summary_highlights.ts b/x-pack/plugins/infra/common/http_api/log_entries/summary_highlights.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/log_entries/summary_highlights.ts rename to x-pack/plugins/infra/common/http_api/log_entries/summary_highlights.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/metadata_api.ts b/x-pack/plugins/infra/common/http_api/metadata_api.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/metadata_api.ts rename to x-pack/plugins/infra/common/http_api/metadata_api.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/metrics_explorer/index.ts b/x-pack/plugins/infra/common/http_api/metrics_explorer/index.ts similarity index 78% rename from x-pack/legacy/plugins/infra/common/http_api/metrics_explorer/index.ts rename to x-pack/plugins/infra/common/http_api/metrics_explorer/index.ts index c10f86c40ad46..93655f931f45d 100644 --- a/x-pack/legacy/plugins/infra/common/http_api/metrics_explorer/index.ts +++ b/x-pack/plugins/infra/common/http_api/metrics_explorer/index.ts @@ -94,3 +94,21 @@ export const metricsExplorerResponseRT = rt.type({ series: rt.array(metricsExplorerSeriesRT), pageInfo: metricsExplorerPageInfoRT, }); + +export type MetricsExplorerAggregation = rt.TypeOf; + +export type MetricsExplorerColumnType = rt.TypeOf; + +export type MetricsExplorerMetric = rt.TypeOf; + +export type MetricsExplorerPageInfo = rt.TypeOf; + +export type MetricsExplorerColumn = rt.TypeOf; + +export type MetricsExplorerRow = rt.TypeOf; + +export type MetricsExplorerSeries = rt.TypeOf; + +export type MetricsExplorerRequestBody = rt.TypeOf; + +export type MetricsExplorerResponse = rt.TypeOf; diff --git a/x-pack/legacy/plugins/infra/common/http_api/node_details_api.ts b/x-pack/plugins/infra/common/http_api/node_details_api.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/node_details_api.ts rename to x-pack/plugins/infra/common/http_api/node_details_api.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/shared/errors.ts b/x-pack/plugins/infra/common/http_api/shared/errors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/shared/errors.ts rename to x-pack/plugins/infra/common/http_api/shared/errors.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/shared/index.ts b/x-pack/plugins/infra/common/http_api/shared/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/shared/index.ts rename to x-pack/plugins/infra/common/http_api/shared/index.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/shared/metric_statistics.ts b/x-pack/plugins/infra/common/http_api/shared/metric_statistics.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/shared/metric_statistics.ts rename to x-pack/plugins/infra/common/http_api/shared/metric_statistics.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/shared/time_range.ts b/x-pack/plugins/infra/common/http_api/shared/time_range.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/shared/time_range.ts rename to x-pack/plugins/infra/common/http_api/shared/time_range.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/shared/timing.ts b/x-pack/plugins/infra/common/http_api/shared/timing.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/shared/timing.ts rename to x-pack/plugins/infra/common/http_api/shared/timing.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/snapshot_api.ts b/x-pack/plugins/infra/common/http_api/snapshot_api.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/http_api/snapshot_api.ts rename to x-pack/plugins/infra/common/http_api/snapshot_api.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx similarity index 89% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx index a3074b78f9f3b..c8e0680287526 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx @@ -5,12 +5,19 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/cpu.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/cpu.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/cpu.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/cpu.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_read_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_read_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_read_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_read_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_write_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_write_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_write_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/disk_io_write_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/rx.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/rx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/rx.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/rx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/tx.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/tx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/tx.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/snapshot/tx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_cpu_utilization.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_cpu_utilization.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_cpu_utilization.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_cpu_utilization.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_diskio_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_diskio_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_diskio_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_diskio_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_network_traffic.ts b/x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_network_traffic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_network_traffic.ts rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/metrics/tsvb/aws_ec2_network_traffic.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx index 4b16728a52bec..683851fec4d77 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx @@ -5,6 +5,7 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx index debb569fcd5bb..4bc4562ab2760 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx @@ -5,11 +5,17 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/cpu.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/cpu.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/cpu.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/cpu.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_active_transactions.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_active_transactions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_active_transactions.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_active_transactions.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_connections.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_connections.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_connections.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_connections.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_latency.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_latency.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_latency.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_latency.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_queries_executed.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_queries_executed.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_queries_executed.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/snapshot/rds_queries_executed.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_active_transactions.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_active_transactions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_active_transactions.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_active_transactions.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_connections.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_connections.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_connections.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_connections.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_cpu_total.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_cpu_total.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_cpu_total.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_cpu_total.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_latency.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_latency.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_latency.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_latency.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_queries_executed.ts b/x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_queries_executed.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_queries_executed.ts rename to x-pack/plugins/infra/common/inventory_models/aws_rds/metrics/tsvb/aws_rds_queries_executed.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx index e4654825a8de1..24f05fd91589c 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx @@ -5,8 +5,8 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; - import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; import { SnapshotMetricType } from '../types'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx similarity index 91% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx index 955960f5baeda..c40c8e7b8c6d3 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx @@ -5,11 +5,17 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_bucket_size.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_bucket_size.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_bucket_size.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_bucket_size.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_download_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_download_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_download_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_download_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_number_of_objects.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_number_of_objects.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_number_of_objects.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_number_of_objects.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_total_requests.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_total_requests.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_total_requests.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_total_requests.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_upload_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_upload_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_upload_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/snapshot/s3_upload_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_bucket_size.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_bucket_size.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_bucket_size.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_bucket_size.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_download_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_download_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_download_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_download_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_number_of_objects.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_number_of_objects.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_number_of_objects.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_number_of_objects.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_total_requests.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_total_requests.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_total_requests.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_total_requests.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_upload_bytes.ts b/x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_upload_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_upload_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/aws_s3/metrics/tsvb/aws_s3_upload_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx index d1aa48260db47..54c3196ae2833 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx @@ -5,6 +5,7 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx similarity index 92% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx index 5d460c971ec3b..7f2dc92f42205 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx @@ -5,11 +5,17 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_delayed.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_delayed.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_delayed.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_delayed.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_empty.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_empty.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_empty.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_empty.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_sent.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_sent.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_sent.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_sent.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_visible.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_visible.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_visible.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_messages_visible.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_oldest_message.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_oldest_message.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_oldest_message.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/snapshot/sqs_oldest_message.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_delayed.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_delayed.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_delayed.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_delayed.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_empty.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_empty.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_empty.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_empty.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_sent.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_sent.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_sent.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_sent.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_visible.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_visible.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_visible.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_messages_visible.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_oldest_message.ts b/x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_oldest_message.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_oldest_message.ts rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/metrics/tsvb/aws_sqs_oldest_message.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx index 9c5ff51b2d9a2..22cb2740a4a7f 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx @@ -5,6 +5,7 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/index.ts b/x-pack/plugins/infra/common/inventory_models/container/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/index.ts rename to x-pack/plugins/infra/common/inventory_models/container/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx b/x-pack/plugins/infra/common/inventory_models/container/layout.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/container/layout.tsx index e207687cf8643..b61e8eed09cce 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/container/layout.tsx @@ -5,13 +5,21 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/cpu.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/cpu.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/cpu.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/cpu.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/memory.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/memory.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/memory.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/memory.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/rx.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/rx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/rx.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/rx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/tx.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/tx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/snapshot/tx.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/snapshot/tx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_kernel.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_kernel.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_kernel.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_kernel.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_usage.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_usage.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_usage.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_cpu_usage.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_disk_io_bytes.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_disk_io_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_disk_io_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_disk_io_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_diskio_ops.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_diskio_ops.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_diskio_ops.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_diskio_ops.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_memory.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_memory.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_memory.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_memory.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_network_traffic.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_network_traffic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_network_traffic.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_network_traffic.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_overview.ts b/x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_overview.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/tsvb/container_overview.ts rename to x-pack/plugins/infra/common/inventory_models/container/metrics/tsvb/container_overview.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/common/inventory_models/container/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx index f1e7ea721cabd..dbb77cb3b677e 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/container/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx @@ -5,6 +5,7 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { SnapshotMetricType } from '../types'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/create_tsvb_model.ts b/x-pack/plugins/infra/common/inventory_models/create_tsvb_model.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/create_tsvb_model.ts rename to x-pack/plugins/infra/common/inventory_models/create_tsvb_model.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/index.ts b/x-pack/plugins/infra/common/inventory_models/host/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/index.ts rename to x-pack/plugins/infra/common/inventory_models/host/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx b/x-pack/plugins/infra/common/inventory_models/host/layout.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/host/layout.tsx index ca53193e64ca2..15e5530e8db53 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/host/layout.tsx @@ -5,15 +5,23 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { withTheme } from '../../../../../common/eui_styled_components/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import * as Aws from '../shared/layouts/aws'; import * as Ngnix from '../shared/layouts/nginx'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/cpu.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/cpu.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/cpu.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/cpu.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/load.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/load.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/load.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/load.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/log_rate.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/log_rate.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/log_rate.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/log_rate.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/memory.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/memory.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/memory.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/memory.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/rx.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/rx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/rx.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/rx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/tx.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/tx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/snapshot/tx.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/snapshot/tx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_cpu_usage.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_cpu_usage.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_cpu_usage.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_cpu_usage.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_info.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_info.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_info.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_info.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_overview.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_overview.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_overview.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_overview.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_cpu.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_cpu.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_cpu.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_cpu.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_memory.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_memory.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_memory.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_docker_top_5_by_memory.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_filesystem.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_filesystem.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_filesystem.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_filesystem.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_cpu_cap.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_cpu_cap.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_cpu_cap.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_cpu_cap.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_disk_cap.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_disk_cap.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_disk_cap.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_disk_cap.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_memory_cap.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_memory_cap.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_memory_cap.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_memory_cap.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_overview.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_overview.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_overview.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_overview.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_pod_cap.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_pod_cap.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_pod_cap.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_k8s_pod_cap.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_load.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_load.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_load.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_load.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_memory_usage.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_memory_usage.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_memory_usage.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_memory_usage.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_network_traffic.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_network_traffic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_network_traffic.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_network_traffic.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_system_overview.ts b/x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_system_overview.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/metrics/tsvb/host_system_overview.ts rename to x-pack/plugins/infra/common/inventory_models/host/metrics/tsvb/host_system_overview.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/common/inventory_models/host/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx index 6e0563f2f555b..fc7696ee53c9d 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/host/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx @@ -5,6 +5,7 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { SnapshotMetricType } from '../types'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/index.ts b/x-pack/plugins/infra/common/inventory_models/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/index.ts rename to x-pack/plugins/infra/common/inventory_models/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/intl_strings.ts b/x-pack/plugins/infra/common/inventory_models/intl_strings.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/intl_strings.ts rename to x-pack/plugins/infra/common/inventory_models/intl_strings.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/layouts.ts b/x-pack/plugins/infra/common/inventory_models/layouts.ts similarity index 96% rename from x-pack/legacy/plugins/infra/common/inventory_models/layouts.ts rename to x-pack/plugins/infra/common/inventory_models/layouts.ts index d9008753adf7b..b59ce010361ec 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/layouts.ts +++ b/x-pack/plugins/infra/common/inventory_models/layouts.ts @@ -22,6 +22,7 @@ import { Layout as AwsS3Layout } from './aws_s3/layout'; import { Layout as AwsRDSLayout } from './aws_rds/layout'; import { Layout as AwsSQSLayout } from './aws_sqs/layout'; import { InventoryItemType } from './types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutProps } from '../../public/pages/metrics/types'; interface Layouts { diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/metrics.ts b/x-pack/plugins/infra/common/inventory_models/metrics.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/metrics.ts rename to x-pack/plugins/infra/common/inventory_models/metrics.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/index.ts b/x-pack/plugins/infra/common/inventory_models/pod/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/index.ts rename to x-pack/plugins/infra/common/inventory_models/pod/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx b/x-pack/plugins/infra/common/inventory_models/pod/layout.tsx similarity index 91% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx rename to x-pack/plugins/infra/common/inventory_models/pod/layout.tsx index f0c27ccff13b1..43b95d73f6d95 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/pod/layout.tsx @@ -5,14 +5,22 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../observability/public'; import * as Nginx from '../shared/layouts/nginx'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/cpu.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/cpu.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/cpu.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/cpu.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/memory.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/memory.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/memory.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/memory.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/rx.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/rx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/rx.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/rx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/tx.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/tx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/snapshot/tx.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/snapshot/tx.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_cpu_usage.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_cpu_usage.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_cpu_usage.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_cpu_usage.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_log_usage.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_log_usage.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_log_usage.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_log_usage.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_memory_usage.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_memory_usage.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_memory_usage.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_memory_usage.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_network_traffic.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_network_traffic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_network_traffic.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_network_traffic.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_overview.ts b/x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_overview.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_overview.ts rename to x-pack/plugins/infra/common/inventory_models/pod/metrics/tsvb/pod_overview.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/common/inventory_models/pod/toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx index b075f10a15680..d48c27efd88fd 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/pod/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx @@ -5,6 +5,7 @@ */ import React from 'react'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; import { SnapshotMetricType } from '../types'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx similarity index 87% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx index 7150d58be4eb7..766a8ae8142f5 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx @@ -6,8 +6,11 @@ import React from 'react'; import { EuiFlexItem } from '@elastic/eui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../../public/components/inventory/toolbars/toolbar'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WaffleAccountsControls } from '../../../../public/components/waffle/waffle_accounts_controls'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WaffleRegionControls } from '../../../../public/components/waffle/waffle_region_controls'; type Props = ToolbarProps; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx similarity index 88% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx index dd7be5619df46..fcaedcdd080b8 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx @@ -6,12 +6,16 @@ import React, { useMemo } from 'react'; import { EuiFlexItem } from '@elastic/eui'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../../../public/components/inventory/toolbars/toolbar'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WaffleMetricControls } from '../../../../public/components/waffle/waffle_metric_controls'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WaffleGroupByControls } from '../../../../public/components/waffle/waffle_group_by_controls'; import { toGroupByOpt, toMetricOpt, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../../../public/components/inventory/toolbars/toolbar_wrapper'; import { SnapshotMetricType } from '../../types'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/layouts/aws.tsx b/x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/layouts/aws.tsx rename to x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx index 2cabbe4c33ff3..fba48c4224e6b 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/shared/layouts/aws.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx @@ -5,12 +5,18 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { GaugesSectionVis } from '../../../../public/pages/metrics/components/gauges_section_vis'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../../observability/public'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx b/x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx similarity index 90% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx rename to x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx index 9d31ffa775d21..eff0a9bbca85a 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx @@ -5,11 +5,16 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { LayoutPropsWithTheme } from '../../../../public/pages/metrics/types'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { Section } from '../../../../public/pages/metrics/components/section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SubSection } from '../../../../public/pages/metrics/components/sub_section'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ChartSectionVis } from '../../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../../common/eui_styled_components'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { withTheme } from '../../../../../observability/public'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/index.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/index.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/required_metrics.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/required_metrics.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/required_metrics.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/required_metrics.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/count.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/count.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/count.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/count.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic_with_interfaces.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic_with_interfaces.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic_with_interfaces.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/network_traffic_with_interfaces.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/rate.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/rate.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/snapshot/rate.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/snapshot/rate.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_cpu_utilization.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_cpu_utilization.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_cpu_utilization.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_cpu_utilization.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_bytes.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_ops.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_ops.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_ops.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_diskio_ops.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_bytes.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_bytes.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_bytes.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_packets.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_packets.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_packets.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_network_packets.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_overview.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_overview.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_overview.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/aws_overview.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_active_connections.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_active_connections.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_active_connections.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_active_connections.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_hits.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_hits.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_hits.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_hits.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_request_rate.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_request_rate.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_request_rate.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_request_rate.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_requests_per_connection.ts b/x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_requests_per_connection.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_requests_per_connection.ts rename to x-pack/plugins/infra/common/inventory_models/shared/metrics/tsvb/nginx_requests_per_connection.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/toolbars.ts b/x-pack/plugins/infra/common/inventory_models/toolbars.ts similarity index 96% rename from x-pack/legacy/plugins/infra/common/inventory_models/toolbars.ts rename to x-pack/plugins/infra/common/inventory_models/toolbars.ts index 05def078c7f2d..39e9f5a260f7a 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/toolbars.ts +++ b/x-pack/plugins/infra/common/inventory_models/toolbars.ts @@ -10,6 +10,7 @@ import { InventoryItemType } from './types'; import { HostToolbarItems } from './host/toolbar_items'; import { ContainerToolbarItems } from './container/toolbar_items'; import { PodToolbarItems } from './pod/toolbar_items'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ToolbarProps } from '../../public/components/inventory/toolbars/toolbar'; import { AwsEC2ToolbarItems } from './aws_ec2/toolbar_items'; import { AwsS3ToolbarItems } from './aws_s3/toolbar_items'; diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/types.ts b/x-pack/plugins/infra/common/inventory_models/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/inventory_models/types.ts rename to x-pack/plugins/infra/common/inventory_models/types.ts diff --git a/x-pack/legacy/plugins/infra/common/log_analysis/index.ts b/x-pack/plugins/infra/common/log_analysis/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_analysis/index.ts rename to x-pack/plugins/infra/common/log_analysis/index.ts diff --git a/x-pack/legacy/plugins/infra/common/log_analysis/job_parameters.ts b/x-pack/plugins/infra/common/log_analysis/job_parameters.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_analysis/job_parameters.ts rename to x-pack/plugins/infra/common/log_analysis/job_parameters.ts diff --git a/x-pack/legacy/plugins/infra/common/log_analysis/log_analysis.ts b/x-pack/plugins/infra/common/log_analysis/log_analysis.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_analysis/log_analysis.ts rename to x-pack/plugins/infra/common/log_analysis/log_analysis.ts diff --git a/x-pack/legacy/plugins/infra/common/log_analysis/log_analysis_results.ts b/x-pack/plugins/infra/common/log_analysis/log_analysis_results.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_analysis/log_analysis_results.ts rename to x-pack/plugins/infra/common/log_analysis/log_analysis_results.ts diff --git a/x-pack/legacy/plugins/infra/common/log_analysis/log_entry_categories_analysis.ts b/x-pack/plugins/infra/common/log_analysis/log_entry_categories_analysis.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_analysis/log_entry_categories_analysis.ts rename to x-pack/plugins/infra/common/log_analysis/log_entry_categories_analysis.ts diff --git a/x-pack/legacy/plugins/infra/common/log_analysis/log_entry_rate_analysis.ts b/x-pack/plugins/infra/common/log_analysis/log_entry_rate_analysis.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_analysis/log_entry_rate_analysis.ts rename to x-pack/plugins/infra/common/log_analysis/log_entry_rate_analysis.ts diff --git a/x-pack/legacy/plugins/infra/common/log_entry/index.ts b/x-pack/plugins/infra/common/log_entry/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_entry/index.ts rename to x-pack/plugins/infra/common/log_entry/index.ts diff --git a/x-pack/legacy/plugins/infra/common/log_entry/log_entry.ts b/x-pack/plugins/infra/common/log_entry/log_entry.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_entry/log_entry.ts rename to x-pack/plugins/infra/common/log_entry/log_entry.ts diff --git a/x-pack/legacy/plugins/infra/common/log_search_result/index.ts b/x-pack/plugins/infra/common/log_search_result/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_search_result/index.ts rename to x-pack/plugins/infra/common/log_search_result/index.ts diff --git a/x-pack/legacy/plugins/infra/common/log_search_result/log_search_result.ts b/x-pack/plugins/infra/common/log_search_result/log_search_result.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_search_result/log_search_result.ts rename to x-pack/plugins/infra/common/log_search_result/log_search_result.ts diff --git a/x-pack/legacy/plugins/infra/common/log_search_summary/index.ts b/x-pack/plugins/infra/common/log_search_summary/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_search_summary/index.ts rename to x-pack/plugins/infra/common/log_search_summary/index.ts diff --git a/x-pack/legacy/plugins/infra/common/log_search_summary/log_search_summary.ts b/x-pack/plugins/infra/common/log_search_summary/log_search_summary.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_search_summary/log_search_summary.ts rename to x-pack/plugins/infra/common/log_search_summary/log_search_summary.ts diff --git a/x-pack/legacy/plugins/infra/common/log_text_scale/index.ts b/x-pack/plugins/infra/common/log_text_scale/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_text_scale/index.ts rename to x-pack/plugins/infra/common/log_text_scale/index.ts diff --git a/x-pack/legacy/plugins/infra/common/log_text_scale/log_text_scale.ts b/x-pack/plugins/infra/common/log_text_scale/log_text_scale.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/log_text_scale/log_text_scale.ts rename to x-pack/plugins/infra/common/log_text_scale/log_text_scale.ts diff --git a/x-pack/legacy/plugins/infra/common/performance_tracing.ts b/x-pack/plugins/infra/common/performance_tracing.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/performance_tracing.ts rename to x-pack/plugins/infra/common/performance_tracing.ts diff --git a/x-pack/legacy/plugins/infra/common/runtime_types.ts b/x-pack/plugins/infra/common/runtime_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/runtime_types.ts rename to x-pack/plugins/infra/common/runtime_types.ts diff --git a/x-pack/legacy/plugins/infra/common/saved_objects/inventory_view.ts b/x-pack/plugins/infra/common/saved_objects/inventory_view.ts similarity index 91% rename from x-pack/legacy/plugins/infra/common/saved_objects/inventory_view.ts rename to x-pack/plugins/infra/common/saved_objects/inventory_view.ts index c86be102f85a8..3ab9042947f97 100644 --- a/x-pack/legacy/plugins/infra/common/saved_objects/inventory_view.ts +++ b/x-pack/plugins/infra/common/saved_objects/inventory_view.ts @@ -4,10 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ElasticsearchMappingOf } from '../../server/utils/typed_elasticsearch_mappings'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { WaffleViewState } from '../../public/containers/waffle/with_waffle_view_state'; export const inventoryViewSavedObjectType = 'inventory-view'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SavedViewSavedObject } from '../../public/hooks/use_saved_view'; export const inventoryViewSavedObjectMappings: { diff --git a/x-pack/legacy/plugins/infra/common/saved_objects/metrics_explorer_view.ts b/x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts similarity index 92% rename from x-pack/legacy/plugins/infra/common/saved_objects/metrics_explorer_view.ts rename to x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts index e4ec71907eaa8..a9f1194844640 100644 --- a/x-pack/legacy/plugins/infra/common/saved_objects/metrics_explorer_view.ts +++ b/x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts @@ -4,12 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ElasticsearchMappingOf } from '../../server/utils/typed_elasticsearch_mappings'; import { MetricsExplorerOptions, MetricsExplorerChartOptions, MetricsExplorerTimeOptions, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../public/containers/metrics_explorer/use_metrics_explorer_options'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SavedViewSavedObject } from '../../public/hooks/use_saved_view'; interface MetricsExplorerSavedView { diff --git a/x-pack/legacy/plugins/infra/common/time/index.ts b/x-pack/plugins/infra/common/time/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/time/index.ts rename to x-pack/plugins/infra/common/time/index.ts diff --git a/x-pack/legacy/plugins/infra/common/time/time_key.ts b/x-pack/plugins/infra/common/time/time_key.ts similarity index 97% rename from x-pack/legacy/plugins/infra/common/time/time_key.ts rename to x-pack/plugins/infra/common/time/time_key.ts index 117cd38314de0..e4f41615eb484 100644 --- a/x-pack/legacy/plugins/infra/common/time/time_key.ts +++ b/x-pack/plugins/infra/common/time/time_key.ts @@ -5,7 +5,7 @@ */ import { ascending, bisector } from 'd3-array'; -import pick from 'lodash/fp/pick'; +import { pick } from 'lodash'; export interface TimeKey { time: number; @@ -27,7 +27,7 @@ export const isTimeKey = (value: any): value is TimeKey => typeof value.tiebreaker === 'number'; export const pickTimeKey = (value: T): TimeKey => - pick(['time', 'tiebreaker'], value); + pick(value, ['time', 'tiebreaker']); export function compareTimeKeys( firstKey: TimeKey, diff --git a/x-pack/legacy/plugins/infra/common/time/time_scale.ts b/x-pack/plugins/infra/common/time/time_scale.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/time/time_scale.ts rename to x-pack/plugins/infra/common/time/time_scale.ts diff --git a/x-pack/legacy/plugins/infra/common/time/time_unit.ts b/x-pack/plugins/infra/common/time/time_unit.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/time/time_unit.ts rename to x-pack/plugins/infra/common/time/time_unit.ts diff --git a/x-pack/legacy/plugins/infra/common/typed_json.ts b/x-pack/plugins/infra/common/typed_json.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/typed_json.ts rename to x-pack/plugins/infra/common/typed_json.ts diff --git a/x-pack/legacy/plugins/infra/common/utility_types.ts b/x-pack/plugins/infra/common/utility_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/common/utility_types.ts rename to x-pack/plugins/infra/common/utility_types.ts diff --git a/x-pack/legacy/plugins/infra/docs/arch.md b/x-pack/plugins/infra/docs/arch.md similarity index 100% rename from x-pack/legacy/plugins/infra/docs/arch.md rename to x-pack/plugins/infra/docs/arch.md diff --git a/x-pack/legacy/plugins/infra/docs/arch_client.md b/x-pack/plugins/infra/docs/arch_client.md similarity index 100% rename from x-pack/legacy/plugins/infra/docs/arch_client.md rename to x-pack/plugins/infra/docs/arch_client.md diff --git a/x-pack/legacy/plugins/infra/docs/assets/arch.png b/x-pack/plugins/infra/docs/assets/arch.png similarity index 100% rename from x-pack/legacy/plugins/infra/docs/assets/arch.png rename to x-pack/plugins/infra/docs/assets/arch.png diff --git a/x-pack/legacy/plugins/infra/docs/assets/infra_metricbeat_aws.jpg b/x-pack/plugins/infra/docs/assets/infra_metricbeat_aws.jpg similarity index 100% rename from x-pack/legacy/plugins/infra/docs/assets/infra_metricbeat_aws.jpg rename to x-pack/plugins/infra/docs/assets/infra_metricbeat_aws.jpg diff --git a/x-pack/legacy/plugins/infra/docs/graphql.md b/x-pack/plugins/infra/docs/graphql.md similarity index 100% rename from x-pack/legacy/plugins/infra/docs/graphql.md rename to x-pack/plugins/infra/docs/graphql.md diff --git a/x-pack/legacy/plugins/infra/docs/test_setups/infra_metricbeat_aws.md b/x-pack/plugins/infra/docs/test_setups/infra_metricbeat_aws.md similarity index 100% rename from x-pack/legacy/plugins/infra/docs/test_setups/infra_metricbeat_aws.md rename to x-pack/plugins/infra/docs/test_setups/infra_metricbeat_aws.md diff --git a/x-pack/legacy/plugins/infra/docs/test_setups/infra_metricbeat_docker_nginx.md b/x-pack/plugins/infra/docs/test_setups/infra_metricbeat_docker_nginx.md similarity index 100% rename from x-pack/legacy/plugins/infra/docs/test_setups/infra_metricbeat_docker_nginx.md rename to x-pack/plugins/infra/docs/test_setups/infra_metricbeat_docker_nginx.md diff --git a/x-pack/plugins/infra/kibana.json b/x-pack/plugins/infra/kibana.json index ec5420a4d28d5..7ba81127c1e67 100644 --- a/x-pack/plugins/infra/kibana.json +++ b/x-pack/plugins/infra/kibana.json @@ -2,5 +2,8 @@ "id": "infra", "version": "8.0.0", "kibanaVersion": "kibana", - "server": true + "requiredPlugins": ["features", "apm", "usageCollection", "spaces", "home", "data", "data_enhanced", "metrics"], + "server": true, + "ui": true, + "configPath": ["xpack", "infra"] } diff --git a/x-pack/legacy/plugins/infra/public/apps/start_app.tsx b/x-pack/plugins/infra/public/apps/start_app.tsx similarity index 65% rename from x-pack/legacy/plugins/infra/public/apps/start_app.tsx rename to x-pack/plugins/infra/public/apps/start_app.tsx index dbdc827478a45..300d97d3c45b1 100644 --- a/x-pack/legacy/plugins/infra/public/apps/start_app.tsx +++ b/x-pack/plugins/infra/public/apps/start_app.tsx @@ -4,20 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -import { createHashHistory } from 'history'; +import { createBrowserHistory } from 'history'; import React from 'react'; import ReactDOM from 'react-dom'; import { ApolloProvider } from 'react-apollo'; import { Provider as ReduxStoreProvider } from 'react-redux'; import { BehaviorSubject } from 'rxjs'; import { pluck } from 'rxjs/operators'; -import { CoreStart } from 'kibana/public'; +import { CoreStart, AppMountParameters } from 'kibana/public'; // TODO use theme provided from parentApp when kibana supports it import { EuiErrorBoundary } from '@elastic/eui'; -import { EuiThemeProvider } from '../../../../common/eui_styled_components'; +import { EuiThemeProvider } from '../../../observability/public'; import { InfraFrontendLibs } from '../lib/lib'; -import { PageRouter } from '../routes'; import { createStore } from '../store'; import { ApolloClientContext } from '../utils/apollo_context'; import { ReduxStateContextProvider } from '../utils/redux_context'; @@ -25,12 +24,20 @@ import { HistoryContext } from '../utils/history_context'; import { useUiSetting$, KibanaContextProvider, -} from '../../../../../../src/plugins/kibana_react/public'; -import { ROOT_ELEMENT_ID } from '../app'; +} from '../../../../../src/plugins/kibana_react/public'; +import { AppRouter } from '../routers'; -// NP_TODO: Type plugins -export async function startApp(libs: InfraFrontendLibs, core: CoreStart, plugins: any) { - const history = createHashHistory(); +export const CONTAINER_CLASSNAME = 'infra-container-element'; + +export async function startApp( + libs: InfraFrontendLibs, + core: CoreStart, + plugins: object, + params: AppMountParameters, + Router: AppRouter +) { + const { element, appBasePath } = params; + const history = createBrowserHistory({ basename: appBasePath }); const libs$ = new BehaviorSubject(libs); const store = createStore({ apolloClient: libs$.pipe(pluck('apolloClient')), @@ -49,7 +56,7 @@ export async function startApp(libs: InfraFrontendLibs, core: CoreStart, plugins - + @@ -61,15 +68,22 @@ export async function startApp(libs: InfraFrontendLibs, core: CoreStart, plugins ); }; - const node = await document.getElementById(ROOT_ELEMENT_ID); - - const App = ( + const App: React.FunctionComponent = () => ( ); - if (node) { - ReactDOM.render(App, node); - } + // Ensure the element we're handed from application mounting takes up + // the full size it can, so that our inner application styles work as + // expected. + element.style.height = '100%'; + element.style.display = 'flex'; + element.className += ` ${CONTAINER_CLASSNAME}`; + + ReactDOM.render(, element); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; } diff --git a/x-pack/plugins/infra/public/apps/start_legacy_app.tsx b/x-pack/plugins/infra/public/apps/start_legacy_app.tsx new file mode 100644 index 0000000000000..6e5960ceb2081 --- /dev/null +++ b/x-pack/plugins/infra/public/apps/start_legacy_app.tsx @@ -0,0 +1,100 @@ +/* + * 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 { createBrowserHistory } from 'history'; +import React from 'react'; +import url from 'url'; +import ReactDOM from 'react-dom'; +import { AppMountParameters } from 'kibana/public'; +import { Route, Router, Switch, RouteProps } from 'react-router-dom'; +// TODO use theme provided from parentApp when kibana supports it +import { EuiErrorBoundary } from '@elastic/eui'; + +// This exists purely to facilitate legacy app/infra URL redirects. +// It will be removed in 8.0.0. +export async function startLegacyApp(params: AppMountParameters) { + const { element } = params; + const history = createBrowserHistory(); + + const App: React.FunctionComponent = () => { + return ( + + + + { + if (!location) { + return null; + } + + let nextPath = ''; + let nextBasePath = ''; + let nextSearch; + + if ( + location.hash.indexOf('#infrastructure') > -1 || + location.hash.indexOf('#/infrastructure') > -1 + ) { + nextPath = location.hash.replace( + new RegExp( + '#infrastructure/|#/infrastructure/|#/infrastructure|#infrastructure', + 'g' + ), + '' + ); + nextBasePath = location.pathname.replace('app/infra', 'app/metrics'); + } else if ( + location.hash.indexOf('#logs') > -1 || + location.hash.indexOf('#/logs') > -1 + ) { + nextPath = location.hash.replace( + new RegExp('#logs/|#/logs/|#/logs|#logs', 'g'), + '' + ); + nextBasePath = location.pathname.replace('app/infra', 'app/logs'); + } else { + // This covers /app/infra and /app/infra/home (both of which used to render + // the metrics inventory page) + nextPath = 'inventory'; + nextBasePath = location.pathname.replace('app/infra', 'app/metrics'); + nextSearch = undefined; + } + + // app/inra#infrastructure/metrics/:type/:node was changed to app/metrics/detail/:type/:node, this + // accounts for that edge case + nextPath = nextPath.replace('metrics/', 'detail/'); + + // Query parameters (location.search) will arrive as part of location.hash and not location.search + const nextPathParts = nextPath.split('?'); + nextPath = nextPathParts[0]; + nextSearch = nextPathParts[1] ? nextPathParts[1] : undefined; + + let nextUrl = url.format({ + pathname: `${nextBasePath}/${nextPath}`, + hash: undefined, + search: nextSearch, + }); + + nextUrl = nextUrl.replace('//', '/'); + + window.location.href = nextUrl; + + return null; + }} + /> + + + + ); + }; + + ReactDOM.render(, element); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +} diff --git a/x-pack/legacy/plugins/infra/public/components/auto_sizer.tsx b/x-pack/plugins/infra/public/components/auto_sizer.tsx similarity index 99% rename from x-pack/legacy/plugins/infra/public/components/auto_sizer.tsx rename to x-pack/plugins/infra/public/components/auto_sizer.tsx index 1d6798aacebe5..284b5295111c6 100644 --- a/x-pack/legacy/plugins/infra/public/components/auto_sizer.tsx +++ b/x-pack/plugins/infra/public/components/auto_sizer.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import isEqual from 'lodash/fp/isEqual'; +import { isEqual } from 'lodash'; import React from 'react'; import ResizeObserver from 'resize-observer-polyfill'; diff --git a/x-pack/legacy/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx b/x-pack/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx rename to x-pack/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx index f483f2b1b3f57..2abef7d71e65a 100644 --- a/x-pack/legacy/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx +++ b/x-pack/plugins/infra/public/components/autocomplete_field/autocomplete_field.tsx @@ -12,9 +12,8 @@ import { } from '@elastic/eui'; import React from 'react'; -import { QuerySuggestion } from '../../../../../../../src/plugins/data/public'; - -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; +import { QuerySuggestion } from '../../../../../../src/plugins/data/public'; import { composeStateUpdaters } from '../../utils/typed_react'; import { SuggestionItem } from './suggestion_item'; diff --git a/x-pack/legacy/plugins/infra/public/components/autocomplete_field/index.ts b/x-pack/plugins/infra/public/components/autocomplete_field/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/autocomplete_field/index.ts rename to x-pack/plugins/infra/public/components/autocomplete_field/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx b/x-pack/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx similarity index 79% rename from x-pack/legacy/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx rename to x-pack/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx index 689eb47f289c2..fb0c1127df3d1 100644 --- a/x-pack/legacy/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx +++ b/x-pack/plugins/infra/public/components/autocomplete_field/suggestion_item.tsx @@ -7,9 +7,8 @@ import { EuiIcon } from '@elastic/eui'; import { transparentize } from 'polished'; import React from 'react'; - -import { QuerySuggestion } from '../../../../../../../src/plugins/data/public'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; +import { QuerySuggestion, QuerySuggestionTypes } from '../../../../../../src/plugins/data/public'; interface Props { isSelected?: boolean; @@ -57,7 +56,9 @@ const SuggestionItemField = euiStyled.div` padding: ${props => props.theme.eui.euiSizeXS}; `; -const SuggestionItemIconField = euiStyled(SuggestionItemField)<{ suggestionType: string }>` +const SuggestionItemIconField = euiStyled(SuggestionItemField)<{ + suggestionType: QuerySuggestionTypes; +}>` background-color: ${props => transparentize(0.9, getEuiIconColor(props.theme, props.suggestionType))}; color: ${props => getEuiIconColor(props.theme, props.suggestionType)}; @@ -83,34 +84,34 @@ const SuggestionItemDescriptionField = euiStyled(SuggestionItemField)` } `; -const getEuiIconType = (suggestionType: string) => { +const getEuiIconType = (suggestionType: QuerySuggestionTypes) => { switch (suggestionType) { - case 'field': + case QuerySuggestionTypes.Field: return 'kqlField'; - case 'value': + case QuerySuggestionTypes.Value: return 'kqlValue'; - case 'recentSearch': + case QuerySuggestionTypes.RecentSearch: return 'search'; - case 'conjunction': + case QuerySuggestionTypes.Conjunction: return 'kqlSelector'; - case 'operator': + case QuerySuggestionTypes.Operator: return 'kqlOperand'; default: return 'empty'; } }; -const getEuiIconColor = (theme: any, suggestionType: string): string => { +const getEuiIconColor = (theme: any, suggestionType: QuerySuggestionTypes): string => { switch (suggestionType) { - case 'field': + case QuerySuggestionTypes.Field: return theme.eui.euiColorVis7; - case 'value': + case QuerySuggestionTypes.Value: return theme.eui.euiColorVis0; - case 'operator': + case QuerySuggestionTypes.Operator: return theme.eui.euiColorVis1; - case 'conjunction': + case QuerySuggestionTypes.Conjunction: return theme.eui.euiColorVis2; - case 'recentSearch': + case QuerySuggestionTypes.RecentSearch: default: return theme.eui.euiColorMediumShade; } diff --git a/x-pack/legacy/plugins/infra/public/components/beta_badge.tsx b/x-pack/plugins/infra/public/components/beta_badge.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/beta_badge.tsx rename to x-pack/plugins/infra/public/components/beta_badge.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/document_title.tsx b/x-pack/plugins/infra/public/components/document_title.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/document_title.tsx rename to x-pack/plugins/infra/public/components/document_title.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/empty_states/index.tsx b/x-pack/plugins/infra/public/components/empty_states/index.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/empty_states/index.tsx rename to x-pack/plugins/infra/public/components/empty_states/index.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/empty_states/no_data.tsx b/x-pack/plugins/infra/public/components/empty_states/no_data.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/public/components/empty_states/no_data.tsx rename to x-pack/plugins/infra/public/components/empty_states/no_data.tsx index 7519e3fe10779..97dc7ac1f8520 100644 --- a/x-pack/legacy/plugins/infra/public/components/empty_states/no_data.tsx +++ b/x-pack/plugins/infra/public/components/empty_states/no_data.tsx @@ -7,7 +7,7 @@ import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface NoDataProps { titleText: string; diff --git a/x-pack/legacy/plugins/infra/public/components/empty_states/no_indices.tsx b/x-pack/plugins/infra/public/components/empty_states/no_indices.tsx similarity index 91% rename from x-pack/legacy/plugins/infra/public/components/empty_states/no_indices.tsx rename to x-pack/plugins/infra/public/components/empty_states/no_indices.tsx index bfe282d2cee04..b453a4f0bc342 100644 --- a/x-pack/legacy/plugins/infra/public/components/empty_states/no_indices.tsx +++ b/x-pack/plugins/infra/public/components/empty_states/no_indices.tsx @@ -7,7 +7,7 @@ import { EuiEmptyPrompt } from '@elastic/eui'; import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface NoIndicesProps { message: string; diff --git a/x-pack/legacy/plugins/infra/public/components/error_page.tsx b/x-pack/plugins/infra/public/components/error_page.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/error_page.tsx rename to x-pack/plugins/infra/public/components/error_page.tsx index fea76c83292c2..5c8b576c161d7 100644 --- a/x-pack/legacy/plugins/infra/public/components/error_page.tsx +++ b/x-pack/plugins/infra/public/components/error_page.tsx @@ -15,7 +15,7 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import euiStyled from '../../../../common/eui_styled_components'; +import { euiStyled } from '../../../observability/public'; import { FlexPage } from './page'; interface Props { diff --git a/x-pack/legacy/plugins/infra/public/components/eui/index.ts b/x-pack/plugins/infra/public/components/eui/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/eui/index.ts rename to x-pack/plugins/infra/public/components/eui/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/eui/toolbar/index.ts b/x-pack/plugins/infra/public/components/eui/toolbar/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/eui/toolbar/index.ts rename to x-pack/plugins/infra/public/components/eui/toolbar/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/eui/toolbar/toolbar.tsx b/x-pack/plugins/infra/public/components/eui/toolbar/toolbar.tsx similarity index 88% rename from x-pack/legacy/plugins/infra/public/components/eui/toolbar/toolbar.tsx rename to x-pack/plugins/infra/public/components/eui/toolbar/toolbar.tsx index 2c3b5cb924e36..8446587e8671d 100644 --- a/x-pack/legacy/plugins/infra/public/components/eui/toolbar/toolbar.tsx +++ b/x-pack/plugins/infra/public/components/eui/toolbar/toolbar.tsx @@ -6,7 +6,7 @@ import { EuiPanel } from '@elastic/eui'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; export const Toolbar = euiStyled(EuiPanel).attrs(() => ({ grow: false, diff --git a/x-pack/legacy/plugins/infra/public/components/fixed_datepicker.tsx b/x-pack/plugins/infra/public/components/fixed_datepicker.tsx similarity index 90% rename from x-pack/legacy/plugins/infra/public/components/fixed_datepicker.tsx rename to x-pack/plugins/infra/public/components/fixed_datepicker.tsx index aab1bcd1da873..fcebb89561826 100644 --- a/x-pack/legacy/plugins/infra/public/components/fixed_datepicker.tsx +++ b/x-pack/plugins/infra/public/components/fixed_datepicker.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiDatePicker, EuiDatePickerProps } from '@elastic/eui'; -import euiStyled from '../../../../common/eui_styled_components'; +import { euiStyled } from '../../../observability/public'; export const FixedDatePicker = euiStyled( ({ diff --git a/x-pack/legacy/plugins/infra/public/components/formatted_time.tsx b/x-pack/plugins/infra/public/components/formatted_time.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/formatted_time.tsx rename to x-pack/plugins/infra/public/components/formatted_time.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/header/header.tsx b/x-pack/plugins/infra/public/components/header/header.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/header/header.tsx rename to x-pack/plugins/infra/public/components/header/header.tsx index 731e62b927ae4..fa71426f83645 100644 --- a/x-pack/legacy/plugins/infra/public/components/header/header.tsx +++ b/x-pack/plugins/infra/public/components/header/header.tsx @@ -7,7 +7,7 @@ import { useCallback, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { ChromeBreadcrumb } from 'src/core/public'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; interface HeaderProps { breadcrumbs?: ChromeBreadcrumb[]; diff --git a/x-pack/legacy/plugins/infra/public/components/header/index.ts b/x-pack/plugins/infra/public/components/header/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/header/index.ts rename to x-pack/plugins/infra/public/components/header/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/help_center_content.tsx b/x-pack/plugins/infra/public/components/help_center_content.tsx similarity index 90% rename from x-pack/legacy/plugins/infra/public/components/help_center_content.tsx rename to x-pack/plugins/infra/public/components/help_center_content.tsx index 4b27c6cfce53f..acaf4b069dc1c 100644 --- a/x-pack/legacy/plugins/infra/public/components/help_center_content.tsx +++ b/x-pack/plugins/infra/public/components/help_center_content.tsx @@ -5,7 +5,7 @@ */ import React, { useEffect } from 'react'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; interface HelpCenterContentProps { feedbackLink: string; diff --git a/x-pack/legacy/plugins/infra/public/components/inventory/layout.tsx b/x-pack/plugins/infra/public/components/inventory/layout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/inventory/layout.tsx rename to x-pack/plugins/infra/public/components/inventory/layout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/inventory/toolbars/toolbar.tsx b/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/inventory/toolbars/toolbar.tsx rename to x-pack/plugins/infra/public/components/inventory/toolbars/toolbar.tsx index ee0eceee6d157..a2882a3cd3124 100644 --- a/x-pack/legacy/plugins/infra/public/components/inventory/toolbars/toolbar.tsx +++ b/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar.tsx @@ -17,7 +17,7 @@ import { InfraGroupByOptions } from '../../../lib/lib'; import { WithWaffleViewState } from '../../../containers/waffle/with_waffle_view_state'; import { SavedViewsToolbarControls } from '../../saved_views/toolbar_control'; import { inventoryViewSavedObjectType } from '../../../../common/saved_objects/inventory_view'; -import { IIndexPattern } from '../../../../../../../../src/plugins/data/public'; +import { IIndexPattern } from '../../../../../../../src/plugins/data/public'; import { InventoryItemType } from '../../../../common/inventory_models/types'; export interface ToolbarProps { diff --git a/x-pack/legacy/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx b/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx rename to x-pack/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/loading/__examples__/index.stories.tsx b/x-pack/plugins/infra/public/components/loading/__examples__/index.stories.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/loading/__examples__/index.stories.tsx rename to x-pack/plugins/infra/public/components/loading/__examples__/index.stories.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/loading/index.tsx b/x-pack/plugins/infra/public/components/loading/index.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/loading/index.tsx rename to x-pack/plugins/infra/public/components/loading/index.tsx index 30dfef9ed48bd..8c25dfc2380f9 100644 --- a/x-pack/legacy/plugins/infra/public/components/loading/index.tsx +++ b/x-pack/plugins/infra/public/components/loading/index.tsx @@ -7,7 +7,7 @@ import { EuiLoadingChart, EuiPanel, EuiText } from '@elastic/eui'; import * as React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface InfraLoadingProps { text: string | JSX.Element; diff --git a/x-pack/legacy/plugins/infra/public/components/loading_overlay_wrapper.tsx b/x-pack/plugins/infra/public/components/loading_overlay_wrapper.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/loading_overlay_wrapper.tsx rename to x-pack/plugins/infra/public/components/loading_overlay_wrapper.tsx index 5df1fc07e83b9..599969d9b15a8 100644 --- a/x-pack/legacy/plugins/infra/public/components/loading_overlay_wrapper.tsx +++ b/x-pack/plugins/infra/public/components/loading_overlay_wrapper.tsx @@ -8,7 +8,7 @@ import { EuiLoadingSpinner } from '@elastic/eui'; import { transparentize } from 'polished'; import React from 'react'; -import { euiStyled } from '../../../../common/eui_styled_components'; +import { euiStyled } from '../../../observability/public'; export const LoadingOverlayWrapper: React.FC & { isLoading: boolean; diff --git a/x-pack/legacy/plugins/infra/public/components/loading_page.tsx b/x-pack/plugins/infra/public/components/loading_page.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/loading_page.tsx rename to x-pack/plugins/infra/public/components/loading_page.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/index.ts b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/index.ts rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/job_configuration_outdated_callout.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_configuration_outdated_callout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/job_configuration_outdated_callout.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_configuration_outdated_callout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/job_definition_outdated_callout.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_definition_outdated_callout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/job_definition_outdated_callout.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_definition_outdated_callout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/job_stopped_callout.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_stopped_callout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/job_stopped_callout.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_stopped_callout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/log_analysis_job_problem_indicator.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/log_analysis_job_problem_indicator.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/log_analysis_job_problem_indicator.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/log_analysis_job_problem_indicator.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_button.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_button.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_button.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_button.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_callout.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_callout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_callout.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_callout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx index 9fbba94407dc0..6b946898f6330 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_results/analyze_in_ml_button.tsx @@ -10,9 +10,9 @@ import React from 'react'; import { encode } from 'rison-node'; import url from 'url'; import { stringify } from 'query-string'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { TimeRange } from '../../../../common/http_api/shared/time_range'; -import { url as urlUtils } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { url as urlUtils } from '../../../../../../../src/plugins/kibana_utils/public'; export const AnalyzeInMlButton: React.FunctionComponent<{ jobId: string; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/first_use_callout.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_results/first_use_callout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/first_use_callout.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_results/first_use_callout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/index.ts b/x-pack/plugins/infra/public/components/logging/log_analysis_results/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_results/index.ts rename to x-pack/plugins/infra/public/components/logging/log_analysis_results/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/index.ts b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/index.ts rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_indices_form.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/analysis_setup_timerange_form.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/index.ts b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/index.ts rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/initial_configuration_step.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/validation.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/validation.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/validation.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/initial_configuration_step/validation.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx index 0c3393b0e15e3..2d378508e2b58 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx @@ -8,7 +8,7 @@ import { EuiEmptyPrompt, EuiCode } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { UserManagementLink } from './user_management_link'; export const MissingResultsPrivilegesPrompt: React.FunctionComponent = () => ( diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/missing_setup_privileges_prompt.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_setup_privileges_prompt.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/missing_setup_privileges_prompt.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_setup_privileges_prompt.tsx index 1549ab9120777..db89ff415a6f7 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/missing_setup_privileges_prompt.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_setup_privileges_prompt.tsx @@ -8,7 +8,7 @@ import { EuiEmptyPrompt, EuiCode } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { UserManagementLink } from './user_management_link'; export const MissingSetupPrivilegesPrompt: React.FunctionComponent = () => ( diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/ml_unavailable_prompt.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/ml_unavailable_prompt.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/ml_unavailable_prompt.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/ml_unavailable_prompt.tsx index 63e1bb23a2d82..4b15ce19ef096 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/ml_unavailable_prompt.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/ml_unavailable_prompt.tsx @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; export const MlUnavailablePrompt: React.FunctionComponent<{}> = () => ( = ({ children, diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/setup_status_unknown_prompt.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_status_unknown_prompt.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/setup_status_unknown_prompt.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_status_unknown_prompt.tsx index f65ff6a1eec78..334aaa251f524 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/setup_status_unknown_prompt.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/setup_status_unknown_prompt.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiEmptyPrompt, EuiButton } from '@elastic/eui'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface Props { retry: () => void; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/user_management_link.tsx b/x-pack/plugins/infra/public/components/logging/log_analysis_setup/user_management_link.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_analysis_setup/user_management_link.tsx rename to x-pack/plugins/infra/public/components/logging/log_analysis_setup/user_management_link.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_customization_menu.tsx b/x-pack/plugins/infra/public/components/logging/log_customization_menu.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_customization_menu.tsx rename to x-pack/plugins/infra/public/components/logging/log_customization_menu.tsx index 9ca0d4329a90b..febfdddfcfb0e 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_customization_menu.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_customization_menu.tsx @@ -8,7 +8,7 @@ import { EuiButtonEmpty, EuiPopover } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import * as React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface LogCustomizationMenuState { isShown: boolean; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/index.tsx b/x-pack/plugins/infra/public/components/logging/log_entry_flyout/index.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/index.tsx rename to x-pack/plugins/infra/public/components/logging/log_entry_flyout/index.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.test.tsx b/x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.test.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.test.tsx rename to x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.test.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx b/x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx rename to x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx index 4137027f35c12..60e50f486d22a 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx @@ -8,9 +8,9 @@ import { EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } f import { FormattedMessage } from '@kbn/i18n/react'; import React, { useMemo } from 'react'; import url from 'url'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { useVisibilityState } from '../../../utils/use_visibility_state'; -import { getTraceUrl } from '../../../../../apm/public/components/shared/Links/apm/ExternalLinks'; +import { getTraceUrl } from '../../../../../../legacy/plugins/apm/public/components/shared/Links/apm/ExternalLinks'; import { LogEntriesItem } from '../../../../common/http_api'; const UPTIME_FIELDS = ['container.id', 'host.ip', 'kubernetes.pod.uid']; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx b/x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx rename to x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx index d2cb9cf9370dd..57f27ee76184b 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx @@ -20,7 +20,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import moment from 'moment'; import React, { useCallback, useMemo } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { TimeKey } from '../../../../common/time'; import { InfraLoadingPanel } from '../../loading'; import { LogEntryActionsMenu } from './log_entry_actions_menu'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_highlights_menu.tsx b/x-pack/plugins/infra/public/components/logging/log_highlights_menu.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/logging/log_highlights_menu.tsx rename to x-pack/plugins/infra/public/components/logging/log_highlights_menu.tsx index d13ccde7466cd..f51ed693e7d80 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_highlights_menu.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_highlights_menu.tsx @@ -18,7 +18,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { debounce } from 'lodash'; import React, { useCallback, useMemo, useState } from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { useVisibilityState } from '../../utils/use_visibility_state'; interface LogHighlightsMenuProps { diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/density_chart.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/density_chart.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/density_chart.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/density_chart.tsx index b31afe6abea28..729689e65739e 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/density_chart.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_minimap/density_chart.tsx @@ -6,10 +6,10 @@ import { scaleLinear, scaleTime } from 'd3-scale'; import { area, curveMonotoneY } from 'd3-shape'; -import max from 'lodash/fp/max'; +import { max } from 'lodash'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { SummaryBucket } from './types'; interface DensityChartProps { diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/highlighted_interval.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/highlighted_interval.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/highlighted_interval.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/highlighted_interval.tsx index 4711a7ac6ffde..2e45bcea42109 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/highlighted_interval.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_minimap/highlighted_interval.tsx @@ -6,7 +6,7 @@ import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface HighlightedIntervalProps { className?: string; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/index.ts b/x-pack/plugins/infra/public/components/logging/log_minimap/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/index.ts rename to x-pack/plugins/infra/public/components/logging/log_minimap/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx similarity index 99% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx index 75d8c5a47d32d..e3a7e5aa30633 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_minimap/log_minimap.tsx @@ -7,7 +7,7 @@ import { scaleLinear } from 'd3-scale'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { LogEntryTime } from '../../../../common/log_entry'; import { DensityChart } from './density_chart'; import { HighlightedInterval } from './highlighted_interval'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_marker.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/search_marker.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_marker.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/search_marker.tsx index 5b661562a451e..8b87aa15f16f0 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_marker.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_minimap/search_marker.tsx @@ -7,7 +7,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import * as React from 'react'; -import euiStyled, { keyframes } from '../../../../../../common/eui_styled_components'; +import { euiStyled, keyframes } from '../../../../../observability/public'; import { LogEntryTime } from '../../../../common/log_entry'; import { SearchMarkerTooltip } from './search_marker_tooltip'; import { SummaryHighlightBucket } from './types'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_marker_tooltip.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/search_marker_tooltip.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_marker_tooltip.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/search_marker_tooltip.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_markers.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/search_markers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/search_markers.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/search_markers.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/time_ruler.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap/time_ruler.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/time_ruler.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap/time_ruler.tsx index c72403539563d..b610737663e8d 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/time_ruler.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_minimap/time_ruler.tsx @@ -7,7 +7,7 @@ import { scaleTime } from 'd3-scale'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface TimeRulerProps { end: number; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap/types.ts b/x-pack/plugins/infra/public/components/logging/log_minimap/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap/types.ts rename to x-pack/plugins/infra/public/components/logging/log_minimap/types.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_minimap_scale_controls.tsx b/x-pack/plugins/infra/public/components/logging/log_minimap_scale_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_minimap_scale_controls.tsx rename to x-pack/plugins/infra/public/components/logging/log_minimap_scale_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/index.ts b/x-pack/plugins/infra/public/components/logging/log_search_controls/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/index.ts rename to x-pack/plugins/infra/public/components/logging/log_search_controls/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_buttons.tsx b/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_buttons.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_buttons.tsx rename to x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_buttons.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx b/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx rename to x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_input.tsx b/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_input.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_input.tsx rename to x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_input.tsx index c5eedef83e824..a5277260d56e0 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_search_controls/log_search_input.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_search_controls/log_search_input.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import classNames from 'classnames'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface LogSearchInputProps { className?: string; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_statusbar.tsx b/x-pack/plugins/infra/public/components/logging/log_statusbar.tsx similarity index 91% rename from x-pack/legacy/plugins/infra/public/components/logging/log_statusbar.tsx rename to x-pack/plugins/infra/public/components/logging/log_statusbar.tsx index 4bda5a5a4b009..8a0f1290c2af3 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_statusbar.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_statusbar.tsx @@ -6,7 +6,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; export const LogStatusbar = euiStyled(EuiFlexGroup).attrs(() => ({ alignItems: 'center', diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_scale_controls.tsx b/x-pack/plugins/infra/public/components/logging/log_text_scale_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_scale_controls.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_scale_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/column_headers.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/column_headers.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/column_headers.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/column_headers.tsx index 6516993397e02..72d6aea5ecfc6 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/column_headers.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/column_headers.tsx @@ -7,7 +7,7 @@ import React, { useContext } from 'react'; import { transparentize } from 'polished'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { LogColumnConfiguration, isTimestampLogColumnConfiguration, diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/highlighting.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/highlighting.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/highlighting.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/highlighting.tsx index a48f3c96958be..a6cb8def4f6c4 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/highlighting.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/highlighting.tsx @@ -6,7 +6,7 @@ import React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { chooseLightOrDarkColor, tintOrShade } from '../../../utils/styles'; export const ActiveHighlightMarker = euiStyled.mark` diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/index.ts b/x-pack/plugins/infra/public/components/logging/log_text_stream/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/index.ts rename to x-pack/plugins/infra/public/components/logging/log_text_stream/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/item.ts b/x-pack/plugins/infra/public/components/logging/log_text_stream/item.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/item.ts rename to x-pack/plugins/infra/public/components/logging/log_text_stream/item.ts diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/jump_to_tail.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/jump_to_tail.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/jump_to_tail.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/jump_to_tail.tsx index 05f85ceed49c0..50595cfe971d8 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/jump_to_tail.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/jump_to_tail.tsx @@ -10,7 +10,7 @@ import { EuiButtonEmpty, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface LogTextStreamJumpToTailProps { onClickJump?: () => void; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/loading_item_view.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/loading_item_view.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/loading_item_view.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/loading_item_view.tsx index 4cefbea7225ec..8c48d9e176d3b 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/loading_item_view.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/loading_item_view.tsx @@ -10,7 +10,7 @@ import { EuiButtonEmpty, EuiIcon, EuiProgress, EuiText } from '@elastic/eui'; import { FormattedMessage, FormattedRelative } from '@kbn/i18n/react'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface LogTextStreamLoadingItemViewProps { alignment: 'top' | 'bottom'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_date_row.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_date_row.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_date_row.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_date_row.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_column.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_column.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_column.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_column.tsx index 643f98018cb0a..bcb5400c72209 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_column.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_column.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { LogColumnConfiguration, isMessageLogColumnConfiguration, diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.test.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.test.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.test.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.test.tsx index f947a0fb1adcd..8589f82ba15dd 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.test.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.test.tsx @@ -7,7 +7,7 @@ import { mount } from 'enzyme'; import React from 'react'; -import { EuiThemeProvider } from '../../../../../../common/eui_styled_components'; +import { EuiThemeProvider } from '../../../../../observability/public'; import { LogEntryColumn } from '../../../utils/log_entry'; import { LogEntryFieldColumn } from './log_entry_field_column'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.tsx index 6252b3a396d1b..705a7f4c12de4 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_field_column.tsx @@ -8,7 +8,7 @@ import stringify from 'json-stable-stringify'; import { darken, transparentize } from 'polished'; import React, { useMemo } from 'react'; -import euiStyled, { css } from '../../../../../../common/eui_styled_components'; +import { euiStyled, css } from '../../../../../observability/public'; import { isFieldColumn, isHighlightFieldColumn, diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_icon_column.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_icon_column.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_icon_column.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_icon_column.tsx index f7d841bcce94f..a4099cdf5a1fb 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_icon_column.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_icon_column.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { LogEntryColumnContent } from './log_entry_column'; import { hoveredContentStyle } from './text_styles'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; interface LogEntryIconColumnProps { isHighlighted: boolean; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_message_column.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_message_column.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_message_column.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_message_column.tsx index 11d73736463e2..10bc2a7b4597a 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_message_column.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_message_column.tsx @@ -6,7 +6,7 @@ import React, { memo, useMemo } from 'react'; -import euiStyled, { css } from '../../../../../../common/eui_styled_components'; +import { euiStyled, css } from '../../../../../observability/public'; import { isConstantSegment, isFieldSegment, diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx index 0da601ae52088..9c1a1bb5962e4 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_row.tsx @@ -7,7 +7,7 @@ // import { darken, transparentize } from 'polished'; import React, { useState, useCallback, useMemo } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { LogEntry, LogEntryHighlight, diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_timestamp_column.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_timestamp_column.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_timestamp_column.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_timestamp_column.tsx index 8e161367b428d..e3c1e80a43a1a 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/log_entry_timestamp_column.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/log_entry_timestamp_column.tsx @@ -7,7 +7,7 @@ import { darken, transparentize } from 'polished'; import React, { memo } from 'react'; -import euiStyled, { css } from '../../../../../../common/eui_styled_components'; +import { euiStyled, css } from '../../../../../observability/public'; import { useFormattedTime } from '../../formatted_time'; import { LogEntryColumnContent } from './log_entry_column'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/measurable_item_view.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/measurable_item_view.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/measurable_item_view.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/measurable_item_view.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx similarity index 99% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx index 15d3c83ffebe9..0bf121cf6c1eb 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/scrollable_log_text_stream_view.tsx @@ -9,7 +9,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment, useMemo } from 'react'; import moment from 'moment'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { TextScale } from '../../../../common/log_text_scale'; import { TimeKey, UniqueTimeKey } from '../../../../common/time'; import { callWithoutRepeats } from '../../../utils/handlers'; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/text_styles.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/text_styles.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/text_styles.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/text_styles.tsx index e95ac6aa7923b..6857f94105dad 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/text_styles.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/text_styles.tsx @@ -7,7 +7,7 @@ import { darken, transparentize } from 'polished'; import React, { useMemo, useState, useCallback } from 'react'; -import euiStyled, { css } from '../../../../../../common/eui_styled_components'; +import { euiStyled, css } from '../../../../../observability/public'; import { TextScale } from '../../../../common/log_text_scale'; export const monospaceTextStyle = (scale: TextScale) => css` diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/vertical_scroll_panel.tsx b/x-pack/plugins/infra/public/components/logging/log_text_stream/vertical_scroll_panel.tsx similarity index 91% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/vertical_scroll_panel.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_stream/vertical_scroll_panel.tsx index a57c25bf77bc8..199f24f5d3f53 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_text_stream/vertical_scroll_panel.tsx +++ b/x-pack/plugins/infra/public/components/logging/log_text_stream/vertical_scroll_panel.tsx @@ -5,11 +5,10 @@ */ import { bisector } from 'd3-array'; -import sortBy from 'lodash/fp/sortBy'; -import throttle from 'lodash/fp/throttle'; +import { sortBy, throttle } from 'lodash'; import * as React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { Rect } from './measurable_item_view'; interface VerticalScrollPanelProps { @@ -57,17 +56,14 @@ export class VerticalScrollPanel extends React.PureComponent< public childDimensions = new Map(); private nextScrollEventFromCenterTarget = false; - public handleScroll: React.UIEventHandler = throttle( - SCROLL_THROTTLE_INTERVAL, - () => { - // If this event was fired by the centerTarget method modifying the scrollTop, - // then don't send `fromScroll: true` to reportVisibleChildren. The rest of the - // app needs to respond differently depending on whether the user is scrolling through - // the pane manually, versus whether the pane is updating itself in response to new data - this.reportVisibleChildren(!this.nextScrollEventFromCenterTarget); - this.nextScrollEventFromCenterTarget = false; - } - ); + public handleScroll: React.UIEventHandler = throttle(() => { + // If this event was fired by the centerTarget method modifying the scrollTop, + // then don't send `fromScroll: true` to reportVisibleChildren. The rest of the + // app needs to respond differently depending on whether the user is scrolling through + // the pane manually, versus whether the pane is updating itself in response to new data + this.reportVisibleChildren(!this.nextScrollEventFromCenterTarget); + this.nextScrollEventFromCenterTarget = false; + }, SCROLL_THROTTLE_INTERVAL); public registerChild = (key: any, element: MeasurableChild | null) => { if (element === null) { @@ -79,7 +75,7 @@ export class VerticalScrollPanel extends React.PureComponent< public updateChildDimensions = () => { this.childDimensions = new Map( - sortDimensionsByTop( + sortBy<[any, Rect]>( Array.from(this.childRefs.entries()).reduce((accumulatedDimensions, [key, child]) => { const currentOffsetRect = child.getOffsetRect(); @@ -88,7 +84,8 @@ export class VerticalScrollPanel extends React.PureComponent< } return accumulatedDimensions; - }, [] as Array<[any, Rect]>) + }, [] as Array<[any, Rect]>), + '1.top' ) ); }; @@ -302,7 +299,5 @@ const getVisibleChildren = ( }; }; -const sortDimensionsByTop = sortBy<[any, Rect]>('1.top'); - const getChildIndexBefore = bisector<[any, Rect], number>(([key, rect]) => rect.top + rect.height) .left; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_text_wrap_controls.tsx b/x-pack/plugins/infra/public/components/logging/log_text_wrap_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_text_wrap_controls.tsx rename to x-pack/plugins/infra/public/components/logging/log_text_wrap_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_time_controls.tsx b/x-pack/plugins/infra/public/components/logging/log_time_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/logging/log_time_controls.tsx rename to x-pack/plugins/infra/public/components/logging/log_time_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/aggregation.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/aggregation.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/aggregation.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/aggregation.tsx index 2abc03d6ea9b9..76fa519ab3756 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/aggregation.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/aggregation.tsx @@ -8,7 +8,7 @@ import { EuiSelect } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useCallback } from 'react'; -import { MetricsExplorerAggregation } from '../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerAggregation } from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions } from '../../containers/metrics_explorer/use_metrics_explorer_options'; import { metricsExplorerAggregationRT, diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/chart.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/chart.tsx index f66ae867eef5a..43b08f45eed34 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/chart.tsx @@ -10,14 +10,14 @@ import { EuiTitle, EuiToolTip, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipValue } from '@elastic/charts'; import { first, last } from 'lodash'; import moment from 'moment'; -import { MetricsExplorerSeries } from '../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerSeries } from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, MetricsExplorerYAxisMode, MetricsExplorerChartOptions, } from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { createFormatterForMetric } from './helpers/create_formatter_for_metric'; import { MetricExplorerSeriesChart } from './series_chart'; import { MetricsExplorerChartContextMenu } from './chart_context_menu'; @@ -27,7 +27,7 @@ import { MetricsExplorerNoMetrics } from './no_metrics'; import { getChartTheme } from './helpers/get_chart_theme'; import { useKibanaUiSetting } from '../../utils/use_kibana_ui_setting'; import { calculateDomain } from './helpers/calculate_domain'; -import { useKibana, useUiSetting } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana, useUiSetting } from '../../../../../../src/plugins/kibana_react/public'; interface Props { title?: string | null; diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx similarity index 61% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx index 4dd46e9ef233a..9c3319d467ae2 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx @@ -5,12 +5,12 @@ */ import React from 'react'; -import { MetricsExplorerChartContextMenu, createNodeDetailLink } from './chart_context_menu'; -import { mount } from 'enzyme'; +import { MetricsExplorerChartContextMenu, createNodeDetailLink, Props } from './chart_context_menu'; +import { ReactWrapper, mount } from 'enzyme'; import { options, source, timeRange, chartOptions } from '../../utils/fixtures/metrics_explorer'; import DateMath from '@elastic/datemath'; -import { ReactWrapper } from 'enzyme'; import { Capabilities } from 'src/core/public'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; const series = { id: 'exmaple-01', rows: [], columns: [] }; const uiCapabilities: Capabilities = { @@ -24,22 +24,36 @@ const getTestSubject = (component: ReactWrapper, name: string) => { return component.find(`[data-test-subj="${name}"]`).hostNodes(); }; +const mountComponentWithProviders = (props: Props): ReactWrapper => { + const services = { + http: { + fetch: jest.fn(), + }, + application: { + getUrlForApp: jest.fn(), + }, + }; + + return mount( + + + + ); +}; + describe('MetricsExplorerChartContextMenu', () => { describe('component', () => { it('should just work', async () => { const onFilter = jest.fn().mockImplementation((query: string) => void 0); - const component = mount( - - ); - + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options, + onFilter, + uiCapabilities, + chartOptions, + }); component.find('button').simulate('click'); expect(getTestSubject(component, 'metricsExplorerAction-AddFilter').length).toBe(1); expect(getTestSubject(component, 'metricsExplorerAction-OpenInTSVB').length).toBe(1); @@ -49,33 +63,28 @@ describe('MetricsExplorerChartContextMenu', () => { it('should not display View metrics for incompatible groupBy', async () => { const customOptions = { ...options, groupBy: 'system.network.name' }; const onFilter = jest.fn().mockImplementation((query: string) => void 0); - const component = mount( - - ); + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options: customOptions, + onFilter, + uiCapabilities, + chartOptions, + }); component.find('button').simulate('click'); expect(getTestSubject(component, 'metricsExplorerAction-ViewNodeMetrics').length).toBe(0); }); it('should not display "Add Filter" without onFilter', async () => { - const component = mount( - - ); - + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options, + uiCapabilities, + chartOptions, + }); component.find('button').simulate('click'); expect(getTestSubject(component, 'metricsExplorerAction-AddFilter').length).toBe(0); }); @@ -83,35 +92,29 @@ describe('MetricsExplorerChartContextMenu', () => { it('should not display "Add Filter" without options.groupBy', async () => { const customOptions = { ...options, groupBy: void 0 }; const onFilter = jest.fn().mockImplementation((query: string) => void 0); - const component = mount( - - ); - + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options: customOptions, + onFilter, + uiCapabilities, + chartOptions, + }); component.find('button').simulate('click'); expect(getTestSubject(component, 'metricsExplorerAction-AddFilter').length).toBe(0); }); it('should disable "Open in Visualize" when options.metrics is empty', async () => { const customOptions = { ...options, metrics: [] }; - const component = mount( - - ); - + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options: customOptions, + uiCapabilities, + chartOptions, + }); component.find('button').simulate('click'); expect( getTestSubject(component, 'metricsExplorerAction-OpenInTSVB').prop('disabled') @@ -121,17 +124,15 @@ describe('MetricsExplorerChartContextMenu', () => { it('should not display "Open in Visualize" when unavailble in uiCapabilities', async () => { const customUICapabilities = { ...uiCapabilities, visualize: { show: false } }; const onFilter = jest.fn().mockImplementation((query: string) => void 0); - const component = mount( - - ); + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options, + onFilter, + uiCapabilities: customUICapabilities, + chartOptions, + }); component.find('button').simulate('click'); expect(getTestSubject(component, 'metricsExplorerAction-OpenInTSVB').length).toBe(0); @@ -141,17 +142,15 @@ describe('MetricsExplorerChartContextMenu', () => { const customUICapabilities = { ...uiCapabilities, visualize: { show: false } }; const onFilter = jest.fn().mockImplementation((query: string) => void 0); const customOptions = { ...options, groupBy: void 0 }; - const component = mount( - - ); + const component = mountComponentWithProviders({ + timeRange, + source, + series, + options: customOptions, + onFilter, + uiCapabilities: customUICapabilities, + chartOptions, + }); expect(component.find('button').length).toBe(0); }); }); @@ -163,9 +162,7 @@ describe('MetricsExplorerChartContextMenu', () => { const to = DateMath.parse(toDateStrig, { roundUp: true })!; const from = DateMath.parse(fromDateStrig)!; const link = createNodeDetailLink('host', 'example-01', fromDateStrig, toDateStrig); - expect(link).toBe( - `#/link-to/host-detail/example-01?to=${to.valueOf()}&from=${from.valueOf()}` - ); + expect(link).toBe(`link-to/host-detail/example-01?to=${to.valueOf()}&from=${from.valueOf()}`); }); }); }); diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx similarity index 92% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx index 298f7dd8f8d17..f7c97033f8d50 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx @@ -14,7 +14,7 @@ import { } from '@elastic/eui'; import DateMath from '@elastic/datemath'; import { Capabilities } from 'src/core/public'; -import { MetricsExplorerSeries } from '../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerSeries } from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, @@ -24,8 +24,9 @@ import { createTSVBLink } from './helpers/create_tsvb_link'; import { getNodeDetailUrl } from '../../pages/link_to/redirect_to_node_detail'; import { SourceConfiguration } from '../../utils/source_configuration'; import { InventoryItemType } from '../../../common/inventory_models/types'; +import { usePrefixPathWithBasepath } from '../../hooks/use_prefix_path_with_basepath'; -interface Props { +export interface Props { options: MetricsExplorerOptions; onFilter?: (query: string) => void; series: MetricsExplorerSeries; @@ -70,7 +71,7 @@ export const createNodeDetailLink = ( }); }; -export const MetricsExplorerChartContextMenu = ({ +export const MetricsExplorerChartContextMenu: React.FC = ({ onFilter, options, series, @@ -79,6 +80,7 @@ export const MetricsExplorerChartContextMenu = ({ uiCapabilities, chartOptions, }: Props) => { + const urlPrefixer = usePrefixPathWithBasepath(); const [isPopoverOpen, setPopoverState] = useState(false); const supportFiltering = options.groupBy != null && onFilter != null; const handleFilter = useCallback(() => { @@ -115,7 +117,10 @@ export const MetricsExplorerChartContextMenu = ({ values: { name: nodeType }, }), icon: 'metricsApp', - href: createNodeDetailLink(nodeType, series.id, timeRange.from, timeRange.to), + href: urlPrefixer( + 'metrics', + createNodeDetailLink(nodeType, series.id, timeRange.from, timeRange.to) + ), 'data-test-subj': 'metricsExplorerAction-ViewNodeMetrics', }, ] diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_options.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/chart_options.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart_options.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/chart_options.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/charts.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/charts.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/charts.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/charts.tsx index 32c9ac36b5c52..64e7b27f5722f 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/charts.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/charts.tsx @@ -8,7 +8,7 @@ import { EuiButton, EuiFlexGrid, EuiFlexItem, EuiText, EuiHorizontalRule } from import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { MetricsExplorerResponse } from '../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerResponse } from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/empty_chart.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/empty_chart.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/empty_chart.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/empty_chart.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/group_by.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/group_by.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/group_by.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/group_by.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts similarity index 56% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts index fd18adea3aad0..90569854b833b 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts @@ -3,10 +3,20 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { min, max, sum } from 'lodash'; -import { MetricsExplorerSeries } from '../../../../server/routes/metrics_explorer/types'; +import { min, max, sum, isNumber } from 'lodash'; +import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptionsMetric } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; +const getMin = (values: Array) => { + const minValue = min(values); + return isNumber(minValue) && Number.isFinite(minValue) ? minValue : undefined; +}; + +const getMax = (values: Array) => { + const maxValue = max(values); + return isNumber(maxValue) && Number.isFinite(maxValue) ? maxValue : undefined; +}; + export const calculateDomain = ( series: MetricsExplorerSeries, metrics: MetricsExplorerOptionsMetric[], @@ -18,13 +28,13 @@ export const calculateDomain = ( .map((m, index) => { return (row[`metric_${index}`] as number) || null; }) - .filter(v => v); - const minValue = min(rowValues); + .filter(v => isNumber(v)); + const minValue = getMin(rowValues); // For stacked domains we want to add 10% head room so the charts have // enough room to draw the 2 pixel line as well. - const maxValue = stacked ? sum(rowValues) * 1.1 : max(rowValues); + const maxValue = stacked ? sum(rowValues) * 1.1 : getMax(rowValues); return acc.concat([minValue || null, maxValue || null]); }, [] as Array) - .filter(v => v); - return { min: min(values) || 0, max: max(values) || 0 }; + .filter(v => isNumber(v)); + return { min: getMin(values) || 0, max: getMax(values) || 0 }; }; diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts similarity index 95% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts index e85cd67060d2c..4b45534d41db8 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts @@ -5,7 +5,7 @@ */ import { calculateDomain } from './calculate_domain'; -import { MetricsExplorerSeries } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptionsMetric } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; import { MetricsExplorerColor } from '../../../../common/color_palette'; describe('calculateDomain()', () => { diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts similarity index 90% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts index 1e9902337e032..33ec2ce2715a3 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MetricsExplorerMetric } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; import { createFormatter } from '../../../utils/formatters'; import { InfraFormatterType } from '../../../lib/lib'; import { metricToFormat } from './metric_to_format'; diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts index 592dd70345bfa..ec41e90e441a4 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts @@ -5,7 +5,7 @@ */ import { createFormatterForMetric } from './create_formatter_for_metric'; -import { MetricsExplorerMetric } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; describe('createFormatterForMetric()', () => { it('should just work for count', () => { diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts similarity index 89% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts index 0c52d8d56a6e9..cbf6904d246c7 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts @@ -5,7 +5,7 @@ */ import { createMetricLabel } from './create_metric_label'; -import { MetricsExplorerMetric } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; describe('createMetricLabel()', () => { it('should work with metrics with fields', () => { diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts similarity index 80% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts index 489520177f07d..b6453a81317b1 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MetricsExplorerMetric } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; export const createMetricLabel = (metric: MetricsExplorerMetric) => { return `${metric.aggregation}(${metric.field || ''})`; diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts index 2fe81123594e9..cb23a96b9c163 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts @@ -8,7 +8,7 @@ import { encode } from 'rison-node'; import uuid from 'uuid'; import { set } from 'lodash'; import { colorTransformer, MetricsExplorerColor } from '../../../../common/color_palette'; -import { MetricsExplorerSeries } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerOptionsMetric, diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/get_chart_theme.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/get_chart_theme.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/get_chart_theme.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/get_chart_theme.ts diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts index a38a9ac54d828..4cb27b4fb65c3 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts @@ -5,7 +5,7 @@ */ import { metricToFormat } from './metric_to_format'; -import { MetricsExplorerMetric } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; import { InfraFormatterType } from '../../../lib/lib'; describe('metricToFormat()', () => { it('should just work for numeric metrics', () => { diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts similarity index 89% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts rename to x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts index 69f2bd50ef42f..63272c86a5dc7 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts +++ b/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts @@ -5,7 +5,7 @@ */ import { last } from 'lodash'; -import { MetricsExplorerMetric } from '../../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; import { InfraFormatterType } from '../../../lib/lib'; export const metricToFormat = (metric?: MetricsExplorerMetric) => { if (metric && metric.field) { diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx index 7114217920998..0e18deedd404c 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx @@ -10,7 +10,7 @@ import React, { useEffect, useState } from 'react'; import { WithKueryAutocompletion } from '../../containers/with_kuery_autocompletion'; import { AutocompleteField } from '../autocomplete_field'; import { isDisplayable } from '../../utils/is_displayable'; -import { esKuery, IIndexPattern } from '../../../../../../../src/plugins/data/public'; +import { esKuery, IIndexPattern } from '../../../../../../src/plugins/data/public'; interface Props { derivedIndexPattern: IIndexPattern; diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/metrics.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/metrics.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/metrics.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/metrics.tsx index 0010fce7efa49..79d4122733c55 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/metrics.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/metrics.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import React, { useCallback, useState } from 'react'; import { IFieldType } from 'src/plugins/data/public'; import { colorTransformer, MetricsExplorerColor } from '../../../common/color_palette'; -import { MetricsExplorerMetric } from '../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerMetric } from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions } from '../../containers/metrics_explorer/use_metrics_explorer_options'; import { isDisplayable } from '../../utils/is_displayable'; diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/no_metrics.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/no_metrics.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/no_metrics.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/no_metrics.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/series_chart.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/series_chart.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/series_chart.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/series_chart.tsx index f365faa134d93..65911a02c938a 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/series_chart.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/series_chart.tsx @@ -13,7 +13,7 @@ import { AreaSeriesStyle, BarSeriesStyle, } from '@elastic/charts'; -import { MetricsExplorerSeries } from '../../../server/routes/metrics_explorer/types'; +import { MetricsExplorerSeries } from '../../../common/http_api/metrics_explorer'; import { colorTransformer, MetricsExplorerColor } from '../../../common/color_palette'; import { createMetricLabel } from './helpers/create_metric_label'; import { diff --git a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/toolbar.tsx b/x-pack/plugins/infra/public/components/metrics_explorer/toolbar.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/metrics_explorer/toolbar.tsx rename to x-pack/plugins/infra/public/components/metrics_explorer/toolbar.tsx index 839e40e057c9a..9e96819a36cac 100644 --- a/x-pack/legacy/plugins/infra/public/components/metrics_explorer/toolbar.tsx +++ b/x-pack/plugins/infra/public/components/metrics_explorer/toolbar.tsx @@ -11,7 +11,7 @@ import { IIndexPattern } from 'src/plugins/data/public'; import { MetricsExplorerMetric, MetricsExplorerAggregation, -} from '../../../server/routes/metrics_explorer/types'; +} from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, diff --git a/x-pack/legacy/plugins/infra/public/components/navigation/app_navigation.tsx b/x-pack/plugins/infra/public/components/navigation/app_navigation.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/public/components/navigation/app_navigation.tsx rename to x-pack/plugins/infra/public/components/navigation/app_navigation.tsx index 79785c11a3ebe..b229fb4a6b494 100644 --- a/x-pack/legacy/plugins/infra/public/components/navigation/app_navigation.tsx +++ b/x-pack/plugins/infra/public/components/navigation/app_navigation.tsx @@ -6,7 +6,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface AppNavigationProps { 'aria-label': string; diff --git a/x-pack/legacy/plugins/infra/public/components/navigation/routed_tabs.tsx b/x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx similarity index 53% rename from x-pack/legacy/plugins/infra/public/components/navigation/routed_tabs.tsx rename to x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx index c43ade12ded6d..2838ac6cda6dd 100644 --- a/x-pack/legacy/plugins/infra/public/components/navigation/routed_tabs.tsx +++ b/x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx @@ -8,7 +8,7 @@ import { EuiLink, EuiTab, EuiTabs } from '@elastic/eui'; import React from 'react'; import { Route } from 'react-router-dom'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface TabConfiguration { title: string | React.ReactNode; @@ -32,23 +32,27 @@ export class RoutedTabs extends React.Component { ( - - {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} - ) => { - e.preventDefault(); - history.push(tab.path); - }} - > - - {tab.title} - - - - )} + children={({ match, history }) => { + return ( + + {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} + ) => { + e.preventDefault(); + history.push(tab.path); + }} + > + + {tab.title} + + + + ); + }} /> ); }); diff --git a/x-pack/legacy/plugins/infra/public/components/nodes_overview/index.tsx b/x-pack/plugins/infra/public/components/nodes_overview/index.tsx similarity index 99% rename from x-pack/legacy/plugins/infra/public/components/nodes_overview/index.tsx rename to x-pack/plugins/infra/public/components/nodes_overview/index.tsx index 8e8015ce6a82e..8cd3faabd1e12 100644 --- a/x-pack/legacy/plugins/infra/public/components/nodes_overview/index.tsx +++ b/x-pack/plugins/infra/public/components/nodes_overview/index.tsx @@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { get, max, min } from 'lodash'; import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraFormatterType, InfraWaffleMapBounds, InfraWaffleMapOptions } from '../../lib/lib'; import { KueryFilterQuery } from '../../store/local/waffle_filter'; import { createFormatter } from '../../utils/formatters'; diff --git a/x-pack/legacy/plugins/infra/public/components/nodes_overview/table.tsx b/x-pack/plugins/infra/public/components/nodes_overview/table.tsx similarity index 94% rename from x-pack/legacy/plugins/infra/public/components/nodes_overview/table.tsx rename to x-pack/plugins/infra/public/components/nodes_overview/table.tsx index 5c793f670119c..82991076255ee 100644 --- a/x-pack/legacy/plugins/infra/public/components/nodes_overview/table.tsx +++ b/x-pack/plugins/infra/public/components/nodes_overview/table.tsx @@ -15,7 +15,7 @@ import { fieldToName } from '../waffle/lib/field_to_display_name'; import { NodeContextMenu } from '../waffle/node_context_menu'; import { InventoryItemType } from '../../../common/inventory_models/types'; import { SnapshotNode, SnapshotNodePath } from '../../../common/http_api/snapshot_api'; -import { ROOT_ELEMENT_ID } from '../../app'; +import { CONTAINER_CLASSNAME } from '../../apps/start_app'; interface Props { nodes: SnapshotNode[]; @@ -57,10 +57,13 @@ export const TableView = (props: Props) => { ); useEffect(() => { - if (openPopovers.length > 0) { - document.getElementById(ROOT_ELEMENT_ID)!.style.overflowY = 'hidden'; - } else { - document.getElementById(ROOT_ELEMENT_ID)!.style.overflowY = 'auto'; + const el = document.getElementsByClassName(CONTAINER_CLASSNAME)[0]; + if (el instanceof HTMLElement) { + if (openPopovers.length > 0) { + el.style.overflowY = 'hidden'; + } else { + el.style.overflowY = 'auto'; + } } }, [openPopovers]); diff --git a/x-pack/legacy/plugins/infra/public/components/page.tsx b/x-pack/plugins/infra/public/components/page.tsx similarity index 90% rename from x-pack/legacy/plugins/infra/public/components/page.tsx rename to x-pack/plugins/infra/public/components/page.tsx index ca029e43ac37b..b51afdd8ca803 100644 --- a/x-pack/legacy/plugins/infra/public/components/page.tsx +++ b/x-pack/plugins/infra/public/components/page.tsx @@ -6,7 +6,7 @@ import { EuiPage } from '@elastic/eui'; -import euiStyled from '../../../../common/eui_styled_components'; +import { euiStyled } from '../../../observability/public'; export const ColumnarPage = euiStyled.div` display: flex; diff --git a/x-pack/legacy/plugins/infra/public/components/saved_views/create_modal.tsx b/x-pack/plugins/infra/public/components/saved_views/create_modal.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/saved_views/create_modal.tsx rename to x-pack/plugins/infra/public/components/saved_views/create_modal.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/saved_views/toolbar_control.tsx b/x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/saved_views/toolbar_control.tsx rename to x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx index e03b7fcc8ffa4..c66aea669682e 100644 --- a/x-pack/legacy/plugins/infra/public/components/saved_views/toolbar_control.tsx +++ b/x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import { useSavedView } from '../../hooks/use_saved_view'; import { SavedViewCreateModal } from './create_modal'; import { SavedViewListFlyout } from './view_list_flyout'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; interface Props { viewType: string; diff --git a/x-pack/legacy/plugins/infra/public/components/saved_views/view_list_flyout.tsx b/x-pack/plugins/infra/public/components/saved_views/view_list_flyout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/saved_views/view_list_flyout.tsx rename to x-pack/plugins/infra/public/components/saved_views/view_list_flyout.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/add_log_column_popover.tsx b/x-pack/plugins/infra/public/components/source_configuration/add_log_column_popover.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/add_log_column_popover.tsx rename to x-pack/plugins/infra/public/components/source_configuration/add_log_column_popover.tsx index fc8407c5298e6..0835a904585ed 100644 --- a/x-pack/legacy/plugins/infra/public/components/source_configuration/add_log_column_popover.tsx +++ b/x-pack/plugins/infra/public/components/source_configuration/add_log_column_popover.tsx @@ -12,7 +12,7 @@ import { v4 as uuidv4 } from 'uuid'; import { LogColumnConfiguration } from '../../utils/source_configuration'; import { useVisibilityState } from '../../utils/use_visibility_state'; -import { euiStyled } from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; interface SelectableColumnOption { optionProps: Option; diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/fields_configuration_panel.tsx b/x-pack/plugins/infra/public/components/source_configuration/fields_configuration_panel.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/fields_configuration_panel.tsx rename to x-pack/plugins/infra/public/components/source_configuration/fields_configuration_panel.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/index.ts b/x-pack/plugins/infra/public/components/source_configuration/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/index.ts rename to x-pack/plugins/infra/public/components/source_configuration/index.ts diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/indices_configuration_form_state.ts b/x-pack/plugins/infra/public/components/source_configuration/indices_configuration_form_state.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/indices_configuration_form_state.ts rename to x-pack/plugins/infra/public/components/source_configuration/indices_configuration_form_state.ts diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/indices_configuration_panel.tsx b/x-pack/plugins/infra/public/components/source_configuration/indices_configuration_panel.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/indices_configuration_panel.tsx rename to x-pack/plugins/infra/public/components/source_configuration/indices_configuration_panel.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/input_fields.tsx b/x-pack/plugins/infra/public/components/source_configuration/input_fields.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/input_fields.tsx rename to x-pack/plugins/infra/public/components/source_configuration/input_fields.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_form_state.tsx b/x-pack/plugins/infra/public/components/source_configuration/log_columns_configuration_form_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_form_state.tsx rename to x-pack/plugins/infra/public/components/source_configuration/log_columns_configuration_form_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx b/x-pack/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx similarity index 99% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx rename to x-pack/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx index 90361a5c2b541..9ccd28f149ec7 100644 --- a/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx +++ b/x-pack/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx @@ -22,7 +22,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { useCallback } from 'react'; -import { DragHandleProps, DropResult } from '../../../../../common/eui_draggable'; +import { DragHandleProps, DropResult } from '../../../../observability/public'; import { AddLogColumnButtonAndPopover } from './add_log_column_popover'; import { diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/name_configuration_panel.tsx b/x-pack/plugins/infra/public/components/source_configuration/name_configuration_panel.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/name_configuration_panel.tsx rename to x-pack/plugins/infra/public/components/source_configuration/name_configuration_panel.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/source_configuration_form_state.tsx b/x-pack/plugins/infra/public/components/source_configuration/source_configuration_form_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/source_configuration_form_state.tsx rename to x-pack/plugins/infra/public/components/source_configuration/source_configuration_form_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/source_configuration_settings.tsx b/x-pack/plugins/infra/public/components/source_configuration/source_configuration_settings.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/source_configuration_settings.tsx rename to x-pack/plugins/infra/public/components/source_configuration/source_configuration_settings.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/view_source_configuration_button.tsx b/x-pack/plugins/infra/public/components/source_configuration/view_source_configuration_button.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_configuration/view_source_configuration_button.tsx rename to x-pack/plugins/infra/public/components/source_configuration/view_source_configuration_button.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_error_page.tsx b/x-pack/plugins/infra/public/components/source_error_page.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_error_page.tsx rename to x-pack/plugins/infra/public/components/source_error_page.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/source_loading_page.tsx b/x-pack/plugins/infra/public/components/source_loading_page.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/source_loading_page.tsx rename to x-pack/plugins/infra/public/components/source_loading_page.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/conditional_tooltip.tsx b/x-pack/plugins/infra/public/components/waffle/conditional_tooltip.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/conditional_tooltip.tsx rename to x-pack/plugins/infra/public/components/waffle/conditional_tooltip.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/custom_field_panel.tsx b/x-pack/plugins/infra/public/components/waffle/custom_field_panel.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/custom_field_panel.tsx rename to x-pack/plugins/infra/public/components/waffle/custom_field_panel.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/gradient_legend.tsx b/x-pack/plugins/infra/public/components/waffle/gradient_legend.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/waffle/gradient_legend.tsx rename to x-pack/plugins/infra/public/components/waffle/gradient_legend.tsx index 3dcc40818b4d5..6b0c4bb41dc98 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/gradient_legend.tsx +++ b/x-pack/plugins/infra/public/components/waffle/gradient_legend.tsx @@ -6,7 +6,7 @@ import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraFormatter, InfraWaffleMapBounds, diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/group_name.tsx b/x-pack/plugins/infra/public/components/waffle/group_name.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/components/waffle/group_name.tsx rename to x-pack/plugins/infra/public/components/waffle/group_name.tsx index 731bcdd52a98e..01bd3600a1624 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/group_name.tsx +++ b/x-pack/plugins/infra/public/components/waffle/group_name.tsx @@ -6,7 +6,7 @@ import { EuiLink, EuiToolTip } from '@elastic/eui'; import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraWaffleMapGroup, InfraWaffleMapOptions } from '../../lib/lib'; interface Props { diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/group_of_groups.tsx b/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/waffle/group_of_groups.tsx rename to x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx index 60a117e3ed617..9634293587d49 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/group_of_groups.tsx +++ b/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx @@ -6,7 +6,7 @@ import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraWaffleMapBounds, InfraWaffleMapGroupOfGroups, diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/group_of_nodes.tsx b/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/waffle/group_of_nodes.tsx rename to x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx index b47b8f6a1bf39..6b82671617df7 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/group_of_nodes.tsx +++ b/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx @@ -6,7 +6,7 @@ import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraWaffleMapBounds, InfraWaffleMapGroupOfNodes, diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/legend.tsx b/x-pack/plugins/infra/public/components/waffle/legend.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/waffle/legend.tsx rename to x-pack/plugins/infra/public/components/waffle/legend.tsx index c7f647449606e..de070efb35a1f 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/legend.tsx +++ b/x-pack/plugins/infra/public/components/waffle/legend.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { WithWaffleOptions } from '../../containers/waffle/with_waffle_options'; import { InfraFormatter, InfraWaffleMapBounds, InfraWaffleMapLegend } from '../../lib/lib'; import { GradientLegend } from './gradient_legend'; diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/legend_controls.tsx b/x-pack/plugins/infra/public/components/waffle/legend_controls.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/waffle/legend_controls.tsx rename to x-pack/plugins/infra/public/components/waffle/legend_controls.tsx index f6e4a65eead24..26b5b1c0af727 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/legend_controls.tsx +++ b/x-pack/plugins/infra/public/components/waffle/legend_controls.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { SyntheticEvent, useState } from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraWaffleMapBounds } from '../../lib/lib'; interface Props { diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts b/x-pack/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts rename to x-pack/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/color_from_value.ts b/x-pack/plugins/infra/public/components/waffle/lib/color_from_value.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/color_from_value.ts rename to x-pack/plugins/infra/public/components/waffle/lib/color_from_value.ts diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts b/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts similarity index 86% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts rename to x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts index 1a285ceefec0e..fb9791fae9b5e 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts +++ b/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts @@ -46,9 +46,7 @@ describe('createUptimeLink()', () => { avg: 0.6, }, }; - expect(createUptimeLink(options, 'host', node)).toBe( - '../app/uptime#/?search=host.ip:"10.0.1.2"' - ); + expect(createUptimeLink(options, 'host', node)).toBe('#/?search=host.ip:"10.0.1.2"'); }); it('should work for hosts without ip', () => { @@ -64,9 +62,7 @@ describe('createUptimeLink()', () => { avg: 0.6, }, }; - expect(createUptimeLink(options, 'host', node)).toBe( - '../app/uptime#/?search=host.name:"host-01"' - ); + expect(createUptimeLink(options, 'host', node)).toBe('#/?search=host.name:"host-01"'); }); it('should work for pods', () => { @@ -83,7 +79,7 @@ describe('createUptimeLink()', () => { }, }; expect(createUptimeLink(options, 'pod', node)).toBe( - '../app/uptime#/?search=kubernetes.pod.uid:"29193-pod-02939"' + '#/?search=kubernetes.pod.uid:"29193-pod-02939"' ); }); @@ -101,7 +97,7 @@ describe('createUptimeLink()', () => { }, }; expect(createUptimeLink(options, 'container', node)).toBe( - '../app/uptime#/?search=container.id:"docker-1234"' + '#/?search=container.id:"docker-1234"' ); }); }); diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/create_uptime_link.ts b/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.ts similarity index 81% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/create_uptime_link.ts rename to x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.ts index 05b4b6d514cd0..023a1a4b6ecef 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/lib/create_uptime_link.ts +++ b/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.ts @@ -8,16 +8,14 @@ import { get } from 'lodash'; import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../../lib/lib'; import { InventoryItemType } from '../../../../common/inventory_models/types'; -const BASE_URL = '../app/uptime#/?search='; - export const createUptimeLink = ( options: InfraWaffleMapOptions, nodeType: InventoryItemType, node: InfraWaffleMapNode ) => { if (nodeType === 'host' && node.ip) { - return `${BASE_URL}host.ip:"${node.ip}"`; + return `#/?search=host.ip:"${node.ip}"`; } const field = get(options, ['fields', nodeType], ''); - return `${BASE_URL}${field ? field + ':' : ''}"${node.id}"`; + return `#/?search=${field ? field + ':' : ''}"${node.id}"`; }; diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/field_to_display_name.ts b/x-pack/plugins/infra/public/components/waffle/lib/field_to_display_name.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/field_to_display_name.ts rename to x-pack/plugins/infra/public/components/waffle/lib/field_to_display_name.ts diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/size_of_squares.ts b/x-pack/plugins/infra/public/components/waffle/lib/size_of_squares.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/size_of_squares.ts rename to x-pack/plugins/infra/public/components/waffle/lib/size_of_squares.ts diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/lib/type_guards.ts b/x-pack/plugins/infra/public/components/waffle/lib/type_guards.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/lib/type_guards.ts rename to x-pack/plugins/infra/public/components/waffle/lib/type_guards.ts diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/map.tsx b/x-pack/plugins/infra/public/components/waffle/map.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/waffle/map.tsx rename to x-pack/plugins/infra/public/components/waffle/map.tsx index 91fb84840f37f..7cab2307dacfa 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/map.tsx +++ b/x-pack/plugins/infra/public/components/waffle/map.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { nodesToWaffleMap } from '../../containers/waffle/nodes_to_wafflemap'; import { isWaffleMapGroupWithGroups, diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/node.tsx b/x-pack/plugins/infra/public/components/waffle/node.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/waffle/node.tsx rename to x-pack/plugins/infra/public/components/waffle/node.tsx index 72e2a4c8f35d7..4eb5ccb8c1b4d 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/node.tsx +++ b/x-pack/plugins/infra/public/components/waffle/node.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { ConditionalToolTip } from './conditional_tooltip'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraWaffleMapBounds, InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; import { colorFromValue } from './lib/color_from_value'; import { NodeContextMenu } from './node_context_menu'; diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/node_context_menu.tsx b/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx similarity index 89% rename from x-pack/legacy/plugins/infra/public/components/waffle/node_context_menu.tsx rename to x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx index 97b85a7e6e17d..43d27bb8259b3 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/node_context_menu.tsx +++ b/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx @@ -13,7 +13,7 @@ import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; import { getNodeDetailUrl, getNodeLogsUrl } from '../../pages/link_to'; import { createUptimeLink } from './lib/create_uptime_link'; import { findInventoryModel, findInventoryFields } from '../../../common/inventory_models'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { InventoryItemType } from '../../../common/inventory_models/types'; import { Section, @@ -23,7 +23,8 @@ import { SectionSubtitle, SectionLinks, SectionLink, -} from '../../../../../../plugins/observability/public'; +} from '../../../../observability/public'; +import { usePrefixPathWithBasepath } from '../../hooks/use_prefix_path_with_basepath'; interface Props { options: InfraWaffleMapOptions; @@ -45,6 +46,7 @@ export const NodeContextMenu: React.FC = ({ nodeType, popoverPosition, }) => { + const urlPrefixer = usePrefixPathWithBasepath(); const uiCapabilities = useKibana().services.application?.capabilities; const inventoryModel = findInventoryModel(nodeType); const nodeDetailFrom = currentTime - inventoryModel.metrics.defaultTimeRangeInSeconds * 1000; @@ -84,11 +86,14 @@ export const NodeContextMenu: React.FC = ({ defaultMessage: '{inventoryName} logs', values: { inventoryName: inventoryModel.singularDisplayName }, }), - href: getNodeLogsUrl({ - nodeType, - nodeId: node.id, - time: currentTime, - }), + href: urlPrefixer( + 'logs', + getNodeLogsUrl({ + nodeType, + nodeId: node.id, + time: currentTime, + }) + ), 'data-test-subj': 'viewLogsContextMenuItem', isDisabled: !showLogsLink, }; @@ -98,12 +103,15 @@ export const NodeContextMenu: React.FC = ({ defaultMessage: '{inventoryName} metrics', values: { inventoryName: inventoryModel.singularDisplayName }, }), - href: getNodeDetailUrl({ - nodeType, - nodeId: node.id, - from: nodeDetailFrom, - to: currentTime, - }), + href: urlPrefixer( + 'metrics', + getNodeDetailUrl({ + nodeType, + nodeId: node.id, + from: nodeDetailFrom, + to: currentTime, + }) + ), isDisabled: !showDetail, }; @@ -112,7 +120,7 @@ export const NodeContextMenu: React.FC = ({ defaultMessage: '{inventoryName} APM traces', values: { inventoryName: inventoryModel.singularDisplayName }, }), - href: `../app/apm#/traces?_g=()&kuery=${apmField}:"${node.id}"`, + href: urlPrefixer('apm', `#traces?_g=()&kuery=${apmField}:"${node.id}"`), 'data-test-subj': 'viewApmTracesContextMenuItem', isDisabled: !showAPMTraceLink, }; @@ -122,7 +130,7 @@ export const NodeContextMenu: React.FC = ({ defaultMessage: '{inventoryName} in Uptime', values: { inventoryName: inventoryModel.singularDisplayName }, }), - href: createUptimeLink(options, nodeType, node), + href: urlPrefixer('uptime', createUptimeLink(options, nodeType, node)), isDisabled: !showUptimeLink, }; diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/steps_legend.tsx b/x-pack/plugins/infra/public/components/waffle/steps_legend.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/components/waffle/steps_legend.tsx rename to x-pack/plugins/infra/public/components/waffle/steps_legend.tsx index e251720795074..d2079d53dad71 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/steps_legend.tsx +++ b/x-pack/plugins/infra/public/components/waffle/steps_legend.tsx @@ -7,7 +7,7 @@ import { darken } from 'polished'; import React from 'react'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InfraFormatter, InfraWaffleMapRuleOperator, diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/view_switcher.tsx b/x-pack/plugins/infra/public/components/waffle/view_switcher.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/view_switcher.tsx rename to x-pack/plugins/infra/public/components/waffle/view_switcher.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx rename to x-pack/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx rename to x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx index 3e697dccabac5..81f82ec27b4a3 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx +++ b/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { IFieldType } from 'src/plugins/data/public'; import { InfraGroupByOptions } from '../../lib/lib'; import { CustomFieldPanel } from './custom_field_panel'; -import euiStyled from '../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../observability/public'; import { InventoryItemType } from '../../../common/inventory_models/types'; import { SnapshotGroupBy } from '../../../common/http_api/snapshot_api'; diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx rename to x-pack/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_metric_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_metric_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/waffle_metric_controls.tsx rename to x-pack/plugins/infra/public/components/waffle/waffle_metric_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_region_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_region_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/waffle_region_controls.tsx rename to x-pack/plugins/infra/public/components/waffle/waffle_region_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/waffle_time_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_time_controls.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/components/waffle/waffle_time_controls.tsx rename to x-pack/plugins/infra/public/components/waffle/waffle_time_controls.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts b/x-pack/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts rename to x-pack/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_api_types.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_api_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_api_types.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_api_types.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_cleanup.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_cleanup.ts similarity index 88% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_cleanup.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_cleanup.ts index 76e5f210ca238..21ae7804292dd 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_cleanup.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_cleanup.ts @@ -8,7 +8,7 @@ import * as rt from 'io-ts'; import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { getDatafeedId, getJobId } from '../../../../../common/log_analysis'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; @@ -19,7 +19,7 @@ export const callDeleteJobs = async ( jobTypes: JobType[] ) => { // NOTE: Deleting the jobs via this API will delete the datafeeds at the same time - const deleteJobsResponse = await npStart.core.http.fetch('/api/ml/jobs/delete_jobs', { + const deleteJobsResponse = await npStart.http.fetch('/api/ml/jobs/delete_jobs', { method: 'POST', body: JSON.stringify( deleteJobsRequestPayloadRT.encode({ @@ -35,9 +35,7 @@ export const callDeleteJobs = async ( }; export const callGetJobDeletionTasks = async () => { - const jobDeletionTasksResponse = await npStart.core.http.fetch( - '/api/ml/jobs/deleting_jobs_tasks' - ); + const jobDeletionTasksResponse = await npStart.http.fetch('/api/ml/jobs/deleting_jobs_tasks'); return pipe( getJobDeletionTasksResponsePayloadRT.decode(jobDeletionTasksResponse), @@ -51,7 +49,7 @@ export const callStopDatafeeds = async ( jobTypes: JobType[] ) => { // Stop datafeed due to https://github.com/elastic/kibana/issues/44652 - const stopDatafeedResponse = await npStart.core.http.fetch('/api/ml/jobs/stop_datafeeds', { + const stopDatafeedResponse = await npStart.http.fetch('/api/ml/jobs/stop_datafeeds', { method: 'POST', body: JSON.stringify( stopDatafeedsRequestPayloadRT.encode({ diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_jobs_summary_api.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_get_jobs_summary_api.ts similarity index 93% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_jobs_summary_api.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_get_jobs_summary_api.ts index a067285026e33..ef463561a863f 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_jobs_summary_api.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_get_jobs_summary_api.ts @@ -8,7 +8,7 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import * as rt from 'io-ts'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { jobCustomSettingsRT } from './ml_api_types'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; import { getJobId } from '../../../../../common/log_analysis'; @@ -18,7 +18,7 @@ export const callJobsSummaryAPI = async ( sourceId: string, jobTypes: JobType[] ) => { - const response = await npStart.core.http.fetch('/api/ml/jobs/jobs_summary', { + const response = await npStart.http.fetch('/api/ml/jobs/jobs_summary', { method: 'POST', body: JSON.stringify( fetchJobStatusRequestPayloadRT.encode({ diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts similarity index 88% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts index ae90c7bb84130..7c34eeca76a98 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_get_module.ts @@ -8,12 +8,12 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import * as rt from 'io-ts'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; import { jobCustomSettingsRT } from './ml_api_types'; export const callGetMlModuleAPI = async (moduleId: string) => { - const response = await npStart.core.http.fetch(`/api/ml/modules/get_module/${moduleId}`, { + const response = await npStart.http.fetch(`/api/ml/modules/get_module/${moduleId}`, { method: 'GET', }); diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_setup_module_api.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_setup_module_api.ts similarity index 95% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_setup_module_api.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_setup_module_api.ts index 774a521ff1d34..d90bbab267871 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/ml_setup_module_api.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/ml_setup_module_api.ts @@ -8,7 +8,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import * as rt from 'io-ts'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; import { getJobIdPrefix } from '../../../../../common/log_analysis'; @@ -22,7 +22,7 @@ export const callSetupMlModuleAPI = async ( jobOverrides: SetupMlModuleJobOverrides[] = [], datafeedOverrides: SetupMlModuleDatafeedOverrides[] = [] ) => { - const response = await npStart.core.http.fetch(`/api/ml/modules/setup/${moduleId}`, { + const response = await npStart.http.fetch(`/api/ml/modules/setup/${moduleId}`, { method: 'POST', body: JSON.stringify( setupMlModuleRequestPayloadRT.encode({ diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts similarity index 88% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts index 480e84ff53e43..bbef7d201045f 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts @@ -7,7 +7,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { LOG_ANALYSIS_VALIDATE_INDICES_PATH, ValidationIndicesFieldSpecification, @@ -21,7 +21,7 @@ export const callValidateIndicesAPI = async ( indices: string[], fields: ValidationIndicesFieldSpecification[] ) => { - const response = await npStart.core.http.fetch(LOG_ANALYSIS_VALIDATE_INDICES_PATH, { + const response = await npStart.http.fetch(LOG_ANALYSIS_VALIDATE_INDICES_PATH, { method: 'POST', body: JSON.stringify(validationIndicesRequestPayloadRT.encode({ data: { indices, fields } })), }); diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/index.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/index.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_capabilities.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_capabilities.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_capabilities.tsx rename to x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_capabilities.tsx index 3c10ba805fad5..7bee10c3bfaa7 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_capabilities.tsx +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_capabilities.tsx @@ -6,11 +6,11 @@ import createContainer from 'constate'; import { useMemo, useState, useEffect } from 'react'; -import { npStart } from 'ui/new_platform'; import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import { useTrackedPromise } from '../../../utils/use_tracked_promise'; +import { npStart } from '../../../legacy_singletons'; import { getMlCapabilitiesResponsePayloadRT, GetMlCapabilitiesResponsePayload, @@ -26,7 +26,7 @@ export const useLogAnalysisCapabilities = () => { { cancelPreviousOn: 'resolution', createPromise: async () => { - const rawResponse = await npStart.core.http.fetch('/api/ml/ml_capabilities'); + const rawResponse = await npStart.http.fetch('/api/ml/ml_capabilities'); return pipe( getMlCapabilitiesResponsePayloadRT.decode(rawResponse), diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_cleanup.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_cleanup.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_cleanup.tsx rename to x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_cleanup.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_module.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_module.tsx rename to x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_status.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_status.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_status.tsx rename to x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_status.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts rename to x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_setup_state.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_setup_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_analysis/log_analysis_setup_state.tsx rename to x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_setup_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts b/x-pack/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts similarity index 87% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts rename to x-pack/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts index fd093f20dd490..5fde01e458e36 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts @@ -7,7 +7,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { kfetch } from 'ui/kfetch'; +import { npStart } from '../../../../legacy_singletons'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; @@ -19,9 +19,8 @@ import { } from '../../../../../common/http_api'; export const fetchLogEntriesItem = async (requestArgs: LogEntriesItemRequest) => { - const response = await kfetch({ + const response = await npStart.http.fetch(LOG_ENTRIES_ITEM_PATH, { method: 'POST', - pathname: LOG_ENTRIES_ITEM_PATH, body: JSON.stringify(logEntriesItemRequestRT.encode(requestArgs)), }); diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/gql_queries.ts b/x-pack/plugins/infra/public/containers/logs/log_entries/gql_queries.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_entries/gql_queries.ts rename to x-pack/plugins/infra/public/containers/logs/log_entries/gql_queries.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/index.ts b/x-pack/plugins/infra/public/containers/logs/log_entries/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_entries/index.ts rename to x-pack/plugins/infra/public/containers/logs/log_entries/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/types.ts b/x-pack/plugins/infra/public/containers/logs/log_entries/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_entries/types.ts rename to x-pack/plugins/infra/public/containers/logs/log_entries/types.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_filter/index.ts b/x-pack/plugins/infra/public/containers/logs/log_filter/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_filter/index.ts rename to x-pack/plugins/infra/public/containers/logs/log_filter/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts b/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts similarity index 97% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts rename to x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts index 2911ee729638a..dd1ba585061fe 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts @@ -7,7 +7,7 @@ import { useState, useMemo } from 'react'; import createContainer from 'constate'; import { IIndexPattern } from 'src/plugins/data/public'; -import { esKuery } from '../../../../../../../../src/plugins/data/public'; +import { esKuery } from '../../../../../../../src/plugins/data/public'; import { convertKueryToElasticSearchQuery } from '../../../utils/kuery'; export interface KueryFilterQuery { diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_filter/with_log_filter_url_state.tsx b/x-pack/plugins/infra/public/containers/logs/log_filter/with_log_filter_url_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_filter/with_log_filter_url_state.tsx rename to x-pack/plugins/infra/public/containers/logs/log_filter/with_log_filter_url_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_flyout.tsx b/x-pack/plugins/infra/public/containers/logs/log_flyout.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_flyout.tsx rename to x-pack/plugins/infra/public/containers/logs/log_flyout.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/api/fetch_log_summary_highlights.ts b/x-pack/plugins/infra/public/containers/logs/log_highlights/api/fetch_log_summary_highlights.ts similarity index 87% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/api/fetch_log_summary_highlights.ts rename to x-pack/plugins/infra/public/containers/logs/log_highlights/api/fetch_log_summary_highlights.ts index 781e8401cf881..bda8f535549c7 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/api/fetch_log_summary_highlights.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_highlights/api/fetch_log_summary_highlights.ts @@ -6,8 +6,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { kfetch } from 'ui/kfetch'; - +import { npStart } from '../../../../legacy_singletons'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; import { @@ -20,9 +19,8 @@ import { export const fetchLogSummaryHighlights = async ( requestArgs: LogEntriesSummaryHighlightsRequest ) => { - const response = await kfetch({ + const response = await npStart.http.fetch(LOG_ENTRIES_SUMMARY_HIGHLIGHTS_PATH, { method: 'POST', - pathname: LOG_ENTRIES_SUMMARY_HIGHLIGHTS_PATH, body: JSON.stringify(logEntriesSummaryHighlightsRequestRT.encode(requestArgs)), }); diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/index.ts b/x-pack/plugins/infra/public/containers/logs/log_highlights/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/index.ts rename to x-pack/plugins/infra/public/containers/logs/log_highlights/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.gql_query.ts b/x-pack/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.gql_query.ts rename to x-pack/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.tsx b/x-pack/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.tsx rename to x-pack/plugins/infra/public/containers/logs/log_highlights/log_entry_highlights.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_highlights.tsx b/x-pack/plugins/infra/public/containers/logs/log_highlights/log_highlights.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_highlights.tsx rename to x-pack/plugins/infra/public/containers/logs/log_highlights/log_highlights.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_summary_highlights.ts b/x-pack/plugins/infra/public/containers/logs/log_highlights/log_summary_highlights.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/log_summary_highlights.ts rename to x-pack/plugins/infra/public/containers/logs/log_highlights/log_summary_highlights.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/next_and_previous.tsx b/x-pack/plugins/infra/public/containers/logs/log_highlights/next_and_previous.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_highlights/next_and_previous.tsx rename to x-pack/plugins/infra/public/containers/logs/log_highlights/next_and_previous.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_position/index.ts b/x-pack/plugins/infra/public/containers/logs/log_position/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_position/index.ts rename to x-pack/plugins/infra/public/containers/logs/log_position/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_position/log_position_state.ts b/x-pack/plugins/infra/public/containers/logs/log_position/log_position_state.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_position/log_position_state.ts rename to x-pack/plugins/infra/public/containers/logs/log_position/log_position_state.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx b/x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx rename to x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/api/fetch_log_summary.ts b/x-pack/plugins/infra/public/containers/logs/log_summary/api/fetch_log_summary.ts similarity index 87% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_summary/api/fetch_log_summary.ts rename to x-pack/plugins/infra/public/containers/logs/log_summary/api/fetch_log_summary.ts index 5dabb8ebf0179..f74f0dc0e3117 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/api/fetch_log_summary.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_summary/api/fetch_log_summary.ts @@ -7,8 +7,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { kfetch } from 'ui/kfetch'; - +import { npStart } from '../../../../legacy_singletons'; import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; import { @@ -19,9 +18,8 @@ import { } from '../../../../../common/http_api'; export const fetchLogSummary = async (requestArgs: LogEntriesSummaryRequest) => { - const response = await kfetch({ + const response = await npStart.http.fetch(LOG_ENTRIES_SUMMARY_PATH, { method: 'POST', - pathname: LOG_ENTRIES_SUMMARY_PATH, body: JSON.stringify(logEntriesSummaryRequestRT.encode(requestArgs)), }); diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/index.ts b/x-pack/plugins/infra/public/containers/logs/log_summary/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_summary/index.ts rename to x-pack/plugins/infra/public/containers/logs/log_summary/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/log_summary.test.tsx b/x-pack/plugins/infra/public/containers/logs/log_summary/log_summary.test.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_summary/log_summary.test.tsx rename to x-pack/plugins/infra/public/containers/logs/log_summary/log_summary.test.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/log_summary.tsx b/x-pack/plugins/infra/public/containers/logs/log_summary/log_summary.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_summary/log_summary.tsx rename to x-pack/plugins/infra/public/containers/logs/log_summary/log_summary.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/use_log_summary_buffer_interval.ts b/x-pack/plugins/infra/public/containers/logs/log_summary/use_log_summary_buffer_interval.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_summary/use_log_summary_buffer_interval.ts rename to x-pack/plugins/infra/public/containers/logs/log_summary/use_log_summary_buffer_interval.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_summary/with_summary.ts b/x-pack/plugins/infra/public/containers/logs/log_summary/with_summary.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_summary/with_summary.ts rename to x-pack/plugins/infra/public/containers/logs/log_summary/with_summary.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_view_configuration.test.tsx b/x-pack/plugins/infra/public/containers/logs/log_view_configuration.test.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_view_configuration.test.tsx rename to x-pack/plugins/infra/public/containers/logs/log_view_configuration.test.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_view_configuration.tsx b/x-pack/plugins/infra/public/containers/logs/log_view_configuration.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/log_view_configuration.tsx rename to x-pack/plugins/infra/public/containers/logs/log_view_configuration.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/with_log_minimap.tsx b/x-pack/plugins/infra/public/containers/logs/with_log_minimap.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/with_log_minimap.tsx rename to x-pack/plugins/infra/public/containers/logs/with_log_minimap.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/with_log_textview.tsx b/x-pack/plugins/infra/public/containers/logs/with_log_textview.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/with_log_textview.tsx rename to x-pack/plugins/infra/public/containers/logs/with_log_textview.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/with_stream_items.ts b/x-pack/plugins/infra/public/containers/logs/with_stream_items.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/logs/with_stream_items.ts rename to x-pack/plugins/infra/public/containers/logs/with_stream_items.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts b/x-pack/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts rename to x-pack/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/metadata/use_metadata.ts b/x-pack/plugins/infra/public/containers/metadata/use_metadata.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/metadata/use_metadata.ts rename to x-pack/plugins/infra/public/containers/metadata/use_metadata.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx similarity index 81% rename from x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx rename to x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx index 4baa93f93753c..bbc8778545b4a 100644 --- a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx +++ b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx @@ -4,10 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fetch } from '../../utils/fetch'; +import React from 'react'; import { useMetricsExplorerData } from './use_metrics_explorer_data'; import { renderHook } from '@testing-library/react-hooks'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { options, @@ -18,8 +19,18 @@ import { createSeries, } from '../../utils/fixtures/metrics_explorer'; -const renderUseMetricsExplorerDataHook = () => - renderHook( +const mockedFetch = jest.fn(); + +const renderUseMetricsExplorerDataHook = () => { + const wrapper: React.FC = ({ children }) => { + const services = { + http: { + fetch: mockedFetch, + }, + }; + return {children}; + }; + return renderHook( props => useMetricsExplorerData( props.options, @@ -38,14 +49,20 @@ const renderUseMetricsExplorerDataHook = () => afterKey: null as string | null, signal: 1, }, + wrapper, } ); +}; + +jest.mock('../../utils/kuery', () => { + return { + convertKueryToElasticSearchQuery: (query: string) => query, + }; +}); -jest.mock('../../utils/fetch'); -const mockedFetch = fetch as jest.Mocked; describe('useMetricsExplorerData Hook', () => { it('should just work', async () => { - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); const { result, waitForNextUpdate } = renderUseMetricsExplorerDataHook(); expect(result.current.data).toBe(null); expect(result.current.loading).toBe(true); @@ -58,7 +75,7 @@ describe('useMetricsExplorerData Hook', () => { }); it('should paginate', async () => { - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); const { result, waitForNextUpdate, rerender } = renderUseMetricsExplorerDataHook(); expect(result.current.data).toBe(null); expect(result.current.loading).toBe(true); @@ -68,11 +85,9 @@ describe('useMetricsExplorerData Hook', () => { const { series, pageInfo } = result.current.data!; expect(series).toBeDefined(); expect(series.length).toBe(3); - mockedFetch.post.mockResolvedValue({ - data: { - pageInfo: { total: 10, afterKey: 'host-06' }, - series: [createSeries('host-04'), createSeries('host-05'), createSeries('host-06')], - }, + mockedFetch.mockResolvedValue({ + pageInfo: { total: 10, afterKey: 'host-06' }, + series: [createSeries('host-04'), createSeries('host-05'), createSeries('host-06')], } as any); rerender({ options, @@ -92,7 +107,7 @@ describe('useMetricsExplorerData Hook', () => { it('should reset error upon recovery', async () => { const error = new Error('Network Error'); - mockedFetch.post.mockRejectedValue(error); + mockedFetch.mockRejectedValue(error); const { result, waitForNextUpdate, rerender } = renderUseMetricsExplorerDataHook(); expect(result.current.data).toBe(null); expect(result.current.error).toEqual(null); @@ -101,7 +116,7 @@ describe('useMetricsExplorerData Hook', () => { expect(result.current.data).toEqual(null); expect(result.current.error).toEqual(error); expect(result.current.loading).toBe(false); - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); rerender({ options, source, @@ -117,7 +132,7 @@ describe('useMetricsExplorerData Hook', () => { }); it('should not paginate on option change', async () => { - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); const { result, waitForNextUpdate, rerender } = renderUseMetricsExplorerDataHook(); expect(result.current.data).toBe(null); expect(result.current.loading).toBe(true); @@ -127,7 +142,7 @@ describe('useMetricsExplorerData Hook', () => { const { series, pageInfo } = result.current.data!; expect(series).toBeDefined(); expect(series.length).toBe(3); - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); rerender({ options: { ...options, @@ -147,7 +162,7 @@ describe('useMetricsExplorerData Hook', () => { }); it('should not paginate on time change', async () => { - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); const { result, waitForNextUpdate, rerender } = renderUseMetricsExplorerDataHook(); expect(result.current.data).toBe(null); expect(result.current.loading).toBe(true); @@ -157,7 +172,7 @@ describe('useMetricsExplorerData Hook', () => { const { series, pageInfo } = result.current.data!; expect(series).toBeDefined(); expect(series.length).toBe(3); - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedFetch.mockResolvedValue(resp as any); rerender({ options, source, diff --git a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts similarity index 59% rename from x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts rename to x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts index 1bca733a6e02a..b32496fbf30a1 100644 --- a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts +++ b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts @@ -9,10 +9,14 @@ import { isEqual } from 'lodash'; import { useEffect, useState } from 'react'; import { IIndexPattern } from 'src/plugins/data/public'; import { SourceQuery } from '../../../common/graphql/types'; -import { MetricsExplorerResponse } from '../../../server/routes/metrics_explorer/types'; -import { fetch } from '../../utils/fetch'; +import { + MetricsExplorerResponse, + metricsExplorerResponseRT, +} from '../../../common/http_api/metrics_explorer'; import { convertKueryToElasticSearchQuery } from '../../utils/kuery'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions } from './use_metrics_explorer_options'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; +import { decodeOrThrow } from '../../../common/runtime_types'; function isSameOptions(current: MetricsExplorerOptions, next: MetricsExplorerOptions) { return isEqual(current, next); @@ -26,6 +30,7 @@ export function useMetricsExplorerData( afterKey: string | null, signal: any ) { + const fetch = useKibana().services.http?.fetch; const [error, setError] = useState(null); const [loading, setLoading] = useState(true); const [data, setData] = useState(null); @@ -41,48 +46,54 @@ export function useMetricsExplorerData( if (!from || !to) { throw new Error('Unalble to parse timerange'); } - const response = await fetch.post( - '../api/infra/metrics_explorer', - { - metrics: - options.aggregation === 'count' - ? [{ aggregation: 'count' }] - : options.metrics.map(metric => ({ - aggregation: metric.aggregation, - field: metric.field, - })), - groupBy: options.groupBy, - afterKey, - limit: options.limit, - indexPattern: source.metricAlias, - filterQuery: - (options.filterQuery && - convertKueryToElasticSearchQuery(options.filterQuery, derivedIndexPattern)) || - void 0, - timerange: { - ...timerange, - field: source.fields.timestamp, - from: from.valueOf(), - to: to.valueOf(), - }, - } + if (!fetch) { + throw new Error('HTTP service is unavailable'); + } + const response = decodeOrThrow(metricsExplorerResponseRT)( + await fetch('/api/infra/metrics_explorer', { + method: 'POST', + body: JSON.stringify({ + metrics: + options.aggregation === 'count' + ? [{ aggregation: 'count' }] + : options.metrics.map(metric => ({ + aggregation: metric.aggregation, + field: metric.field, + })), + groupBy: options.groupBy, + afterKey, + limit: options.limit, + indexPattern: source.metricAlias, + filterQuery: + (options.filterQuery && + convertKueryToElasticSearchQuery(options.filterQuery, derivedIndexPattern)) || + void 0, + timerange: { + ...timerange, + field: source.fields.timestamp, + from: from.valueOf(), + to: to.valueOf(), + }, + }), + }) ); - if (response.data) { + + if (response) { if ( data && lastOptions && - data.pageInfo.afterKey !== response.data.pageInfo.afterKey && + data.pageInfo.afterKey !== response.pageInfo.afterKey && isSameOptions(lastOptions, options) && isEqual(timerange, lastTimerange) && afterKey ) { const { series } = data; setData({ - ...response.data, - series: [...series, ...response.data.series], + ...response, + series: [...series, ...response.series], }); } else { - setData(response.data); + setData(response); } setLastOptions(options); setLastTimerange(timerange); diff --git a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.test.tsx b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.test.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.test.tsx rename to x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.test.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts similarity index 98% rename from x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts rename to x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts index 076a9159940e2..2b802af8e8c15 100644 --- a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts +++ b/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts @@ -10,7 +10,7 @@ import { MetricsExplorerColor } from '../../../common/color_palette'; import { MetricsExplorerAggregation, MetricsExplorerMetric, -} from '../../../server/routes/metrics_explorer/types'; +} from '../../../common/http_api/metrics_explorer'; export type MetricsExplorerOptionsMetric = MetricsExplorerMetric & { color?: MetricsExplorerColor; diff --git a/x-pack/legacy/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx b/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx rename to x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/node_details/use_node_details.ts b/x-pack/plugins/infra/public/containers/node_details/use_node_details.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/node_details/use_node_details.ts rename to x-pack/plugins/infra/public/containers/node_details/use_node_details.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source/create_source.gql_query.ts b/x-pack/plugins/infra/public/containers/source/create_source.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source/create_source.gql_query.ts rename to x-pack/plugins/infra/public/containers/source/create_source.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source/index.ts b/x-pack/plugins/infra/public/containers/source/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source/index.ts rename to x-pack/plugins/infra/public/containers/source/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source/query_source.gql_query.ts b/x-pack/plugins/infra/public/containers/source/query_source.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source/query_source.gql_query.ts rename to x-pack/plugins/infra/public/containers/source/query_source.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source/source.tsx b/x-pack/plugins/infra/public/containers/source/source.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source/source.tsx rename to x-pack/plugins/infra/public/containers/source/source.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/source/source_fields_fragment.gql_query.ts b/x-pack/plugins/infra/public/containers/source/source_fields_fragment.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source/source_fields_fragment.gql_query.ts rename to x-pack/plugins/infra/public/containers/source/source_fields_fragment.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source/update_source.gql_query.ts b/x-pack/plugins/infra/public/containers/source/update_source.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source/update_source.gql_query.ts rename to x-pack/plugins/infra/public/containers/source/update_source.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source_id/index.ts b/x-pack/plugins/infra/public/containers/source_id/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source_id/index.ts rename to x-pack/plugins/infra/public/containers/source_id/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/source_id/source_id.ts b/x-pack/plugins/infra/public/containers/source_id/source_id.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/source_id/source_id.ts rename to x-pack/plugins/infra/public/containers/source_id/source_id.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/index.ts b/x-pack/plugins/infra/public/containers/waffle/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/index.ts rename to x-pack/plugins/infra/public/containers/waffle/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts b/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts rename to x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/type_guards.ts b/x-pack/plugins/infra/public/containers/waffle/type_guards.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/type_guards.ts rename to x-pack/plugins/infra/public/containers/waffle/type_guards.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/use_snaphot.ts b/x-pack/plugins/infra/public/containers/waffle/use_snaphot.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/use_snaphot.ts rename to x-pack/plugins/infra/public/containers/waffle/use_snaphot.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/waffle_nodes.gql_query.ts b/x-pack/plugins/infra/public/containers/waffle/waffle_nodes.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/waffle_nodes.gql_query.ts rename to x-pack/plugins/infra/public/containers/waffle/waffle_nodes.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_filters.tsx b/x-pack/plugins/infra/public/containers/waffle/with_waffle_filters.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_filters.tsx rename to x-pack/plugins/infra/public/containers/waffle/with_waffle_filters.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_options.tsx b/x-pack/plugins/infra/public/containers/waffle/with_waffle_options.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_options.tsx rename to x-pack/plugins/infra/public/containers/waffle/with_waffle_options.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_time.tsx b/x-pack/plugins/infra/public/containers/waffle/with_waffle_time.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_time.tsx rename to x-pack/plugins/infra/public/containers/waffle/with_waffle_time.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_view_state.tsx b/x-pack/plugins/infra/public/containers/waffle/with_waffle_view_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/waffle/with_waffle_view_state.tsx rename to x-pack/plugins/infra/public/containers/waffle/with_waffle_view_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/with_kuery_autocompletion.tsx b/x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx similarity index 77% rename from x-pack/legacy/plugins/infra/public/containers/with_kuery_autocompletion.tsx rename to x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx index 8188517ba7617..98e59227bc6f0 100644 --- a/x-pack/legacy/plugins/infra/public/containers/with_kuery_autocompletion.tsx +++ b/x-pack/plugins/infra/public/containers/with_kuery_autocompletion.tsx @@ -5,11 +5,16 @@ */ import React from 'react'; -import { npStart } from 'ui/new_platform'; -import { QuerySuggestion, IIndexPattern } from 'src/plugins/data/public'; +import { QuerySuggestion, IIndexPattern, DataPublicPluginStart } from 'src/plugins/data/public'; +import { + withKibana, + KibanaReactContextValue, + KibanaServices, +} from '../../../../../src/plugins/kibana_react/public'; import { RendererFunction } from '../utils/typed_react'; interface WithKueryAutocompletionLifecycleProps { + kibana: KibanaReactContextValue<{ data: DataPublicPluginStart } & KibanaServices>; children: RendererFunction<{ isLoadingSuggestions: boolean; loadSuggestions: (expression: string, cursorPosition: number, maxSuggestions?: number) => void; @@ -28,7 +33,7 @@ interface WithKueryAutocompletionLifecycleState { suggestions: QuerySuggestion[]; } -export class WithKueryAutocompletion extends React.Component< +class WithKueryAutocompletionComponent extends React.Component< WithKueryAutocompletionLifecycleProps, WithKueryAutocompletionLifecycleState > { @@ -54,7 +59,9 @@ export class WithKueryAutocompletion extends React.Component< ) => { const { indexPattern } = this.props; const language = 'kuery'; - const hasQuerySuggestions = npStart.plugins.data.autocomplete.hasQuerySuggestions(language); + const hasQuerySuggestions = this.props.kibana.services.data.autocomplete.hasQuerySuggestions( + language + ); if (!hasQuerySuggestions) { return; @@ -69,7 +76,7 @@ export class WithKueryAutocompletion extends React.Component< }); const suggestions = - (await npStart.plugins.data.autocomplete.getQuerySuggestions({ + (await this.props.kibana.services.data.autocomplete.getQuerySuggestions({ language, query: expression, selectionStart: cursorPosition, @@ -91,3 +98,7 @@ export class WithKueryAutocompletion extends React.Component< ); }; } + +export const WithKueryAutocompletion = withKibana( + WithKueryAutocompletionComponent +); diff --git a/x-pack/legacy/plugins/infra/public/containers/with_options.tsx b/x-pack/plugins/infra/public/containers/with_options.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/with_options.tsx rename to x-pack/plugins/infra/public/containers/with_options.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/with_source/index.ts b/x-pack/plugins/infra/public/containers/with_source/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/with_source/index.ts rename to x-pack/plugins/infra/public/containers/with_source/index.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/with_source/with_source.tsx b/x-pack/plugins/infra/public/containers/with_source/with_source.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/containers/with_source/with_source.tsx rename to x-pack/plugins/infra/public/containers/with_source/with_source.tsx diff --git a/x-pack/legacy/plugins/infra/public/containers/with_state_from_location.tsx b/x-pack/plugins/infra/public/containers/with_state_from_location.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/containers/with_state_from_location.tsx rename to x-pack/plugins/infra/public/containers/with_state_from_location.tsx index 6f7baf6b98b62..2a9676046d451 100644 --- a/x-pack/legacy/plugins/infra/public/containers/with_state_from_location.tsx +++ b/x-pack/plugins/infra/public/containers/with_state_from_location.tsx @@ -6,7 +6,7 @@ import { parse, stringify } from 'query-string'; import { Location } from 'history'; -import omit from 'lodash/fp/omit'; +import { omit } from 'lodash'; import React from 'react'; import { RouteComponentProps, withRouter } from 'react-router-dom'; // eslint-disable-next-line @typescript-eslint/camelcase @@ -46,7 +46,7 @@ export const withStateFromLocation = ({ public render() { const { location } = this.props; - const otherProps = omit(['location', 'history', 'match', 'staticContext'], this.props); + const otherProps = omit(this.props, ['location', 'history', 'match', 'staticContext']); const stateFromLocation = mapLocationToState(location); diff --git a/x-pack/legacy/plugins/infra/public/graphql/introspection.json b/x-pack/plugins/infra/public/graphql/introspection.json similarity index 100% rename from x-pack/legacy/plugins/infra/public/graphql/introspection.json rename to x-pack/plugins/infra/public/graphql/introspection.json diff --git a/x-pack/legacy/plugins/infra/public/graphql/log_entries.gql_query.ts b/x-pack/plugins/infra/public/graphql/log_entries.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/graphql/log_entries.gql_query.ts rename to x-pack/plugins/infra/public/graphql/log_entries.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/graphql/types.ts b/x-pack/plugins/infra/public/graphql/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/graphql/types.ts rename to x-pack/plugins/infra/public/graphql/types.ts diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx b/x-pack/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx similarity index 71% rename from x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx rename to x-pack/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx index 934022d6e6bd0..80d1b67e59798 100644 --- a/x-pack/legacy/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx +++ b/x-pack/plugins/infra/public/hooks/use_bulk_get_saved_object.tsx @@ -5,11 +5,11 @@ */ import { useState, useCallback } from 'react'; - -import { npStart } from 'ui/new_platform'; import { SavedObjectAttributes, SavedObjectsBatchResponse } from 'src/core/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export const useBulkGetSavedObject = (type: string) => { + const kibana = useKibana(); const [data, setData] = useState | null>(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); @@ -19,7 +19,11 @@ export const useBulkGetSavedObject = (type: string) => { setLoading(true); const fetchData = async () => { try { - const d = await npStart.core.savedObjects.client.bulkGet(ids.map(i => ({ type, id: i }))); + const savedObjectsClient = kibana.services.savedObjects?.client; + if (!savedObjectsClient) { + throw new Error('Saved objects client is unavailable'); + } + const d = await savedObjectsClient.bulkGet(ids.map(i => ({ type, id: i }))); setError(null); setLoading(false); setData(d); @@ -30,7 +34,7 @@ export const useBulkGetSavedObject = (type: string) => { }; fetchData(); }, - [type] + [type, kibana.services.savedObjects] ); return { diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx b/x-pack/plugins/infra/public/hooks/use_create_saved_object.tsx similarity index 74% rename from x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx rename to x-pack/plugins/infra/public/hooks/use_create_saved_object.tsx index f03a198355bb8..8313d496a0651 100644 --- a/x-pack/legacy/plugins/infra/public/hooks/use_create_saved_object.tsx +++ b/x-pack/plugins/infra/public/hooks/use_create_saved_object.tsx @@ -5,15 +5,15 @@ */ import { useState, useCallback } from 'react'; - -import { npStart } from 'ui/new_platform'; import { SavedObjectAttributes, SavedObjectsCreateOptions, SimpleSavedObject, } from 'src/core/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export const useCreateSavedObject = (type: string) => { + const kibana = useKibana(); const [data, setData] = useState | null>(null); const [createdId, setCreatedId] = useState(null); const [error, setError] = useState(null); @@ -24,7 +24,11 @@ export const useCreateSavedObject = (type: string) => { setLoading(true); const save = async () => { try { - const d = await npStart.core.savedObjects.client.create(type, attributes, options); + const savedObjectsClient = kibana.services.savedObjects?.client; + if (!savedObjectsClient) { + throw new Error('Saved objects client is unavailable'); + } + const d = await savedObjectsClient.create(type, attributes, options); setCreatedId(d.id); setError(null); setData(d); @@ -36,7 +40,7 @@ export const useCreateSavedObject = (type: string) => { }; save(); }, - [type] + [type, kibana.services.savedObjects] ); return { diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_delete_saved_object.tsx b/x-pack/plugins/infra/public/hooks/use_delete_saved_object.tsx similarity index 81% rename from x-pack/legacy/plugins/infra/public/hooks/use_delete_saved_object.tsx rename to x-pack/plugins/infra/public/hooks/use_delete_saved_object.tsx index cd04d82cc215b..3f2d15b3b86aa 100644 --- a/x-pack/legacy/plugins/infra/public/hooks/use_delete_saved_object.tsx +++ b/x-pack/plugins/infra/public/hooks/use_delete_saved_object.tsx @@ -5,9 +5,10 @@ */ import { useState, useCallback } from 'react'; -import { npStart } from 'ui/new_platform'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export const useDeleteSavedObject = (type: string) => { + const kibana = useKibana(); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const [deletedId, setDeletedId] = useState(null); @@ -17,7 +18,7 @@ export const useDeleteSavedObject = (type: string) => { setLoading(true); const dobj = async () => { try { - await npStart.core.savedObjects.client.delete(type, id); + await kibana.services.savedObjects?.client.delete(type, id); setError(null); setDeletedId(id); setLoading(false); @@ -28,7 +29,7 @@ export const useDeleteSavedObject = (type: string) => { }; dobj(); }, - [type] + [type, kibana.services.savedObjects] ); return { diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx b/x-pack/plugins/infra/public/hooks/use_find_saved_object.tsx similarity index 67% rename from x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx rename to x-pack/plugins/infra/public/hooks/use_find_saved_object.tsx index 2487d830266b1..2b704e7984415 100644 --- a/x-pack/legacy/plugins/infra/public/hooks/use_find_saved_object.tsx +++ b/x-pack/plugins/infra/public/hooks/use_find_saved_object.tsx @@ -5,11 +5,11 @@ */ import { useState, useCallback } from 'react'; - -import { npStart } from 'ui/new_platform'; import { SavedObjectAttributes, SavedObjectsBatchResponse } from 'src/core/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export const useFindSavedObject = (type: string) => { + const kibana = useKibana(); const [data, setData] = useState | null>(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); @@ -18,7 +18,11 @@ export const useFindSavedObject = { try { - const d = await npStart.core.savedObjects.client.find({ + const savedObjectsClient = kibana.services.savedObjects?.client; + if (!savedObjectsClient) { + throw new Error('Saved objects client is unavailable'); + } + const d = await savedObjectsClient.find({ type, search: query, searchFields, @@ -33,14 +37,17 @@ export const useFindSavedObject = { - const objects = await npStart.core.savedObjects.client.find({ + const savedObjectsClient = kibana.services.savedObjects?.client; + if (!savedObjectsClient) { + throw new Error('Saved objects client is unavailable'); + } + const objects = await savedObjectsClient.find({ type, }); - return objects.savedObjects.filter(o => o.attributes.name === name).length > 0; }; diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_http_request.tsx b/x-pack/plugins/infra/public/hooks/use_http_request.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/hooks/use_http_request.tsx rename to x-pack/plugins/infra/public/hooks/use_http_request.tsx index 2078c4bdc151d..50f4a636b48a3 100644 --- a/x-pack/legacy/plugins/infra/public/hooks/use_http_request.tsx +++ b/x-pack/plugins/infra/public/hooks/use_http_request.tsx @@ -8,7 +8,7 @@ import React, { useMemo, useState } from 'react'; import { IHttpFetchError } from 'src/core/public'; import { i18n } from '@kbn/i18n'; import { useTrackedPromise } from '../utils/use_tracked_promise'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export function useHTTPRequest( pathname: string, diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_interval.ts b/x-pack/plugins/infra/public/hooks/use_interval.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/hooks/use_interval.ts rename to x-pack/plugins/infra/public/hooks/use_interval.ts diff --git a/x-pack/plugins/infra/public/hooks/use_prefix_path_with_basepath.tsx b/x-pack/plugins/infra/public/hooks/use_prefix_path_with_basepath.tsx new file mode 100644 index 0000000000000..652a3fb478605 --- /dev/null +++ b/x-pack/plugins/infra/public/hooks/use_prefix_path_with_basepath.tsx @@ -0,0 +1,22 @@ +/* + * 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 { useMemo } from 'react'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; + +export const usePrefixPathWithBasepath = () => { + const getUrlForApp = useKibana().services.application?.getUrlForApp; + const prefixer = useMemo(() => { + if (!getUrlForApp) { + throw new Error('Application core service is unavailable'); + } + + return (app: string, path: string) => { + return getUrlForApp(app, { path }); + }; + }, [getUrlForApp]); + return prefixer; +}; diff --git a/x-pack/legacy/plugins/infra/public/hooks/use_saved_view.ts b/x-pack/plugins/infra/public/hooks/use_saved_view.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/hooks/use_saved_view.ts rename to x-pack/plugins/infra/public/hooks/use_saved_view.ts diff --git a/x-pack/legacy/plugins/infra/public/images/docker.svg b/x-pack/plugins/infra/public/images/docker.svg similarity index 100% rename from x-pack/legacy/plugins/infra/public/images/docker.svg rename to x-pack/plugins/infra/public/images/docker.svg diff --git a/x-pack/legacy/plugins/infra/public/images/hosts.svg b/x-pack/plugins/infra/public/images/hosts.svg similarity index 100% rename from x-pack/legacy/plugins/infra/public/images/hosts.svg rename to x-pack/plugins/infra/public/images/hosts.svg diff --git a/x-pack/legacy/plugins/infra/public/images/infra_mono_white.svg b/x-pack/plugins/infra/public/images/infra_mono_white.svg similarity index 100% rename from x-pack/legacy/plugins/infra/public/images/infra_mono_white.svg rename to x-pack/plugins/infra/public/images/infra_mono_white.svg diff --git a/x-pack/legacy/plugins/infra/public/images/k8.svg b/x-pack/plugins/infra/public/images/k8.svg similarity index 100% rename from x-pack/legacy/plugins/infra/public/images/k8.svg rename to x-pack/plugins/infra/public/images/k8.svg diff --git a/x-pack/legacy/plugins/infra/public/images/logging_mono_white.svg b/x-pack/plugins/infra/public/images/logging_mono_white.svg similarity index 100% rename from x-pack/legacy/plugins/infra/public/images/logging_mono_white.svg rename to x-pack/plugins/infra/public/images/logging_mono_white.svg diff --git a/x-pack/legacy/plugins/infra/public/images/services.svg b/x-pack/plugins/infra/public/images/services.svg similarity index 100% rename from x-pack/legacy/plugins/infra/public/images/services.svg rename to x-pack/plugins/infra/public/images/services.svg diff --git a/x-pack/legacy/plugins/infra/public/index.scss b/x-pack/plugins/infra/public/index.scss similarity index 100% rename from x-pack/legacy/plugins/infra/public/index.scss rename to x-pack/plugins/infra/public/index.scss diff --git a/x-pack/plugins/infra/public/index.ts b/x-pack/plugins/infra/public/index.ts new file mode 100644 index 0000000000000..4465bde377c12 --- /dev/null +++ b/x-pack/plugins/infra/public/index.ts @@ -0,0 +1,22 @@ +/* + * 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 { PluginInitializerContext, PluginInitializer } from 'kibana/public'; +import { Plugin, ClientSetup, ClientStart, ClientPluginsSetup, ClientPluginsStart } from './plugin'; + +export const plugin: PluginInitializer< + ClientSetup, + ClientStart, + ClientPluginsSetup, + ClientPluginsStart +> = (context: PluginInitializerContext) => { + return new Plugin(context); +}; + +export { FORMATTERS } from './utils/formatters'; +export { InfraFormatterType } from './lib/lib'; + +export type InfraAppId = 'logs' | 'metrics'; diff --git a/x-pack/legacy/plugins/infra/public/new_platform_index.ts b/x-pack/plugins/infra/public/legacy_singletons.ts similarity index 55% rename from x-pack/legacy/plugins/infra/public/new_platform_index.ts rename to x-pack/plugins/infra/public/legacy_singletons.ts index 33b40da236145..f57047f21c281 100644 --- a/x-pack/legacy/plugins/infra/public/new_platform_index.ts +++ b/x-pack/plugins/infra/public/legacy_singletons.ts @@ -3,10 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { CoreStart } from 'kibana/public'; -import { PluginInitializerContext } from 'kibana/public'; -import { Plugin } from './new_platform_plugin'; +let npStart: CoreStart; -export function plugin(context: PluginInitializerContext) { - return new Plugin(context); +export function registerStartSingleton(start: CoreStart) { + npStart = start; } + +export { npStart }; diff --git a/x-pack/legacy/plugins/infra/public/lib/adapters/observable_api/kibana_observable_api.ts b/x-pack/plugins/infra/public/lib/adapters/observable_api/kibana_observable_api.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/lib/adapters/observable_api/kibana_observable_api.ts rename to x-pack/plugins/infra/public/lib/adapters/observable_api/kibana_observable_api.ts diff --git a/x-pack/legacy/plugins/infra/public/lib/lib.ts b/x-pack/plugins/infra/public/lib/lib.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/lib/lib.ts rename to x-pack/plugins/infra/public/lib/lib.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/404.tsx b/x-pack/plugins/infra/public/pages/404.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/404.tsx rename to x-pack/plugins/infra/public/pages/404.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/error.tsx b/x-pack/plugins/infra/public/pages/error.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/error.tsx rename to x-pack/plugins/infra/public/pages/error.tsx index b525dd9b165ba..b8b598ba1a98b 100644 --- a/x-pack/legacy/plugins/infra/public/pages/error.tsx +++ b/x-pack/plugins/infra/public/pages/error.tsx @@ -15,7 +15,7 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import euiStyled from '../../../../common/eui_styled_components'; +import { euiStyled } from '../../../observability/public'; import { Header } from '../components/header'; import { ColumnarPage, PageContent } from '../components/page'; diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/index.tsx b/x-pack/plugins/infra/public/pages/infrastructure/index.tsx similarity index 89% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/index.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/index.tsx index 5eaa2850aebdb..2271147c9d088 100644 --- a/x-pack/legacy/plugins/infra/public/pages/infrastructure/index.tsx +++ b/x-pack/plugins/infra/public/pages/infrastructure/index.tsx @@ -23,7 +23,7 @@ import { SnapshotPage } from './snapshot'; import { MetricsSettingsPage } from './settings'; import { AppNavigation } from '../../components/navigation/app_navigation'; import { SourceLoadingPage } from '../../components/source_loading_page'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; export const InfrastructurePage = ({ match }: RouteComponentProps) => { const uiCapabilities = useKibana().services.application?.capabilities; @@ -65,28 +65,28 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => { title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', { defaultMessage: 'Inventory', }), - path: `${match.path}/inventory`, + path: '/inventory', }, { title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', { defaultMessage: 'Metrics Explorer', }), - path: `${match.path}/metrics-explorer`, + path: '/explorer', }, { title: i18n.translate('xpack.infra.homePage.settingsTabTitle', { defaultMessage: 'Settings', }), - path: `${match.path}/settings`, + path: '/settings', }, ]} /> - + ( {({ configuration, createDerivedIndexPattern }) => ( @@ -106,7 +106,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => { )} /> - + diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx b/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx index 4db4319b91d3c..0999cea59731c 100644 --- a/x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx +++ b/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx @@ -14,7 +14,7 @@ import { MetricsExplorerToolbar } from '../../../components/metrics_explorer/too import { SourceQuery } from '../../../../common/graphql/types'; import { NoData } from '../../../components/empty_states'; import { useMetricsExplorerState } from './use_metric_explorer_state'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; +import { useTrackPageview } from '../../../../../observability/public'; interface MetricsExplorerPageProps { source: SourceQuery.Query['source']['configuration']; diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx b/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx similarity index 68% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx index 14533d46aaef8..874ac0987023b 100644 --- a/x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx +++ b/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fetch } from '../../../utils/fetch'; -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook, act } from '@testing-library/react-hooks'; import { useMetricsExplorerState } from './use_metric_explorer_state'; import { MetricsExplorerOptionsContainer } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; import React from 'react'; @@ -26,8 +25,15 @@ const renderUseMetricsExplorerStateHook = () => ), }); -jest.mock('../../../utils/fetch'); -const mockedFetch = fetch as jest.Mocked; +const mockedUseMetricsExplorerData = jest.fn(); + +jest.mock('../../../containers/metrics_explorer/use_metrics_explorer_data', () => { + return { + useMetricsExplorerData: () => { + return mockedUseMetricsExplorerData(); + }, + }; +}); interface LocalStore { [key: string]: string; @@ -54,33 +60,36 @@ Object.defineProperty(window, 'localStorage', { describe('useMetricsExplorerState', () => { beforeEach(() => { - mockedFetch.post.mockResolvedValue({ data: resp } as any); + mockedUseMetricsExplorerData.mockReturnValue({ + loading: false, + error: null, + data: null, + }); delete STORE.MetricsExplorerOptions; delete STORE.MetricsExplorerTimeRange; }); it('should just work', async () => { - const { result, waitForNextUpdate } = renderUseMetricsExplorerStateHook(); - expect(result.current.data).toBe(null); + mockedUseMetricsExplorerData.mockReturnValue({ + loading: true, + error: null, + data: resp, + }); + const { result } = renderUseMetricsExplorerStateHook(); + expect(result.current.data).toEqual(resp); expect(result.current.error).toBe(null); expect(result.current.loading).toBe(true); - await waitForNextUpdate(); - expect(result.current.data).toEqual(resp); - expect(result.current.loading).toBe(false); - const { series } = result.current.data!; - expect(series).toBeDefined(); - expect(series.length).toBe(3); }); describe('handleRefresh', () => { it('should trigger an addition request when handleRefresh is called', async () => { - const { result, waitForNextUpdate } = renderUseMetricsExplorerStateHook(); - await waitForNextUpdate(); - expect(mockedFetch.post.mock.calls.length).toBe(2); - const { handleRefresh } = result.current; - handleRefresh(); - await waitForNextUpdate(); - expect(mockedFetch.post.mock.calls.length).toBe(3); + const { result } = renderUseMetricsExplorerStateHook(); + expect(result.current.refreshSignal).toBe(0); + act(() => { + result.current.handleRefresh(); + }); + expect(result.current.afterKey).toBe(null); + expect(result.current.refreshSignal).toBe(1); }); }); @@ -88,7 +97,9 @@ describe('useMetricsExplorerState', () => { it('should change the metric', async () => { const { result } = renderUseMetricsExplorerStateHook(); const { handleMetricsChange } = result.current; - handleMetricsChange([{ aggregation: 'max', field: 'system.load.1' }]); + act(() => { + handleMetricsChange([{ aggregation: 'max', field: 'system.load.1' }]); + }); expect(result.current.options.metrics).toEqual([ { aggregation: 'max', field: 'system.load.1' }, ]); @@ -99,7 +110,9 @@ describe('useMetricsExplorerState', () => { it('should change the metric', async () => { const { result } = renderUseMetricsExplorerStateHook(); const { handleGroupByChange } = result.current; - handleGroupByChange('host.name'); + act(() => { + handleGroupByChange('host.name'); + }); expect(result.current.options.groupBy).toBeDefined(); expect(result.current.options.groupBy).toBe('host.name'); }); @@ -109,7 +122,9 @@ describe('useMetricsExplorerState', () => { it('should change the time range', async () => { const { result } = renderUseMetricsExplorerStateHook(); const { handleTimeChange } = result.current; - handleTimeChange('now-10m', 'now'); + act(() => { + handleTimeChange('now-10m', 'now'); + }); expect(result.current.currentTimerange).toEqual({ from: 'now-10m', to: 'now', @@ -122,38 +137,44 @@ describe('useMetricsExplorerState', () => { it('should set the filter query', async () => { const { result } = renderUseMetricsExplorerStateHook(); const { handleFilterQuerySubmit } = result.current; - handleFilterQuerySubmit('host.name: "example-host-01"'); + act(() => { + handleFilterQuerySubmit('host.name: "example-host-01"'); + }); expect(result.current.options.filterQuery).toBe('host.name: "example-host-01"'); }); }); describe('handleAggregationChange', () => { it('should set the metrics to only count when selecting count', async () => { - const { result, waitForNextUpdate } = renderUseMetricsExplorerStateHook(); + const { result } = renderUseMetricsExplorerStateHook(); const { handleMetricsChange } = result.current; - handleMetricsChange([{ aggregation: 'avg', field: 'system.load.1' }]); + act(() => { + handleMetricsChange([{ aggregation: 'avg', field: 'system.load.1' }]); + }); expect(result.current.options.metrics).toEqual([ { aggregation: 'avg', field: 'system.load.1' }, ]); - await waitForNextUpdate(); const { handleAggregationChange } = result.current; - handleAggregationChange('count'); - await waitForNextUpdate(); + act(() => { + handleAggregationChange('count'); + }); expect(result.current.options.aggregation).toBe('count'); expect(result.current.options.metrics).toEqual([{ aggregation: 'count' }]); }); it('should change aggregation for metrics', async () => { - const { result, waitForNextUpdate } = renderUseMetricsExplorerStateHook(); + const { result } = renderUseMetricsExplorerStateHook(); const { handleMetricsChange } = result.current; - handleMetricsChange([{ aggregation: 'avg', field: 'system.load.1' }]); + act(() => { + handleMetricsChange([{ aggregation: 'avg', field: 'system.load.1' }]); + }); expect(result.current.options.metrics).toEqual([ { aggregation: 'avg', field: 'system.load.1' }, ]); - await waitForNextUpdate(); const { handleAggregationChange } = result.current; - handleAggregationChange('max'); - await waitForNextUpdate(); + act(() => { + handleAggregationChange('max'); + }); expect(result.current.options.aggregation).toBe('max'); expect(result.current.options.metrics).toEqual([ { aggregation: 'max', field: 'system.load.1' }, @@ -163,30 +184,32 @@ describe('useMetricsExplorerState', () => { describe('handleLoadMore', () => { it('should load more based on the afterKey', async () => { - const { result, waitForNextUpdate, rerender } = renderUseMetricsExplorerStateHook(); + const { result, rerender } = renderUseMetricsExplorerStateHook(); expect(result.current.data).toBe(null); - expect(result.current.loading).toBe(true); - await waitForNextUpdate(); - expect(result.current.data).toEqual(resp); expect(result.current.loading).toBe(false); + mockedUseMetricsExplorerData.mockReturnValue({ + loading: false, + error: null, + data: resp, + }); + await rerender(); const { series, pageInfo } = result.current.data!; expect(series).toBeDefined(); expect(series.length).toBe(3); - mockedFetch.post.mockResolvedValue({ + mockedUseMetricsExplorerData.mockReturnValue({ + loading: false, + error: null, data: { pageInfo: { total: 10, afterKey: 'host-06' }, series: [createSeries('host-04'), createSeries('host-05'), createSeries('host-06')], - }, - } as any); - const { handleLoadMore } = result.current; - handleLoadMore(pageInfo.afterKey!); + } as any, + }); await rerender(); - expect(result.current.loading).toBe(true); - await waitForNextUpdate(); - expect(result.current.loading).toBe(false); - const { series: nextSeries } = result.current.data!; - expect(nextSeries).toBeDefined(); - expect(nextSeries.length).toBe(6); + const { handleLoadMore } = result.current; + act(() => { + handleLoadMore(pageInfo.afterKey!); + }); + expect(result.current.afterKey).toBe(pageInfo.afterKey); }); }); }); diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts b/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts rename to x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts index 22d18234197b6..88e6d9d800661 100644 --- a/x-pack/legacy/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts +++ b/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts @@ -9,7 +9,7 @@ import { IIndexPattern } from 'src/plugins/data/public'; import { MetricsExplorerMetric, MetricsExplorerAggregation, -} from '../../../../server/routes/metrics_explorer/types'; +} from '../../../../common/http_api/metrics_explorer'; import { useMetricsExplorerData } from '../../../containers/metrics_explorer/use_metrics_explorer_data'; import { MetricsExplorerOptionsContainer, @@ -144,5 +144,8 @@ export const useMetricsExplorerState = ( handleLoadMore: setAfterKey, defaultViewState, onViewStateChange, + + refreshSignal, + afterKey, }; }; diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/settings.tsx b/x-pack/plugins/infra/public/pages/infrastructure/settings.tsx similarity index 89% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/settings.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/settings.tsx index d75af7879d17a..9414eb7d3e564 100644 --- a/x-pack/legacy/plugins/infra/public/pages/infrastructure/settings.tsx +++ b/x-pack/plugins/infra/public/pages/infrastructure/settings.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { SourceConfigurationSettings } from '../../components/source_configuration/source_configuration_settings'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; export const MetricsSettingsPage = () => { const uiCapabilities = useKibana().services.application?.capabilities; diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/index.tsx b/x-pack/plugins/infra/public/pages/infrastructure/snapshot/index.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/index.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/snapshot/index.tsx index 27d276a50c30d..7f3be965af8db 100644 --- a/x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/index.tsx +++ b/x-pack/plugins/infra/public/pages/infrastructure/snapshot/index.tsx @@ -26,8 +26,8 @@ import { Source } from '../../../containers/source'; import { WithWaffleFilterUrlState } from '../../../containers/waffle/with_waffle_filters'; import { WithWaffleOptionsUrlState } from '../../../containers/waffle/with_waffle_options'; import { WithWaffleTimeUrlState } from '../../../containers/waffle/with_waffle_time'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; +import { useTrackPageview } from '../../../../../observability/public'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; export const SnapshotPage = () => { const uiCapabilities = useKibana().services.application?.capabilities; diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/page_content.tsx b/x-pack/plugins/infra/public/pages/infrastructure/snapshot/page_content.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/page_content.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/snapshot/page_content.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx b/x-pack/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx rename to x-pack/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/index.ts b/x-pack/plugins/infra/public/pages/link_to/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/link_to/index.ts rename to x-pack/plugins/infra/public/pages/link_to/index.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/link_to.tsx b/x-pack/plugins/infra/public/pages/link_to/link_to.tsx similarity index 54% rename from x-pack/legacy/plugins/infra/public/pages/link_to/link_to.tsx rename to x-pack/plugins/infra/public/pages/link_to/link_to.tsx index 7a7c9eb8408a3..ce62a0a3f4e33 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/link_to.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/link_to.tsx @@ -19,21 +19,23 @@ interface LinkToPageProps { const ITEM_TYPES = inventoryModels.map(m => m.id).join('|'); -export const LinkToPage: React.FC = props => ( - - - - - - - -); +export const LinkToPage: React.FC = props => { + return ( + + + + + + + + ); +}; diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/query_params.ts b/x-pack/plugins/infra/public/pages/link_to/query_params.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/link_to/query_params.ts rename to x-pack/plugins/infra/public/pages/link_to/query_params.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx rename to x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx index c1b0814f550a3..01b02f1acbbf2 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx @@ -49,7 +49,7 @@ export const RedirectToHostDetailViaIP = ({ )(''); if (name) { - return ; + return ; } return ( diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx similarity index 79% rename from x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx rename to x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx index e9ec053f8c609..3efefe93990bd 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.test.tsx @@ -19,7 +19,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -33,7 +33,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -45,7 +45,7 @@ describe('RedirectToLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx similarity index 92% rename from x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_logs.tsx rename to x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx index b3fcaff75aafd..cc4b6967d34fb 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_logs.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_logs.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import compose from 'lodash/fp/compose'; +import { compose } from 'lodash'; import React from 'react'; import { match as RouteMatch, Redirect, RouteComponentProps } from 'react-router-dom'; @@ -30,5 +30,5 @@ export const RedirectToLogs = ({ location, match }: RedirectToLogsProps) => { replaceSourceIdInQueryString(sourceId) )(''); - return ; + return ; }; diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx similarity index 88% rename from x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx rename to x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx index ec1cc8ba45332..55dd15158b96f 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx @@ -27,7 +27,7 @@ export const RedirectToNodeDetail = ({ getToFromLocation(location) )(''); - return ; + return ; }; export const getNodeDetailUrl = ({ @@ -42,5 +42,5 @@ export const getNodeDetailUrl = ({ from?: number; }) => { const args = to && from ? `?to=${to}&from=${from}` : ''; - return `#/link-to/${nodeType}-detail/${nodeId}${args}`; + return `link-to/${nodeType}-detail/${nodeId}${args}`; }; diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx similarity index 79% rename from x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx rename to x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx index 1e97072cac109..7c1cb9d7329ef 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.test.tsx @@ -35,7 +35,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -47,7 +47,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -59,7 +59,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -73,7 +73,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -89,7 +89,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); @@ -103,7 +103,7 @@ describe('RedirectToNodeLogs component', () => { expect(component).toMatchInlineSnapshot(` `); }); diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx rename to x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx index 6f1fdd606dd73..9c998085400ca 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; -import compose from 'lodash/fp/compose'; +import { compose } from 'lodash'; import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; @@ -70,7 +70,7 @@ export const RedirectToNodeLogs = ({ replaceSourceIdInQueryString(sourceId) )(''); - return ; + return ; }; export const getNodeLogsUrl = ({ @@ -81,4 +81,6 @@ export const getNodeLogsUrl = ({ nodeId: string; nodeType: InventoryItemType; time?: number; -}) => [`#/link-to/${nodeType}-logs/`, nodeId, ...(time ? [`?time=${time}`] : [])].join(''); +}) => { + return [`link-to/${nodeType}-logs/`, nodeId, ...(time ? [`?time=${time}`] : [])].join(''); +}; diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/use_host_ip_to_name.test.ts b/x-pack/plugins/infra/public/pages/link_to/use_host_ip_to_name.test.ts similarity index 81% rename from x-pack/legacy/plugins/infra/public/pages/link_to/use_host_ip_to_name.test.ts rename to x-pack/plugins/infra/public/pages/link_to/use_host_ip_to_name.test.ts index 3b61181dfc6e0..739ea872021cf 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/use_host_ip_to_name.test.ts +++ b/x-pack/plugins/infra/public/pages/link_to/use_host_ip_to_name.test.ts @@ -5,7 +5,6 @@ */ import { useHostIpToName } from './use_host_ip_to_name'; -import { fetch } from '../../utils/fetch'; import { renderHook } from '@testing-library/react-hooks'; const renderUseHostIpToNameHook = () => @@ -13,12 +12,25 @@ const renderUseHostIpToNameHook = () => initialProps: { ipAddress: '127.0.0.1', indexPattern: 'metricbest-*' }, }); -jest.mock('../../utils/fetch'); -const mockedFetch = fetch as jest.Mocked; +const mockedFetch = jest.fn(); + +jest.mock('../../../../../../src/plugins/kibana_react/public', () => { + return { + useKibana: () => { + return { + services: { + http: { + fetch: mockedFetch, + }, + }, + }; + }, + }; +}); describe('useHostIpToName Hook', () => { it('should basically work', async () => { - mockedFetch.post.mockResolvedValue({ data: { host: 'example-01' } } as any); + mockedFetch.mockResolvedValue({ host: 'example-01' } as any); const { result, waitForNextUpdate } = renderUseHostIpToNameHook(); expect(result.current.name).toBe(null); expect(result.current.loading).toBe(true); @@ -30,7 +42,7 @@ describe('useHostIpToName Hook', () => { it('should handle errors', async () => { const error = new Error('Host not found'); - mockedFetch.post.mockRejectedValue(error); + mockedFetch.mockRejectedValue(error); const { result, waitForNextUpdate } = renderUseHostIpToNameHook(); expect(result.current.name).toBe(null); expect(result.current.loading).toBe(true); @@ -42,7 +54,7 @@ describe('useHostIpToName Hook', () => { it('should reset errors', async () => { const error = new Error('Host not found'); - mockedFetch.post.mockRejectedValue(error); + mockedFetch.mockRejectedValue(error); const { result, waitForNextUpdate, rerender } = renderUseHostIpToNameHook(); expect(result.current.name).toBe(null); expect(result.current.loading).toBe(true); @@ -50,7 +62,7 @@ describe('useHostIpToName Hook', () => { expect(result.current.name).toBe(null); expect(result.current.loading).toBe(false); expect(result.current.error).toBe(error); - mockedFetch.post.mockResolvedValue({ data: { host: 'example-01' } } as any); + mockedFetch.mockResolvedValue({ host: 'example-01' } as any); rerender({ ipAddress: '192.168.1.2', indexPattern: 'metricbeat-*' }); await waitForNextUpdate(); expect(result.current.name).toBe('example-01'); diff --git a/x-pack/legacy/plugins/infra/public/pages/link_to/use_host_ip_to_name.ts b/x-pack/plugins/infra/public/pages/link_to/use_host_ip_to_name.ts similarity index 61% rename from x-pack/legacy/plugins/infra/public/pages/link_to/use_host_ip_to_name.ts rename to x-pack/plugins/infra/public/pages/link_to/use_host_ip_to_name.ts index 7b4b56f34a678..82236e152d6d0 100644 --- a/x-pack/legacy/plugins/infra/public/pages/link_to/use_host_ip_to_name.ts +++ b/x-pack/plugins/infra/public/pages/link_to/use_host_ip_to_name.ts @@ -5,10 +5,11 @@ */ import { useState, useEffect } from 'react'; -import { IpToHostResponse } from '../../../server/routes/ip_to_hostname'; -import { fetch } from '../../utils/fetch'; +import { IpToHostResponse } from '../../../common/http_api/ip_to_hostname'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; export const useHostIpToName = (ipAddress: string | null, indexPattern: string | null) => { + const fetch = useKibana().services.http?.fetch; const [error, setError] = useState(null); const [loading, setLoadingState] = useState(true); const [data, setData] = useState(null); @@ -18,19 +19,25 @@ export const useHostIpToName = (ipAddress: string | null, indexPattern: string | setLoadingState(true); setError(null); try { + if (!fetch) { + throw new Error('HTTP service is unavailable'); + } if (ipAddress && indexPattern) { - const response = await fetch.post('../api/infra/ip_to_host', { - ip: ipAddress, - index_pattern: indexPattern, + const response = await fetch('/api/infra/ip_to_host', { + method: 'POST', + body: JSON.stringify({ + ip: ipAddress, + index_pattern: indexPattern, + }), }); setLoadingState(false); - setData(response.data); + setData(response); } } catch (err) { setLoadingState(false); setError(err); } })(); - }, [ipAddress, indexPattern]); + }, [ipAddress, indexPattern, fetch]); return { name: (data && data.host) || null, loading, error }; }; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/index.tsx b/x-pack/plugins/infra/public/pages/logs/index.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/index.tsx rename to x-pack/plugins/infra/public/pages/logs/index.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/index.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/index.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/index.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/module_descriptor.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/module_descriptor.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/module_descriptor.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/module_descriptor.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/page.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_content.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_providers.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx index a810ce447d369..5826435878378 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_results_content.tsx @@ -10,8 +10,8 @@ import { i18n } from '@kbn/i18n'; import moment from 'moment'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { euiStyled } from '../../../../../observability/public'; import { TimeRange } from '../../../../common/http_api/shared/time_range'; import { LogAnalysisJobProblemIndicator, @@ -19,7 +19,7 @@ import { } from '../../../components/logging/log_analysis_job_status'; import { FirstUseCallout } from '../../../components/logging/log_analysis_results'; import { useInterval } from '../../../hooks/use_interval'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; +import { useTrackPageview } from '../../../../../observability/public'; import { TopCategoriesSection } from './sections/top_categories'; import { useLogEntryCategoriesModuleContext } from './use_log_entry_categories_module'; import { useLogEntryCategoriesResults } from './use_log_entry_categories_results'; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_setup_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_setup_content.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_setup_content.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_setup_content.tsx index ac902029f938e..a7ff98923a427 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/page_setup_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/page_setup_content.tsx @@ -16,7 +16,7 @@ import { LogAnalysisSetupPageContent, LogAnalysisSetupPageHeader, } from '../../../components/logging/log_analysis_setup'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; +import { useTrackPageview } from '../../../../../observability/public'; import { useLogEntryCategoriesSetup } from './use_log_entry_categories_setup'; export const LogEntryCategoriesSetupContent: React.FunctionComponent = () => { diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/anomaly_severity_indicator.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/anomaly_severity_indicator.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/anomaly_severity_indicator.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/anomaly_severity_indicator.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_expression.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_expression.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_expression.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_expression.tsx index 5c8b18528cae6..f6cf62421e2d5 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_expression.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/category_expression.tsx @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import React, { memo } from 'react'; -import euiStyled from '../../../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../../../observability/public'; export const RegularExpressionRepresentation: React.FunctionComponent<{ maximumSegmentCount?: number; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_list.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_list.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_list.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_list.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_selector.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_selector.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_selector.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/datasets_selector.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/index.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/index.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/index.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/log_entry_count_sparkline.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/log_entry_count_sparkline.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/log_entry_count_sparkline.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/log_entry_count_sparkline.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_comparison.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_comparison.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_comparison.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_comparison.tsx index 1352afb60a505..d73f9f33fe5db 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_comparison.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_comparison.tsx @@ -9,7 +9,7 @@ import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; import React from 'react'; -import euiStyled from '../../../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../../../observability/public'; export const SingleMetricComparison: React.FunctionComponent<{ currentValue: number; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_sparkline.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_sparkline.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_sparkline.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/single_metric_sparkline.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_section.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx index 3d20aef03ff15..a2bd2983092a0 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/sections/top_categories/top_categories_table.tsx @@ -9,7 +9,7 @@ import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; import React, { useMemo } from 'react'; -import euiStyled from '../../../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../../../observability/public'; import { LogEntryCategory, LogEntryCategoryHistogram, diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts similarity index 69% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts index 942ded4230e97..a8cd7854efb6b 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_log_entry_category_datasets.ts @@ -7,7 +7,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { getLogEntryCategoryDatasetsRequestPayloadRT, @@ -21,23 +21,20 @@ export const callGetLogEntryCategoryDatasetsAPI = async ( startTime: number, endTime: number ) => { - const response = await npStart.core.http.fetch( - LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_DATASETS_PATH, - { - method: 'POST', - body: JSON.stringify( - getLogEntryCategoryDatasetsRequestPayloadRT.encode({ - data: { - sourceId, - timeRange: { - startTime, - endTime, - }, + const response = await npStart.http.fetch(LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_DATASETS_PATH, { + method: 'POST', + body: JSON.stringify( + getLogEntryCategoryDatasetsRequestPayloadRT.encode({ + data: { + sourceId, + timeRange: { + startTime, + endTime, }, - }) - ), - } - ); + }, + }) + ), + }); return pipe( getLogEntryCategoryDatasetsSuccessReponsePayloadRT.decode(response), diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts similarity index 92% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts index 35d6f1ec4f893..2ebcff4fd3ca5 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/service_calls/get_top_log_entry_categories.ts @@ -7,7 +7,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { getLogEntryCategoriesRequestPayloadRT, @@ -25,7 +25,7 @@ export const callGetTopLogEntryCategoriesAPI = async ( ) => { const intervalDuration = endTime - startTime; - const response = await npStart.core.http.fetch(LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORIES_PATH, { + const response = await npStart.http.fetch(LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORIES_PATH, { method: 'POST', body: JSON.stringify( getLogEntryCategoriesRequestPayloadRT.encode({ diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_module.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_module.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_module.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_module.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results_url_state.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results_url_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results_url_state.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_results_url_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_setup.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_setup.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_setup.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_categories/use_log_entry_categories_setup.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/index.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/index.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/index.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/module_descriptor.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/module_descriptor.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/module_descriptor.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/module_descriptor.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/page.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_content.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_providers.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx index fd77cc8dd7173..50d58865e9746 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_results_content.tsx @@ -20,12 +20,12 @@ import { FormattedMessage } from '@kbn/i18n/react'; import moment from 'moment'; import React, { useCallback, useMemo, useState, useEffect } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { TimeRange } from '../../../../common/http_api/shared/time_range'; import { bucketSpan } from '../../../../common/log_analysis'; import { LoadingOverlayWrapper } from '../../../components/loading_overlay_wrapper'; import { useInterval } from '../../../hooks/use_interval'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; +import { useTrackPageview } from '../../../../../observability/public'; import { useKibanaUiSetting } from '../../../utils/use_kibana_ui_setting'; import { AnomaliesResults } from './sections/anomalies'; import { LogRateResults } from './sections/log_rate'; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx index 13574f589a111..a02dbfa941588 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/page_setup_content.tsx @@ -16,7 +16,7 @@ import { LogAnalysisSetupPageContent, LogAnalysisSetupPageHeader, } from '../../../components/logging/log_analysis_setup'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; +import { useTrackPageview } from '../../../../../observability/public'; import { useLogEntryRateSetup } from './use_log_entry_rate_setup'; export const LogEntryRateSetupContent: React.FunctionComponent = () => { diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/chart.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/chart.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/chart.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/chart.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/expanded_row.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/index.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/index.tsx similarity index 99% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/index.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/index.tsx index 0dc52d2762765..2551170c44f4e 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/index.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/index.tsx @@ -17,7 +17,7 @@ import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; import React, { useMemo } from 'react'; -import euiStyled from '../../../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../../../observability/public'; import { LogEntryRateResults } from '../../use_log_entry_rate_results'; import { TimeRange } from '../../../../../../common/http_api/shared/time_range'; import { formatAnomalyScore, JobStatus, SetupStatus } from '../../../../../../common/log_analysis'; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx index 3e86b45fadfdd..39d76c4afcffe 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/anomalies/table.tsx @@ -9,7 +9,6 @@ import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services'; import { i18n } from '@kbn/i18n'; import React, { useCallback, useMemo, useState } from 'react'; -import euiStyled from '../../../../../../../../common/eui_styled_components'; import { TimeRange } from '../../../../../../common/http_api/shared/time_range'; import { formatAnomalyScore, @@ -17,6 +16,7 @@ import { } from '../../../../../../common/log_analysis'; import { LogEntryRateResults } from '../../use_log_entry_rate_results'; import { AnomaliesTableExpandedRow } from './expanded_row'; +import { euiStyled } from '../../../../../../../observability/public'; interface TableItem { id: string; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/helpers/data_formatters.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/helpers/data_formatters.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/helpers/data_formatters.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/helpers/data_formatters.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/bar_chart.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/bar_chart.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/bar_chart.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/bar_chart.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/index.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/index.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/index.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections/log_rate/index.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_rate.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_rate.ts similarity index 89% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_rate.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_rate.ts index 1df7ef06b9d46..794139385f467 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_rate.ts +++ b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_rate.ts @@ -7,7 +7,7 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; -import { npStart } from 'ui/new_platform'; +import { npStart } from '../../../../legacy_singletons'; import { getLogEntryRateRequestPayloadRT, getLogEntryRateSuccessReponsePayloadRT, @@ -21,7 +21,7 @@ export const callGetLogEntryRateAPI = async ( endTime: number, bucketDuration: number ) => { - const response = await npStart.core.http.fetch(LOG_ANALYSIS_GET_LOG_ENTRY_RATE_PATH, { + const response = await npStart.http.fetch(LOG_ANALYSIS_GET_LOG_ENTRY_RATE_PATH, { method: 'POST', body: JSON.stringify( getLogEntryRateRequestPayloadRT.encode({ diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_module.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_module.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_module.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_module.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results.ts b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results.ts rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results_url_state.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results_url_state.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results_url_state.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_results_url_state.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_setup.tsx b/x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_setup.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_setup.tsx rename to x-pack/plugins/infra/public/pages/logs/log_entry_rate/use_log_entry_rate_setup.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/page.tsx b/x-pack/plugins/infra/public/pages/logs/page.tsx similarity index 91% rename from x-pack/legacy/plugins/infra/public/pages/logs/page.tsx rename to x-pack/plugins/infra/public/pages/logs/page.tsx index 72826b156d7b4..08049183d0a18 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/page.tsx +++ b/x-pack/plugins/infra/public/pages/logs/page.tsx @@ -13,7 +13,7 @@ import { LogsPageProviders } from './page_providers'; export const LogsPage: React.FunctionComponent = ({ match }) => { return ( - + ); }; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/page_content.tsx similarity index 89% rename from x-pack/legacy/plugins/infra/public/pages/logs/page_content.tsx rename to x-pack/plugins/infra/public/pages/logs/page_content.tsx index 41ef9987d1ad0..48ead15b2a232 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/page_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/page_content.tsx @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { Route, Switch } from 'react-router-dom'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { DocumentTitle } from '../../components/document_title'; import { Header } from '../../components/header'; import { HelpCenterContent } from '../../components/help_center_content'; @@ -25,31 +25,29 @@ import { LogEntryRatePage } from './log_entry_rate'; import { LogsSettingsPage } from './settings'; import { StreamPage } from './stream'; -export const LogsPageContent: React.FunctionComponent<{ - logsPagePath: string; -}> = ({ logsPagePath }) => { +export const LogsPageContent: React.FunctionComponent = () => { const uiCapabilities = useKibana().services.application?.capabilities; const source = useSourceContext(); const logAnalysisCapabilities = useLogAnalysisCapabilitiesContext(); const streamTab = { title: streamTabTitle, - path: `${logsPagePath}/stream`, + path: '/stream', }; const logRateTab = { title: logRateTabTitle, - path: `${logsPagePath}/log-rate`, + path: '/log-rate', }; const logCategoriesTab = { title: logCategoriesTabTitle, - path: `${logsPagePath}/log-categories`, + path: '/log-categories', }; const settingsTab = { title: settingsTabTitle, - path: `${logsPagePath}/settings`, + path: '/settings', }; return ( @@ -91,7 +89,7 @@ export const LogsPageContent: React.FunctionComponent<{ - + )} diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/page_providers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/page_providers.tsx rename to x-pack/plugins/infra/public/pages/logs/page_providers.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/settings.tsx b/x-pack/plugins/infra/public/pages/logs/settings.tsx similarity index 88% rename from x-pack/legacy/plugins/infra/public/pages/logs/settings.tsx rename to x-pack/plugins/infra/public/pages/logs/settings.tsx index 52ccf5d59e611..faee7a643085a 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/settings.tsx +++ b/x-pack/plugins/infra/public/pages/logs/settings.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { SourceConfigurationSettings } from '../../components/source_configuration/source_configuration_settings'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; export const LogsSettingsPage = () => { const uiCapabilities = useKibana().services.application?.capabilities; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/index.ts b/x-pack/plugins/infra/public/pages/logs/stream/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/index.ts rename to x-pack/plugins/infra/public/pages/logs/stream/index.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page.tsx similarity index 92% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page.tsx index 9031a8cb4785d..3e07dcebf112d 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page.tsx +++ b/x-pack/plugins/infra/public/pages/logs/stream/page.tsx @@ -10,7 +10,7 @@ import { ColumnarPage } from '../../../components/page'; import { StreamPageContent } from './page_content'; import { StreamPageHeader } from './page_header'; import { LogsPageProviders } from './page_providers'; -import { useTrackPageview } from '../../../hooks/use_track_metric'; +import { useTrackPageview } from '../../../../../observability/public'; export const StreamPage = () => { useTrackPageview({ app: 'infra_logs', path: 'stream' }); diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_content.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page_content.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page_content.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_header.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_header.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page_header.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page_header.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_logs_content.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_logs_content.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page_logs_content.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page_logs_content.tsx index 4d2b99da9b412..c3c31b5d5bd0f 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_logs_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/stream/page_logs_content.tsx @@ -6,7 +6,7 @@ import React, { useContext } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { AutoSizer } from '../../../components/auto_sizer'; import { LogEntryFlyout } from '../../../components/logging/log_entry_flyout'; import { LogMinimap } from '../../../components/logging/log_minimap'; diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_no_indices_content.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_no_indices_content.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page_no_indices_content.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page_no_indices_content.tsx index 7c697e8d22f14..1294007240027 100644 --- a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_no_indices_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/stream/page_no_indices_content.tsx @@ -9,12 +9,12 @@ import { i18n } from '@kbn/i18n'; import { identity } from 'fp-ts/lib/function'; import React from 'react'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; import { NoIndices } from '../../../components/empty_states/no_indices'; import { ViewSourceConfigurationButton, ViewSourceConfigurationButtonHrefBase, } from '../../../components/source_configuration'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; export const LogsPageNoIndicesContent = () => { const { diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_providers.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page_providers.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page_providers.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/logs/stream/page_toolbar.tsx b/x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/logs/stream/page_toolbar.tsx rename to x-pack/plugins/infra/public/pages/logs/stream/page_toolbar.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx b/x-pack/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx index 1731e9aa62cda..49e95394deb97 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx @@ -20,7 +20,7 @@ import { } from './helpers'; import { ErrorMessage } from './error_message'; import { useKibanaUiSetting } from '../../../utils/use_kibana_ui_setting'; -import { useUiSetting } from '../../../../../../../../src/plugins/kibana_react/public'; +import { useUiSetting } from '../../../../../../../src/plugins/kibana_react/public'; import { VisSectionProps } from '../types'; export const ChartSectionVis = ({ diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/error_message.tsx b/x-pack/plugins/infra/public/pages/metrics/components/error_message.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/error_message.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/error_message.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx b/x-pack/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx index 4c0c7faa464dd..e069b52be8be7 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx @@ -16,7 +16,7 @@ import { import { get, last, max } from 'lodash'; import React, { ReactText } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { createFormatter } from '../../../utils/formatters'; import { InventoryFormatterType } from '../../../../common/inventory_models/types'; import { SeriesOverrides, VisSectionProps } from '../types'; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/helpers.ts b/x-pack/plugins/infra/public/pages/metrics/components/helpers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/helpers.ts rename to x-pack/plugins/infra/public/pages/metrics/components/helpers.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/invalid_node.tsx b/x-pack/plugins/infra/public/pages/metrics/components/invalid_node.tsx similarity index 93% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/invalid_node.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/invalid_node.tsx index 0e810d9815cf9..fde3b61de50b5 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/invalid_node.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/invalid_node.tsx @@ -9,12 +9,12 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { identity } from 'fp-ts/lib/function'; import React from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { ViewSourceConfigurationButton, ViewSourceConfigurationButtonHrefBase, } from '../../../components/source_configuration'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; interface InvalidNodeErrorProps { nodeName: string; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx b/x-pack/plugins/infra/public/pages/metrics/components/layout_content.tsx similarity index 83% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/layout_content.tsx index a2bd9cdc13179..4e10f245acdcc 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/layout_content.tsx @@ -5,7 +5,7 @@ */ import { EuiPageContent } from '@elastic/eui'; -import { euiStyled } from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; export const LayoutContent = euiStyled(EuiPageContent)` position: relative; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/metadata_details.tsx b/x-pack/plugins/infra/public/pages/metrics/components/metadata_details.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/metadata_details.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/metadata_details.tsx index c43f2d10d7163..3bf492d398f2c 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/metadata_details.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/metadata_details.tsx @@ -9,7 +9,7 @@ import { EuiButtonIcon, EuiFlexGrid, EuiFlexItem, EuiTitle, EuiText } from '@ela import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; import { InfraMetadata } from '../../../../common/http_api'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { MetadataContext } from '../containers/metadata_context'; interface FieldDef { diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx b/x-pack/plugins/infra/public/pages/metrics/components/node_details_page.tsx similarity index 98% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/node_details_page.tsx index cc662f8fd5b57..ea91c53faf675 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/node_details_page.tsx @@ -21,7 +21,7 @@ import { AutoSizer } from '../../../components/auto_sizer'; import { MetricsTimeControls } from './time_controls'; import { SideNavContext, NavItem } from '../lib/side_nav_context'; import { PageBody } from './page_body'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { MetricsTimeInput } from '../containers/with_metrics_time'; import { InfraMetadata } from '../../../../common/http_api/metadata_api'; import { PageError } from './page_error'; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/page_body.tsx b/x-pack/plugins/infra/public/pages/metrics/components/page_body.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/page_body.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/page_body.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/page_error.tsx b/x-pack/plugins/infra/public/pages/metrics/components/page_error.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/page_error.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/page_error.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/section.tsx b/x-pack/plugins/infra/public/pages/metrics/components/section.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/section.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/section.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/series_chart.tsx b/x-pack/plugins/infra/public/pages/metrics/components/series_chart.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/series_chart.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/series_chart.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/side_nav.tsx b/x-pack/plugins/infra/public/pages/metrics/components/side_nav.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/side_nav.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/side_nav.tsx index 8e922818222b4..94f97c7f45e61 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/side_nav.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/side_nav.tsx @@ -6,7 +6,7 @@ import { EuiHideFor, EuiPageSideBar, EuiShowFor, EuiSideNav } from '@elastic/eui'; import React, { useState, useCallback } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { NavItem } from '../lib/side_nav_context'; interface Props { diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/sub_section.tsx b/x-pack/plugins/infra/public/pages/metrics/components/sub_section.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/sub_section.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/sub_section.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/time_controls.test.tsx b/x-pack/plugins/infra/public/pages/metrics/components/time_controls.test.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/time_controls.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/time_controls.test.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/time_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/components/time_controls.tsx similarity index 97% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/time_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/components/time_controls.tsx index 1546966c10a1e..b1daaa0320fab 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/time_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/components/time_controls.tsx @@ -6,7 +6,7 @@ import { EuiSuperDatePicker, OnRefreshChangeProps, OnTimeChangeProps } from '@elastic/eui'; import React, { useCallback } from 'react'; -import euiStyled from '../../../../../../common/eui_styled_components'; +import { euiStyled } from '../../../../../observability/public'; import { MetricsTimeInput } from '../containers/with_metrics_time'; import { useKibanaUiSetting } from '../../../utils/use_kibana_ui_setting'; import { mapKibanaQuickRangesToDatePickerRanges } from '../../../utils/map_timepicker_quickranges_to_datepicker_ranges'; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/containers/metadata_context.ts b/x-pack/plugins/infra/public/pages/metrics/containers/metadata_context.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/containers/metadata_context.ts rename to x-pack/plugins/infra/public/pages/metrics/containers/metadata_context.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/containers/metrics.gql_query.ts b/x-pack/plugins/infra/public/pages/metrics/containers/metrics.gql_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/containers/metrics.gql_query.ts rename to x-pack/plugins/infra/public/pages/metrics/containers/metrics.gql_query.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/containers/metrics_time.test.tsx b/x-pack/plugins/infra/public/pages/metrics/containers/metrics_time.test.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/containers/metrics_time.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/containers/metrics_time.test.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/containers/with_metrics_time.tsx b/x-pack/plugins/infra/public/pages/metrics/containers/with_metrics_time.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/containers/with_metrics_time.tsx rename to x-pack/plugins/infra/public/pages/metrics/containers/with_metrics_time.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/metrics/index.tsx rename to x-pack/plugins/infra/public/pages/metrics/index.tsx index 4c0d2d7c93d7a..533e6a7b9a8f3 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; import React, { useContext, useState } from 'react'; -import euiStyled, { EuiTheme, withTheme } from '../../../../../common/eui_styled_components'; +import { euiStyled, EuiTheme, withTheme } from '../../../../observability/public'; import { DocumentTitle } from '../../components/document_title'; import { Header } from '../../components/header'; import { ColumnarPage, PageContent } from '../../components/page'; @@ -17,7 +17,7 @@ import { InfraLoadingPanel } from '../../components/loading'; import { findInventoryModel } from '../../../common/inventory_models'; import { NavItem } from './lib/side_nav_context'; import { NodeDetailsPage } from './components/node_details_page'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { InventoryItemType } from '../../../common/inventory_models/types'; const DetailPageContent = euiStyled(PageContent)` diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/lib/side_nav_context.ts b/x-pack/plugins/infra/public/pages/metrics/lib/side_nav_context.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/lib/side_nav_context.ts rename to x-pack/plugins/infra/public/pages/metrics/lib/side_nav_context.ts diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/page_providers.tsx b/x-pack/plugins/infra/public/pages/metrics/page_providers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/pages/metrics/page_providers.tsx rename to x-pack/plugins/infra/public/pages/metrics/page_providers.tsx diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/types.ts b/x-pack/plugins/infra/public/pages/metrics/types.ts similarity index 96% rename from x-pack/legacy/plugins/infra/public/pages/metrics/types.ts rename to x-pack/plugins/infra/public/pages/metrics/types.ts index 4b9e32fddcc76..fd6243292ec07 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/types.ts +++ b/x-pack/plugins/infra/public/pages/metrics/types.ts @@ -5,7 +5,7 @@ */ import rt from 'io-ts'; -import { EuiTheme } from '../../../../../common/eui_styled_components'; +import { EuiTheme } from '../../../../observability/public'; import { InventoryFormatterTypeRT } from '../../../common/inventory_models/types'; import { MetricsTimeInput } from './containers/with_metrics_time'; import { NodeDetailsMetricData } from '../../../common/http_api/node_details_api'; diff --git a/x-pack/plugins/infra/public/plugin.ts b/x-pack/plugins/infra/public/plugin.ts new file mode 100644 index 0000000000000..5d529e1fda0dc --- /dev/null +++ b/x-pack/plugins/infra/public/plugin.ts @@ -0,0 +1,209 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { merge } from 'lodash'; +import { + Plugin as PluginClass, + CoreSetup, + CoreStart, + PluginInitializerContext, + AppMountParameters, +} from 'kibana/public'; +import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'; +import ApolloClient from 'apollo-client'; +import { ApolloLink } from 'apollo-link'; +import { createHttpLink } from 'apollo-link-http'; +import { withClientState } from 'apollo-link-state'; +import { HttpFetchOptions } from 'src/core/public'; +import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils'; +import { InfraFrontendLibs } from './lib/lib'; +import introspectionQueryResultData from './graphql/introspection.json'; +import { InfraKibanaObservableApiAdapter } from './lib/adapters/observable_api/kibana_observable_api'; +import { registerStartSingleton } from './legacy_singletons'; +import { registerFeatures } from './register_feature'; +import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../src/plugins/home/public'; +import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public'; +import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public'; +import { DataEnhancedSetup, DataEnhancedStart } from '../../data_enhanced/public'; +import { LogsRouter, MetricsRouter } from './routers'; + +export type ClientSetup = void; +export type ClientStart = void; + +export interface ClientPluginsSetup { + home: HomePublicPluginSetup; + data: DataPublicPluginSetup; + usageCollection: UsageCollectionSetup; + dataEnhanced: DataEnhancedSetup; +} + +export interface ClientPluginsStart { + home: HomePublicPluginStart; + data: DataPublicPluginStart; + dataEnhanced: DataEnhancedStart; +} + +export type InfraPlugins = ClientPluginsSetup & ClientPluginsStart; + +const getMergedPlugins = (setup: ClientPluginsSetup, start: ClientPluginsStart): InfraPlugins => { + return merge({}, setup, start); +}; + +export class Plugin + implements PluginClass { + constructor(context: PluginInitializerContext) {} + + setup(core: CoreSetup, pluginsSetup: ClientPluginsSetup) { + registerFeatures(pluginsSetup.home); + + core.application.register({ + id: 'logs', + title: i18n.translate('xpack.infra.logs.pluginTitle', { + defaultMessage: 'Logs', + }), + euiIconType: 'logsApp', + order: 8001, + appRoute: '/app/logs', + category: DEFAULT_APP_CATEGORIES.observability, + mount: async (params: AppMountParameters) => { + const [coreStart, pluginsStart] = await core.getStartServices(); + const plugins = getMergedPlugins(pluginsSetup, pluginsStart as ClientPluginsStart); + const { startApp } = await import('./apps/start_app'); + return startApp( + this.composeLibs(coreStart, plugins), + coreStart, + plugins, + params, + LogsRouter + ); + }, + }); + + core.application.register({ + id: 'metrics', + title: i18n.translate('xpack.infra.metrics.pluginTitle', { + defaultMessage: 'Metrics', + }), + euiIconType: 'metricsApp', + order: 8000, + appRoute: '/app/metrics', + category: DEFAULT_APP_CATEGORIES.observability, + mount: async (params: AppMountParameters) => { + const [coreStart, pluginsStart] = await core.getStartServices(); + const plugins = getMergedPlugins(pluginsSetup, pluginsStart as ClientPluginsStart); + const { startApp } = await import('./apps/start_app'); + return startApp( + this.composeLibs(coreStart, plugins), + coreStart, + plugins, + params, + MetricsRouter + ); + }, + }); + + /* This exists purely to facilitate URL redirects from the old App ID ("infra"), + to our new App IDs ("metrics" and "logs"). With version 8.0.0 we can remove this. */ + core.application.register({ + id: 'infra', + appRoute: '/app/infra', + title: 'infra', + navLinkStatus: 3, + mount: async (params: AppMountParameters) => { + const { startLegacyApp } = await import('./apps/start_legacy_app'); + return startLegacyApp(params); + }, + }); + } + + start(core: CoreStart, plugins: ClientPluginsStart) { + registerStartSingleton(core); + } + + composeLibs(core: CoreStart, plugins: ClientPluginsStart) { + const cache = new InMemoryCache({ + addTypename: false, + fragmentMatcher: new IntrospectionFragmentMatcher({ + introspectionQueryResultData, + }), + }); + + const observableApi = new InfraKibanaObservableApiAdapter({ + basePath: core.http.basePath.get(), + }); + + const wrappedFetch = (path: string, options: HttpFetchOptions) => { + return new Promise(async (resolve, reject) => { + // core.http.fetch isn't 100% compatible with the Fetch API and will + // throw Errors on 401s. This top level try / catch handles those scenarios. + try { + core.http + .fetch(path, { + ...options, + // Set headers to undefined due to this bug: https://github.com/apollographql/apollo-link/issues/249, + // Apollo will try to set a "content-type" header which will conflict with the "Content-Type" header that + // core.http.fetch correctly sets. + headers: undefined, + asResponse: true, + }) + .then(res => { + if (!res.response) { + return reject(); + } + // core.http.fetch will parse the Response and set a body before handing it back. As such .text() / .json() + // will have already been called on the Response instance. However, Apollo will also want to call + // .text() / .json() on the instance, as it expects the raw Response instance, rather than core's wrapper. + // .text() / .json() can only be called once, and an Error will be thrown if those methods are accessed again. + // This hacks around that by setting up a new .text() method that will restringify the JSON response we already have. + // This does result in an extra stringify / parse cycle, which isn't ideal, but as we only have a few endpoints left using + // GraphQL this shouldn't create excessive overhead. + // Ref: https://github.com/apollographql/apollo-link/blob/master/packages/apollo-link-http/src/httpLink.ts#L134 + // and + // https://github.com/apollographql/apollo-link/blob/master/packages/apollo-link-http-common/src/index.ts#L125 + return resolve({ + ...res.response, + text: () => { + return new Promise(async (resolveText, rejectText) => { + if (res.body) { + return resolveText(JSON.stringify(res.body)); + } else { + return rejectText(); + } + }); + }, + }); + }); + } catch (error) { + reject(error); + } + }); + }; + + const HttpLink = createHttpLink({ + fetch: wrappedFetch, + uri: `/api/infra/graphql`, + }); + + const graphQLOptions = { + cache, + link: ApolloLink.from([ + withClientState({ + cache, + resolvers: {}, + }), + HttpLink, + ]), + }; + + const apolloClient = new ApolloClient(graphQLOptions); + + const libs: InfraFrontendLibs = { + apolloClient, + observableApi, + }; + return libs; + } +} diff --git a/x-pack/legacy/plugins/infra/public/feature_catalogue_entry.ts b/x-pack/plugins/infra/public/register_feature.ts similarity index 75% rename from x-pack/legacy/plugins/infra/public/feature_catalogue_entry.ts rename to x-pack/plugins/infra/public/register_feature.ts index 6442083234f2c..37217eaeaab2a 100644 --- a/x-pack/legacy/plugins/infra/public/feature_catalogue_entry.ts +++ b/x-pack/plugins/infra/public/register_feature.ts @@ -5,13 +5,14 @@ */ import { i18n } from '@kbn/i18n'; -import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public'; +import { + HomePublicPluginSetup, + FeatureCatalogueCategory, +} from '../../../../src/plugins/home/public'; -const APP_ID = 'infra'; - -export const featureCatalogueEntries = { - metrics: { - id: 'infraops', +export const registerFeatures = (homePlugin: HomePublicPluginSetup) => { + homePlugin.featureCatalogue.register({ + id: 'metrics', title: i18n.translate('xpack.infra.registerFeatures.infraOpsTitle', { defaultMessage: 'Metrics', }), @@ -20,12 +21,13 @@ export const featureCatalogueEntries = { 'Explore infrastructure metrics and logs for common servers, containers, and services.', }), icon: 'metricsApp', - path: `/app/${APP_ID}#infrastructure`, + path: `/app/metrics`, showOnHomePage: true, category: FeatureCatalogueCategory.DATA, - }, - logs: { - id: 'infralogging', + }); + + homePlugin.featureCatalogue.register({ + id: 'logs', title: i18n.translate('xpack.infra.registerFeatures.logsTitle', { defaultMessage: 'Logs', }), @@ -34,8 +36,8 @@ export const featureCatalogueEntries = { 'Stream logs in real time or scroll through historical views in a console-like experience.', }), icon: 'logsApp', - path: `/app/${APP_ID}#logs`, + path: `/app/logs`, showOnHomePage: true, category: FeatureCatalogueCategory.DATA, - }, + }); }; diff --git a/x-pack/plugins/infra/public/routers/index.ts b/x-pack/plugins/infra/public/routers/index.ts new file mode 100644 index 0000000000000..71ab2613d8dc1 --- /dev/null +++ b/x-pack/plugins/infra/public/routers/index.ts @@ -0,0 +1,15 @@ +/* + * 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 { History } from 'history'; + +export * from './logs_router'; +export * from './metrics_router'; + +interface RouterProps { + history: History; +} + +export type AppRouter = React.FC; diff --git a/x-pack/plugins/infra/public/routers/logs_router.tsx b/x-pack/plugins/infra/public/routers/logs_router.tsx new file mode 100644 index 0000000000000..6700ed1fc8479 --- /dev/null +++ b/x-pack/plugins/infra/public/routers/logs_router.tsx @@ -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 React from 'react'; +import { Route, Router, Switch } from 'react-router-dom'; + +import { NotFoundPage } from '../pages/404'; +import { LinkToPage } from '../pages/link_to'; +import { LogsPage } from '../pages/logs'; +import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; +import { AppRouter } from './index'; + +export const LogsRouter: AppRouter = ({ history }) => { + const uiCapabilities = useKibana().services.application?.capabilities; + return ( + + + + {uiCapabilities?.logs?.show && ( + + )} + {uiCapabilities?.logs?.show && } + + + + ); +}; diff --git a/x-pack/plugins/infra/public/routers/metrics_router.tsx b/x-pack/plugins/infra/public/routers/metrics_router.tsx new file mode 100644 index 0000000000000..7c2ebed8463f1 --- /dev/null +++ b/x-pack/plugins/infra/public/routers/metrics_router.tsx @@ -0,0 +1,41 @@ +/* + * 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 { Route, Router, Switch } from 'react-router-dom'; + +import { NotFoundPage } from '../pages/404'; +import { InfrastructurePage } from '../pages/infrastructure'; +import { LinkToPage } from '../pages/link_to'; +import { MetricDetail } from '../pages/metrics'; +import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; +import { AppRouter } from './index'; + +export const MetricsRouter: AppRouter = ({ history }) => { + const uiCapabilities = useKibana().services.application?.capabilities; + return ( + + + + {uiCapabilities?.infrastructure?.show && ( + + )} + {uiCapabilities?.infrastructure?.show && ( + + )} + {uiCapabilities?.infrastructure?.show && ( + + )} + {uiCapabilities?.infrastructure?.show && ( + + )} + {uiCapabilities?.infrastructure?.show && } + + + + ); +}; diff --git a/x-pack/legacy/plugins/infra/public/store/actions.ts b/x-pack/plugins/infra/public/store/actions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/actions.ts rename to x-pack/plugins/infra/public/store/actions.ts diff --git a/x-pack/legacy/plugins/infra/public/store/epics.ts b/x-pack/plugins/infra/public/store/epics.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/epics.ts rename to x-pack/plugins/infra/public/store/epics.ts diff --git a/x-pack/legacy/plugins/infra/public/store/index.ts b/x-pack/plugins/infra/public/store/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/index.ts rename to x-pack/plugins/infra/public/store/index.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/actions.ts b/x-pack/plugins/infra/public/store/local/actions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/actions.ts rename to x-pack/plugins/infra/public/store/local/actions.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/epic.ts b/x-pack/plugins/infra/public/store/local/epic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/epic.ts rename to x-pack/plugins/infra/public/store/local/epic.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/index.ts b/x-pack/plugins/infra/public/store/local/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/index.ts rename to x-pack/plugins/infra/public/store/local/index.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/reducer.ts b/x-pack/plugins/infra/public/store/local/reducer.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/reducer.ts rename to x-pack/plugins/infra/public/store/local/reducer.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/selectors.ts b/x-pack/plugins/infra/public/store/local/selectors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/selectors.ts rename to x-pack/plugins/infra/public/store/local/selectors.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_filter/actions.ts b/x-pack/plugins/infra/public/store/local/waffle_filter/actions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_filter/actions.ts rename to x-pack/plugins/infra/public/store/local/waffle_filter/actions.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_filter/index.ts b/x-pack/plugins/infra/public/store/local/waffle_filter/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_filter/index.ts rename to x-pack/plugins/infra/public/store/local/waffle_filter/index.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_filter/reducer.ts b/x-pack/plugins/infra/public/store/local/waffle_filter/reducer.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_filter/reducer.ts rename to x-pack/plugins/infra/public/store/local/waffle_filter/reducer.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_filter/selectors.ts b/x-pack/plugins/infra/public/store/local/waffle_filter/selectors.ts similarity index 93% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_filter/selectors.ts rename to x-pack/plugins/infra/public/store/local/waffle_filter/selectors.ts index 0acce82950f77..047dabd3f0dd3 100644 --- a/x-pack/legacy/plugins/infra/public/store/local/waffle_filter/selectors.ts +++ b/x-pack/plugins/infra/public/store/local/waffle_filter/selectors.ts @@ -6,7 +6,7 @@ import { createSelector } from 'reselect'; -import { esKuery } from '../../../../../../../../src/plugins/data/public'; +import { esKuery } from '../../../../../../../src/plugins/data/public'; import { WaffleFilterState } from './reducer'; export const selectWaffleFilterQuery = (state: WaffleFilterState) => diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_options/actions.ts b/x-pack/plugins/infra/public/store/local/waffle_options/actions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_options/actions.ts rename to x-pack/plugins/infra/public/store/local/waffle_options/actions.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_options/index.ts b/x-pack/plugins/infra/public/store/local/waffle_options/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_options/index.ts rename to x-pack/plugins/infra/public/store/local/waffle_options/index.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_options/reducer.ts b/x-pack/plugins/infra/public/store/local/waffle_options/reducer.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_options/reducer.ts rename to x-pack/plugins/infra/public/store/local/waffle_options/reducer.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_options/selector.ts b/x-pack/plugins/infra/public/store/local/waffle_options/selector.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_options/selector.ts rename to x-pack/plugins/infra/public/store/local/waffle_options/selector.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_time/actions.ts b/x-pack/plugins/infra/public/store/local/waffle_time/actions.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_time/actions.ts rename to x-pack/plugins/infra/public/store/local/waffle_time/actions.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_time/epic.ts b/x-pack/plugins/infra/public/store/local/waffle_time/epic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_time/epic.ts rename to x-pack/plugins/infra/public/store/local/waffle_time/epic.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_time/index.ts b/x-pack/plugins/infra/public/store/local/waffle_time/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_time/index.ts rename to x-pack/plugins/infra/public/store/local/waffle_time/index.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_time/reducer.ts b/x-pack/plugins/infra/public/store/local/waffle_time/reducer.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_time/reducer.ts rename to x-pack/plugins/infra/public/store/local/waffle_time/reducer.ts diff --git a/x-pack/legacy/plugins/infra/public/store/local/waffle_time/selectors.ts b/x-pack/plugins/infra/public/store/local/waffle_time/selectors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/local/waffle_time/selectors.ts rename to x-pack/plugins/infra/public/store/local/waffle_time/selectors.ts diff --git a/x-pack/legacy/plugins/infra/public/store/reducer.ts b/x-pack/plugins/infra/public/store/reducer.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/reducer.ts rename to x-pack/plugins/infra/public/store/reducer.ts diff --git a/x-pack/legacy/plugins/infra/public/store/selectors.ts b/x-pack/plugins/infra/public/store/selectors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/selectors.ts rename to x-pack/plugins/infra/public/store/selectors.ts diff --git a/x-pack/legacy/plugins/infra/public/store/store.ts b/x-pack/plugins/infra/public/store/store.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/store/store.ts rename to x-pack/plugins/infra/public/store/store.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/apollo_context.ts b/x-pack/plugins/infra/public/utils/apollo_context.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/apollo_context.ts rename to x-pack/plugins/infra/public/utils/apollo_context.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/cancellable_effect.ts b/x-pack/plugins/infra/public/utils/cancellable_effect.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/cancellable_effect.ts rename to x-pack/plugins/infra/public/utils/cancellable_effect.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/convert_interval_to_string.ts b/x-pack/plugins/infra/public/utils/convert_interval_to_string.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/convert_interval_to_string.ts rename to x-pack/plugins/infra/public/utils/convert_interval_to_string.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/enzyme_helpers.tsx b/x-pack/plugins/infra/public/utils/enzyme_helpers.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/enzyme_helpers.tsx rename to x-pack/plugins/infra/public/utils/enzyme_helpers.tsx diff --git a/x-pack/legacy/plugins/infra/public/utils/fixtures/metrics_explorer.ts b/x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts similarity index 97% rename from x-pack/legacy/plugins/infra/public/utils/fixtures/metrics_explorer.ts rename to x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts index 3d5198f2d379b..e39d6f785d53e 100644 --- a/x-pack/legacy/plugins/infra/public/utils/fixtures/metrics_explorer.ts +++ b/x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts @@ -7,7 +7,7 @@ import { MetricsExplorerResponse, MetricsExplorerSeries, -} from '../../../server/routes/metrics_explorer/types'; +} from '../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/bytes.test.ts b/x-pack/plugins/infra/public/utils/formatters/bytes.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/bytes.test.ts rename to x-pack/plugins/infra/public/utils/formatters/bytes.test.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/bytes.ts b/x-pack/plugins/infra/public/utils/formatters/bytes.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/bytes.ts rename to x-pack/plugins/infra/public/utils/formatters/bytes.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/datetime.ts b/x-pack/plugins/infra/public/utils/formatters/datetime.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/datetime.ts rename to x-pack/plugins/infra/public/utils/formatters/datetime.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/high_precision.ts b/x-pack/plugins/infra/public/utils/formatters/high_precision.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/high_precision.ts rename to x-pack/plugins/infra/public/utils/formatters/high_precision.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/index.ts b/x-pack/plugins/infra/public/utils/formatters/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/index.ts rename to x-pack/plugins/infra/public/utils/formatters/index.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/number.ts b/x-pack/plugins/infra/public/utils/formatters/number.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/number.ts rename to x-pack/plugins/infra/public/utils/formatters/number.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/formatters/percent.ts b/x-pack/plugins/infra/public/utils/formatters/percent.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/formatters/percent.ts rename to x-pack/plugins/infra/public/utils/formatters/percent.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/handlers.ts b/x-pack/plugins/infra/public/utils/handlers.ts similarity index 93% rename from x-pack/legacy/plugins/infra/public/utils/handlers.ts rename to x-pack/plugins/infra/public/utils/handlers.ts index 4678718169b94..077355a9c5960 100644 --- a/x-pack/legacy/plugins/infra/public/utils/handlers.ts +++ b/x-pack/plugins/infra/public/utils/handlers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import isEqual from 'lodash/fp/isEqual'; +import { isEqual } from 'lodash'; export function callWithoutRepeats( func: (...args: any[]) => T, diff --git a/x-pack/legacy/plugins/infra/public/utils/history_context.ts b/x-pack/plugins/infra/public/utils/history_context.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/history_context.ts rename to x-pack/plugins/infra/public/utils/history_context.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/is_displayable.test.ts b/x-pack/plugins/infra/public/utils/is_displayable.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/is_displayable.test.ts rename to x-pack/plugins/infra/public/utils/is_displayable.test.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/is_displayable.ts b/x-pack/plugins/infra/public/utils/is_displayable.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/is_displayable.ts rename to x-pack/plugins/infra/public/utils/is_displayable.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/kuery.ts b/x-pack/plugins/infra/public/utils/kuery.ts similarity index 87% rename from x-pack/legacy/plugins/infra/public/utils/kuery.ts rename to x-pack/plugins/infra/public/utils/kuery.ts index 2292bf272b388..60d3f6454c546 100644 --- a/x-pack/legacy/plugins/infra/public/utils/kuery.ts +++ b/x-pack/plugins/infra/public/utils/kuery.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { esKuery, IIndexPattern } from '../../../../../../src/plugins/data/public'; +import { esKuery, IIndexPattern } from '../../../../../src/plugins/data/public'; export const convertKueryToElasticSearchQuery = ( kueryExpression: string, diff --git a/x-pack/legacy/plugins/infra/public/utils/loading_state/index.ts b/x-pack/plugins/infra/public/utils/loading_state/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/loading_state/index.ts rename to x-pack/plugins/infra/public/utils/loading_state/index.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/loading_state/loading_policy.ts b/x-pack/plugins/infra/public/utils/loading_state/loading_policy.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/loading_state/loading_policy.ts rename to x-pack/plugins/infra/public/utils/loading_state/loading_policy.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/loading_state/loading_progress.ts b/x-pack/plugins/infra/public/utils/loading_state/loading_progress.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/loading_state/loading_progress.ts rename to x-pack/plugins/infra/public/utils/loading_state/loading_progress.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/loading_state/loading_result.ts b/x-pack/plugins/infra/public/utils/loading_state/loading_result.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/loading_state/loading_result.ts rename to x-pack/plugins/infra/public/utils/loading_state/loading_result.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/loading_state/loading_state.ts b/x-pack/plugins/infra/public/utils/loading_state/loading_state.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/loading_state/loading_state.ts rename to x-pack/plugins/infra/public/utils/loading_state/loading_state.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/log_entry/index.ts b/x-pack/plugins/infra/public/utils/log_entry/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/log_entry/index.ts rename to x-pack/plugins/infra/public/utils/log_entry/index.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/log_entry/log_entry.ts b/x-pack/plugins/infra/public/utils/log_entry/log_entry.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/log_entry/log_entry.ts rename to x-pack/plugins/infra/public/utils/log_entry/log_entry.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/log_entry/log_entry_highlight.ts b/x-pack/plugins/infra/public/utils/log_entry/log_entry_highlight.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/log_entry/log_entry_highlight.ts rename to x-pack/plugins/infra/public/utils/log_entry/log_entry_highlight.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/map_timepicker_quickranges_to_datepicker_ranges.ts b/x-pack/plugins/infra/public/utils/map_timepicker_quickranges_to_datepicker_ranges.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/map_timepicker_quickranges_to_datepicker_ranges.ts rename to x-pack/plugins/infra/public/utils/map_timepicker_quickranges_to_datepicker_ranges.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/redirect_with_query_params.tsx b/x-pack/plugins/infra/public/utils/redirect_with_query_params.tsx similarity index 59% rename from x-pack/legacy/plugins/infra/public/utils/redirect_with_query_params.tsx rename to x-pack/plugins/infra/public/utils/redirect_with_query_params.tsx index 915b82860dd1b..7065ba7bf9b2e 100644 --- a/x-pack/legacy/plugins/infra/public/utils/redirect_with_query_params.tsx +++ b/x-pack/plugins/infra/public/utils/redirect_with_query_params.tsx @@ -18,27 +18,29 @@ export const RedirectWithQueryParams: React.FunctionComponent ( - - location ? ( - - ) : null - } - /> -); +}) => { + return ( + { + return location ? ( + + ) : null; + }} + /> + ); +}; diff --git a/x-pack/legacy/plugins/infra/public/utils/redux_context.tsx b/x-pack/plugins/infra/public/utils/redux_context.tsx similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/redux_context.tsx rename to x-pack/plugins/infra/public/utils/redux_context.tsx diff --git a/x-pack/legacy/plugins/infra/public/utils/source_configuration.ts b/x-pack/plugins/infra/public/utils/source_configuration.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/source_configuration.ts rename to x-pack/plugins/infra/public/utils/source_configuration.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/styles.ts b/x-pack/plugins/infra/public/utils/styles.ts similarity index 94% rename from x-pack/legacy/plugins/infra/public/utils/styles.ts rename to x-pack/plugins/infra/public/utils/styles.ts index 523f123666f6f..831996ddeca65 100644 --- a/x-pack/legacy/plugins/infra/public/utils/styles.ts +++ b/x-pack/plugins/infra/public/utils/styles.ts @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import get from 'lodash/fp/get'; -import getOr from 'lodash/fp/getOr'; +import { get } from 'lodash'; import { getLuminance, parseToHsl, parseToRgb, rgba, shade, tint } from 'polished'; type PropReader = (props: object, defaultValue?: Default) => Prop; @@ -16,7 +15,7 @@ const asPropReader = (reader: string | string[] | PropReader) => : ( props: Props, defaultValue?: Default - ) => getOr(defaultValue, reader as Prop, props); + ) => get(props, reader as Prop, defaultValue); export const switchProp = Object.assign( (propName: string | string[] | PropReader, options: Map | object) => ( @@ -26,7 +25,7 @@ export const switchProp = Object.assign( if (typeof propValue === 'undefined') { return; } - return options instanceof Map ? options.get(propValue) : get(propValue, options); + return options instanceof Map ? options.get(propValue) : get(options, propValue); }, { default: Symbol('default'), diff --git a/x-pack/legacy/plugins/infra/public/utils/typed_react.tsx b/x-pack/plugins/infra/public/utils/typed_react.tsx similarity index 95% rename from x-pack/legacy/plugins/infra/public/utils/typed_react.tsx rename to x-pack/plugins/infra/public/utils/typed_react.tsx index d057899ba18be..c997fb4ac983a 100644 --- a/x-pack/legacy/plugins/infra/public/utils/typed_react.tsx +++ b/x-pack/plugins/infra/public/utils/typed_react.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import omit from 'lodash/fp/omit'; +import { omit } from 'lodash'; import React from 'react'; import { InferableComponentEnhancerWithProps, ConnectedComponent } from 'react-redux'; @@ -56,7 +56,7 @@ export const asChildFunctionRenderer = ( } private getRendererArgs = () => - omit(['children', 'initializeOnMount', 'resetOnUnmount'], this.props) as Pick< + omit(this.props, ['children', 'initializeOnMount', 'resetOnUnmount']) as Pick< ChildFunctionRendererProps, keyof InjectedProps >; diff --git a/x-pack/legacy/plugins/infra/public/utils/typed_redux.ts b/x-pack/plugins/infra/public/utils/typed_redux.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/typed_redux.ts rename to x-pack/plugins/infra/public/utils/typed_redux.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/url_state.tsx b/x-pack/plugins/infra/public/utils/url_state.tsx similarity index 96% rename from x-pack/legacy/plugins/infra/public/utils/url_state.tsx rename to x-pack/plugins/infra/public/utils/url_state.tsx index 58835715fe55c..bf4cfbaf05965 100644 --- a/x-pack/legacy/plugins/infra/public/utils/url_state.tsx +++ b/x-pack/plugins/infra/public/utils/url_state.tsx @@ -6,11 +6,11 @@ import { parse, stringify } from 'query-string'; import { History, Location } from 'history'; -import throttle from 'lodash/fp/throttle'; +import { throttle } from 'lodash'; import React from 'react'; import { Route, RouteProps } from 'react-router-dom'; import { decode, encode, RisonValue } from 'rison-node'; -import { url } from '../../../../../../src/plugins/kibana_utils/public'; +import { url } from '../../../../../src/plugins/kibana_utils/public'; interface UrlStateContainerProps { urlState: UrlState | undefined; @@ -54,7 +54,7 @@ class UrlStateContainerLifecycle extends React.Component< this.handleInitialize(location); } - private replaceStateInLocation = throttle(1000, (urlState: UrlState | undefined) => { + private replaceStateInLocation = throttle((urlState: UrlState | undefined) => { const { history, location, urlStateKey } = this.props; const newLocation = replaceQueryStringInLocation( @@ -65,7 +65,7 @@ class UrlStateContainerLifecycle extends React.Component< if (newLocation !== location) { history.replace(newLocation); } - }); + }, 1000); private handleInitialize = (location: Location) => { const { onInitialize, mapToUrlState, urlStateKey, urlState } = this.props; diff --git a/x-pack/legacy/plugins/infra/public/utils/use_kibana_space_id.ts b/x-pack/plugins/infra/public/utils/use_kibana_space_id.ts similarity index 64% rename from x-pack/legacy/plugins/infra/public/utils/use_kibana_space_id.ts rename to x-pack/plugins/infra/public/utils/use_kibana_space_id.ts index 52c896feef1a2..d229542ec940f 100644 --- a/x-pack/legacy/plugins/infra/public/utils/use_kibana_space_id.ts +++ b/x-pack/plugins/infra/public/utils/use_kibana_space_id.ts @@ -7,12 +7,13 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import * as rt from 'io-ts'; - -import { useKibanaInjectedVar } from './use_kibana_injected_var'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export const useKibanaSpaceId = (): string => { - // NOTICE: use of `activeSpace` is deprecated and will not be made available in the New Platform. - const activeSpace = useKibanaInjectedVar('activeSpace'); + const kibana = useKibana(); + // NOTE: The injectedMetadata service will be deprecated at some point. We should migrate + // this to the client side Spaces plugin when it becomes available. + const activeSpace = kibana.services.injectedMetadata?.getInjectedVar('activeSpace'); return pipe( activeSpaceRT.decode(activeSpace), diff --git a/x-pack/legacy/plugins/infra/public/utils/use_kibana_ui_setting.ts b/x-pack/plugins/infra/public/utils/use_kibana_ui_setting.ts similarity index 72% rename from x-pack/legacy/plugins/infra/public/utils/use_kibana_ui_setting.ts rename to x-pack/plugins/infra/public/utils/use_kibana_ui_setting.ts index b3697db81fb6e..aef75570e7db1 100644 --- a/x-pack/legacy/plugins/infra/public/utils/use_kibana_ui_setting.ts +++ b/x-pack/plugins/infra/public/utils/use_kibana_ui_setting.ts @@ -3,11 +3,8 @@ * 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'; - -import { npSetup } from 'ui/new_platform'; -import useObservable from 'react-use/lib/useObservable'; +import { useMemo } from 'react'; +import { useUiSetting$ } from '../../../../../src/plugins/kibana_react/public'; /** * This hook behaves like a `useState` hook in that it provides a requested @@ -46,19 +43,9 @@ export function useKibanaUiSetting( ): [any, (key: string, value: any) => Promise]; export function useKibanaUiSetting(key: string, defaultValue?: any) { - const uiSettingsClient = npSetup.core.uiSettings; - - const uiSetting$ = useMemo(() => uiSettingsClient.get$(key, defaultValue), [ - defaultValue, - key, - uiSettingsClient, - ]); - const uiSetting = useObservable(uiSetting$); - - const setUiSetting = useCallback((value: any) => uiSettingsClient.set(key, value), [ - key, - uiSettingsClient, - ]); - - return [uiSetting, setUiSetting]; + const [uiSetting, setUiSetting] = useUiSetting$(key); + const uiSettingValue = useMemo(() => { + return uiSetting ? uiSetting : defaultValue; + }, [uiSetting, defaultValue]); + return [uiSettingValue, setUiSetting]; } diff --git a/x-pack/legacy/plugins/infra/public/utils/use_tracked_promise.ts b/x-pack/plugins/infra/public/utils/use_tracked_promise.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/use_tracked_promise.ts rename to x-pack/plugins/infra/public/utils/use_tracked_promise.ts diff --git a/x-pack/legacy/plugins/infra/public/utils/use_url_state.ts b/x-pack/plugins/infra/public/utils/use_url_state.ts similarity index 98% rename from x-pack/legacy/plugins/infra/public/utils/use_url_state.ts rename to x-pack/plugins/infra/public/utils/use_url_state.ts index 284af62e52fbb..7a63b48fa9a1a 100644 --- a/x-pack/legacy/plugins/infra/public/utils/use_url_state.ts +++ b/x-pack/plugins/infra/public/utils/use_url_state.ts @@ -8,7 +8,7 @@ import { parse, stringify } from 'query-string'; import { Location } from 'history'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { decode, encode, RisonValue } from 'rison-node'; -import { url } from '../../../../../../src/plugins/kibana_utils/public'; +import { url } from '../../../../../src/plugins/kibana_utils/public'; import { useHistory } from './history_context'; diff --git a/x-pack/legacy/plugins/infra/public/utils/use_visibility_state.ts b/x-pack/plugins/infra/public/utils/use_visibility_state.ts similarity index 100% rename from x-pack/legacy/plugins/infra/public/utils/use_visibility_state.ts rename to x-pack/plugins/infra/public/utils/use_visibility_state.ts diff --git a/x-pack/legacy/plugins/infra/scripts/combined_schema.ts b/x-pack/plugins/infra/scripts/combined_schema.ts similarity index 91% rename from x-pack/legacy/plugins/infra/scripts/combined_schema.ts rename to x-pack/plugins/infra/scripts/combined_schema.ts index 625eb3a4a4755..4813a3b674b31 100644 --- a/x-pack/legacy/plugins/infra/scripts/combined_schema.ts +++ b/x-pack/plugins/infra/scripts/combined_schema.ts @@ -5,7 +5,7 @@ */ import { buildSchemaFromTypeDefinitions } from 'graphql-tools'; - +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { schemas as serverSchemas } from '../server/graphql'; export const schemas = [...serverSchemas]; diff --git a/x-pack/legacy/plugins/infra/scripts/generate_types_from_graphql.js b/x-pack/plugins/infra/scripts/generate_types_from_graphql.js similarity index 97% rename from x-pack/legacy/plugins/infra/scripts/generate_types_from_graphql.js rename to x-pack/plugins/infra/scripts/generate_types_from_graphql.js index 9e2d3f4e05453..aec5ff6da99ce 100644 --- a/x-pack/legacy/plugins/infra/scripts/generate_types_from_graphql.js +++ b/x-pack/plugins/infra/scripts/generate_types_from_graphql.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -require('../../../../../src/setup_node_env'); +require('../../../../src/setup_node_env'); const { join, resolve } = require('path'); // eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved diff --git a/x-pack/legacy/plugins/infra/scripts/gql_gen_client.json b/x-pack/plugins/infra/scripts/gql_gen_client.json similarity index 100% rename from x-pack/legacy/plugins/infra/scripts/gql_gen_client.json rename to x-pack/plugins/infra/scripts/gql_gen_client.json diff --git a/x-pack/legacy/plugins/infra/scripts/gql_gen_server.json b/x-pack/plugins/infra/scripts/gql_gen_server.json similarity index 100% rename from x-pack/legacy/plugins/infra/scripts/gql_gen_server.json rename to x-pack/plugins/infra/scripts/gql_gen_server.json diff --git a/x-pack/legacy/plugins/infra/scripts/storybook.js b/x-pack/plugins/infra/scripts/storybook.js similarity index 100% rename from x-pack/legacy/plugins/infra/scripts/storybook.js rename to x-pack/plugins/infra/scripts/storybook.js diff --git a/x-pack/legacy/plugins/infra/server/features.ts b/x-pack/plugins/infra/server/features.ts similarity index 96% rename from x-pack/legacy/plugins/infra/server/features.ts rename to x-pack/plugins/infra/server/features.ts index 02658002694d2..edf94beab43a7 100644 --- a/x-pack/legacy/plugins/infra/server/features.ts +++ b/x-pack/plugins/infra/server/features.ts @@ -12,7 +12,7 @@ export const METRICS_FEATURE = { defaultMessage: 'Metrics', }), icon: 'metricsApp', - navLinkId: 'infra:home', + navLinkId: 'metrics', app: ['infra', 'kibana'], catalogue: ['infraops'], privileges: { @@ -41,7 +41,7 @@ export const LOGS_FEATURE = { defaultMessage: 'Logs', }), icon: 'logsApp', - navLinkId: 'infra:logs', + navLinkId: 'logs', app: ['infra', 'kibana'], catalogue: ['infralogging'], privileges: { diff --git a/x-pack/legacy/plugins/infra/server/graphql/index.ts b/x-pack/plugins/infra/server/graphql/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/index.ts rename to x-pack/plugins/infra/server/graphql/index.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/log_entries/index.ts b/x-pack/plugins/infra/server/graphql/log_entries/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/log_entries/index.ts rename to x-pack/plugins/infra/server/graphql/log_entries/index.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/log_entries/resolvers.ts b/x-pack/plugins/infra/server/graphql/log_entries/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/log_entries/resolvers.ts rename to x-pack/plugins/infra/server/graphql/log_entries/resolvers.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/log_entries/schema.gql.ts b/x-pack/plugins/infra/server/graphql/log_entries/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/log_entries/schema.gql.ts rename to x-pack/plugins/infra/server/graphql/log_entries/schema.gql.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/source_status/index.ts b/x-pack/plugins/infra/server/graphql/source_status/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/source_status/index.ts rename to x-pack/plugins/infra/server/graphql/source_status/index.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/source_status/resolvers.ts b/x-pack/plugins/infra/server/graphql/source_status/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/source_status/resolvers.ts rename to x-pack/plugins/infra/server/graphql/source_status/resolvers.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/source_status/schema.gql.ts b/x-pack/plugins/infra/server/graphql/source_status/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/source_status/schema.gql.ts rename to x-pack/plugins/infra/server/graphql/source_status/schema.gql.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/sources/index.ts b/x-pack/plugins/infra/server/graphql/sources/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/sources/index.ts rename to x-pack/plugins/infra/server/graphql/sources/index.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/sources/resolvers.ts b/x-pack/plugins/infra/server/graphql/sources/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/sources/resolvers.ts rename to x-pack/plugins/infra/server/graphql/sources/resolvers.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/sources/schema.gql.ts b/x-pack/plugins/infra/server/graphql/sources/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/sources/schema.gql.ts rename to x-pack/plugins/infra/server/graphql/sources/schema.gql.ts diff --git a/x-pack/legacy/plugins/infra/server/graphql/types.ts b/x-pack/plugins/infra/server/graphql/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/graphql/types.ts rename to x-pack/plugins/infra/server/graphql/types.ts diff --git a/x-pack/plugins/infra/server/index.ts b/x-pack/plugins/infra/server/index.ts index b12f92c8c5a9d..54f858554a5a3 100644 --- a/x-pack/plugins/infra/server/index.ts +++ b/x-pack/plugins/infra/server/index.ts @@ -4,21 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { schema, TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext } from 'src/core/server'; -import { InfraPlugin } from './plugin'; +import { config, InfraConfig, InfraServerPlugin } from './plugin'; +import { savedObjectMappings } from './saved_objects'; -export const config = { - schema: schema.object({ - enabled: schema.maybe(schema.boolean()), - query: schema.object({ - partitionSize: schema.maybe(schema.number()), - partitionFactor: schema.maybe(schema.number()), - }), - }), -}; +export { config, InfraConfig, savedObjectMappings }; -export const plugin = (initContext: PluginInitializerContext) => new InfraPlugin(initContext); - -export type InfraConfig = TypeOf; -export { InfraSetup } from './plugin'; +export function plugin(context: PluginInitializerContext) { + return new InfraServerPlugin(context); +} diff --git a/x-pack/legacy/plugins/infra/server/infra_server.ts b/x-pack/plugins/infra/server/infra_server.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/infra_server.ts rename to x-pack/plugins/infra/server/infra_server.ts diff --git a/x-pack/legacy/plugins/infra/server/kibana.index.ts b/x-pack/plugins/infra/server/kibana.index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/kibana.index.ts rename to x-pack/plugins/infra/server/kibana.index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/fields/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/fields/adapter_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/fields/adapter_types.ts rename to x-pack/plugins/infra/server/lib/adapters/fields/adapter_types.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/fields/framework_fields_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/fields/framework_fields_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/fields/framework_fields_adapter.ts rename to x-pack/plugins/infra/server/lib/adapters/fields/framework_fields_adapter.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/fields/index.ts b/x-pack/plugins/infra/server/lib/adapters/fields/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/fields/index.ts rename to x-pack/plugins/infra/server/lib/adapters/fields/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts similarity index 89% rename from x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts rename to x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index b14536275cec3..f8177365c9bdd 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -7,12 +7,12 @@ import { SearchResponse, GenericParams } from 'elasticsearch'; import { Lifecycle } from 'hapi'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import { RouteMethod, RouteConfig } from '../../../../../../../../src/core/server'; -import { PluginSetupContract as FeaturesPluginSetup } from '../../../../../../../plugins/features/server'; -import { SpacesPluginSetup } from '../../../../../../../plugins/spaces/server'; -import { VisTypeTimeseriesSetup } from '../../../../../../../../src/plugins/vis_type_timeseries/server'; -import { APMPluginContract } from '../../../../../../../plugins/apm/server'; -import { HomeServerPluginSetup } from '../../../../../../../../src/plugins/home/server'; +import { RouteMethod, RouteConfig } from '../../../../../../../src/core/server'; +import { PluginSetupContract as FeaturesPluginSetup } from '../../../../../../plugins/features/server'; +import { SpacesPluginSetup } from '../../../../../../plugins/spaces/server'; +import { VisTypeTimeseriesSetup } from '../../../../../../../src/plugins/vis_type_timeseries/server'; +import { APMPluginContract } from '../../../../../../plugins/apm/server'; +import { HomeServerPluginSetup } from '../../../../../../../src/plugins/home/server'; // NP_TODO: Compose real types from plugins we depend on, no "any" export interface InfraServerPluginDeps { diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/index.ts b/x-pack/plugins/infra/server/lib/adapters/framework/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/framework/index.ts rename to x-pack/plugins/infra/server/lib/adapters/framework/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts similarity index 92% rename from x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts rename to x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index 4b1aa774a523f..7c12e23d7e903 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -6,7 +6,6 @@ /* eslint-disable @typescript-eslint/array-type */ -import { GenericParams } from 'elasticsearch'; import { GraphQLSchema } from 'graphql'; import { Legacy } from 'kibana'; import { runHttpQuery } from 'apollo-server-core'; @@ -30,9 +29,11 @@ import { RequestHandlerContext, KibanaResponseFactory, RouteMethod, -} from '../../../../../../../../src/core/server'; -import { RequestHandler } from '../../../../../../../../src/core/server'; -import { InfraConfig } from '../../../../../../../plugins/infra/server'; + APICaller, +} from '../../../../../../../src/core/server'; +import { RequestHandler } from '../../../../../../../src/core/server'; +import { InfraConfig } from '../../../plugin'; +import { IndexPatternsFetcher } from '../../../../../../../src/plugins/data/server'; export class KibanaFramework { public router: IRouter; @@ -214,14 +215,10 @@ export class KibanaFramework { public getIndexPatternsService( requestContext: RequestHandlerContext ): Legacy.IndexPatternsService { - return this.plugins.indexPatterns.indexPatternsServiceFactory({ - callCluster: async (method: string, args: [GenericParams], ...rest: any[]) => { - const fieldCaps = await this.callWithRequest(requestContext, method, { - ...args, - allowNoIndices: true, - } as GenericParams); - return fieldCaps; - }, + return new IndexPatternsFetcher((...rest: Parameters) => { + rest[1] = rest[1] || {}; + rest[1].allowNoIndices = true; + return requestContext.core.elasticsearch.adminClient.callAsCurrentUser(...rest); }); } diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/adapter_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/adapter_types.ts rename to x-pack/plugins/infra/server/lib/adapters/log_entries/adapter_types.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/index.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/index.ts rename to x-pack/plugins/infra/server/lib/adapters/log_entries/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts similarity index 97% rename from x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts rename to x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts index b936d79a8edcd..f48c949329b04 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts @@ -8,11 +8,7 @@ import { timeMilliseconds } from 'd3-time'; import * as runtimeTypes from 'io-ts'; -import { compact } from 'lodash'; -import first from 'lodash/fp/first'; -import get from 'lodash/fp/get'; -import has from 'lodash/fp/has'; -import zip from 'lodash/fp/zip'; +import { compact, first, get, has, zip } from 'lodash'; import { pipe } from 'fp-ts/lib/pipeable'; import { map, fold } from 'fp-ts/lib/Either'; import { identity, constant } from 'fp-ts/lib/function'; @@ -408,8 +404,8 @@ function mapHitsToLogEntryDocuments( return hits.map(hit => { const logFields = fields.reduce<{ [fieldName: string]: JsonValue }>( (flattenedFields, field) => { - if (has(field, hit._source)) { - flattenedFields[field] = get(field, hit._source); + if (has(hit._source, field)) { + flattenedFields[field] = get(hit._source, field); } return flattenedFields; }, @@ -434,13 +430,13 @@ const convertHitToLogEntryDocument = (fields: string[]) => ( gid: hit._id, fields: fields.reduce( (flattenedFields, fieldName) => - has(fieldName, hit._source) + has(hit._source, fieldName) ? { ...flattenedFields, - [fieldName]: get(fieldName, hit._source), + [fieldName]: get(hit._source, fieldName), } : flattenedFields, - {} as { [fieldName: string]: string | number | boolean | null } + {} as { [fieldName: string]: string | number | object | boolean | null } ), highlights: hit.highlight || {}, key: { diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/adapter_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts rename to x-pack/plugins/infra/server/lib/adapters/metrics/adapter_types.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/index.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/metrics/index.ts rename to x-pack/plugins/infra/server/lib/adapters/metrics/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts rename to x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts rename to x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/lib/errors.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/errors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/metrics/lib/errors.ts rename to x-pack/plugins/infra/server/lib/adapters/metrics/lib/errors.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts rename to x-pack/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/source_status/index.ts b/x-pack/plugins/infra/server/lib/adapters/source_status/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/adapters/source_status/index.ts rename to x-pack/plugins/infra/server/lib/adapters/source_status/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/compose/kibana.ts b/x-pack/plugins/infra/server/lib/compose/kibana.ts similarity index 94% rename from x-pack/legacy/plugins/infra/server/lib/compose/kibana.ts rename to x-pack/plugins/infra/server/lib/compose/kibana.ts index d8a39a6b9c16f..f100726b5b92e 100644 --- a/x-pack/legacy/plugins/infra/server/lib/compose/kibana.ts +++ b/x-pack/plugins/infra/server/lib/compose/kibana.ts @@ -16,8 +16,8 @@ import { LogEntryCategoriesAnalysis, LogEntryRateAnalysis } from '../log_analysi import { InfraSnapshot } from '../snapshot'; import { InfraSourceStatus } from '../source_status'; import { InfraSources } from '../sources'; -import { InfraConfig } from '../../../../../../plugins/infra/server'; -import { CoreSetup } from '../../../../../../../src/core/server'; +import { InfraConfig } from '../../../server'; +import { CoreSetup } from '../../../../../../src/core/server'; import { InfraServerPluginDeps } from '../adapters/framework/adapter_types'; export function compose(core: CoreSetup, config: InfraConfig, plugins: InfraServerPluginDeps) { diff --git a/x-pack/legacy/plugins/infra/server/lib/constants.ts b/x-pack/plugins/infra/server/lib/constants.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/constants.ts rename to x-pack/plugins/infra/server/lib/constants.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/fields_domain.ts b/x-pack/plugins/infra/server/lib/domains/fields_domain.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/fields_domain.ts rename to x-pack/plugins/infra/server/lib/domains/fields_domain.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_apache2.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_auditd.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_haproxy.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_icinga.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_iis.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_logstash.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mongodb.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_mysql.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_nginx.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_osquery.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_redis.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_redis.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_redis.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_redis.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_system.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_system.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_system.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_system.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_traefik.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic_webserver.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic_webserver.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic_webserver.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/generic_webserver.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/helpers.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/helpers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/helpers.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/helpers.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/index.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/index.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.test.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/convert_document_source_to_log_item_fields.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/index.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/index.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/message.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/message.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/message.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/message.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/rule_types.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/rule_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/log_entries_domain/rule_types.ts rename to x-pack/plugins/infra/server/lib/domains/log_entries_domain/rule_types.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/domains/metrics_domain.ts b/x-pack/plugins/infra/server/lib/domains/metrics_domain.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/domains/metrics_domain.ts rename to x-pack/plugins/infra/server/lib/domains/metrics_domain.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/infra_types.ts b/x-pack/plugins/infra/server/lib/infra_types.ts similarity index 92% rename from x-pack/legacy/plugins/infra/server/lib/infra_types.ts rename to x-pack/plugins/infra/server/lib/infra_types.ts index d52416b39596b..51c433557f4fc 100644 --- a/x-pack/legacy/plugins/infra/server/lib/infra_types.ts +++ b/x-pack/plugins/infra/server/lib/infra_types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraSourceConfiguration } from '../../public/graphql/types'; +import { InfraSourceConfiguration } from '../../common/graphql/types'; import { InfraFieldsDomain } from './domains/fields_domain'; import { InfraLogEntriesDomain } from './domains/log_entries_domain'; import { InfraMetricsDomain } from './domains/metrics_domain'; @@ -12,7 +12,7 @@ import { LogEntryCategoriesAnalysis, LogEntryRateAnalysis } from './log_analysis import { InfraSnapshot } from './snapshot'; import { InfraSources } from './sources'; import { InfraSourceStatus } from './source_status'; -import { InfraConfig } from '../../../../../plugins/infra/server'; +import { InfraConfig } from '../plugin'; import { KibanaFramework } from './adapters/framework/kibana_framework_adapter'; // NP_TODO: We shouldn't need this context anymore but I am diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/errors.ts b/x-pack/plugins/infra/server/lib/log_analysis/errors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/errors.ts rename to x-pack/plugins/infra/server/lib/log_analysis/errors.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/index.ts b/x-pack/plugins/infra/server/lib/log_analysis/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/index.ts rename to x-pack/plugins/infra/server/lib/log_analysis/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts similarity index 99% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts rename to x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts index f2b6c468df69f..2e270f16ca867 100644 --- a/x-pack/legacy/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { KibanaRequest, RequestHandlerContext } from '../../../../../../../src/core/server'; +import { KibanaRequest, RequestHandlerContext } from 'src/core/server'; import { getJobId, logEntryCategoriesJobTypes } from '../../../common/log_analysis'; import { startTracingSpan, TracingSpan } from '../../../common/performance_tracing'; import { decodeOrThrow } from '../../../common/runtime_types'; diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/log_entry_rate_analysis.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_rate_analysis.ts similarity index 98% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/log_entry_rate_analysis.ts rename to x-pack/plugins/infra/server/lib/log_analysis/log_entry_rate_analysis.ts index 515856fa6be8a..f60f758053c47 100644 --- a/x-pack/legacy/plugins/infra/server/lib/log_analysis/log_entry_rate_analysis.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_rate_analysis.ts @@ -7,6 +7,7 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { map, fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; +import { RequestHandlerContext, KibanaRequest } from 'src/core/server'; import { getJobId } from '../../../common/log_analysis'; import { throwErrors, createPlainError } from '../../../common/runtime_types'; import { KibanaFramework } from '../adapters/framework/kibana_framework_adapter'; @@ -17,7 +18,6 @@ import { LogRateModelPlotBucket, CompositeTimestampPartitionKey, } from './queries'; -import { RequestHandlerContext, KibanaRequest } from '../../../../../../../src/core/server'; const COMPOSITE_AGGREGATION_BATCH_SIZE = 1000; diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/common.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/common.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/index.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/index.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_categories.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_categories.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_categories.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_categories.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_category_histograms.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_category_histograms.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_category_histograms.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_category_histograms.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_data_sets.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_data_sets.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_data_sets.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_data_sets.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_rate.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_rate.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/log_entry_rate.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_rate.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/top_log_entry_categories.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/top_log_entry_categories.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/log_analysis/queries/top_log_entry_categories.ts rename to x-pack/plugins/infra/server/lib/log_analysis/queries/top_log_entry_categories.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/constants.ts b/x-pack/plugins/infra/server/lib/snapshot/constants.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/constants.ts rename to x-pack/plugins/infra/server/lib/snapshot/constants.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/create_timerange_with_interval.ts b/x-pack/plugins/infra/server/lib/snapshot/create_timerange_with_interval.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/create_timerange_with_interval.ts rename to x-pack/plugins/infra/server/lib/snapshot/create_timerange_with_interval.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/index.ts b/x-pack/plugins/infra/server/lib/snapshot/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/index.ts rename to x-pack/plugins/infra/server/lib/snapshot/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/query_helpers.ts b/x-pack/plugins/infra/server/lib/snapshot/query_helpers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/query_helpers.ts rename to x-pack/plugins/infra/server/lib/snapshot/query_helpers.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/response_helpers.test.ts b/x-pack/plugins/infra/server/lib/snapshot/response_helpers.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/response_helpers.test.ts rename to x-pack/plugins/infra/server/lib/snapshot/response_helpers.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/response_helpers.ts b/x-pack/plugins/infra/server/lib/snapshot/response_helpers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/response_helpers.ts rename to x-pack/plugins/infra/server/lib/snapshot/response_helpers.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/snapshot.ts b/x-pack/plugins/infra/server/lib/snapshot/snapshot.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/snapshot.ts rename to x-pack/plugins/infra/server/lib/snapshot/snapshot.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/snapshot/types.ts b/x-pack/plugins/infra/server/lib/snapshot/types.ts similarity index 90% rename from x-pack/legacy/plugins/infra/server/lib/snapshot/types.ts rename to x-pack/plugins/infra/server/lib/snapshot/types.ts index 3627747e327e0..7e17cb91c6a59 100644 --- a/x-pack/legacy/plugins/infra/server/lib/snapshot/types.ts +++ b/x-pack/plugins/infra/server/lib/snapshot/types.ts @@ -5,7 +5,7 @@ */ import { JsonObject } from '../../../common/typed_json'; -import { InfraSourceConfiguration } from '../../../public/graphql/types'; +import { InfraSourceConfiguration } from '../../../common/graphql/types'; import { SnapshotRequest } from '../../../common/http_api/snapshot_api'; export interface InfraSnapshotRequestOptions diff --git a/x-pack/legacy/plugins/infra/server/lib/source_status.ts b/x-pack/plugins/infra/server/lib/source_status.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/source_status.ts rename to x-pack/plugins/infra/server/lib/source_status.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/defaults.ts b/x-pack/plugins/infra/server/lib/sources/defaults.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/sources/defaults.ts rename to x-pack/plugins/infra/server/lib/sources/defaults.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/errors.ts b/x-pack/plugins/infra/server/lib/sources/errors.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/sources/errors.ts rename to x-pack/plugins/infra/server/lib/sources/errors.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/index.ts b/x-pack/plugins/infra/server/lib/sources/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/sources/index.ts rename to x-pack/plugins/infra/server/lib/sources/index.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/saved_object_mappings.ts b/x-pack/plugins/infra/server/lib/sources/saved_object_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/sources/saved_object_mappings.ts rename to x-pack/plugins/infra/server/lib/sources/saved_object_mappings.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/sources.test.ts b/x-pack/plugins/infra/server/lib/sources/sources.test.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/sources/sources.test.ts rename to x-pack/plugins/infra/server/lib/sources/sources.test.ts diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/sources.ts b/x-pack/plugins/infra/server/lib/sources/sources.ts similarity index 99% rename from x-pack/legacy/plugins/infra/server/lib/sources/sources.ts rename to x-pack/plugins/infra/server/lib/sources/sources.ts index 2b38d81e4a8d5..5b9207a88e6e4 100644 --- a/x-pack/legacy/plugins/infra/server/lib/sources/sources.ts +++ b/x-pack/plugins/infra/server/lib/sources/sources.ts @@ -21,7 +21,7 @@ import { SourceConfigurationSavedObjectRuntimeType, StaticSourceConfigurationRuntimeType, } from './types'; -import { InfraConfig } from '../../../../../../plugins/infra/server'; +import { InfraConfig } from '../../../server'; interface Libs { config: InfraConfig; diff --git a/x-pack/legacy/plugins/infra/server/lib/sources/types.ts b/x-pack/plugins/infra/server/lib/sources/types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/lib/sources/types.ts rename to x-pack/plugins/infra/server/lib/sources/types.ts diff --git a/x-pack/plugins/infra/server/plugin.ts b/x-pack/plugins/infra/server/plugin.ts index 0c763313fb973..ac45321e870e6 100644 --- a/x-pack/plugins/infra/server/plugin.ts +++ b/x-pack/plugins/infra/server/plugin.ts @@ -4,30 +4,158 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, PluginInitializerContext } from 'src/core/server'; +import { CoreSetup, PluginInitializerContext } from 'src/core/server'; +import { Server } from 'hapi'; +import { Observable } from 'rxjs'; +import { schema, TypeOf } from '@kbn/config-schema'; +import { i18n } from '@kbn/i18n'; +import { initInfraServer } from './infra_server'; +import { InfraBackendLibs, InfraDomainLibs } from './lib/infra_types'; +import { FrameworkFieldsAdapter } from './lib/adapters/fields/framework_fields_adapter'; +import { KibanaFramework } from './lib/adapters/framework/kibana_framework_adapter'; +import { InfraKibanaLogEntriesAdapter } from './lib/adapters/log_entries/kibana_log_entries_adapter'; +import { KibanaMetricsAdapter } from './lib/adapters/metrics/kibana_metrics_adapter'; +import { InfraElasticsearchSourceStatusAdapter } from './lib/adapters/source_status'; +import { InfraFieldsDomain } from './lib/domains/fields_domain'; +import { InfraLogEntriesDomain } from './lib/domains/log_entries_domain'; +import { InfraMetricsDomain } from './lib/domains/metrics_domain'; +import { LogEntryCategoriesAnalysis, LogEntryRateAnalysis } from './lib/log_analysis'; +import { InfraSnapshot } from './lib/snapshot'; +import { InfraSourceStatus } from './lib/source_status'; +import { InfraSources } from './lib/sources'; +import { InfraServerPluginDeps } from './lib/adapters/framework'; +import { METRICS_FEATURE, LOGS_FEATURE } from './features'; +import { UsageCollector } from './usage/usage_collector'; +import { InfraStaticSourceConfiguration } from './lib/sources/types'; -export class InfraPlugin implements Plugin { - private readonly initContext: PluginInitializerContext; +export const config = { + schema: schema.object({ + query: schema.object({ + partitionSize: schema.number({ defaultValue: 75 }), + partitionFactor: schema.number({ defaultValue: 1.2 }), + }), + sources: schema.maybe( + schema.object({ + default: schema.maybe( + schema.object({ + logAlias: schema.maybe(schema.string()), + metricAlias: schema.maybe(schema.string()), + fields: schema.maybe( + schema.object({ + timestamp: schema.maybe(schema.string()), + message: schema.maybe(schema.arrayOf(schema.string())), + tiebreaker: schema.maybe(schema.string()), + host: schema.maybe(schema.string()), + container: schema.maybe(schema.string()), + pod: schema.maybe(schema.string()), + }) + ), + }) + ), + }) + ), + }), +}; - constructor(initContext: PluginInitializerContext) { - this.initContext = initContext; +export type InfraConfig = TypeOf; + +export interface KbnServer extends Server { + usage: any; +} + +const logsSampleDataLinkLabel = i18n.translate('xpack.infra.sampleDataLinkLabel', { + defaultMessage: 'Logs', +}); + +export interface InfraPluginSetup { + defineInternalSourceConfiguration: ( + sourceId: string, + sourceProperties: InfraStaticSourceConfiguration + ) => void; +} + +export class InfraServerPlugin { + private config$: Observable; + public config = {} as InfraConfig; + public libs: InfraBackendLibs | undefined; + + constructor(context: PluginInitializerContext) { + this.config$ = context.config.create(); + } + + getLibs() { + if (!this.libs) { + throw new Error('libs not set up yet'); + } + return this.libs; } - public setup() { + async setup(core: CoreSetup, plugins: InfraServerPluginDeps) { + await new Promise(resolve => { + this.config$.subscribe(configValue => { + this.config = configValue; + resolve(); + }); + }); + const framework = new KibanaFramework(core, this.config, plugins); + const sources = new InfraSources({ + config: this.config, + }); + const sourceStatus = new InfraSourceStatus( + new InfraElasticsearchSourceStatusAdapter(framework), + { + sources, + } + ); + const snapshot = new InfraSnapshot({ sources, framework }); + const logEntryCategoriesAnalysis = new LogEntryCategoriesAnalysis({ framework }); + const logEntryRateAnalysis = new LogEntryRateAnalysis({ framework }); + + // TODO: separate these out individually and do away with "domains" as a temporary group + const domainLibs: InfraDomainLibs = { + fields: new InfraFieldsDomain(new FrameworkFieldsAdapter(framework), { + sources, + }), + logEntries: new InfraLogEntriesDomain(new InfraKibanaLogEntriesAdapter(framework), { + sources, + }), + metrics: new InfraMetricsDomain(new KibanaMetricsAdapter(framework)), + }; + + this.libs = { + configuration: this.config, + framework, + logEntryCategoriesAnalysis, + logEntryRateAnalysis, + snapshot, + sources, + sourceStatus, + ...domainLibs, + }; + + plugins.features.registerFeature(METRICS_FEATURE); + plugins.features.registerFeature(LOGS_FEATURE); + + plugins.home.sampleData.addAppLinksToSampleDataset('logs', [ + { + path: `/app/logs`, + label: logsSampleDataLinkLabel, + icon: 'logsApp', + }, + ]); + + initInfraServer(this.libs); + + // Telemetry + UsageCollector.registerUsageCollector(plugins.usageCollection); + return { - __legacy: { - config: this.initContext.config, + defineInternalSourceConfiguration(sourceId, sourceProperties) { + sources.defineInternalSourceConfiguration(sourceId, sourceProperties); }, - }; + } as InfraPluginSetup; } - public start() {} - public stop() {} -} - -export interface InfraSetup { - /** @deprecated */ - __legacy: { - config: PluginInitializerContext['config']; - }; + start() {} + stop() {} } diff --git a/x-pack/legacy/plugins/infra/server/routes/inventory_metadata/index.ts b/x-pack/plugins/infra/server/routes/inventory_metadata/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/inventory_metadata/index.ts rename to x-pack/plugins/infra/server/routes/inventory_metadata/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts rename to x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/ip_to_hostname.ts b/x-pack/plugins/infra/server/routes/ip_to_hostname.ts similarity index 96% rename from x-pack/legacy/plugins/infra/server/routes/ip_to_hostname.ts rename to x-pack/plugins/infra/server/routes/ip_to_hostname.ts index 5ad79b3d17a13..28b7777c1d688 100644 --- a/x-pack/legacy/plugins/infra/server/routes/ip_to_hostname.ts +++ b/x-pack/plugins/infra/server/routes/ip_to_hostname.ts @@ -7,10 +7,6 @@ import { first } from 'lodash'; import { schema } from '@kbn/config-schema'; import { InfraBackendLibs } from '../lib/infra_types'; -export interface IpToHostResponse { - host: string; -} - interface HostDoc { _source: { host: { diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/index.ts b/x-pack/plugins/infra/server/routes/log_analysis/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/index.ts rename to x-pack/plugins/infra/server/routes/log_analysis/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/results/index.ts b/x-pack/plugins/infra/server/routes/log_analysis/results/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/results/index.ts rename to x-pack/plugins/infra/server/routes/log_analysis/results/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_categories.ts b/x-pack/plugins/infra/server/routes/log_analysis/results/log_entry_categories.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_categories.ts rename to x-pack/plugins/infra/server/routes/log_analysis/results/log_entry_categories.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_category_datasets.ts b/x-pack/plugins/infra/server/routes/log_analysis/results/log_entry_category_datasets.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_category_datasets.ts rename to x-pack/plugins/infra/server/routes/log_analysis/results/log_entry_category_datasets.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts b/x-pack/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts rename to x-pack/plugins/infra/server/routes/log_analysis/results/log_entry_rate.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/validation/index.ts b/x-pack/plugins/infra/server/routes/log_analysis/validation/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/validation/index.ts rename to x-pack/plugins/infra/server/routes/log_analysis/validation/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_analysis/validation/indices.ts b/x-pack/plugins/infra/server/routes/log_analysis/validation/indices.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_analysis/validation/indices.ts rename to x-pack/plugins/infra/server/routes/log_analysis/validation/indices.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/entries.ts b/x-pack/plugins/infra/server/routes/log_entries/entries.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_entries/entries.ts rename to x-pack/plugins/infra/server/routes/log_entries/entries.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/highlights.ts b/x-pack/plugins/infra/server/routes/log_entries/highlights.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_entries/highlights.ts rename to x-pack/plugins/infra/server/routes/log_entries/highlights.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/index.ts b/x-pack/plugins/infra/server/routes/log_entries/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_entries/index.ts rename to x-pack/plugins/infra/server/routes/log_entries/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/item.ts b/x-pack/plugins/infra/server/routes/log_entries/item.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_entries/item.ts rename to x-pack/plugins/infra/server/routes/log_entries/item.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/summary.ts b/x-pack/plugins/infra/server/routes/log_entries/summary.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_entries/summary.ts rename to x-pack/plugins/infra/server/routes/log_entries/summary.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/summary_highlights.ts b/x-pack/plugins/infra/server/routes/log_entries/summary_highlights.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/log_entries/summary_highlights.ts rename to x-pack/plugins/infra/server/routes/log_entries/summary_highlights.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/index.ts b/x-pack/plugins/infra/server/routes/metadata/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/index.ts rename to x-pack/plugins/infra/server/routes/metadata/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts rename to x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts rename to x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_node_info.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_node_info.ts rename to x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts rename to x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/lib/has_apm_data.ts b/x-pack/plugins/infra/server/routes/metadata/lib/has_apm_data.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/lib/has_apm_data.ts rename to x-pack/plugins/infra/server/routes/metadata/lib/has_apm_data.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metadata/lib/pick_feature_name.ts b/x-pack/plugins/infra/server/routes/metadata/lib/pick_feature_name.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metadata/lib/pick_feature_name.ts rename to x-pack/plugins/infra/server/routes/metadata/lib/pick_feature_name.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/index.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metrics_explorer/index.ts rename to x-pack/plugins/infra/server/routes/metrics_explorer/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts similarity index 96% rename from x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts rename to x-pack/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts index 7e47f50c76088..c537ba0d5163e 100644 --- a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts @@ -5,7 +5,7 @@ */ import { InfraMetricModelMetricType } from '../../../lib/adapters/metrics'; -import { MetricsExplorerRequestBody } from '../types'; +import { MetricsExplorerRequestBody } from '../../../../common/http_api/metrics_explorer'; import { TSVBMetricModel } from '../../../../common/inventory_models/types'; export const createMetricModel = (options: MetricsExplorerRequestBody): TSVBMetricModel => { return { diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts rename to x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts similarity index 96% rename from x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts rename to x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts index 7111d3e7f8ca4..47dc58997a469 100644 --- a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts @@ -6,7 +6,10 @@ import { isObject, set } from 'lodash'; import { InfraDatabaseSearchResponse } from '../../../lib/adapters/framework'; -import { MetricsExplorerRequestBody, MetricsExplorerResponse } from '../types'; +import { + MetricsExplorerRequestBody, + MetricsExplorerResponse, +} from '../../../../common/http_api/metrics_explorer'; interface GroupingAggregation { groupingsCount: { diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts similarity index 98% rename from x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts rename to x-pack/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts index 347feca67aa99..3517800ea0dd1 100644 --- a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts @@ -12,7 +12,7 @@ import { MetricsExplorerSeries, MetricsExplorerRequestBody, MetricsExplorerColumn, -} from '../types'; +} from '../../../../common/http_api/metrics_explorer'; import { createMetricModel } from './create_metrics_model'; import { JsonObject } from '../../../../common/typed_json'; import { calculateMetricInterval } from '../../../utils/calculate_metric_interval'; diff --git a/x-pack/legacy/plugins/infra/server/routes/node_details/index.ts b/x-pack/plugins/infra/server/routes/node_details/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/node_details/index.ts rename to x-pack/plugins/infra/server/routes/node_details/index.ts diff --git a/x-pack/legacy/plugins/infra/server/routes/snapshot/index.ts b/x-pack/plugins/infra/server/routes/snapshot/index.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/routes/snapshot/index.ts rename to x-pack/plugins/infra/server/routes/snapshot/index.ts diff --git a/x-pack/legacy/plugins/infra/server/saved_objects.ts b/x-pack/plugins/infra/server/saved_objects.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/saved_objects.ts rename to x-pack/plugins/infra/server/saved_objects.ts diff --git a/x-pack/legacy/plugins/infra/server/usage/usage_collector.ts b/x-pack/plugins/infra/server/usage/usage_collector.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/usage/usage_collector.ts rename to x-pack/plugins/infra/server/usage/usage_collector.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/README.md b/x-pack/plugins/infra/server/utils/README.md similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/README.md rename to x-pack/plugins/infra/server/utils/README.md diff --git a/x-pack/legacy/plugins/infra/server/utils/calculate_metric_interval.ts b/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/calculate_metric_interval.ts rename to x-pack/plugins/infra/server/utils/calculate_metric_interval.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/create_afterkey_handler.ts b/x-pack/plugins/infra/server/utils/create_afterkey_handler.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/create_afterkey_handler.ts rename to x-pack/plugins/infra/server/utils/create_afterkey_handler.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/elasticsearch_runtime_types.ts b/x-pack/plugins/infra/server/utils/elasticsearch_runtime_types.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/elasticsearch_runtime_types.ts rename to x-pack/plugins/infra/server/utils/elasticsearch_runtime_types.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/get_all_composite_data.ts b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/get_all_composite_data.ts rename to x-pack/plugins/infra/server/utils/get_all_composite_data.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/get_interval_in_seconds.ts b/x-pack/plugins/infra/server/utils/get_interval_in_seconds.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/get_interval_in_seconds.ts rename to x-pack/plugins/infra/server/utils/get_interval_in_seconds.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/serialized_query.ts b/x-pack/plugins/infra/server/utils/serialized_query.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/serialized_query.ts rename to x-pack/plugins/infra/server/utils/serialized_query.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/typed_elasticsearch_mappings.ts b/x-pack/plugins/infra/server/utils/typed_elasticsearch_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/typed_elasticsearch_mappings.ts rename to x-pack/plugins/infra/server/utils/typed_elasticsearch_mappings.ts diff --git a/x-pack/legacy/plugins/infra/server/utils/typed_resolvers.ts b/x-pack/plugins/infra/server/utils/typed_resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/infra/server/utils/typed_resolvers.ts rename to x-pack/plugins/infra/server/utils/typed_resolvers.ts diff --git a/x-pack/legacy/plugins/infra/types/eui.d.ts b/x-pack/plugins/infra/types/eui.d.ts similarity index 100% rename from x-pack/legacy/plugins/infra/types/eui.d.ts rename to x-pack/plugins/infra/types/eui.d.ts diff --git a/x-pack/legacy/plugins/infra/types/eui_experimental.d.ts b/x-pack/plugins/infra/types/eui_experimental.d.ts similarity index 100% rename from x-pack/legacy/plugins/infra/types/eui_experimental.d.ts rename to x-pack/plugins/infra/types/eui_experimental.d.ts diff --git a/x-pack/legacy/plugins/infra/types/graphql_fields.d.ts b/x-pack/plugins/infra/types/graphql_fields.d.ts similarity index 100% rename from x-pack/legacy/plugins/infra/types/graphql_fields.d.ts rename to x-pack/plugins/infra/types/graphql_fields.d.ts diff --git a/x-pack/legacy/plugins/infra/types/redux_observable.d.ts b/x-pack/plugins/infra/types/redux_observable.d.ts similarity index 100% rename from x-pack/legacy/plugins/infra/types/redux_observable.d.ts rename to x-pack/plugins/infra/types/redux_observable.d.ts diff --git a/x-pack/plugins/observability/public/hooks/use_track_metric.tsx b/x-pack/plugins/observability/public/hooks/use_track_metric.tsx new file mode 100644 index 0000000000000..b146a80e89ea8 --- /dev/null +++ b/x-pack/plugins/observability/public/hooks/use_track_metric.tsx @@ -0,0 +1,92 @@ +/* + * 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, useMemo } from 'react'; +import { METRIC_TYPE, UiStatsMetricType } from '@kbn/analytics'; +import { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; + +/** + * Note: The usage_collection plugin will take care of sending this data to the telemetry server. + * You can find these metrics stored at: + * stack_stats.kibana.plugins.ui_metric.{app}.{metric}(__delayed_{n}ms)? + * which will be an array of objects each containing a key, representing the metric, and + * a value, which will be a counter + */ + +type ObservabilityApp = 'infra_metrics' | 'infra_logs' | 'apm' | 'uptime'; + +interface TrackOptions { + app?: ObservabilityApp; + metricType?: UiStatsMetricType; + delay?: number; // in ms +} +type EffectDeps = unknown[]; + +interface ServiceDeps { + usageCollection: UsageCollectionSetup; // TODO: This should really be start. Looking into it. +} + +export type TrackMetricOptions = TrackOptions & { metric: string }; +export type UiTracker = ReturnType; + +export { METRIC_TYPE }; + +export function useUiTracker({ + app: defaultApp, +}: { app?: ObservabilityApp } = {}) { + const reportUiStats = useKibana().services?.usageCollection?.reportUiStats; + const trackEvent = useMemo(() => { + return ({ app = defaultApp, metric, metricType = METRIC_TYPE.COUNT }: TrackMetricOptions) => { + if (reportUiStats) { + reportUiStats(app as string, metricType, metric); + } + }; + }, [defaultApp, reportUiStats]); + return trackEvent; +} + +export function useTrackMetric( + { app, metric, metricType = METRIC_TYPE.COUNT, delay = 0 }: TrackMetricOptions, + effectDependencies: EffectDeps = [] +) { + const reportUiStats = useKibana().services?.usageCollection?.reportUiStats; + + useEffect(() => { + if (!reportUiStats) { + // eslint-disable-next-line no-console + console.log( + 'usageCollection.reportUiStats is unavailable. Ensure this is setup via .' + ); + } else { + let decoratedMetric = metric; + if (delay > 0) { + decoratedMetric += `__delayed_${delay}ms`; + } + const id = setTimeout( + () => reportUiStats(app as string, metricType, decoratedMetric), + Math.max(delay, 0) + ); + return () => clearTimeout(id); + } + // the dependencies are managed externally + // eslint-disable-next-line react-hooks/exhaustive-deps + }, effectDependencies); +} + +/** + * useTrackPageview is a convenience wrapper for tracking a pageview + * Its metrics will be found at: + * stack_stats.kibana.plugins.ui_metric.{app}.pageview__{path}(__delayed_{n}ms)? + */ +type TrackPageviewProps = TrackOptions & { path: string }; + +export function useTrackPageview( + { path, ...rest }: TrackPageviewProps, + effectDependencies: EffectDeps = [] +) { + useTrackMetric({ ...rest, metric: `pageview__${path}` }, effectDependencies); +} diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index c822edc3f4de8..dd8bca90cff4f 100644 --- a/x-pack/plugins/observability/public/index.ts +++ b/x-pack/plugins/observability/public/index.ts @@ -14,3 +14,13 @@ export const plugin: PluginInitializer = ( }; export * from './components/action_menu'; + +export { + useTrackPageview, + useUiTracker, + UiTracker, + TrackMetricOptions, + METRIC_TYPE, +} from './hooks/use_track_metric'; + +export * from './typings'; diff --git a/x-pack/plugins/observability/public/typings/eui_draggable/index.ts b/x-pack/plugins/observability/public/typings/eui_draggable/index.ts new file mode 100644 index 0000000000000..322966b3c982e --- /dev/null +++ b/x-pack/plugins/observability/public/typings/eui_draggable/index.ts @@ -0,0 +1,17 @@ +/* + * 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 { EuiDraggable, EuiDragDropContext } from '@elastic/eui'; + +type PropsOf = T extends React.ComponentType ? ComponentProps : never; +type FirstArgumentOf = Func extends (arg1: infer FirstArgument, ...rest: any[]) => any + ? FirstArgument + : never; +export type DragHandleProps = FirstArgumentOf< + Exclude['children'], React.ReactElement> +>['dragHandleProps']; +export type DropResult = FirstArgumentOf['onDragEnd']>; diff --git a/x-pack/plugins/observability/public/typings/eui_styled_components.tsx b/x-pack/plugins/observability/public/typings/eui_styled_components.tsx new file mode 100644 index 0000000000000..aab16f9d79c4b --- /dev/null +++ b/x-pack/plugins/observability/public/typings/eui_styled_components.tsx @@ -0,0 +1,45 @@ +/* + * 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 * as styledComponents from 'styled-components'; +import { ThemedStyledComponentsModule, ThemeProvider, ThemeProviderProps } from 'styled-components'; + +import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; +import euiLightVars from '@elastic/eui/dist/eui_theme_light.json'; + +export interface EuiTheme { + eui: typeof euiLightVars | typeof euiDarkVars; + darkMode: boolean; +} + +const EuiThemeProvider = < + OuterTheme extends styledComponents.DefaultTheme = styledComponents.DefaultTheme +>({ + darkMode = false, + ...otherProps +}: Omit, 'theme'> & { + darkMode?: boolean; +}) => ( + ({ + ...outerTheme, + eui: darkMode ? euiDarkVars : euiLightVars, + darkMode, + })} + /> +); + +const { + default: euiStyled, + css, + createGlobalStyle, + keyframes, + withTheme, +} = (styledComponents as unknown) as ThemedStyledComponentsModule; + +export { css, euiStyled, EuiThemeProvider, createGlobalStyle, keyframes, withTheme }; diff --git a/x-pack/plugins/observability/public/typings/index.ts b/x-pack/plugins/observability/public/typings/index.ts new file mode 100644 index 0000000000000..3da2febc73efd --- /dev/null +++ b/x-pack/plugins/observability/public/typings/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export * from './eui_draggable'; +export * from './eui_styled_components'; diff --git a/x-pack/plugins/spaces/server/lib/spaces_usage_collector.test.ts b/x-pack/plugins/spaces/server/lib/spaces_usage_collector.test.ts index b343bac9343a3..c0a6a152c8322 100644 --- a/x-pack/plugins/spaces/server/lib/spaces_usage_collector.test.ts +++ b/x-pack/plugins/spaces/server/lib/spaces_usage_collector.test.ts @@ -66,6 +66,38 @@ const defaultCallClusterMock = jest.fn().mockResolvedValue({ }, }); +describe('error handling', () => { + it('handles a 404 when searching for space usage', async () => { + const { features, licensing, usageCollecion } = setup({ + license: { isAvailable: true, type: 'basic' }, + }); + const { fetch: getSpacesUsage } = getSpacesUsageCollector(usageCollecion as any, { + kibanaIndex: '.kibana', + features, + licensing, + }); + + await getSpacesUsage(jest.fn().mockRejectedValue({ status: 404 })); + }); + + it('throws error for a non-404', async () => { + const { features, licensing, usageCollecion } = setup({ + license: { isAvailable: true, type: 'basic' }, + }); + const { fetch: getSpacesUsage } = getSpacesUsageCollector(usageCollecion as any, { + kibanaIndex: '.kibana', + features, + licensing, + }); + + const statusCodes = [401, 402, 403, 500]; + for (const statusCode of statusCodes) { + const error = { status: statusCode }; + await expect(getSpacesUsage(jest.fn().mockRejectedValue(error))).rejects.toBe(error); + } + }); +}); + describe('with a basic license', () => { let usageStats: UsageStats; beforeAll(async () => { diff --git a/x-pack/plugins/spaces/server/lib/spaces_usage_collector.ts b/x-pack/plugins/spaces/server/lib/spaces_usage_collector.ts index eb6843cfe4538..af77f2d3a72ba 100644 --- a/x-pack/plugins/spaces/server/lib/spaces_usage_collector.ts +++ b/x-pack/plugins/spaces/server/lib/spaces_usage_collector.ts @@ -50,31 +50,40 @@ async function getSpacesUsage( const knownFeatureIds = features.getFeatures().map(feature => feature.id); - const resp = await callCluster('search', { - index: kibanaIndex, - body: { - track_total_hits: true, - query: { - term: { - type: { - value: 'space', + let resp: SpacesAggregationResponse | undefined; + try { + resp = await callCluster('search', { + index: kibanaIndex, + body: { + track_total_hits: true, + query: { + term: { + type: { + value: 'space', + }, }, }, - }, - aggs: { - disabledFeatures: { - terms: { - field: 'space.disabledFeatures', - include: knownFeatureIds, - size: knownFeatureIds.length, + aggs: { + disabledFeatures: { + terms: { + field: 'space.disabledFeatures', + include: knownFeatureIds, + size: knownFeatureIds.length, + }, }, }, + size: 0, }, - size: 0, - }, - }); + }); + } catch (err) { + if (err.status === 404) { + return {} as UsageStats; + } + + throw err; + } - const { hits, aggregations } = resp; + const { hits, aggregations } = resp!; const count = get(hits, 'total.value', 0); const disabledFeatureBuckets = get(aggregations, 'disabledFeatures.buckets', []); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index a59a6dbf12566..bb488c0a7b1fb 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -6385,10 +6385,8 @@ "xpack.infra.homePage.noMetricsIndicesTitle": "メトリックインデックスがないようです。", "xpack.infra.homePage.settingsTabTitle": "設定", "xpack.infra.homePage.toolbar.kqlSearchFieldPlaceholder": "インフラストラクチャーデータを検索… (例: host.name:host-1)", - "xpack.infra.infrastructureDescription": "インフラストラクチャーを閲覧します", "xpack.infra.infrastructureMetricsExplorerPage.documentTitle": "{previousTitle} | メトリックエクスプローラー", "xpack.infra.infrastructureSnapshotPage.documentTitle": "{previousTitle} | インベントリ", - "xpack.infra.infrastructureTitle": "メトリック", "xpack.infra.kibanaMetrics.cloudIdMissingErrorMessage": "{metricId} のモデルには cloudId が必要ですが、{nodeId} に cloudId が指定されていません。", "xpack.infra.kibanaMetrics.invalidInfraMetricErrorMessage": "{id} は有効な InfraMetric ではありません", "xpack.infra.kibanaMetrics.nodeDoesNotExistErrorMessage": "{nodeId} が存在しません。", @@ -6398,10 +6396,6 @@ "xpack.infra.legendControls.maxLabel": "最高", "xpack.infra.legendControls.minLabel": "最低", "xpack.infra.legendControls.switchLabel": "自動計算範囲", - "xpack.infra.linkInfrastructureDescription": "インフラストラクチャーを閲覧します", - "xpack.infra.linkInfrastructureTitle": "メトリック", - "xpack.infra.linkLogsDescription": "ログを閲覧します", - "xpack.infra.linkLogsTitle": "ログ", "xpack.infra.linkTo.hostWithIp.error": "IP アドレス「{hostIp}」でホストが見つかりません.", "xpack.infra.linkTo.hostWithIp.loading": "IP アドレス「{hostIp}」のホストを読み込み中", "xpack.infra.logEntryActionsMenu.apmActionLabel": "APMで表示", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index dbc9cab4261d8..402ddd8288830 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -6384,10 +6384,8 @@ "xpack.infra.homePage.noMetricsIndicesTitle": "似乎您没有任何指标索引。", "xpack.infra.homePage.settingsTabTitle": "设置", "xpack.infra.homePage.toolbar.kqlSearchFieldPlaceholder": "搜索基础设施数据……(例如 host.name:host-1)", - "xpack.infra.infrastructureDescription": "浏览您的基础设施", "xpack.infra.infrastructureMetricsExplorerPage.documentTitle": "{previousTitle} | 指标浏览器", "xpack.infra.infrastructureSnapshotPage.documentTitle": "{previousTitle} | 库存", - "xpack.infra.infrastructureTitle": "指标", "xpack.infra.kibanaMetrics.cloudIdMissingErrorMessage": "{metricId} 的模型需要云 ID,但没有为 {nodeId} 提供。", "xpack.infra.kibanaMetrics.invalidInfraMetricErrorMessage": "{id} 不是有效的 InfraMetric", "xpack.infra.kibanaMetrics.nodeDoesNotExistErrorMessage": "{nodeId} 不存在。", @@ -6397,10 +6395,6 @@ "xpack.infra.legendControls.maxLabel": "最大值", "xpack.infra.legendControls.minLabel": "最小值", "xpack.infra.legendControls.switchLabel": "自动计算范围", - "xpack.infra.linkInfrastructureDescription": "浏览您的基础设施", - "xpack.infra.linkInfrastructureTitle": "指标", - "xpack.infra.linkLogsDescription": "浏览您的日志", - "xpack.infra.linkLogsTitle": "鏃ュ織", "xpack.infra.linkTo.hostWithIp.error": "未找到 IP 地址为“{hostIp}”的主机。", "xpack.infra.linkTo.hostWithIp.loading": "正在加载 IP 地址为“{hostIp}”的主机。", "xpack.infra.logEntryActionsMenu.apmActionLabel": "在 APM 中查看", diff --git a/x-pack/plugins/triggers_actions_ui/README.md b/x-pack/plugins/triggers_actions_ui/README.md new file mode 100644 index 0000000000000..c6a7808356b86 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/README.md @@ -0,0 +1,1200 @@ +# Kibana Alerts and Actions UI + +The Kibana alerts and actions UI plugin provides a user interface for managing alerts and actions. +As a developer you can reuse and extend built-in alerts and actions UI functionality: + +- Create and register a new Alert Type. +- Create and register a new Action Type. +- Embed the Create Alert flyout within any Kibana plugin. + +To enable Alerts and Actions UIs, the following configuration settings are needed: +``` +xpack.triggers_actions_ui.enabled: true +xpack.triggers_actions_ui.createAlertUiEnabled: true +``` + +----- + + +Table of Contents + +- [Kibana Alerts and Actions UI](#kibana-alerts-and-actions-ui) + - [Build and register Alert Types](#build-and-register-alert-types) + - [Built-in Alert Types](#built-in-alert-types) + - [Index Threshold Alert](#index-threshold-alert) + - [Alert type model definition](#alert-type-model-definition) + - [Register alert type model](#register-alert-type-model) + - [Create and register new alert type UI example](#create-and-register-new-alert-type-ui-example) + - [Common expression components](#common-expression-components) + - [WHEN expression component](#when-expression-component) + - [OF expression component](#of-expression-component) + - [GROUPED BY expression component](#grouped-by-expression-component) + - [FOR THE LAST expression component](#for-the-last-expression-component) + - [THRESHOLD expression component](#threshold-expression-component) + - [Embed the Create Alert flyout within any Kibana plugin](#embed-the-create-alert-flyout-within-any-kibana-plugin) + - [Build and register Action Types](#build-and-register-action-types) + - [Built-in Action Types](#built-in-action-types) + - [Server log](#server-log) + - [Email](#email) + - [Slack](#slack) + - [Index](#index) + - [Webhook](#webhook) + - [PagerDuty](#pagerduty) + - [Action type model definition](#action-type-model-definition) + - [Register action type model](#register-action-type-model) + - [Create and register new action type UI example](#reate-and-register-new-action-type-ui-example) + +## Built-in Alert Types + +Kibana ships with several built-in alert types: + +|Type|Id|Description| +|---|---|---| +|[Index Threshold](#index-threshold-alert)|`threshold`|Index Threshold Alert| + +Every alert type must be registered server side, and can optionally be registered client side. +Only alert types registered on both client and server will be displayed in the Create Alert flyout, as a part of the UI. +Built-in alert types UI are located under the folder `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types` +and this is a file `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/index.ts` for client side registration. + +### Index Threshold Alert + +ID: `threshold` + +In the Kibana UI, this alert type is available as a select card on the Create Alert flyout: +![Index Threshold select card](https://i.imgur.com/a0bqLwC.png) + +AlertTypeModel: + +``` +export function getAlertType(): AlertTypeModel { + return { + id: 'threshold', + name: 'Index Threshold', + iconClass: 'alert', + alertParamsExpression: IndexThresholdAlertTypeExpression, + validate: validateAlertType, + }; +} +``` + +alertParamsExpression form represented as an expression using `EuiExpression` components: +![Index Threshold Alert expression form](https://i.imgur.com/Ysk1ljY.png) + +``` +interface IndexThresholdProps { + alertParams: IndexThresholdAlertParams; + setAlertParams: (property: string, value: any) => void; + setAlertProperty: (key: string, value: any) => void; + errors: { [key: string]: string[] }; + alertsContext: AlertsContextValue; +} +``` + +|Property|Description| +|---|---| +|alertParams|Set of Alert params relevant for the index threshold alert type.| +|setAlertParams|Alert reducer method, which is used to create a new copy of alert object with the changed params property any subproperty value.| +|setAlertProperty|Alert reducer method, which is used to create a new copy of alert object with the changed any direct alert property value.| +|errors|Alert level errors tracking object.| +|alertsContext|Alert context, which is used to pass down common objects like http client.| + + +Alert reducer is defined on the AlertAdd functional component level and passed down to the subcomponents to provide a new state of Alert object: + +``` +const [{ alert }, dispatch] = useReducer(alertReducer, { alert: initialAlert }); + +... + +const setAlertProperty = (key: string, value: any) => { + dispatch({ command: { type: 'setProperty' }, payload: { key, value } }); + }; + + const setAlertParams = (key: string, value: any) => { + dispatch({ command: { type: 'setAlertParams' }, payload: { key, value } }); + }; + + const setScheduleProperty = (key: string, value: any) => { + dispatch({ command: { type: 'setScheduleProperty' }, payload: { key, value } }); + }; + + const setActionParamsProperty = (key: string, value: any, index: number) => { + dispatch({ command: { type: 'setAlertActionParams' }, payload: { key, value, index } }); + }; + + const setActionProperty = (key: string, value: any, index: number) => { + dispatch({ command: { type: 'setAlertActionProperty' }, payload: { key, value, index } }); + }; + +``` + +'x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_reducer.ts' define the methods for changing different type of alert properties: +``` +export const alertReducer = (state: any, action: AlertReducerAction) => { + const { command, payload } = action; + const { alert } = state; + + switch (command.type) { + // create a new alert state with a new alert value + case 'setAlert': { + .... + // create a new alert state with set new value to one alert property by key + case 'setProperty': { + .... + // create a new alert state with set new value to any subproperty for a 'schedule' alert property + case 'setScheduleProperty': { + .... + // create a new alert state with set new value to action subproperty by index from the array of alert actions + case 'setAlertActionParams': { // + .... + // create a new alert state with set new value to any subproperty for a 'params' alert property + case 'setAlertParams': { + const { key, value } = payload; + if (isEqual(alert.params[key], value)) { + return state; + } else { + return { + ...state, + alert: { + ...alert, + params: { + ...alert.params, + [key]: value, + }, + }, + }; + } + } + // create a new alert state with add or remove action from alert actions array + case 'setAlertActionProperty': { + .... + } + } + +``` + + +``` +export const IndexThresholdAlertTypeExpression: React.FunctionComponent = ({ + alertParams, + setAlertParams, + setAlertProperty, + errors, + alertsContext, +}) => { + + .... + + // expression validation + const hasExpressionErrors = !!Object.keys(errors).find( + errorKey => + expressionFieldsWithValidation.includes(errorKey) && + errors[errorKey].length >= 1 && + (alertParams as { [key: string]: any })[errorKey] !== undefined + ); + + .... + + // loading indeces and set default expression values + useEffect(() => { + getIndexPatterns(); + }, []); + + useEffect(() => { + setDefaultExpressionValues(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + .... + + return ( + + {hasExpressionErrors ? ( + + + + + + ) : null} + + + + .... + + ); +}; +``` + +Index Threshold Alert form with validation: +![Index Threshold Alert validation](https://i.imgur.com/TV8c7hL.png) + +## Alert type model definition + +Each alert type should be defined as `AlertTypeModel` object with the these properties: +``` + id: string; + name: string; + iconClass: string; + validate: (alertParams: any) => ValidationResult; + alertParamsExpression: React.FunctionComponent; + defaultActionMessage?: string; +``` +|Property|Description| +|---|---| +|id|Alert type id. Should be the same as on the server side.| +|name|Name of the alert type that will be displayed on the select card in the UI.| +|iconClass|Icon of the alert type that will be displayed on the select card in the UI.| +|validate|Validation function for the alert params.| +|alertParamsExpression|React functional component for building UI of the current alert type params.| +|defaultActionMessage|Optional property for providing default message for all added actions with `message` property.| + +IMPORTANT: The current UI supports a single action group only. +Action groups are mapped from the server API result for [GET /api/alert/types: List alert types](https://github.com/elastic/kibana/tree/master/x-pack/legacy/plugins/alerting#get-apialerttypes-list-alert-types). +Server side alert type model: +``` +export interface AlertType { + id: string; + name: string; + validate?: { + params?: { validate: (object: any) => any }; + }; + actionGroups: string[]; + executor: ({ services, params, state }: AlertExecutorOptions) => Promise; +} +``` +Only the default (which means first item of the array) action group is displayed in the current UI. +Design of user interface and server API for multiple action groups is under discussion and development. + +## Register alert type model + +There are two ways of registering a new alert type: + +1. Directly in the `triggers_actions_ui` plugin. In this case, the alert type will be available in the Create Alert flyout of the Alerts and Actions management section. +Registration code for a new alert type model should be added to the file `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/index.ts` +Only registered alert types are available in UI. + +2. Register the alert type in another plugin. In this case, the alert type will be available only in the current plugin UI. +It should be done by importing dependency `TriggersAndActionsUIPublicPluginSetup` and adding the next code on plugin setup: + +``` +function getSomeNewAlertType() { + return { ... } as AlertTypeModel; +} + +triggers_actions_ui.alertTypeRegistry.register(getSomeNewAlertType()); +``` + +## Create and register new alert type UI example + +Before registering a UI for a new Alert Type, you should first register the type on the server-side by following the Alerting guide: https://github.com/elastic/kibana/tree/master/x-pack/legacy/plugins/alerting#example + +Alert type UI is expected to be defined as `AlertTypeModel` object. + +Below is a list of steps that should be done to build and register a new alert type with the name `Example Alert Type`: + +1. At any suitable place in Kibana, create a file, which will expose an object implementing interface [AlertTypeModel](https://github.com/elastic/kibana/blob/55b7905fb5265b73806006e7265739545d7521d0/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/types.ts#L83). Example: +``` +import { AlertTypeModel } from '../../../../types'; +import { ExampleExpression } from './expression'; +import { validateExampleAlertType } from './validation'; + +export function getAlertType(): AlertTypeModel { + return { + id: 'example', + name: 'Example Alert Type', + iconClass: 'bell', + alertParamsExpression: ExampleExpression, + validate: validateExampleAlertType, + defaultActionMessage: 'Alert [{{ctx.metadata.name}}] has exceeded the threshold', + }; +} +``` +Fields of this object `AlertTypeModel` will be mapped properly in the UI below. + +2. Define `alertParamsExpression` as `React.FunctionComponent` - this is the form for filling Alert params based on the current Alert type. +``` +import React, { Fragment, useState } from 'react'; +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { WhenExpression, OfExpression } from '../../../../common/expression_items'; +import { builtInAggregationTypes } from '../../../../common/constants'; + +interface ExampleProps { + testAggType?: string; + testAggField?: string; + errors: { [key: string]: string[] }; +} + +export const ExampleExpression: React.FunctionComponent = ({ + testAggType, + testAggField, + errors, +}) => { + const [aggType, setAggType] = useState('count'); + return ( + + + + { + console.log(`Set alert type params field "aggType" value as ${selectedAggType}`); + setAggType(selectedAggType); + }} + /> + + {aggType && builtInAggregationTypes[aggType].fieldRequired ? ( + + + console.log(`Set alert type params field "aggField" value as ${selectedAggField}`) + } + /> + + ) : null} + + + ); +}; + +``` +This alert type form becomes available, when the card of `Example Alert Type` is selected. +Each expression word here is `EuiExpression` component and implements the basic aggregation, grouping and comparison methods. +Expression components, which can be embedded to different alert types, are described here [Common expression components](#common-expression-components). + +3. Define alert type params validation using the property of `AlertTypeModel` `validate`: +``` +import { i18n } from '@kbn/i18n'; +import { ValidationResult } from '../../../../types'; + +export function validateExampleAlertType({ + testAggField, +}: { + testAggField: string; +}): ValidationResult { + const validationResult = { errors: {} }; + const errors = { + aggField: new Array(), + }; + validationResult.errors = errors; + if (!testAggField) { + errors.aggField.push( + i18n.translate('xpack.triggersActionsUI.components.example.error.requiredTestAggFieldText', { + defaultMessage: 'Test aggregation field is required.', + }) + ); + } + return validationResult; +} +``` + +4. Extend registration code with the new alert type register in the file `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/index.ts` +``` +import { getAlertType as getExampledAlertType } from './example'; +... + +... +alertTypeRegistry.register(getExampledAlertType()); +``` + +After these four steps, the new `Example Alert Type` is available in UI of Create flyout: +![Example Alert Type is in the select cards list](https://i.imgur.com/j71AEQV.png) + +Click on the select card for `Example Alert Type` to open the expression form that was created in step 2: +![Example Alert Type expression with validation](https://i.imgur.com/Z0jIwCS.png) + +## Common expression components + +### WHEN expression component + +![WHEN](https://i.imgur.com/7bYlxXK.png) + +``` + + setAlertParams('aggType', selectedAggType) + } +/> +``` + +Props definition: +``` +interface WhenExpressionProps { + aggType: string; + customAggTypesOptions?: { [key: string]: AggregationType }; + onChangeSelectedAggType: (selectedAggType: string) => void; + popupPosition?: 'upCenter' | 'upLeft' | 'upRight' | 'downCenter' | 'downLeft' + | 'downRight' | 'leftCenter' | 'leftUp' | 'leftDown' | 'rightCenter' | 'rightUp' | 'rightDown'; +} +``` + +|Property|Description| +|---|---| +|aggType|Selected aggregation type that will be set as the alert type property.| +|customAggTypesOptions|(Optional) List of aggregation types that replaces the default options defined in constants `x-pack/plugins/triggers_actions_ui/public/common/constants/aggregation_types.ts`.| +|onChangeSelectedAggType|event handler that will be executed when selected aggregation type is changed.| +|popupPosition|(Optional) expression popup position. Default is `downLeft`. Recommend changing it for a small parent window space.| + +### OF expression component + +![OF](https://i.imgur.com/4MC8Kbb.png) + +OF expression is available, if aggregation type requires selecting data fields for aggregating. + +``` + + setAlertParams('aggField', selectedAggField) + } +/> +``` + +Props definition: +``` +interface OfExpressionProps { + aggType: string; + aggField?: string; + errors: { [key: string]: string[] }; + onChangeSelectedAggField: (selectedAggType?: string) => void; + fields: Record; + customAggTypesOptions?: { + [key: string]: AggregationType; + }; + popupPosition?: 'upCenter' | 'upLeft' | 'upRight' | 'downCenter' | 'downLeft' + | 'downRight' | 'leftCenter' | 'leftUp' | 'leftDown' | 'rightCenter' | 'rightUp' | 'rightDown'; +} +``` + +|Property|Description| +|---|---| +|aggType|Selected aggregation type that will be set as the alert type property.| +|aggField|Selected aggregation field that will be set as the alert type property.| +|errors|List of errors with proper messages for the alert params that should be validated. In current component is validated `aggField`.| +|onChangeSelectedAggField|Event handler that will be excuted if selected aggregation field is changed.| +|fields|Fields list that will be available in the OF `Select a field` dropdown.| +|customAggTypesOptions|(Optional) List of aggregation types that replaces the default options defined in constants `x-pack/plugins/triggers_actions_ui/public/common/constants/aggregation_types.ts`.| +|popupPosition|(Optional) expression popup position. Default is `downRight`. Recommend changing it for a small parent window space.| + +### GROUPED BY expression component + +![GROUPED BY](https://i.imgur.com/eej7WIw.png) + +``` + setAlertParams('groupBy', selectedGroupBy)} + onChangeSelectedTermField={selectedTermField => + setAlertParams('termField', selectedTermField) + } + onChangeSelectedTermSize={selectedTermSize => + setAlertParams('termSize', selectedTermSize) + } +/> +``` + +Props definition: +``` +interface GroupByExpressionProps { + groupBy: string; + termSize?: number; + termField?: string; + errors: { [key: string]: string[] }; + onChangeSelectedTermSize: (selectedTermSize?: number) => void; + onChangeSelectedTermField: (selectedTermField?: string) => void; + onChangeSelectedGroupBy: (selectedGroupBy?: string) => void; + fields: Record; + customGroupByTypes?: { + [key: string]: GroupByType; + }; + popupPosition?: 'upCenter' | 'upLeft' | 'upRight' | 'downCenter' | 'downLeft' + | 'downRight' | 'leftCenter' | 'leftUp' | 'leftDown' | 'rightCenter' | 'rightUp' | 'rightDown'; +} +``` + +|Property|Description| +|---|---| +|groupBy|Selected group by type that will be set as the alert type property.| +|termSize|Selected term size that will be set as the alert type property.| +|termField|Selected term field that will be set as the alert type property.| +|errors|List of errors with proper messages for the alert params that should be validated. In current component is validated `termSize` and `termField`.| +|onChangeSelectedTermSize|Event handler that will be excuted if selected term size is changed.| +|onChangeSelectedTermField|Event handler that will be excuted if selected term field is changed.| +|onChangeSelectedGroupBy|Event handler that will be excuted if selected group by is changed.| +|fields|Fields list with options for the `termField` dropdown.| +|customGroupByTypes|(Optional) List of group by types that replaces the default options defined in constants `x-pack/plugins/triggers_actions_ui/public/common/constants/group_by_types.ts`.| +|popupPosition|(Optional) expression popup position. Default is `downLeft`. Recommend changing it for a small parent window space.| + +### FOR THE LAST expression component + +![FOR THE LAST](https://i.imgur.com/vYJTo8F.png) + +``` + + setAlertParams('timeWindowSize', selectedWindowSize) + } + onChangeWindowUnit={(selectedWindowUnit: any) => + setAlertParams('timeWindowUnit', selectedWindowUnit) + } +/> +``` + +Props definition: +``` +interface ForLastExpressionProps { + timeWindowSize?: number; + timeWindowUnit?: string; + errors: { [key: string]: string[] }; + onChangeWindowSize: (selectedWindowSize: number | '') => void; + onChangeWindowUnit: (selectedWindowUnit: string) => void; + popupPosition?: 'upCenter' | 'upLeft' | 'upRight' | 'downCenter' | 'downLeft' + | 'downRight' | 'leftCenter' | 'leftUp' | 'leftDown' | 'rightCenter' | 'rightUp' | 'rightDown'; +} +``` + +|Property|Description| +|---|---| +|timeWindowSize|Selected time window size that will be set as the alert type property.| +|timeWindowUnit|Selected time window unit that will be set as the alert type property.| +|errors|List of errors with proper messages for the alert params that should be validated. In current component is validated `termWindowSize`.| +|onChangeWindowSize|Event handler that will be excuted if selected window size is changed.| +|onChangeWindowUnit|Event handler that will be excuted if selected window unit is changed.| +|popupPosition|(Optional) expression popup position. Default is `downLeft`. Recommend changing it for a small parent window space.| + +### THRESHOLD expression component + +![THRESHOLD](https://i.imgur.com/B92ZcT8.png) + +``` + + setAlertParams('threshold', selectedThresholds) + } + onChangeSelectedThresholdComparator={selectedThresholdComparator => + setAlertParams('thresholdComparator', selectedThresholdComparator) + } +/> +``` + +Props definition: +``` +interface ThresholdExpressionProps { + thresholdComparator: string; + errors: { [key: string]: string[] }; + onChangeSelectedThresholdComparator: (selectedThresholdComparator?: string) => void; + onChangeSelectedThreshold: (selectedThreshold?: number[]) => void; + customComparators?: { + [key: string]: Comparator; + }; + threshold?: number[]; + popupPosition?: 'upCenter' | 'upLeft' | 'upRight' | 'downCenter' | 'downLeft' + | 'downRight' | 'leftCenter' | 'leftUp' | 'leftDown' | 'rightCenter' | 'rightUp' | 'rightDown'; +} +``` + +|Property|Description| +|---|---| +|thresholdComparator|Selected time window size that will be set as the alert type property.| +|threshold|Selected time window size that will be set as the alert type property.| +|errors|List of errors with proper messages for the alert params that should be validated. In current component is validated `threshold0` and `threshold1`.| +|onChangeSelectedThresholdComparator|Event handler that will be excuted if selected threshold comparator is changed.| +|onChangeSelectedThreshold|Event handler that will be excuted if selected threshold is changed.| +|customComparators|(Optional) List of comparators that replaces the default options defined in constants `x-pack/plugins/triggers_actions_ui/public/common/constants/comparators.ts`.| +|popupPosition|(Optional) expression popup position. Default is `downLeft`. Recommend changing it for a small parent window space.| + +## Embed the Create Alert flyout within any Kibana plugin + +Follow the instructions bellow to embed the Create Alert flyout within any Kibana plugin: +1. Add TriggersAndActionsUIPublicPluginSetup to Kibana plugin setup dependencies: + +``` +triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup; +``` +Then this dependency will be used to embed Create Alert flyout or register new alert/action type. + +2. Add Create Alert flyout to React component: +``` +// import section +import { AlertsContextProvider, AlertAdd } from '../../../../../../../triggers_actions_ui/public'; + +// in the component state definition section +const [alertFlyoutVisible, setAlertFlyoutVisibility] = useState(false); + +// UI control item for open flyout + setAlertFlyoutVisibility(true)} +> + + + +// in render section of component + + + +``` + +AlertAdd Props definition: +``` +interface AlertAddProps { + consumer: string; + alertTypeId?: string; + canChangeTrigger?: boolean; +} +``` + +|Property|Description| +|---|---| +|consumer|Name of the plugin that creates an alert.| +|alertTypeId|Optional property to preselect alert type.| +|canChangeTrigger|Optional property, that hides change alert type possibility.| + +AlertsContextProvider value options: +``` +export interface AlertsContextValue { + addFlyoutVisible: boolean; + setAddFlyoutVisibility: React.Dispatch>; + reloadAlerts?: () => Promise; + http: HttpSetup; + alertTypeRegistry: TypeRegistry; + actionTypeRegistry: TypeRegistry; + uiSettings?: IUiSettingsClient; + toastNotifications?: Pick< + ToastsApi, + 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' + >; + charts?: ChartsPluginSetup; + dataFieldsFormats?: Pick; +} +``` + +|Property|Description| +|---|---| +|addFlyoutVisible|Visibility state of the Create Alert flyout.| +|setAddFlyoutVisibility|Function for changing visibility state of the Create Alert flyout.| +|reloadAlerts|Optional function, which will be executed if alert was saved sucsessfuly.| +|http|HttpSetup needed for executing API calls.| +|alertTypeRegistry|Registry for alert types.| +|actionTypeRegistry|Registry for action types.| +|uiSettings|Optional property, which is needed to display visualization of alert type expression. Will be changed after visualization refactoring.| +|toastNotifications|Optional toast messages.| +|charts|Optional property, which is needed to display visualization of alert type expression. Will be changed after visualization refactoring.| +|dataFieldsFormats|Optional property, which is needed to display visualization of alert type expression. Will be changed after visualization refactoring.| + +## Build and register Action Types + +Kibana ships with a set of built-in action types UI: + +|Type|Id|Description| +|---|---|---| +|[Server log](#server-log)|`.log`|Logs messages to the Kibana log using `server.log()`| +|[Email](#email)|`.email`|Sends an email using SMTP| +|[Slack](#slack)|`.slack`|Posts a message to a Slack channel| +|[Index](#index)|`.index`|Indexes document(s) into Elasticsearch| +|[Webhook](#webhook)|`.webhook`|Sends a payload to a web service using HTTP POST or PUT| +|[PagerDuty](#pagerduty)|`.pagerduty`|Triggers, resolves, or acknowledges an incident to a PagerDuty service| + +Every action type should be registered server side, and can be optionally registered client side. +Only action types registered on both client and server will be displayed in the Alerts and Actions UI. +Built-in action types UI is located under the folder `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types` +and this is a file `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/index.ts` for client side registration. + + +### Server log + +Action type model definition: +``` +export function getActionType(): ActionTypeModel { + return { + id: '.server-log', + iconClass: 'logsApp', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.serverLogAction.selectMessageText', + { + defaultMessage: 'Add a message to a Kibana log.', + } + ), + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.serverLogAction.actionTypeTitle', + { + defaultMessage: 'Send to Server log', + } + ), + validateConnector: (): ValidationResult => { + return { errors: {} }; + }, + validateParams: (actionParams: ServerLogActionParams): ValidationResult => { + // validation of action params implementation + }, + actionConnectorFields: null, + actionParamsFields: ServerLogParamsFields, + }; +} +``` +Server log has a connector UI: + +![Server log connector card](https://i.imgur.com/ZIWhV89.png) + +![Server log connector form](https://i.imgur.com/rkc3U59.png) + +and action params form available in Create Alert form: +![Server log action form](https://i.imgur.com/c0ds76T.png) + +### Email + +Action type model definition: +``` +export function getActionType(): ActionTypeModel { + const mailformat = /^[^@\s]+@[^@\s]+$/; + return { + id: '.email', + iconClass: 'email', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.emailAction.selectMessageText', + { + defaultMessage: 'Send email from your server.', + } + ), + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.emailAction.actionTypeTitle', + { + defaultMessage: 'Send to email', + } + ), + validateConnector: (action: EmailActionConnector): ValidationResult => { + // validation of connector properties implementation + }, + validateParams: (actionParams: EmailActionParams): ValidationResult => { + // validation of action params implementation + }, + actionConnectorFields: EmailActionConnectorFields, + actionParamsFields: EmailParamsFields, + }; +} +``` +![Email connector card](https://i.imgur.com/d8kCbjQ.png) + +![Email connector form](https://i.imgur.com/Uf6HU7X.png) + +and action params form available in Create Alert form: +![Email action form](https://i.imgur.com/lhkUEHf.png) + +### Slack + +Action type model definition: +``` +export function getActionType(): ActionTypeModel { + return { + id: '.slack', + iconClass: 'logoSlack', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.slackAction.selectMessageText', + { + defaultMessage: 'Send a message to a Slack channel or user.', + } + ), + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.slackAction.actionTypeTitle', + { + defaultMessage: 'Send to Slack', + } + ), + validateConnector: (action: SlackActionConnector): ValidationResult => { + // validation of connector properties implementation + }, + validateParams: (actionParams: SlackActionParams): ValidationResult => { + // validation of action params implementation + }, + actionConnectorFields: SlackActionFields, + actionParamsFields: SlackParamsFields, + }; +} +``` + +![Slack connector card](https://i.imgur.com/JbvmNOy.png) + +![Slack connector form](https://i.imgur.com/IqdnmF9.png) + +and action params form available in Create Alert form: +![Slack action form](https://i.imgur.com/GUEVZWK.png) + +### Index + +Action type model definition: +``` +export function getActionType(): ActionTypeModel { + return { + id: '.index', + iconClass: 'indexOpen', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.indexAction.selectMessageText', + { + defaultMessage: 'Index data into Elasticsearch.', + } + ), + validateConnector: (): ValidationResult => { + return { errors: {} }; + }, + actionConnectorFields: IndexActionConnectorFields, + actionParamsFields: IndexParamsFields, + validateParams: (): ValidationResult => { + return { errors: {} }; + }, + }; +} +``` + +![Index connector card](https://i.imgur.com/fflsmu5.png) + +![Index connector form](https://i.imgur.com/tbgyvAL.png) + +and action params form available in Create Alert form: +![Index action form](https://i.imgur.com/VsWMLeU.png) + +### Webhook + +Action type model definition: +``` +export function getActionType(): ActionTypeModel { + return { + id: '.webhook', + iconClass: 'logoWebhook', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.webhookAction.selectMessageText', + { + defaultMessage: 'Send a request to a web service.', + } + ), + validateConnector: (action: WebhookActionConnector): ValidationResult => { + // validation of connector properties implementation + }, + validateParams: (actionParams: WebhookActionParams): ValidationResult => { + // validation of action params implementation + }, + actionConnectorFields: WebhookActionConnectorFields, + actionParamsFields: WebhookParamsFields, + }; +} +``` + +![Webhook connector card](https://i.imgur.com/IBgn75T.png) + +![Webhook connector form](https://i.imgur.com/xqORAJ7.png) + +and action params form available in Create Alert form: +![Webhook action form](https://i.imgur.com/mBGfeuC.png) + + +### PagerDuty + +Action type model definition: +``` +export function getActionType(): ActionTypeModel { + return { + id: '.pagerduty', + iconClass: 'apps', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.selectMessageText', + { + defaultMessage: 'Send an event in PagerDuty.', + } + ), + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.actionTypeTitle', + { + defaultMessage: 'Send to PagerDuty', + } + ), + validateConnector: (action: PagerDutyActionConnector): ValidationResult => { + // validation of connector properties implementation + }, + validateParams: (actionParams: PagerDutyActionParams): ValidationResult => { + // validation of action params implementation + }, + actionConnectorFields: PagerDutyActionConnectorFields, + actionParamsFields: PagerDutyParamsFields, + }; +} +``` + +![PagerDuty connector card](https://i.imgur.com/Br8MuKG.png) + +![PagerDuty connector form](https://i.imgur.com/DZpCfRv.png) + +and action params form available in Create Alert form: +![PagerDuty action form](https://i.imgur.com/xxXmhMK.png) + +## Action type model definition + +Each action type should be defined as an `ActionTypeModel` object with the following properties: +``` + id: string; + iconClass: string; + selectMessage: string; + actionTypeTitle?: string; + validateConnector: (connector: any) => ValidationResult; + validateParams: (actionParams: any) => ValidationResult; + actionConnectorFields: React.FunctionComponent | null; + actionParamsFields: any; +``` +|Property|Description| +|---|---| +|id|Action type id. Should be the same as on server side.| +|iconClass|Icon of action type, that will be displayed on the select card in UI.| +|selectMessage|Short description of action type responsibility, that will be displayed on the select card in UI.| +|validateConnector|Validation function for action connector.| +|validateParams|Validation function for action params.| +|actionConnectorFields|React functional component for building UI of current action type connector.| +|actionParamsFields|React functional component for building UI of current action type params. Displayed as a part of Create Alert flyout.| + +## Register action type model + +There are two ways to register a new action type UI: + +1. Directly in `triggers_actions_ui` plugin. In this case, the action type will be available in the Alerts and Actions management section. +Registration code for a new action type model should be added to the file `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/index.ts` +Only registered action types are available in UI. + +2. Register action type in another plugin. In this case, the action type will be available only in the current plugin UI. +It should be done by importing dependency `TriggersAndActionsUIPublicPluginSetup` and adding the next code on plugin setup: + +``` +function getSomeNewActionType() { + return { ... } as ActionTypeModel; +} + +triggers_actions_ui.actionTypeRegistry.register(getSomeNewActionType()); +``` + +## Create and register new action type UI + +Before starting the UI implementation, the [server side registration](https://github.com/elastic/kibana/tree/master/x-pack/plugins/actions#kibana-actions-configuration) should be done first. + +Action type UI is expected to be defined as `ActionTypeModel` object. + +Below is a list of steps that should be done to build and register a new action type with the name `Example Action Type`: + +1. At any suitable place in Kibana, create a file, which will expose an object implementing interface [ActionTypeModel]: +``` +import React, { Fragment } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + ActionTypeModel, + ValidationResult, + ActionConnectorFieldsProps, + ActionParamsProps, +} from '../../../types'; + +interface ExampleActionParams { + message: string; +} + +export function getActionType(): ActionTypeModel { + return { + id: '.example-action', + iconClass: 'logoGmail', + selectMessage: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.exampleAction.selectMessageText', + { + defaultMessage: 'Example Action is used to show how to create new action type UI.', + } + ), + actionTypeTitle: i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.exampleAction.actionTypeTitle', + { + defaultMessage: 'Example Action', + } + ), + validateConnector: (action: ExampleActionConnector): ValidationResult => { + const validationResult = { errors: {} }; + const errors = { + someConnectorField: new Array(), + }; + validationResult.errors = errors; + if (!action.config.someConnectorField) { + errors.someConnectorField.push( + i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredSomeConnectorFieldeText', + { + defaultMessage: 'SomeConnectorField is required.', + } + ) + ); + } + return validationResult; + }, + validateParams: (actionParams: ExampleActionParams): ValidationResult => { + const validationResult = { errors: {} }; + const errors = { + message: new Array(), + }; + validationResult.errors = errors; + if (!actionParams.message?.length) { + errors.message.push( + i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.error.requiredExampleMessageText', + { + defaultMessage: 'Message is required.', + } + ) + ); + } + return validationResult; + }, + actionConnectorFields: ExampleConnectorFields, + actionParamsFields: ExampleParamsFields, + }; +} +``` + +2. Define `actionConnectorFields` as `React.FunctionComponent` - this is the form for action connector. +``` +import React, { Fragment } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiFieldText } from '@elastic/eui'; +import { EuiTextArea } from '@elastic/eui'; +import { + ActionTypeModel, + ValidationResult, + ActionConnectorFieldsProps, + ActionParamsProps, +} from '../../../types'; + +interface ExampleActionConnector { + config: { + someConnectorField: string; + }; +} + +const ExampleConnectorFields: React.FunctionComponent> = ({ action, editActionConfig, errors }) => { + const { someConnectorField } = action.config; + return ( + + 0 && someConnectorField !== undefined} + name="someConnectorField" + value={someConnectorField || ''} + onChange={e => { + editActionConfig('someConnectorField', e.target.value); + }} + onBlur={() => { + if (!someConnectorField) { + editActionConfig('someConnectorField', ''); + } + }} + /> + + ); +}; +``` + +3. Define action type params fields using the property of `ActionTypeModel` `actionParamsFields`: +``` +import React, { Fragment } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiFieldText } from '@elastic/eui'; +import { EuiTextArea } from '@elastic/eui'; +import { + ActionTypeModel, + ValidationResult, + ActionConnectorFieldsProps, + ActionParamsProps, +} from '../../../types'; + +interface ExampleActionParams { + message: string; +} + +const ExampleParamsFields: React.FunctionComponent> = ({ + actionParams, + editAction, + index, + errors, +}) => { + const { message } = actionParams; + return ( + + 0 && message !== undefined} + name="message" + value={message || ''} + onChange={e => { + editAction('message', e.target.value, index); + }} + onBlur={() => { + if (!message) { + editAction('message', '', index); + } + }} + /> + + ); +}; +``` + +4. Extend registration code with the new action type register in the file `x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/index.ts` +``` +import { getActionType as getExampledActionType } from './example'; +... + +... +actionTypeRegistry.register(getExampledActionType()); +``` + +After these four steps, the new `Example Action Type` is available in UI of Create connector: +![Example Action Type is in the select cards list](https://i.imgur.com/PTYdBos.png) + +Clicking on the select card for `Example Action Type` will open the connector form that was created in step 2: +![Example Action Type connector](https://i.imgur.com/KdxAXAs.png) + +Example Action Type is in the select cards list of Create Alert flyout: +![Example Action Type is in the select cards list of Create Alert flyout](https://i.imgur.com/CSRBkFe.png) + +Clicking on the select card for `Example Action Type` will open the action type Add Action form: +![Example Action Type with existing connectors list](https://i.imgur.com/8FA3NAW.png) + +or create a new connector: +![Example Action Type with empty connectors list](https://i.imgur.com/EamA9Xv.png) diff --git a/x-pack/test/api_integration/apis/endpoint/resolver.ts b/x-pack/test/api_integration/apis/endpoint/resolver.ts index 96d16e0d76e40..c1e9240c09951 100644 --- a/x-pack/test/api_integration/apis/endpoint/resolver.ts +++ b/x-pack/test/api_integration/apis/endpoint/resolver.ts @@ -6,24 +6,226 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; - const commonHeaders = { - Accept: 'application/json', + accept: 'application/json', 'kbn-xsrf': 'some-xsrf-token', }; // eslint-disable-next-line import/no-default-export export default function resolverAPIIntegrationTests({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - describe('Resolver api', function() { - it('should respond to hello-world', async function() { - const { body } = await supertest - .get('/api/endpoint/hello-world') - .set(commonHeaders) - .expect('Content-Type', /application\/json/) - .expect(200); - - expect(body).to.eql({ hello: 'world' }); + const esArchiver = getService('esArchiver'); + + describe('Resolver', () => { + before(() => esArchiver.load('endpoint/resolver/api_feature')); + after(() => esArchiver.unload('endpoint/resolver/api_feature')); + + describe('related events endpoint', () => { + const endpointID = '5a0c957f-b8e7-4538-965e-57e8bb86ad3a'; + const entityID = '94042'; + const cursor = 'eyJ0aW1lc3RhbXAiOjE1ODE0NTYyNTUwMDAsImV2ZW50SUQiOiI5NDA0MyJ9'; + + it('should return details for the root node', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}/related?legacyEndpointID=${endpointID}`) + .set(commonHeaders) + .expect(200); + expect(body.events.length).to.eql(1); + expect(body.pagination.next).to.eql(cursor); + expect(body.pagination.total).to.eql(1); + // default limit + expect(body.pagination.limit).to.eql(100); + }); + + it('returns no values when there is no more data', async () => { + const { body } = await supertest + // after is set to the document id of the last event so there shouldn't be any more after it + .get( + `/api/endpoint/resolver/${entityID}/related?legacyEndpointID=${endpointID}&after=${cursor}` + ) + .set(commonHeaders) + .expect(200); + expect(body.events).be.empty(); + expect(body.pagination.next).to.eql(null); + expect(body.pagination.total).to.eql(1); + }); + + it('should return the first page of information when the cursor is invalid', async () => { + const { body } = await supertest + .get( + `/api/endpoint/resolver/${entityID}/related?legacyEndpointID=${endpointID}&after=blah` + ) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(1); + expect(body.pagination.next).to.not.eql(null); + }); + + it('should error on invalid pagination values', async () => { + await supertest + .get(`/api/endpoint/resolver/${entityID}/related?limit=0`) + .set(commonHeaders) + .expect(400); + await supertest + .get(`/api/endpoint/resolver/${entityID}/related?limit=2000`) + .set(commonHeaders) + .expect(400); + await supertest + .get(`/api/endpoint/resolver/${entityID}/related?limit=-1`) + .set(commonHeaders) + .expect(400); + }); + + it('should not find any events', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/5555/related`) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(0); + expect(body.pagination.next).to.eql(null); + expect(body.events).to.be.empty(); + }); + + it('should return no results for an invalid endpoint ID', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}/related?legacyEndpointID=foo`) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(0); + expect(body.pagination.next).to.eql(null); + expect(body.events).to.be.empty(); + }); + }); + + describe('lifecycle events endpoint', () => { + const endpointID = '5a0c957f-b8e7-4538-965e-57e8bb86ad3a'; + const entityID = '94042'; + + it('should return details for the root node', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}?legacyEndpointID=${endpointID}&ancestors=5`) + .set(commonHeaders) + .expect(200); + expect(body.lifecycle.length).to.eql(2); + expect(body.ancestors.length).to.eql(1); + expect(body.pagination.next).to.eql(null); + // 5 is default parameter + expect(body.pagination.ancestors).to.eql(5); + }); + + it('should have a populated next parameter', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}?legacyEndpointID=${endpointID}`) + .set(commonHeaders) + .expect(200); + expect(body.pagination.next).to.eql('94041'); + }); + + it('should handle an ancestors param request', async () => { + let { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}?legacyEndpointID=${endpointID}`) + .set(commonHeaders) + .expect(200); + const next = body.pagination.next; + + ({ body } = await supertest + .get(`/api/endpoint/resolver/${next}?legacyEndpointID=${endpointID}&ancestors=1`) + .set(commonHeaders) + .expect(200)); + expect(body.lifecycle.length).to.eql(1); + expect(body.ancestors.length).to.eql(0); + expect(body.pagination.next).to.eql(null); + }); + + it('should handle an invalid id', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/alskdjflasj`) + .set(commonHeaders) + .expect(200); + expect(body.lifecycle.length).to.eql(0); + expect(body.ancestors.length).to.eql(0); + expect(body.pagination.next).to.eql(null); + }); + }); + + describe('children endpoint', () => { + const endpointID = '5a0c957f-b8e7-4538-965e-57e8bb86ad3a'; + const entityID = '94041'; + const cursor = 'eyJ0aW1lc3RhbXAiOjE1ODE0NTYyNTUwMDAsImV2ZW50SUQiOiI5NDA0MiJ9'; + + it('returns child process lifecycle events', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}/children?legacyEndpointID=${endpointID}`) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(1); + expect(body.pagination.next).to.eql(cursor); + // default limit + expect(body.pagination.limit).to.eql(10); + + expect(body.children.length).to.eql(1); + expect(body.children[0].lifecycle.length).to.eql(2); + expect(body.children[0].lifecycle[0].endgame.unique_pid).to.eql(94042); + }); + + it('returns no values when there is no more data', async () => { + const { body } = await supertest + // after is set to the document id of the last event so there shouldn't be any more after it + .get( + `/api/endpoint/resolver/${entityID}/children?legacyEndpointID=${endpointID}&after=${cursor}` + ) + .set(commonHeaders) + .expect(200); + expect(body.children).be.empty(); + expect(body.pagination.next).to.eql(null); + expect(body.pagination.total).to.eql(1); + }); + + it('returns the first page of information when the cursor is invalid', async () => { + const { body } = await supertest + .get( + `/api/endpoint/resolver/${entityID}/children?legacyEndpointID=${endpointID}&after=blah` + ) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(1); + expect(body.pagination.next).to.not.eql(null); + }); + + it('errors on invalid pagination values', async () => { + await supertest + .get(`/api/endpoint/resolver/${entityID}/children?limit=0`) + .set(commonHeaders) + .expect(400); + await supertest + .get(`/api/endpoint/resolver/${entityID}/children?limit=2000`) + .set(commonHeaders) + .expect(400); + await supertest + .get(`/api/endpoint/resolver/${entityID}/children?limit=-1`) + .set(commonHeaders) + .expect(400); + }); + + it('returns empty events without a matching entity id', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/5555/children`) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(0); + expect(body.pagination.next).to.eql(null); + expect(body.children).to.be.empty(); + }); + + it('returns empty events with an invalid endpoint id', async () => { + const { body } = await supertest + .get(`/api/endpoint/resolver/${entityID}/children?legacyEndpointID=foo`) + .set(commonHeaders) + .expect(200); + expect(body.pagination.total).to.eql(0); + expect(body.pagination.next).to.eql(null); + expect(body.children).to.be.empty(); + }); }); }); } diff --git a/x-pack/test/api_integration/apis/infra/ip_to_hostname.ts b/x-pack/test/api_integration/apis/infra/ip_to_hostname.ts index 5d1a519efb5b9..3821e4b5aab0e 100644 --- a/x-pack/test/api_integration/apis/infra/ip_to_hostname.ts +++ b/x-pack/test/api_integration/apis/infra/ip_to_hostname.ts @@ -6,7 +6,6 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { IpToHostResponse } from '../../../../legacy/plugins/infra/server/routes/ip_to_hostname'; export default function ipToHostNameTest({ getService }: FtrProviderContext) { const supertest = getService('supertest'); @@ -27,8 +26,7 @@ export default function ipToHostNameTest({ getService }: FtrProviderContext) { .send(postBody) .expect(200); - const body: IpToHostResponse = response.body; - expect(body).to.have.property('host', 'demo-stack-mysql-01'); + expect(response.body).to.have.property('host', 'demo-stack-mysql-01'); }); it('should return 404 for invalid ip', async () => { diff --git a/x-pack/test/api_integration/apis/infra/log_analysis.ts b/x-pack/test/api_integration/apis/infra/log_analysis.ts index 2e57678d1d4c2..2f27b5d5b7021 100644 --- a/x-pack/test/api_integration/apis/infra/log_analysis.ts +++ b/x-pack/test/api_integration/apis/infra/log_analysis.ts @@ -13,11 +13,8 @@ import { LOG_ANALYSIS_GET_LOG_ENTRY_RATE_PATH, getLogEntryRateRequestPayloadRT, getLogEntryRateSuccessReponsePayloadRT, -} from '../../../../legacy/plugins/infra/common/http_api/log_analysis'; -import { - createPlainError, - throwErrors, -} from '../../../../legacy/plugins/infra/common/runtime_types'; +} from '../../../../plugins/infra/common/http_api/log_analysis'; +import { createPlainError, throwErrors } from '../../../../plugins/infra/common/runtime_types'; import { FtrProviderContext } from '../../ftr_provider_context'; const TIME_BEFORE_START = 1569934800000; diff --git a/x-pack/test/api_integration/apis/infra/log_entries.ts b/x-pack/test/api_integration/apis/infra/log_entries.ts index 8db1426a219d4..75e7750058a87 100644 --- a/x-pack/test/api_integration/apis/infra/log_entries.ts +++ b/x-pack/test/api_integration/apis/infra/log_entries.ts @@ -13,19 +13,16 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import { fold } from 'fp-ts/lib/Either'; -import { - createPlainError, - throwErrors, -} from '../../../../legacy/plugins/infra/common/runtime_types'; +import { createPlainError, throwErrors } from '../../../../plugins/infra/common/runtime_types'; import { LOG_ENTRIES_PATH, logEntriesRequestRT, logEntriesResponseRT, -} from '../../../../legacy/plugins/infra/common/http_api'; +} from '../../../../plugins/infra/common/http_api'; -import { sharedFragments } from '../../../../legacy/plugins/infra/common/graphql/shared'; -import { InfraTimeKey } from '../../../../legacy/plugins/infra/public/graphql/types'; +import { sharedFragments } from '../../../../plugins/infra/common/graphql/shared'; +import { InfraTimeKey } from '../../../../plugins/infra/public/graphql/types'; import { FtrProviderContext } from '../../ftr_provider_context'; const KEY_WITHIN_DATA_RANGE = { diff --git a/x-pack/test/api_integration/apis/infra/log_entry_highlights.ts b/x-pack/test/api_integration/apis/infra/log_entry_highlights.ts index 66701de2704a6..a34cd89eb3262 100644 --- a/x-pack/test/api_integration/apis/infra/log_entry_highlights.ts +++ b/x-pack/test/api_integration/apis/infra/log_entry_highlights.ts @@ -12,20 +12,17 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import { fold } from 'fp-ts/lib/Either'; -import { - createPlainError, - throwErrors, -} from '../../../../legacy/plugins/infra/common/runtime_types'; +import { createPlainError, throwErrors } from '../../../../plugins/infra/common/runtime_types'; import { LOG_ENTRIES_HIGHLIGHTS_PATH, logEntriesHighlightsRequestRT, logEntriesHighlightsResponseRT, -} from '../../../../legacy/plugins/infra/common/http_api'; +} from '../../../../plugins/infra/common/http_api'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { sharedFragments } from '../../../../legacy/plugins/infra/common/graphql/shared'; -import { InfraTimeKey } from '../../../../legacy/plugins/infra/public/graphql/types'; +import { sharedFragments } from '../../../../plugins/infra/common/graphql/shared'; +import { InfraTimeKey } from '../../../../plugins/infra/public/graphql/types'; const KEY_BEFORE_START = { time: new Date('2000-01-01T00:00:00.000Z').valueOf(), diff --git a/x-pack/test/api_integration/apis/infra/log_item.ts b/x-pack/test/api_integration/apis/infra/log_item.ts index bae2d0ebb891b..5a8e88c0aad62 100644 --- a/x-pack/test/api_integration/apis/infra/log_item.ts +++ b/x-pack/test/api_integration/apis/infra/log_item.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; import { LOG_ENTRIES_ITEM_PATH, logEntriesItemRequestRT, -} from '../../../../legacy/plugins/infra/common/http_api'; +} from '../../../../plugins/infra/common/http_api'; const COMMON_HEADERS = { 'kbn-xsrf': 'some-xsrf-token', diff --git a/x-pack/test/api_integration/apis/infra/log_summary.ts b/x-pack/test/api_integration/apis/infra/log_summary.ts index 017b1c6f7ab45..15e503f7b4a5a 100644 --- a/x-pack/test/api_integration/apis/infra/log_summary.ts +++ b/x-pack/test/api_integration/apis/infra/log_summary.ts @@ -12,16 +12,13 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import { fold } from 'fp-ts/lib/Either'; -import { - createPlainError, - throwErrors, -} from '../../../../legacy/plugins/infra/common/runtime_types'; +import { createPlainError, throwErrors } from '../../../../plugins/infra/common/runtime_types'; import { LOG_ENTRIES_SUMMARY_PATH, logEntriesSummaryRequestRT, logEntriesSummaryResponseRT, -} from '../../../../legacy/plugins/infra/common/http_api/log_entries'; +} from '../../../../plugins/infra/common/http_api/log_entries'; import { FtrProviderContext } from '../../ftr_provider_context'; diff --git a/x-pack/test/api_integration/apis/infra/logs_without_millis.ts b/x-pack/test/api_integration/apis/infra/logs_without_millis.ts index ce2319259985b..9295380cfbec1 100644 --- a/x-pack/test/api_integration/apis/infra/logs_without_millis.ts +++ b/x-pack/test/api_integration/apis/infra/logs_without_millis.ts @@ -12,19 +12,16 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { identity } from 'fp-ts/lib/function'; import { fold } from 'fp-ts/lib/Either'; -import { - createPlainError, - throwErrors, -} from '../../../../legacy/plugins/infra/common/runtime_types'; +import { createPlainError, throwErrors } from '../../../../plugins/infra/common/runtime_types'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { sharedFragments } from '../../../../legacy/plugins/infra/common/graphql/shared'; -import { InfraTimeKey } from '../../../../legacy/plugins/infra/public/graphql/types'; +import { sharedFragments } from '../../../../plugins/infra/common/graphql/shared'; +import { InfraTimeKey } from '../../../../plugins/infra/public/graphql/types'; import { LOG_ENTRIES_SUMMARY_PATH, logEntriesSummaryRequestRT, logEntriesSummaryResponseRT, -} from '../../../../legacy/plugins/infra/common/http_api/log_entries'; +} from '../../../../plugins/infra/common/http_api/log_entries'; const COMMON_HEADERS = { 'kbn-xsrf': 'some-xsrf-token', diff --git a/x-pack/test/api_integration/apis/infra/metadata.ts b/x-pack/test/api_integration/apis/infra/metadata.ts index ac3fa06d958dd..b693881abcdf7 100644 --- a/x-pack/test/api_integration/apis/infra/metadata.ts +++ b/x-pack/test/api_integration/apis/infra/metadata.ts @@ -5,11 +5,11 @@ */ import expect from '@kbn/expect'; -import { InfraNodeType } from '../../../../legacy/plugins/infra/server/graphql/types'; +import { InfraNodeType } from '../../../../plugins/infra/server/graphql/types'; import { InfraMetadata, InfraMetadataRequest, -} from '../../../../legacy/plugins/infra/common/http_api/metadata_api'; +} from '../../../../plugins/infra/common/http_api/metadata_api'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function({ getService }: FtrProviderContext) { diff --git a/x-pack/test/api_integration/apis/infra/metrics.ts b/x-pack/test/api_integration/apis/infra/metrics.ts index 432b95163b4c1..f373bb788930d 100644 --- a/x-pack/test/api_integration/apis/infra/metrics.ts +++ b/x-pack/test/api_integration/apis/infra/metrics.ts @@ -7,16 +7,13 @@ import expect from '@kbn/expect'; import { first, last } from 'lodash'; -import { InventoryMetric } from '../../../../legacy/plugins/infra/common/inventory_models/types'; -import { - InfraNodeType, - InfraTimerangeInput, -} from '../../../../legacy/plugins/infra/public/graphql/types'; +import { InventoryMetric } from '../../../../plugins/infra/common/inventory_models/types'; +import { InfraNodeType, InfraTimerangeInput } from '../../../../plugins/infra/public/graphql/types'; import { FtrProviderContext } from '../../ftr_provider_context'; import { DATES } from './constants'; -import { NodeDetailsMetricDataResponse } from '../../../../legacy/plugins/infra/common/http_api/node_details_api'; +import { NodeDetailsMetricDataResponse } from '../../../../plugins/infra/common/http_api/node_details_api'; const { min, max } = DATES['7.0.0'].hosts; interface NodeDetailsRequest { diff --git a/x-pack/test/api_integration/apis/infra/metrics_explorer.ts b/x-pack/test/api_integration/apis/infra/metrics_explorer.ts index ee81b665adbe6..1563ae208867c 100644 --- a/x-pack/test/api_integration/apis/infra/metrics_explorer.ts +++ b/x-pack/test/api_integration/apis/infra/metrics_explorer.ts @@ -8,8 +8,9 @@ import expect from '@kbn/expect'; import { first } from 'lodash'; import moment from 'moment'; import { DATES } from './constants'; -import { MetricsExplorerResponse } from '../../../../legacy/plugins/infra/server/routes/metrics_explorer/types'; import { FtrProviderContext } from '../../ftr_provider_context'; +import { metricsExplorerResponseRT } from '../../../../plugins/infra/common/http_api/metrics_explorer'; +import { decodeOrThrow } from '../../../../plugins/infra/common/runtime_types'; const { min, max } = DATES['7.0.0'].hosts; @@ -48,20 +49,17 @@ export default function({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .send(postBody) .expect(200); - const body: MetricsExplorerResponse = response.body; - expect(body).to.have.property('series'); + const body = decodeOrThrow(metricsExplorerResponseRT)(response.body); expect(body.series).length(1); const firstSeries = first(body.series); expect(firstSeries).to.have.property('id', 'ALL'); - expect(firstSeries).to.have.property('columns'); - expect(firstSeries).to.have.property('rows'); - expect(firstSeries!.columns).to.eql([ + expect(firstSeries.columns).to.eql([ { name: 'timestamp', type: 'date' }, { name: 'metric_0', type: 'number' }, { name: 'metric_1', type: 'number' }, ]); - expect(firstSeries!.rows).to.have.length(9); - expect(firstSeries!.rows![1]).to.eql({ + expect(firstSeries.rows).to.have.length(9); + expect(firstSeries.rows![1]).to.eql({ metric_0: 0.005333333333333333, metric_1: 131, timestamp: 1547571300000, @@ -92,19 +90,16 @@ export default function({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .send(postBody) .expect(200); - const body: MetricsExplorerResponse = response.body; - expect(body).to.have.property('series'); + const body = decodeOrThrow(metricsExplorerResponseRT)(response.body); expect(body.series).length(1); const firstSeries = first(body.series); expect(firstSeries).to.have.property('id', 'ALL'); - expect(firstSeries).to.have.property('columns'); - expect(firstSeries).to.have.property('rows'); - expect(firstSeries!.columns).to.eql([ + expect(firstSeries.columns).to.eql([ { name: 'timestamp', type: 'date' }, { name: 'metric_0', type: 'number' }, ]); - expect(firstSeries!.rows).to.have.length(9); - expect(firstSeries!.rows![1]).to.eql({ + expect(firstSeries.rows).to.have.length(9); + expect(firstSeries.rows![1]).to.eql({ metric_0: 0.024, timestamp: 1547571300000, }); @@ -126,15 +121,12 @@ export default function({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .send(postBody) .expect(200); - const body: MetricsExplorerResponse = response.body; - expect(body).to.have.property('series'); + const body = decodeOrThrow(metricsExplorerResponseRT)(response.body); expect(body.series).length(1); const firstSeries = first(body.series); expect(firstSeries).to.have.property('id', 'ALL'); - expect(firstSeries).to.have.property('columns'); - expect(firstSeries).to.have.property('rows'); - expect(firstSeries!.columns).to.eql([]); - expect(firstSeries!.rows).to.have.length(0); + expect(firstSeries.columns).to.eql([]); + expect(firstSeries.rows).to.have.length(0); }); it('should work with groupBy', async () => { @@ -161,25 +153,21 @@ export default function({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .send(postBody) .expect(200); - const body: MetricsExplorerResponse = response.body; - expect(body).to.have.property('series'); + const body = decodeOrThrow(metricsExplorerResponseRT)(response.body); expect(body.series).length(3); const firstSeries = first(body.series); expect(firstSeries).to.have.property('id', 'system.diskio'); - expect(firstSeries).to.have.property('columns'); - expect(firstSeries).to.have.property('rows'); - expect(firstSeries!.columns).to.eql([ + expect(firstSeries.columns).to.eql([ { name: 'timestamp', type: 'date' }, { name: 'metric_0', type: 'number' }, { name: 'groupBy', type: 'string' }, ]); - expect(firstSeries!.rows).to.have.length(9); - expect(firstSeries!.rows![1]).to.eql({ + expect(firstSeries.rows).to.have.length(9); + expect(firstSeries.rows![1]).to.eql({ groupBy: 'system.diskio', metric_0: 24, timestamp: 1547571300000, }); - expect(body).to.have.property('pageInfo'); expect(body.pageInfo).to.eql({ afterKey: 'system.fsstat', total: 12, @@ -212,12 +200,10 @@ export default function({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .send(postBody) .expect(200); - const body: MetricsExplorerResponse = response.body; - expect(body).to.have.property('series'); + const body = decodeOrThrow(metricsExplorerResponseRT)(response.body); expect(body.series).length(1); expect(body.series[0]!).to.have.property('rows'); expect(body.series[0]!.rows).length(0); - expect(body).to.have.property('pageInfo'); expect(body.pageInfo).to.eql({ afterKey: null, total: 0, @@ -248,10 +234,8 @@ export default function({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .send(postBody) .expect(200); - const body: MetricsExplorerResponse = response.body; - expect(body).to.have.property('series'); + const body = decodeOrThrow(metricsExplorerResponseRT)(response.body); expect(body.series).length(0); - expect(body).to.have.property('pageInfo'); expect(body.pageInfo).to.eql({ afterKey: null, total: 0, diff --git a/x-pack/test/api_integration/apis/infra/sources.ts b/x-pack/test/api_integration/apis/infra/sources.ts index 8e51610d208be..fb8ab1d0592a0 100644 --- a/x-pack/test/api_integration/apis/infra/sources.ts +++ b/x-pack/test/api_integration/apis/infra/sources.ts @@ -7,14 +7,14 @@ import expect from '@kbn/expect'; import gql from 'graphql-tag'; -import { sourceQuery } from '../../../../legacy/plugins/infra/public/containers/source/query_source.gql_query'; +import { sourceQuery } from '../../../../plugins/infra/public/containers/source/query_source.gql_query'; import { sourceConfigurationFieldsFragment, sourceStatusFieldsFragment, -} from '../../../../legacy/plugins/infra/public/containers/source/source_fields_fragment.gql_query'; -import { SourceQuery } from '../../../../legacy/plugins/infra/public/graphql/types'; +} from '../../../../plugins/infra/public/containers/source/source_fields_fragment.gql_query'; +import { SourceQuery } from '../../../../plugins/infra/public/graphql/types'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { sharedFragments } from '../../../../legacy/plugins/infra/common/graphql/shared'; +import { sharedFragments } from '../../../../plugins/infra/common/graphql/shared'; export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); diff --git a/x-pack/test/api_integration/apis/infra/waffle.ts b/x-pack/test/api_integration/apis/infra/waffle.ts index 1f79ad4eee4e5..80fea1cdcd295 100644 --- a/x-pack/test/api_integration/apis/infra/waffle.ts +++ b/x-pack/test/api_integration/apis/infra/waffle.ts @@ -12,9 +12,9 @@ import { InfraNodeType, InfraTimerangeInput, InfraSnapshotGroupbyInput, -} from '../../../../legacy/plugins/infra/server/graphql/types'; +} from '../../../../plugins/infra/server/graphql/types'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { SnapshotNodeResponse } from '../../../../legacy/plugins/infra/common/http_api/snapshot_api'; +import { SnapshotNodeResponse } from '../../../../plugins/infra/common/http_api/snapshot_api'; import { DATES } from './constants'; interface SnapshotRequest { diff --git a/x-pack/test/api_integration/services/infraops_graphql_client.ts b/x-pack/test/api_integration/services/infraops_graphql_client.ts index 33d1a59575c17..7236bbd82f3f0 100644 --- a/x-pack/test/api_integration/services/infraops_graphql_client.ts +++ b/x-pack/test/api_integration/services/infraops_graphql_client.ts @@ -12,7 +12,7 @@ import { HttpLink } from 'apollo-link-http'; import { FtrProviderContext } from '../ftr_provider_context'; -import introspectionQueryResultData from '../../../legacy/plugins/infra/public/graphql/introspection.json'; +import introspectionQueryResultData from '../../../plugins/infra/public/graphql/introspection.json'; export function InfraOpsGraphQLClientProvider(context: FtrProviderContext) { return InfraOpsGraphQLClientFactoryProvider(context)(); diff --git a/x-pack/test/api_integration/services/infraops_source_configuration.ts b/x-pack/test/api_integration/services/infraops_source_configuration.ts index facfe485ab88a..728a58829d1ce 100644 --- a/x-pack/test/api_integration/services/infraops_source_configuration.ts +++ b/x-pack/test/api_integration/services/infraops_source_configuration.ts @@ -7,10 +7,7 @@ import gql from 'graphql-tag'; import { FtrProviderContext } from '../ftr_provider_context'; -import { - UpdateSourceInput, - UpdateSourceResult, -} from '../../../legacy/plugins/infra/public/graphql/types'; +import { UpdateSourceInput, UpdateSourceResult } from '../../../plugins/infra/public/graphql/types'; const createSourceMutation = gql` mutation createSource($sourceId: ID!, $sourceProperties: UpdateSourceInput!) { diff --git a/x-pack/test/functional/apps/endpoint/alert_list.ts b/x-pack/test/functional/apps/endpoint/alert_list.ts new file mode 100644 index 0000000000000..089fa487ef1b8 --- /dev/null +++ b/x-pack/test/functional/apps/endpoint/alert_list.ts @@ -0,0 +1,25 @@ +/* + * 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 { FtrProviderContext } from '../../ftr_provider_context'; + +export default function({ getPageObjects, getService }: FtrProviderContext) { + const pageObjects = getPageObjects(['common', 'endpoint']); + const testSubjects = getService('testSubjects'); + + describe('Endpoint Alert List', function() { + this.tags(['ciGroup7']); + before(async () => { + await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/alerts'); + }); + + it('loads the Alert List Page', async () => { + await testSubjects.existOrFail('alertListPage'); + }); + it('includes Alert list data grid', async () => { + await testSubjects.existOrFail('alertListGrid'); + }); + }); +} diff --git a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts index bda336e73c4f8..287892903dd2b 100644 --- a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts +++ b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts @@ -42,11 +42,16 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`endpoint management shows 'Manage Endpoints'`, async () => { - await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/management', { - basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); + await pageObjects.common.navigateToUrlWithBrowserHistory( + 'endpoint', + '/management', + undefined, + { + basePath: '/s/custom_space', + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + } + ); await testSubjects.existOrFail('managementViewTitle'); }); }); diff --git a/x-pack/test/functional/apps/endpoint/index.ts b/x-pack/test/functional/apps/endpoint/index.ts index 0ea9344a67aba..818c040f824d9 100644 --- a/x-pack/test/functional/apps/endpoint/index.ts +++ b/x-pack/test/functional/apps/endpoint/index.ts @@ -13,5 +13,6 @@ export default function({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./landing_page')); loadTestFile(require.resolve('./management')); loadTestFile(require.resolve('./policy_list')); + loadTestFile(require.resolve('./alert_list')); }); } diff --git a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts index ac7bd66d3466f..ede77b7d9afa7 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_security.ts @@ -66,7 +66,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure landing page without data', () => { it(`shows 'Change source configuration' button`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -89,7 +89,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`shows Wafflemap`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -121,9 +121,10 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`metrics page is visible`, async () => { - await PageObjects.common.navigateToActualUrl( + await PageObjects.common.navigateToUrlWithBrowserHistory( 'infraOps', - '/infrastructure/metrics/host/demo-stack-redis-01', + '/detail/host/demo-stack-redis-01', + undefined, { ensureCurrentUrl: false, shouldLoginIfPrompted: false, @@ -181,7 +182,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { describe('infrastructure landing page without data', () => { it(`doesn't show 'Change source configuration' button`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -204,7 +205,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`shows Wafflemap`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -236,9 +237,10 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`metrics page is visible`, async () => { - await PageObjects.common.navigateToActualUrl( + await PageObjects.common.navigateToUrlWithBrowserHistory( 'infraOps', - '/infrastructure/metrics/host/demo-stack-redis-01', + '/detail/host/demo-stack-redis-01', + undefined, { ensureCurrentUrl: false, shouldLoginIfPrompted: false, @@ -300,7 +302,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`context menu allows user to view logs`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -366,7 +368,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`context menu allows user to view APM traces`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -421,48 +423,19 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.not.contain(['Metrics']); }); - it(`infrastructure root renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', '', { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`infrastructure home page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`infrastructure landing page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'infrastructure', { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`infrastructure snapshot page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'infrastructure/inventory', { - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`metrics page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl( + it(`metrics app is inaccessible and Application Not Found message is rendered`, async () => { + await PageObjects.common.navigateToApp('infraOps'); + await testSubjects.existOrFail('~appNotFoundPageContent'); + await PageObjects.common.navigateToUrlWithBrowserHistory( 'infraOps', - '/metrics/host/demo-stack-redis-01', + '/inventory', + undefined, { ensureCurrentUrl: false, shouldLoginIfPrompted: false, } ); - await testSubjects.existOrFail('~infraNotFoundPage'); + await testSubjects.existOrFail('~appNotFoundPageContent'); }); }); }); diff --git a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts index 1d7ef9bea81e6..3bbcc1aa7043c 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts @@ -5,9 +5,6 @@ */ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; -import { DATES } from '../constants'; - -const DATE_WITH_DATA = DATES.metricsAndLogs.hosts.withData; export default function({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); @@ -21,22 +18,20 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { ]); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); - const retry = getService('retry'); describe('infrastructure spaces', () => { before(async () => { - await esArchiver.load('infra/metrics_and_logs'); + await esArchiver.load('empty_kibana'); }); after(async () => { - await esArchiver.unload('infra/metrics_and_logs'); + await esArchiver.unload('empty_kibana'); }); describe('space with no features disabled', () => { before(async () => { // we need to load the following in every situation as deleting // a space deletes all of the associated saved objects - await esArchiver.load('empty_kibana'); await spacesService.create({ id: 'custom_space', name: 'custom_space', @@ -46,7 +41,6 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { after(async () => { await spacesService.delete('custom_space'); - await esArchiver.unload('empty_kibana'); }); it('shows Metrics navlink', async () => { @@ -58,29 +52,11 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.contain('Metrics'); }); - it(`landing page shows Wafflemap`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + it(`Metrics app is accessible`, async () => { + await PageObjects.common.navigateToApp('infraOps', { basePath: '/s/custom_space', - ensureCurrentUrl: true, - }); - await PageObjects.infraHome.goToTime(DATE_WITH_DATA); - await testSubjects.existOrFail('~waffleMap'); - }); - - describe('context menu', () => { - before(async () => { - await testSubjects.click('~nodeContainer'); - }); - - it(`shows link to view logs`, async () => { - await retry.waitFor('context menu', () => testSubjects.exists('~nodeContextMenu')); - await testSubjects.existOrFail('~viewLogsContextMenuItem'); - }); - - it(`shows link to view apm traces`, async () => { - await retry.waitFor('context menu', () => testSubjects.exists('~nodeContextMenu')); - await testSubjects.existOrFail('~viewApmTracesContextMenuItem'); }); + await testSubjects.existOrFail('~noMetricsIndicesPrompt'); }); }); @@ -109,52 +85,22 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).not.to.contain('Metrics'); }); - it(`infrastructure root renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', '', { - basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`infrastructure home page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { - basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`infrastructure landing page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'infrastructure', { - basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`infrastructure snapshot page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'infrastructure/inventory', { + it(`metrics app is inaccessible and Application Not Found message is rendered`, async () => { + await PageObjects.common.navigateToApp('infraOps', { basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, }); - await testSubjects.existOrFail('~infraNotFoundPage'); - }); - - it(`metrics page renders not found page`, async () => { - await PageObjects.common.navigateToActualUrl( + await testSubjects.existOrFail('~appNotFoundPageContent'); + await PageObjects.common.navigateToUrlWithBrowserHistory( 'infraOps', - '/infrastructure/metrics/host/demo-stack-redis-01', + '/inventory', + undefined, { basePath: '/s/custom_space', - ensureCurrentUrl: true, + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, } ); - await testSubjects.existOrFail('~infraNotFoundPage'); + await testSubjects.existOrFail('~appNotFoundPageContent'); }); }); @@ -175,30 +121,11 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await esArchiver.unload('empty_kibana'); }); - it(`landing page shows Wafflemap`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + it(`Metrics app is accessible`, async () => { + await PageObjects.common.navigateToApp('infraOps', { basePath: '/s/custom_space', - ensureCurrentUrl: true, - }); - await PageObjects.infraHome.goToTime(DATE_WITH_DATA); - await testSubjects.existOrFail('~waffleMap'); - }); - - describe('context menu', () => { - before(async () => { - await testSubjects.click('~nodeContainer'); - }); - - it(`doesn't show link to view logs`, async () => { - await retry.waitFor('context menu', () => testSubjects.exists('~nodeContextMenu')); - const link = await testSubjects.find('~viewLogsContextMenuItem'); - expect(await link.isEnabled()).to.be(false); - }); - - it(`shows link to view apm traces`, async () => { - await retry.waitFor('context menu', () => testSubjects.exists('~nodeContextMenu')); - await testSubjects.existOrFail('~viewApmTracesContextMenuItem'); }); + await testSubjects.existOrFail('~noMetricsIndicesPrompt'); }); }); @@ -219,30 +146,11 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await esArchiver.unload('empty_kibana'); }); - it(`landing page shows Wafflemap`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'home', { + it(`Metrics app is accessible`, async () => { + await PageObjects.common.navigateToApp('infraOps', { basePath: '/s/custom_space', - ensureCurrentUrl: true, - }); - await PageObjects.infraHome.goToTime(DATE_WITH_DATA); - await testSubjects.existOrFail('~waffleMap'); - }); - - describe('context menu', () => { - before(async () => { - await testSubjects.click('~nodeContainer'); - }); - - it(`shows link to view logs`, async () => { - await retry.waitFor('context menu', () => testSubjects.exists('~nodeContextMenu')); - await testSubjects.existOrFail('~viewLogsContextMenuItem'); - }); - - it(`doesn't show link to view apm traces`, async () => { - await retry.waitFor('context menu', () => testSubjects.exists('~nodeContextMenu')); - const link = await testSubjects.find('~viewApmTracesContextMenuItem'); - expect(await link.isEnabled()).to.be(false); }); + await testSubjects.existOrFail('~noMetricsIndicesPrompt'); }); }); }); diff --git a/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts b/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts index 5008f93feeb01..48ad4e90fd413 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/logs_security.ts @@ -63,7 +63,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { describe('logs landing page without data', () => { it(`shows 'Change source configuration' button`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'logs', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraLogs', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -126,7 +126,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { describe('logs landing page without data', () => { it(`doesn't show 'Change source configuration' button`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'logs', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraLogs', '', undefined, { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); @@ -187,12 +187,19 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.not.contain('Logs'); }); - it('logs landing page renders not found page', async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'logs', { - ensureCurrentUrl: true, - shouldLoginIfPrompted: false, - }); - await testSubjects.existOrFail('~infraNotFoundPage'); + it(`logs app is inaccessible and Application Not Found message is rendered`, async () => { + await PageObjects.common.navigateToApp('infraLogs'); + await testSubjects.existOrFail('~appNotFoundPageContent'); + await PageObjects.common.navigateToUrlWithBrowserHistory( + 'infraLogs', + '/stream', + undefined, + { + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + } + ); + await testSubjects.existOrFail('~appNotFoundPageContent'); }); }); }); diff --git a/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts b/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts index 61a57e09f96c5..0094d227514c0 100644 --- a/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts +++ b/x-pack/test/functional/apps/infra/feature_controls/logs_spaces.ts @@ -49,7 +49,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { describe('logs landing page without data', () => { it(`shows 'Change source configuration' button`, async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'logs', { + await PageObjects.common.navigateToUrlWithBrowserHistory('infraLogs', '', undefined, { basePath: '/s/custom_space', ensureCurrentUrl: true, shouldLoginIfPrompted: false, @@ -86,13 +86,22 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(navLinks).to.not.contain('Logs'); }); - it('logs landing page renders not found page', async () => { - await PageObjects.common.navigateToActualUrl('infraOps', 'logs', { + it(`logs app is inaccessible and Application Not Found message is rendered`, async () => { + await PageObjects.common.navigateToApp('infraLogs', { basePath: '/s/custom_space', - ensureCurrentUrl: true, - shouldLoginIfPrompted: false, }); - await testSubjects.existOrFail('~infraNotFoundPage'); + await testSubjects.existOrFail('~appNotFoundPageContent'); + await PageObjects.common.navigateToUrlWithBrowserHistory( + 'infraLogs', + '/stream', + undefined, + { + basePath: '/s/custom_space', + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + } + ); + await testSubjects.existOrFail('~appNotFoundPageContent'); }); }); }); diff --git a/x-pack/test/functional/apps/infra/link_to.ts b/x-pack/test/functional/apps/infra/link_to.ts index 738dc7efd8fd9..7f803d9c3d0c1 100644 --- a/x-pack/test/functional/apps/infra/link_to.ts +++ b/x-pack/test/functional/apps/infra/link_to.ts @@ -18,23 +18,26 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const location = { hash: '', pathname: '/link-to/logs', - search: '?time=1565707203194&filter=trace.id:433b4651687e18be2c6c8e3b11f53d09', + search: 'time=1565707203194&filter=trace.id:433b4651687e18be2c6c8e3b11f53d09', state: undefined, }; const expectedSearchString = "sourceId=default&logPosition=(position:(tiebreaker:0,time:1565707203194),streamLive:!f)&logFilter=(expression:'trace.id:433b4651687e18be2c6c8e3b11f53d09',kind:kuery)"; const expectedRedirectPath = '/logs/stream?'; - await pageObjects.common.navigateToActualUrl( - 'infraOps', - `${location.pathname}${location.search}` + await pageObjects.common.navigateToUrlWithBrowserHistory( + 'infraLogs', + location.pathname, + location.search, + { + ensureCurrentUrl: false, + } ); await retry.tryForTime(5000, async () => { const currentUrl = await browser.getCurrentUrl(); - const [, currentHash] = decodeURIComponent(currentUrl).split('#'); - // Account for unpredictable location of the g parameter in the search string - expect(currentHash.slice(0, expectedRedirectPath.length)).to.be(expectedRedirectPath); - expect(currentHash.slice(expectedRedirectPath.length)).to.contain(expectedSearchString); + const decodedUrl = decodeURIComponent(currentUrl); + expect(decodedUrl).to.contain(expectedRedirectPath); + expect(decodedUrl).to.contain(expectedSearchString); }); }); }); diff --git a/x-pack/test/functional/apps/infra/metrics_source_configuration.ts b/x-pack/test/functional/apps/infra/metrics_source_configuration.ts index 8f5c765cec6ad..d334fa7956be4 100644 --- a/x-pack/test/functional/apps/infra/metrics_source_configuration.ts +++ b/x-pack/test/functional/apps/infra/metrics_source_configuration.ts @@ -38,7 +38,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('can change the metric indices to a pattern that matches nothing', async () => { - await pageObjects.common.navigateToActualUrl('infraOps', 'infrastructure/settings'); + await pageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '/settings'); const nameInput = await infraSourceConfigurationForm.getNameInput(); await nameInput.clearValueWithKeyboard({ charByChar: true }); @@ -57,7 +57,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('can change the metric indices back to a pattern that matches something', async () => { - await pageObjects.common.navigateToActualUrl('infraOps', 'infrastructure/settings'); + await pageObjects.common.navigateToUrlWithBrowserHistory('infraOps', '/settings'); const metricIndicesInput = await infraSourceConfigurationForm.getMetricIndicesInput(); await metricIndicesInput.clearValueWithKeyboard({ charByChar: true }); diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 913a8ea0c9dac..b589451c76165 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -133,11 +133,10 @@ export default async function({ readConfigFile }) { pathname: '/', }, infraOps: { - pathname: '/app/infra', + pathname: '/app/metrics', }, infraLogs: { - pathname: '/app/infra', - hash: '/logs', + pathname: '/app/logs', }, canvas: { pathname: '/app/canvas', diff --git a/x-pack/test/functional/es_archives/endpoint/resolver/api_feature/data.json.gz b/x-pack/test/functional/es_archives/endpoint/resolver/api_feature/data.json.gz new file mode 100644 index 0000000000000..92e4af68bf22e Binary files /dev/null and b/x-pack/test/functional/es_archives/endpoint/resolver/api_feature/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/endpoint/resolver/api_feature/mappings.json b/x-pack/test/functional/es_archives/endpoint/resolver/api_feature/mappings.json new file mode 100644 index 0000000000000..e1c41ed7111ba --- /dev/null +++ b/x-pack/test/functional/es_archives/endpoint/resolver/api_feature/mappings.json @@ -0,0 +1,2703 @@ +{ + "type": "index", + "value": { + "aliases": { + "endgame-4.21.0": { + "is_write_index": true + } + }, + "index": "endgame-4.21.0-000001", + "mappings": { + "_meta": { + "version": "1.4.0" + }, + "date_detection": false, + "dynamic_templates": [ + { + "strings_as_keyword": { + "mapping": { + "ignore_above": 1024, + "type": "keyword" + }, + "match_mapping_type": "string" + } + } + ], + "properties": { + "@timestamp": { + "type": "date" + }, + "agent": { + "properties": { + "ephemeral_id": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "as": { + "properties": { + "number": { + "type": "long" + }, + "organization": { + "properties": { + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "client": { + "properties": { + "address": { + "ignore_above": 1024, + "type": "keyword" + }, + "as": { + "properties": { + "number": { + "type": "long" + }, + "organization": { + "properties": { + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "bytes": { + "type": "long" + }, + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ip": { + "type": "ip" + }, + "mac": { + "ignore_above": 1024, + "type": "keyword" + }, + "nat": { + "properties": { + "ip": { + "type": "ip" + }, + "port": { + "type": "long" + } + } + }, + "packets": { + "type": "long" + }, + "port": { + "type": "long" + }, + "registered_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "top_level_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "user": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "email": { + "ignore_above": 1024, + "type": "keyword" + }, + "full_name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "cloud": { + "properties": { + "account": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "availability_zone": { + "ignore_above": 1024, + "type": "keyword" + }, + "instance": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "machine": { + "properties": { + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "provider": { + "ignore_above": 1024, + "type": "keyword" + }, + "region": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "container": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "image": { + "properties": { + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "tag": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "labels": { + "type": "object" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "runtime": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "destination": { + "properties": { + "address": { + "ignore_above": 1024, + "type": "keyword" + }, + "as": { + "properties": { + "number": { + "type": "long" + }, + "organization": { + "properties": { + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "bytes": { + "type": "long" + }, + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ip": { + "type": "ip" + }, + "mac": { + "ignore_above": 1024, + "type": "keyword" + }, + "nat": { + "properties": { + "ip": { + "type": "ip" + }, + "port": { + "type": "long" + } + } + }, + "packets": { + "type": "long" + }, + "port": { + "type": "long" + }, + "registered_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "top_level_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "user": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "email": { + "ignore_above": 1024, + "type": "keyword" + }, + "full_name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "dns": { + "properties": { + "answers": { + "properties": { + "class": { + "ignore_above": 1024, + "type": "keyword" + }, + "data": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "ttl": { + "type": "long" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "header_flags": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "op_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "question": { + "properties": { + "class": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "registered_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "subdomain": { + "ignore_above": 1024, + "type": "keyword" + }, + "top_level_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "resolved_ip": { + "type": "ip" + }, + "response_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ecs": { + "properties": { + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "endgame": { + "properties": { + "command_line": { + "ignore_above": 1024, + "type": "keyword" + }, + "destination_address": { + "ignore_above": 1024, + "type": "keyword" + }, + "destination_port": { + "type": "long" + }, + "effective_gid": { + "type": "long" + }, + "effective_group_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "effective_uid": { + "type": "long" + }, + "effective_user_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "event_message": { + "ignore_above": 1024, + "type": "keyword" + }, + "event_subtype_full": { + "ignore_above": 1024, + "type": "keyword" + }, + "event_type_full": { + "ignore_above": 1024, + "type": "keyword" + }, + "exit_code": { + "type": "long" + }, + "exit_code_full": { + "type": "long" + }, + "file_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "file_path": { + "ignore_above": 1024, + "type": "keyword" + }, + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "old_file_path": { + "ignore_above": 1024, + "type": "keyword" + }, + "opcode": { + "type": "long" + }, + "parent_process_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "parent_process_path": { + "ignore_above": 1024, + "type": "keyword" + }, + "pid": { + "type": "long" + }, + "ppid": { + "type": "long" + }, + "process_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "process_path": { + "ignore_above": 1024, + "type": "keyword" + }, + "protocol": { + "ignore_above": 1024, + "type": "keyword" + }, + "real_gid": { + "type": "long" + }, + "real_group_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "real_uid": { + "type": "long" + }, + "real_user_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "serial_event_id": { + "type": "long" + }, + "session_id": { + "type": "long" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + }, + "source_address": { + "ignore_above": 1024, + "type": "keyword" + }, + "source_port": { + "type": "long" + }, + "tid": { + "type": "long" + }, + "timestamp": { + "type": "long" + }, + "total_in_bytes": { + "type": "long" + }, + "total_out_bytes": { + "type": "long" + }, + "unique_pid": { + "type": "long" + }, + "unique_ppid": { + "type": "long" + } + } + }, + "error": { + "properties": { + "code": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "message": { + "norms": false, + "type": "text" + }, + "stack_trace": { + "doc_values": false, + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "index": false, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "event": { + "properties": { + "action": { + "ignore_above": 1024, + "type": "keyword" + }, + "category": { + "ignore_above": 1024, + "type": "keyword" + }, + "code": { + "ignore_above": 1024, + "type": "keyword" + }, + "created": { + "type": "date" + }, + "dataset": { + "ignore_above": 1024, + "type": "keyword" + }, + "duration": { + "type": "long" + }, + "end": { + "type": "date" + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "ingested": { + "type": "date" + }, + "kind": { + "ignore_above": 1024, + "type": "keyword" + }, + "module": { + "ignore_above": 1024, + "type": "keyword" + }, + "original": { + "doc_values": false, + "ignore_above": 1024, + "index": false, + "type": "keyword" + }, + "outcome": { + "ignore_above": 1024, + "type": "keyword" + }, + "provider": { + "ignore_above": 1024, + "type": "keyword" + }, + "risk_score": { + "type": "float" + }, + "risk_score_norm": { + "type": "float" + }, + "sequence": { + "type": "long" + }, + "severity": { + "type": "long" + }, + "start": { + "type": "date" + }, + "timezone": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "file": { + "properties": { + "accessed": { + "type": "date" + }, + "attributes": { + "ignore_above": 1024, + "type": "keyword" + }, + "created": { + "type": "date" + }, + "ctime": { + "type": "date" + }, + "device": { + "ignore_above": 1024, + "type": "keyword" + }, + "directory": { + "ignore_above": 1024, + "type": "keyword" + }, + "drive_letter": { + "ignore_above": 1, + "type": "keyword" + }, + "extension": { + "ignore_above": 1024, + "type": "keyword" + }, + "gid": { + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "ignore_above": 1024, + "type": "keyword" + }, + "hash": { + "properties": { + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha512": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "inode": { + "ignore_above": 1024, + "type": "keyword" + }, + "mode": { + "ignore_above": 1024, + "type": "keyword" + }, + "mtime": { + "type": "date" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "owner": { + "ignore_above": 1024, + "type": "keyword" + }, + "path": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "size": { + "type": "long" + }, + "target_path": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + }, + "uid": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "properties": { + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha512": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "host": { + "properties": { + "architecture": { + "ignore_above": 1024, + "type": "keyword" + }, + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hostname": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "ip": { + "type": "ip" + }, + "mac": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "os": { + "properties": { + "family": { + "ignore_above": 1024, + "type": "keyword" + }, + "full": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "kernel": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "platform": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + }, + "uptime": { + "type": "long" + }, + "user": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "email": { + "ignore_above": 1024, + "type": "keyword" + }, + "full_name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "http": { + "properties": { + "request": { + "properties": { + "body": { + "properties": { + "bytes": { + "type": "long" + }, + "content": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "bytes": { + "type": "long" + }, + "method": { + "ignore_above": 1024, + "type": "keyword" + }, + "referrer": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "response": { + "properties": { + "body": { + "properties": { + "bytes": { + "type": "long" + }, + "content": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "bytes": { + "type": "long" + }, + "status_code": { + "type": "long" + } + } + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "labels": { + "properties": { + "account_id": { + "ignore_above": 1024, + "type": "keyword" + }, + "endpoint_id": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "log": { + "properties": { + "level": { + "ignore_above": 1024, + "type": "keyword" + }, + "logger": { + "ignore_above": 1024, + "type": "keyword" + }, + "origin": { + "properties": { + "file": { + "properties": { + "line": { + "type": "integer" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "function": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "original": { + "doc_values": false, + "ignore_above": 1024, + "index": false, + "type": "keyword" + }, + "syslog": { + "properties": { + "facility": { + "properties": { + "code": { + "type": "long" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "priority": { + "type": "long" + }, + "severity": { + "properties": { + "code": { + "type": "long" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + } + } + }, + "message": { + "norms": false, + "type": "text" + }, + "network": { + "properties": { + "application": { + "ignore_above": 1024, + "type": "keyword" + }, + "bytes": { + "type": "long" + }, + "community_id": { + "ignore_above": 1024, + "type": "keyword" + }, + "direction": { + "ignore_above": 1024, + "type": "keyword" + }, + "forwarded_ip": { + "type": "ip" + }, + "iana_number": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "packets": { + "type": "long" + }, + "protocol": { + "ignore_above": 1024, + "type": "keyword" + }, + "transport": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "observer": { + "properties": { + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hostname": { + "ignore_above": 1024, + "type": "keyword" + }, + "ip": { + "type": "ip" + }, + "mac": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "os": { + "properties": { + "family": { + "ignore_above": 1024, + "type": "keyword" + }, + "full": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "kernel": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "platform": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "product": { + "ignore_above": 1024, + "type": "keyword" + }, + "serial_number": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + }, + "vendor": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "organization": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "os": { + "properties": { + "family": { + "ignore_above": 1024, + "type": "keyword" + }, + "full": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "kernel": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "platform": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "package": { + "properties": { + "architecture": { + "ignore_above": 1024, + "type": "keyword" + }, + "build_version": { + "ignore_above": 1024, + "type": "keyword" + }, + "checksum": { + "ignore_above": 1024, + "type": "keyword" + }, + "description": { + "ignore_above": 1024, + "type": "keyword" + }, + "install_scope": { + "ignore_above": 1024, + "type": "keyword" + }, + "installed": { + "type": "date" + }, + "license": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "path": { + "ignore_above": 1024, + "type": "keyword" + }, + "reference": { + "ignore_above": 1024, + "type": "keyword" + }, + "size": { + "type": "long" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "process": { + "properties": { + "args": { + "ignore_above": 1024, + "type": "keyword" + }, + "args_count": { + "type": "long" + }, + "command_line": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "executable": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "exit_code": { + "type": "long" + }, + "hash": { + "properties": { + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha512": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "parent": { + "properties": { + "args": { + "ignore_above": 1024, + "type": "keyword" + }, + "args_count": { + "type": "long" + }, + "command_line": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "executable": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "exit_code": { + "type": "long" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "pgid": { + "type": "long" + }, + "pid": { + "type": "long" + }, + "ppid": { + "type": "long" + }, + "start": { + "type": "date" + }, + "thread": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "title": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "uptime": { + "type": "long" + }, + "working_directory": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "pgid": { + "type": "long" + }, + "pid": { + "type": "long" + }, + "ppid": { + "type": "long" + }, + "start": { + "type": "date" + }, + "thread": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "title": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "uptime": { + "type": "long" + }, + "working_directory": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "registry": { + "properties": { + "data": { + "properties": { + "bytes": { + "ignore_above": 1024, + "type": "keyword" + }, + "strings": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hive": { + "ignore_above": 1024, + "type": "keyword" + }, + "key": { + "ignore_above": 1024, + "type": "keyword" + }, + "path": { + "ignore_above": 1024, + "type": "keyword" + }, + "value": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "related": { + "properties": { + "ip": { + "type": "ip" + }, + "user": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "rule": { + "properties": { + "category": { + "ignore_above": 1024, + "type": "keyword" + }, + "description": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "reference": { + "ignore_above": 1024, + "type": "keyword" + }, + "ruleset": { + "ignore_above": 1024, + "type": "keyword" + }, + "uuid": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "server": { + "properties": { + "address": { + "ignore_above": 1024, + "type": "keyword" + }, + "as": { + "properties": { + "number": { + "type": "long" + }, + "organization": { + "properties": { + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "bytes": { + "type": "long" + }, + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ip": { + "type": "ip" + }, + "mac": { + "ignore_above": 1024, + "type": "keyword" + }, + "nat": { + "properties": { + "ip": { + "type": "ip" + }, + "port": { + "type": "long" + } + } + }, + "packets": { + "type": "long" + }, + "port": { + "type": "long" + }, + "registered_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "top_level_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "user": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "email": { + "ignore_above": 1024, + "type": "keyword" + }, + "full_name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "service": { + "properties": { + "ephemeral_id": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "node": { + "properties": { + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "state": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "source": { + "properties": { + "address": { + "ignore_above": 1024, + "type": "keyword" + }, + "as": { + "properties": { + "number": { + "type": "long" + }, + "organization": { + "properties": { + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "bytes": { + "type": "long" + }, + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "geo": { + "properties": { + "city_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "continent_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "country_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "location": { + "type": "geo_point" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_iso_code": { + "ignore_above": 1024, + "type": "keyword" + }, + "region_name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ip": { + "type": "ip" + }, + "mac": { + "ignore_above": 1024, + "type": "keyword" + }, + "nat": { + "properties": { + "ip": { + "type": "ip" + }, + "port": { + "type": "long" + } + } + }, + "packets": { + "type": "long" + }, + "port": { + "type": "long" + }, + "registered_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "top_level_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "user": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "email": { + "ignore_above": 1024, + "type": "keyword" + }, + "full_name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "tags": { + "ignore_above": 1024, + "type": "keyword" + }, + "threat": { + "properties": { + "framework": { + "ignore_above": 1024, + "type": "keyword" + }, + "tactic": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "reference": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "technique": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "reference": { + "ignore_above": 1024, + "type": "keyword" + } + } + } + } + }, + "tls": { + "properties": { + "cipher": { + "ignore_above": 1024, + "type": "keyword" + }, + "client": { + "properties": { + "certificate": { + "ignore_above": 1024, + "type": "keyword" + }, + "certificate_chain": { + "ignore_above": 1024, + "type": "keyword" + }, + "hash": { + "properties": { + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "issuer": { + "ignore_above": 1024, + "type": "keyword" + }, + "ja3": { + "ignore_above": 1024, + "type": "keyword" + }, + "not_after": { + "type": "date" + }, + "not_before": { + "type": "date" + }, + "server_name": { + "ignore_above": 1024, + "type": "keyword" + }, + "subject": { + "ignore_above": 1024, + "type": "keyword" + }, + "supported_ciphers": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "curve": { + "ignore_above": 1024, + "type": "keyword" + }, + "established": { + "type": "boolean" + }, + "next_protocol": { + "ignore_above": 1024, + "type": "keyword" + }, + "resumed": { + "type": "boolean" + }, + "server": { + "properties": { + "certificate": { + "ignore_above": 1024, + "type": "keyword" + }, + "certificate_chain": { + "ignore_above": 1024, + "type": "keyword" + }, + "hash": { + "properties": { + "md5": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha1": { + "ignore_above": 1024, + "type": "keyword" + }, + "sha256": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "issuer": { + "ignore_above": 1024, + "type": "keyword" + }, + "ja3s": { + "ignore_above": 1024, + "type": "keyword" + }, + "not_after": { + "type": "date" + }, + "not_before": { + "type": "date" + }, + "subject": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + }, + "version_protocol": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "trace": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "transaction": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "url": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "extension": { + "ignore_above": 1024, + "type": "keyword" + }, + "fragment": { + "ignore_above": 1024, + "type": "keyword" + }, + "full": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "original": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "password": { + "ignore_above": 1024, + "type": "keyword" + }, + "path": { + "ignore_above": 1024, + "type": "keyword" + }, + "port": { + "type": "long" + }, + "query": { + "ignore_above": 1024, + "type": "keyword" + }, + "registered_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "scheme": { + "ignore_above": 1024, + "type": "keyword" + }, + "top_level_domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "username": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "user": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "email": { + "ignore_above": 1024, + "type": "keyword" + }, + "full_name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "group": { + "properties": { + "domain": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "hash": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "user_agent": { + "properties": { + "device": { + "properties": { + "name": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "original": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "os": { + "properties": { + "family": { + "ignore_above": 1024, + "type": "keyword" + }, + "full": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "kernel": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "platform": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "vulnerability": { + "properties": { + "category": { + "ignore_above": 1024, + "type": "keyword" + }, + "classification": { + "ignore_above": 1024, + "type": "keyword" + }, + "description": { + "fields": { + "text": { + "norms": false, + "type": "text" + } + }, + "ignore_above": 1024, + "type": "keyword" + }, + "enumeration": { + "ignore_above": 1024, + "type": "keyword" + }, + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "reference": { + "ignore_above": 1024, + "type": "keyword" + }, + "report_id": { + "ignore_above": 1024, + "type": "keyword" + }, + "scanner": { + "properties": { + "vendor": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "score": { + "properties": { + "base": { + "type": "float" + }, + "environmental": { + "type": "float" + }, + "temporal": { + "type": "float" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "severity": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "winlog": { + "properties": { + "opcode": { + "type": "long" + } + } + } + } + }, + "settings": { + "index": { + "lifecycle": { + "name": "endgame_policy-4.21.0", + "rollover_alias": "endgame-4.21.0" + }, + "mapping": { + "ignore_malformed": "true", + "total_fields": { + "limit": "10000" + } + }, + "number_of_replicas": "0", + "number_of_shards": "5", + "refresh_interval": "5s" + } + } + } +} \ No newline at end of file diff --git a/x-pack/test/functional/page_objects/infra_logs_page.ts b/x-pack/test/functional/page_objects/infra_logs_page.ts index 1c58f8dc41eba..8f554729328bb 100644 --- a/x-pack/test/functional/page_objects/infra_logs_page.ts +++ b/x-pack/test/functional/page_objects/infra_logs_page.ts @@ -19,7 +19,7 @@ export function InfraLogsPageProvider({ getPageObjects, getService }: FtrProvide }, async navigateToTab(logsUiTab: LogsUiTab) { - await pageObjects.common.navigateToActualUrl('infraLogs', `/logs/${logsUiTab}`); + await pageObjects.common.navigateToUrlWithBrowserHistory('infraLogs', `/${logsUiTab}`); }, async getLogStream() { diff --git a/x-pack/legacy/plugins/infra/types/rison_node.d.ts b/x-pack/typings/rison_node.d.ts similarity index 100% rename from x-pack/legacy/plugins/infra/types/rison_node.d.ts rename to x-pack/typings/rison_node.d.ts diff --git a/yarn.lock b/yarn.lock index 587dff16ffe58..74daf198c44d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4223,11 +4223,6 @@ resolved "https://registry.yarnpkg.com/@types/boom/-/boom-7.2.0.tgz#19c36cbb5811a7493f0f2e37f31d42b28df1abc1" integrity sha512-HonbGsHFbskh9zRAzA6tabcw18mCOsSEOL2ibGAuVqk6e7nElcRmWO5L4UfIHpDbWBWw+eZYFdsQ1+MEGgpcVA== -"@types/boom@7.2.1": - version "7.2.1" - resolved "https://registry.yarnpkg.com/@types/boom/-/boom-7.2.1.tgz#a21e21ba08cc49d17b26baef98e1a77ee4d6cdb0" - integrity sha512-kOiap+kSa4DPoookJXQGQyKy1rjZ55tgfKAh9F0m1NUdukkcwVzpSnXPMH42a5L+U++ugdQlh/xFJu/WAdr1aw== - "@types/browserslist-useragent@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/browserslist-useragent/-/browserslist-useragent-3.0.0.tgz#d425c9818182ce71ce53866798cee9c7d41d6e53" @@ -5767,12 +5762,10 @@ abort-controller@^2.0.3: dependencies: event-target-shim "^5.0.0" -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" +abortcontroller-polyfill@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.4.0.tgz#0d5eb58e522a461774af8086414f68e1dda7a6c4" + integrity sha512-3ZFfCRfDzx3GFjO6RAkYx81lPGpUS20ISxux9gLxuKnqafNcFQo59+IoZqpO2WvQlyc287B62HDnDdNYRmlvWA== accept@3.x.x: version "3.0.2" @@ -5892,6 +5885,17 @@ address@^1.0.1: resolved "https://registry.yarnpkg.com/address/-/address-1.0.3.tgz#b5f50631f8d6cec8bd20c963963afb55e06cbce9" integrity sha512-z55ocwKBRLryBs394Sm3ushTtBeg6VAeuku7utSoSnsJKvKcnXFIyC6vh27n3rXyxSgkJBBCAvyOn7gSUcTYjg== +adjust-sourcemap-loader@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/adjust-sourcemap-loader/-/adjust-sourcemap-loader-2.0.0.tgz#6471143af75ec02334b219f54bc7970c52fb29a4" + integrity sha512-4hFsTsn58+YjrU9qKzML2JSSDqKvN8mUGQ0nNIrfPi8hmIONT4L3uUaT6MKdMsZ9AjsU6D2xDkZxCkbQPxChrA== + dependencies: + assert "1.4.1" + camelcase "5.0.0" + loader-utils "1.2.3" + object-path "0.11.4" + regex-parser "2.2.10" + adm-zip@0.4.11: version "0.4.11" resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.11.tgz#2aa54c84c4b01a9d0fb89bb11982a51f13e3d62a" @@ -6647,6 +6651,11 @@ aria-query@3.0.0, aria-query@^3.0.0: ast-types-flow "0.0.7" commander "^2.11.0" +arity-n@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745" + integrity sha1-2edrEXM+CFacCEeuezmyhgswt0U= + arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" @@ -6881,7 +6890,7 @@ assert-plus@^0.2.0: resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" integrity sha1-104bh+ev/A24qttwIfP+SBAasjQ= -assert@^1.1.1: +assert@1.4.1, assert@^1.1.1: version "1.4.1" resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" integrity sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE= @@ -8019,13 +8028,6 @@ boom@5.x.x: dependencies: hoek "4.x.x" -boom@7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/boom/-/boom-7.3.0.tgz#733a6d956d33b0b1999da3fe6c12996950d017b9" - integrity sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A== - dependencies: - hoek "6.x.x" - boom@7.x.x, boom@^7.1.0, boom@^7.2.0: version "7.2.2" resolved "https://registry.yarnpkg.com/boom/-/boom-7.2.2.tgz#ac92101451aa5cea901aed07d881dd32b4f08345" @@ -8653,6 +8655,16 @@ camelcase-keys@^4.0.0: map-obj "^2.0.0" quick-lru "^1.0.0" +camelcase@5.0.0, camelcase@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" + integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA== + +camelcase@5.3.1, camelcase@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" @@ -8673,16 +8685,6 @@ camelcase@^4.0.0, camelcase@^4.1.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= -camelcase@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" - integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA== - -camelcase@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - camelize@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" @@ -9669,6 +9671,13 @@ component-inherit@0.0.3: resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" integrity sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM= +compose-function@3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/compose-function/-/compose-function-3.0.3.tgz#9ed675f13cc54501d30950a486ff6a7ba3ab185f" + integrity sha1-ntZ18TzFRQHTCVCkhv9qe6OrGF8= + dependencies: + arity-n "^1.0.4" + compress-commons@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-2.1.1.tgz#9410d9a534cf8435e3fbbb7c6ce48de2dc2f0610" @@ -9916,11 +9925,23 @@ contour_plot@^0.0.1: resolved "https://registry.yarnpkg.com/contour_plot/-/contour_plot-0.0.1.tgz#475870f032b8e338412aa5fc507880f0bf495c77" integrity sha1-R1hw8DK44zhBKqX8UHiA8L9JXHc= +convert-source-map@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" + integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== + dependencies: + safe-buffer "~5.1.1" + convert-source-map@1.X, convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0: version "1.5.1" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" integrity sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU= +convert-source-map@^0.3.3: + version "0.3.5" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-0.3.5.tgz#f1d802950af7dd2631a1febe0596550c86ab3190" + integrity sha1-8dgClQr33SYxof6+BZZVDIarMZA= + convert-source-map@^1.5.1, convert-source-map@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" @@ -10527,7 +10548,7 @@ css.escape@^1.5.1: resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb" integrity sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s= -css@2.X, css@^2.2.1, css@^2.2.3, css@^2.2.4: +css@2.X, css@^2.0.0, css@^2.2.1, css@^2.2.3, css@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929" integrity sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw== @@ -12417,7 +12438,7 @@ es6-error@^4.0.1: resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== -es6-iterator@^2.0.1, es6-iterator@~2.0.1, es6-iterator@~2.0.3: +es6-iterator@2.0.3, es6-iterator@^2.0.1, es6-iterator@~2.0.1, es6-iterator@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" integrity sha1-p96IkUGgWpSwhUQDstCg+/qY87c= @@ -21879,6 +21900,11 @@ object-path-immutable@^3.1.1: dependencies: is-plain-object "3.0.0" +object-path@0.11.4: + version "0.11.4" + resolved "https://registry.yarnpkg.com/object-path/-/object-path-0.11.4.tgz#370ae752fbf37de3ea70a861c23bba8915691949" + integrity sha1-NwrnUvvzfePqcKhhwju6iRVpGUk= + object-values@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/object-values/-/object-values-1.0.0.tgz#72af839630119e5b98c3b02bb8c27e3237158105" @@ -23305,6 +23331,15 @@ postcss-values-parser@^1.5.0: indexes-of "^1.0.1" uniq "^1.0.1" +postcss@7.0.21: + version "7.0.21" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.21.tgz#06bb07824c19c2021c5d056d5b10c35b989f7e17" + integrity sha512-uIFtJElxJo29QC753JzhidoAhvp/e/Exezkdhfmt8AymWT6/5B7W1WmponYWkHk2eg6sONyTch0A3nkMPun3SQ== + dependencies: + chalk "^2.4.2" + source-map "^0.6.1" + supports-color "^6.1.0" + postcss@^7.0.0, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.2, postcss@^7.0.23, postcss@^7.0.26, postcss@^7.0.5, postcss@^7.0.6: version "7.0.26" resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.26.tgz#5ed615cfcab35ba9bbb82414a4fa88ea10429587" @@ -25448,6 +25483,11 @@ regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" +regex-parser@2.2.10: + version "2.2.10" + resolved "https://registry.yarnpkg.com/regex-parser/-/regex-parser-2.2.10.tgz#9e66a8f73d89a107616e63b39d4deddfee912b37" + integrity sha512-8t6074A68gHfU8Neftl0Le6KTDwfGAj7IyjPIMSfikI2wJUTHDMaIq42bUsfVnj8mhx0R+45rdUXHGpN164avA== + regex-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/regex-regex/-/regex-regex-1.0.0.tgz#9048a1eaeb870f4d480dabc76fc42cdcc0bc3a72" @@ -26004,6 +26044,22 @@ resolve-protobuf-schema@^2.0.0: dependencies: protocol-buffers-schema "^3.3.1" +resolve-url-loader@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/resolve-url-loader/-/resolve-url-loader-3.1.1.tgz#28931895fa1eab9be0647d3b2958c100ae3c0bf0" + integrity sha512-K1N5xUjj7v0l2j/3Sgs5b8CjrrgtC70SmdCuZiJ8tSyb5J+uk3FoeZ4b7yTnH6j7ngI+Bc5bldHJIa8hYdu2gQ== + dependencies: + adjust-sourcemap-loader "2.0.0" + camelcase "5.3.1" + compose-function "3.0.3" + convert-source-map "1.7.0" + es6-iterator "2.0.3" + loader-utils "1.2.3" + postcss "7.0.21" + rework "1.0.1" + rework-visit "1.0.0" + source-map "0.6.1" + resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -26142,6 +26198,19 @@ reusify@^1.0.0: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== +rework-visit@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/rework-visit/-/rework-visit-1.0.0.tgz#9945b2803f219e2f7aca00adb8bc9f640f842c9a" + integrity sha1-mUWygD8hni96ygCtuLyfZA+ELJo= + +rework@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/rework/-/rework-1.0.1.tgz#30806a841342b54510aa4110850cd48534144aa7" + integrity sha1-MIBqhBNCtUUQqkEQhQzUhTQUSqc= + dependencies: + convert-source-map "^0.3.3" + css "^2.0.0" + rfdc@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.2.tgz#e6e72d74f5dc39de8f538f65e00c36c18018e349" @@ -27326,6 +27395,11 @@ source-map@0.5.6: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" integrity sha1-dc449SvwczxafwwRjYEzSiu19BI= +source-map@0.6.1, source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + source-map@^0.4.2: version "0.4.4" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" @@ -27338,11 +27412,6 @@ source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, sour resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - source-map@~0.1.30: version "0.1.43" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346"