From 5bb4a15233f12232f5c7125e520f281f4edaffcb Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 12:49:53 +0100 Subject: [PATCH 1/8] Initial move of searchprofiler into new platform directory, lots of things need testing --- .github/CODEOWNERS | 2 +- x-pack/legacy/plugins/searchprofiler/index.ts | 47 ++--------- .../{np_ready/application => }/index.scss | 0 .../searchprofiler/public/np_ready/plugin.ts | 62 -------------- .../application => }/styles/_index.scss | 0 .../application => }/styles/_mixins.scss | 0 .../components/_highlight_details_flyout.scss | 0 .../styles/components/_percentage_badge.scss | 0 .../styles/components/_profile_tree.scss | 0 .../styles/containers/_main.scss | 0 .../containers/_profile_query_editor.scss | 0 .../server/np_ready/lib/check_license.test.ts | 81 ------------------- .../server/np_ready/lib/check_license.ts | 59 -------------- .../searchprofiler/server/np_ready/plugin.ts | 38 --------- .../server/np_ready/routes/profile.ts | 53 ------------ .../searchprofiler/server/np_ready/types.ts | 33 -------- .../searchprofiler/common/constants.ts | 13 +++ .../searchprofiler/common/types.ts} | 5 +- x-pack/plugins/searchprofiler/kibana.json | 8 ++ .../public}/application/boot.tsx | 5 +- .../highlight_details_flyout.test.tsx | 0 .../highlight_details_flyout.tsx | 0 .../highlight_details_table.tsx | 0 .../highlight_details_flyout/index.ts | 0 .../public}/application/components/index.ts | 0 .../components/license_warning_notice.test.ts | 0 .../components/license_warning_notice.tsx | 0 .../components/percentage_badge.tsx | 0 .../__tests__/fixtures/breakdown.ts | 6 ++ .../__tests__/fixtures/normalize_indices.ts | 0 .../__tests__/fixtures/normalize_times.ts | 6 ++ .../fixtures/processed_search_response.ts | 0 .../__tests__/fixtures/search_response.ts | 0 .../profile_tree/__tests__/init_data.test.ts | 0 .../__tests__/profile_tree.test.tsx | 0 .../__tests__/unsafe_utils.test.ts | 0 .../profile_tree/__tests__/utils.test.ts | 0 .../components/profile_tree/constants.ts | 0 .../profile_tree/highlight_context.tsx | 0 .../components/profile_tree/index.ts | 0 .../components/profile_tree/index_details.tsx | 0 .../components/profile_tree/init_data.ts | 0 .../components/profile_tree/profile_tree.tsx | 0 .../profile_tree/shard_details/index.ts | 0 .../shard_details/shard_details.tsx | 0 .../shard_details/shard_details_tree.tsx | 0 .../shard_details/shard_details_tree_node.tsx | 0 .../components/profile_tree/types.ts | 0 .../components/profile_tree/unsafe_utils.ts | 0 .../profile_tree/use_highlight_tree_node.ts | 0 .../components/profile_tree/utils.ts | 0 .../components/searchprofiler_tabs.test.ts | 0 .../components/searchprofiler_tabs.tsx | 0 .../public}/application/containers/index.ts | 0 .../empty_tree_placeholder.test.tsx | 0 .../components/empty_tree_placeholder.tsx | 0 .../containers/main/components/index.ts | 0 .../profile_loading_placeholder.test.tsx | 0 .../profile_loading_placeholder.tsx | 0 .../application/containers/main/index.ts | 0 .../application/containers/main/main.tsx | 6 +- .../containers/profile_query_editor.tsx | 3 +- .../application/contexts/app_context.tsx | 4 +- .../application/contexts/profiler_context.tsx | 0 .../application/editor/editor.test.tsx | 2 +- .../public}/application/editor/editor.tsx | 0 .../public}/application/editor/index.ts | 0 .../public}/application/editor/init_editor.ts | 0 .../editor/use_ui_ace_keyboard_mode.tsx | 0 .../application/editor/worker/index.ts | 0 .../application/editor/worker/worker.d.ts | 0 .../application/editor/worker/worker.js | 0 .../editor/x_json_highlight_rules.ts | 0 .../public}/application/editor/x_json_mode.ts | 0 .../public}/application/hooks/index.ts | 0 .../application/hooks/use_request_profile.ts | 6 +- .../public}/application/index.tsx | 10 +-- .../public}/application/store/index.ts | 0 .../public}/application/store/reducer.test.ts | 0 .../public}/application/store/reducer.ts | 0 .../public}/application/store/store.ts | 0 .../public}/application/types.ts | 0 .../utils/check_for_json_errors.test.ts | 0 .../utils/check_for_json_errors.ts | 0 .../public}/application/utils/index.ts | 0 .../public}/application/utils/ms_to_pretty.ts | 0 .../application/utils/ns_to_pretty.test.ts | 0 .../public}/application/utils/ns_to_pretty.ts | 0 .../searchprofiler/public}/index.ts | 0 .../plugins/searchprofiler/public/plugin.ts | 80 ++++++++++++++++++ x-pack/plugins/searchprofiler/public/types.ts | 15 ++++ .../searchprofiler/server}/index.ts | 5 +- .../plugins/searchprofiler/server/plugin.ts | 49 +++++++++++ .../searchprofiler/server/routes/profile.ts | 57 +++++++++++++ x-pack/plugins/searchprofiler/server/types.ts | 21 +++++ 95 files changed, 284 insertions(+), 392 deletions(-) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/index.scss (100%) delete mode 100644 x-pack/legacy/plugins/searchprofiler/public/np_ready/plugin.ts rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/_index.scss (100%) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/_mixins.scss (100%) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/components/_highlight_details_flyout.scss (100%) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/components/_percentage_badge.scss (100%) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/components/_profile_tree.scss (100%) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/containers/_main.scss (100%) rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/styles/containers/_profile_query_editor.scss (100%) delete mode 100644 x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/server/np_ready/plugin.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/server/np_ready/routes/profile.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts create mode 100644 x-pack/plugins/searchprofiler/common/constants.ts rename x-pack/{legacy/plugins/searchprofiler/server/np_ready/lib/index.ts => plugins/searchprofiler/common/types.ts} (76%) create mode 100644 x-pack/plugins/searchprofiler/kibana.json rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/boot.tsx (82%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/highlight_details_flyout/highlight_details_flyout.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/highlight_details_flyout/highlight_details_table.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/highlight_details_flyout/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/license_warning_notice.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/license_warning_notice.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/percentage_badge.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/fixtures/breakdown.ts (88%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/fixtures/normalize_indices.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/fixtures/normalize_times.ts (98%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/fixtures/processed_search_response.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/fixtures/search_response.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/init_data.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/profile_tree.test.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/unsafe_utils.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/__tests__/utils.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/constants.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/highlight_context.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/index_details.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/init_data.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/profile_tree.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/shard_details/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/shard_details/shard_details.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/shard_details/shard_details_tree.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/shard_details/shard_details_tree_node.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/types.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/unsafe_utils.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/use_highlight_tree_node.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/profile_tree/utils.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/searchprofiler_tabs.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/searchprofiler_tabs.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/components/empty_tree_placeholder.test.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/components/empty_tree_placeholder.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/components/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/components/profile_loading_placeholder.test.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/components/profile_loading_placeholder.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/main/main.tsx (96%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/containers/profile_query_editor.tsx (97%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/contexts/app_context.tsx (90%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/contexts/profiler_context.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/editor.test.tsx (91%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/editor.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/init_editor.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/use_ui_ace_keyboard_mode.tsx (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/worker/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/worker/worker.d.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/worker/worker.js (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/x_json_highlight_rules.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/editor/x_json_mode.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/hooks/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/hooks/use_request_profile.ts (91%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/index.tsx (74%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/store/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/store/reducer.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/store/reducer.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/store/store.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/types.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/utils/check_for_json_errors.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/utils/check_for_json_errors.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/utils/index.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/utils/ms_to_pretty.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/utils/ns_to_pretty.test.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/utils/ns_to_pretty.ts (100%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/index.ts (100%) create mode 100644 x-pack/plugins/searchprofiler/public/plugin.ts create mode 100644 x-pack/plugins/searchprofiler/public/types.ts rename x-pack/{legacy/plugins/searchprofiler/server/np_ready => plugins/searchprofiler/server}/index.ts (64%) create mode 100644 x-pack/plugins/searchprofiler/server/plugin.ts create mode 100644 x-pack/plugins/searchprofiler/server/routes/profile.ts create mode 100644 x-pack/plugins/searchprofiler/server/types.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ed5721e8756e88..08d882fbafafbe 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -149,6 +149,6 @@ /x-pack/legacy/plugins/license_management/ @elastic/es-ui /x-pack/legacy/plugins/remote_clusters/ @elastic/es-ui /x-pack/legacy/plugins/rollup/ @elastic/es-ui -/x-pack/legacy/plugins/searchprofiler/ @elastic/es-ui +/x-pack/plugins/searchprofiler/ @elastic/es-ui /x-pack/legacy/plugins/snapshot_restore/ @elastic/es-ui /x-pack/legacy/plugins/watcher/ @elastic/es-ui diff --git a/x-pack/legacy/plugins/searchprofiler/index.ts b/x-pack/legacy/plugins/searchprofiler/index.ts index 834f331cd7bf41..fab2e438473488 100644 --- a/x-pack/legacy/plugins/searchprofiler/index.ts +++ b/x-pack/legacy/plugins/searchprofiler/index.ts @@ -5,12 +5,10 @@ */ import { resolve } from 'path'; -import Boom from 'boom'; -import { CoreSetup } from 'src/core/server'; -import { Server } from 'src/legacy/server/kbn_server'; -import { LegacySetup } from './server/np_ready/types'; -import { plugin } from './server/np_ready'; +// TODO: +// Until we can process SCSS in new platform, this part of Searchprofiler +// legacy must remain here. export const searchprofiler = (kibana: any) => { const publicSrc = resolve(__dirname, 'public'); @@ -22,43 +20,8 @@ export const searchprofiler = (kibana: any) => { publicDir: publicSrc, uiExports: { - // NP Ready - devTools: [`${publicSrc}/legacy`], - styleSheetPaths: `${publicSrc}/np_ready/application/index.scss`, - // Legacy - home: ['plugins/searchprofiler/register_feature'], - }, - init(server: Server) { - const serverPlugin = plugin(); - const thisPlugin = this; - - const commonRouteConfig = { - pre: [ - function forbidApiAccess() { - const licenseCheckResults = server.plugins.xpack_main.info - .feature(thisPlugin.id) - .getLicenseCheckResults(); - if (licenseCheckResults.showAppLink && licenseCheckResults.enableAppLink) { - return null; - } else { - throw Boom.forbidden(licenseCheckResults.message); - } - }, - ], - }; - - const legacySetup: LegacySetup = { - route: (args: Parameters[0]) => server.route(args), - plugins: { - __LEGACY: { - thisPlugin, - xpackMain: server.plugins.xpack_main, - elasticsearch: server.plugins.elasticsearch, - commonRouteConfig, - }, - }, - }; - serverPlugin.setup({} as CoreSetup, legacySetup); + styleSheetPaths: `${publicSrc}/index.scss`, }, + init() {}, }); }; diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/index.scss b/x-pack/legacy/plugins/searchprofiler/public/index.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/index.scss rename to x-pack/legacy/plugins/searchprofiler/public/index.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/plugin.ts b/x-pack/legacy/plugins/searchprofiler/public/np_ready/plugin.ts deleted file mode 100644 index f2acc97e55a705..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/plugin.ts +++ /dev/null @@ -1,62 +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 { i18n } from '@kbn/i18n'; -import { - Plugin, - CoreStart, - CoreSetup, - PluginInitializerContext, - ToastsStart, -} from 'src/core/public'; - -import { DevToolsSetup } from '../../../../../../src/plugins/dev_tools/public'; - -export class SearchProfilerUIPlugin implements Plugin { - constructor(ctx: PluginInitializerContext) {} - - async setup( - core: CoreSetup, - plugins: { - __LEGACY: { - I18nContext: any; - licenseEnabled: boolean; - notifications: ToastsStart; - formatAngularHttpError: any; - }; - dev_tools: DevToolsSetup; - } - ) { - const { http } = core; - const { - __LEGACY: { I18nContext, licenseEnabled, notifications, formatAngularHttpError }, - dev_tools, - } = plugins; - dev_tools.register({ - id: 'searchprofiler', - title: i18n.translate('xpack.searchProfiler.pageDisplayName', { - defaultMessage: 'Search Profiler', - }), - order: 5, - enableRouting: false, - async mount(ctx, params) { - const { boot } = await import('./application/boot'); - return boot({ - http, - licenseEnabled, - el: params.element, - I18nContext, - notifications, - formatAngularHttpError, - }); - }, - }); - } - - async start(core: CoreStart, plugins: any) {} - - async stop() {} -} diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/_index.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/_index.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/_index.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/_index.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/_mixins.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/_mixins.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/_mixins.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/_mixins.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/components/_highlight_details_flyout.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/components/_highlight_details_flyout.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/components/_highlight_details_flyout.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/components/_highlight_details_flyout.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/components/_percentage_badge.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/components/_percentage_badge.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/components/_percentage_badge.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/components/_percentage_badge.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/components/_profile_tree.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/components/_profile_tree.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/components/_profile_tree.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/components/_profile_tree.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/containers/_main.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/containers/_main.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/containers/_main.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/containers/_main.scss diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/containers/_profile_query_editor.scss b/x-pack/legacy/plugins/searchprofiler/public/styles/containers/_profile_query_editor.scss similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/styles/containers/_profile_query_editor.scss rename to x-pack/legacy/plugins/searchprofiler/public/styles/containers/_profile_query_editor.scss diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts deleted file mode 100644 index 1b8155221cb9d1..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts +++ /dev/null @@ -1,81 +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 expect from '@kbn/expect'; -import { set } from 'lodash'; -import { checkLicense } from './check_license'; - -describe('check_license', () => { - let mockLicenseInfo: any; - beforeEach(() => (mockLicenseInfo = {})); - - describe('license information is not available', () => { - beforeEach(() => (mockLicenseInfo.isAvailable = () => false)); - - it('should set showLinks to true', () => { - expect(checkLicense(mockLicenseInfo).showAppLink).to.be(true); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableAppLink).to.be(false); - }); - }); - - describe('license information is available', () => { - beforeEach(() => { - mockLicenseInfo.isAvailable = () => true; - set(mockLicenseInfo, 'license.getType', () => 'basic'); - }); - - describe('& license is > basic', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => true)); - - describe('& license is active', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true)); - - it('should set showLinks to true', () => { - expect(checkLicense(mockLicenseInfo).showAppLink).to.be(true); - }); - - it('should set enableLinks to true', () => { - expect(checkLicense(mockLicenseInfo).enableAppLink).to.be(true); - }); - }); - - describe('& license is expired', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false)); - - it('should set showLinks to true', () => { - expect(checkLicense(mockLicenseInfo).showAppLink).to.be(true); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableAppLink).to.be(false); - }); - }); - }); - - describe('& license is basic', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => false)); - - describe('& license is active', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true)); - - it('should set showLinks to false', () => { - expect(checkLicense(mockLicenseInfo).showAppLink).to.be(false); - }); - }); - - describe('& license is expired', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false)); - - it('should set showLinks to false', () => { - expect(checkLicense(mockLicenseInfo).showAppLink).to.be(false); - }); - }); - }); - }); -}); diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts deleted file mode 100644 index 2a22d615ca6e54..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts +++ /dev/null @@ -1,59 +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 { i18n } from '@kbn/i18n'; -import { XPackInfo } from '../../../../xpack_main/server/lib/xpack_info'; - -export function checkLicense( - xpackLicenseInfo: XPackInfo -): { showAppLink: boolean; enableAppLink: boolean; message: string | undefined } { - if (!xpackLicenseInfo || !xpackLicenseInfo.isAvailable()) { - return { - showAppLink: true, - enableAppLink: false, - message: i18n.translate('xpack.searchProfiler.unavailableLicenseInformationMessage', { - defaultMessage: - 'Search Profiler is unavailable - license information is not available at this time.', - }), - }; - } - - const isLicenseActive = xpackLicenseInfo.license.isActive(); - let message: string | undefined; - if (!isLicenseActive) { - message = i18n.translate('xpack.searchProfiler.licenseHasExpiredMessage', { - defaultMessage: 'Search Profiler is unavailable - license has expired.', - }); - } - - if ( - xpackLicenseInfo.license.isOneOf([ - 'trial', - 'basic', - 'standard', - 'gold', - 'platinum', - 'enterprise', - ]) - ) { - return { - showAppLink: true, - enableAppLink: isLicenseActive, - message, - }; - } - - message = i18n.translate('xpack.searchProfiler.upgradeLicenseMessage', { - defaultMessage: - 'Search Profiler is unavailable for the current {licenseInfo} license. Please upgrade your license.', - values: { licenseInfo: xpackLicenseInfo.license.getType() }, - }); - return { - showAppLink: false, - enableAppLink: false, - message, - }; -} diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/plugin.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/plugin.ts deleted file mode 100644 index e00e2829f980d2..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/plugin.ts +++ /dev/null @@ -1,38 +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, Plugin } from 'src/core/server'; -import { LegacySetup } from './types'; -import { checkLicense } from './lib'; -// @ts-ignore -import { mirrorPluginStatus } from '../../../../server/lib/mirror_plugin_status'; - -import * as profileRoute from './routes/profile'; - -export class SearchProfilerServerPlugin implements Plugin { - async setup( - core: CoreSetup, - { - route, - plugins: { - __LEGACY: { thisPlugin, elasticsearch, xpackMain, commonRouteConfig }, - }, - }: LegacySetup - ) { - mirrorPluginStatus(xpackMain, thisPlugin); - (xpackMain as any).status.once('green', () => { - // Register a function that is called whenever the xpack info changes, - // to re-compute the license check results for this plugin - xpackMain.info.feature(thisPlugin.id).registerLicenseCheckResultsGenerator(checkLicense); - }); - - profileRoute.register({ elasticsearch }, route, commonRouteConfig); - } - - async start() {} - - stop(): void {} -} diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/routes/profile.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/routes/profile.ts deleted file mode 100644 index 082307b5a7a2be..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/routes/profile.ts +++ /dev/null @@ -1,53 +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 Joi from 'joi'; -import { RequestShim, ServerShim, RegisterRoute } from '../types'; - -export const handler = async (server: ServerShim, request: RequestShim) => { - const { callWithRequest } = server.elasticsearch.getCluster('data'); - let parsed = request.payload.query; - parsed.profile = true; - parsed = JSON.stringify(parsed, null, 2); - - const body = { - index: request.payload.index, - body: parsed, - }; - try { - const resp = await callWithRequest(request, 'search', body); - return { - ok: true, - resp, - }; - } catch (err) { - return { - ok: false, - err, - }; - } -}; - -export const register = (server: ServerShim, route: RegisterRoute, commonConfig: any) => { - route({ - path: '/api/searchprofiler/profile', - method: 'POST', - config: { - ...commonConfig, - validate: { - payload: Joi.object() - .keys({ - query: Joi.object().required(), - index: Joi.string().required(), - type: Joi.string().optional(), - }) - .required(), - }, - }, - handler: req => { - return handler(server, { headers: req.headers, payload: req.payload as any }); - }, - }); -}; diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts deleted file mode 100644 index 9b25f8bb36b0cf..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/types.ts +++ /dev/null @@ -1,33 +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 { ServerRoute } from 'hapi'; -import { ElasticsearchPlugin, Request } from 'src/legacy/core_plugins/elasticsearch'; -import { XPackMainPlugin } from '../../../xpack_main/server/xpack_main'; - -export type RegisterRoute = (args: ServerRoute & { config: any }) => void; - -export interface LegacyPlugins { - __LEGACY: { - thisPlugin: any; - elasticsearch: ElasticsearchPlugin; - xpackMain: XPackMainPlugin; - commonRouteConfig: any; - }; -} - -export interface LegacySetup { - route: RegisterRoute; - plugins: LegacyPlugins; -} - -export interface ServerShim { - elasticsearch: ElasticsearchPlugin; -} - -export interface RequestShim extends Request { - payload: any; -} diff --git a/x-pack/plugins/searchprofiler/common/constants.ts b/x-pack/plugins/searchprofiler/common/constants.ts new file mode 100644 index 00000000000000..689663988a3084 --- /dev/null +++ b/x-pack/plugins/searchprofiler/common/constants.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { LicenseType } from '../../licensing/common/types'; + +const basicLicense: LicenseType = 'basic'; + +export const PLUGIN = Object.freeze({ + id: 'searchprofiler', + minimumLicenseType: basicLicense, +}); diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/index.ts b/x-pack/plugins/searchprofiler/common/types.ts similarity index 76% rename from x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/index.ts rename to x-pack/plugins/searchprofiler/common/types.ts index f2c070fd44b6e6..3872559fc00662 100644 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/index.ts +++ b/x-pack/plugins/searchprofiler/common/types.ts @@ -4,4 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export { checkLicense } from './check_license'; +export interface LicenseStatus { + valid: boolean; + message?: string; +} diff --git a/x-pack/plugins/searchprofiler/kibana.json b/x-pack/plugins/searchprofiler/kibana.json new file mode 100644 index 00000000000000..af8ee68a9bfa29 --- /dev/null +++ b/x-pack/plugins/searchprofiler/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "searchprofiler", + "version": "8.0.0", + "kibanaVersion": "kibana", + "requiredPlugins": ["dev_tools", "home", "licensing"], + "server": true, + "ui": true +} diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/boot.tsx b/x-pack/plugins/searchprofiler/public/application/boot.tsx similarity index 82% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/boot.tsx rename to x-pack/plugins/searchprofiler/public/application/boot.tsx index fa02124f8a2454..9c0e63e03542ed 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/boot.tsx +++ b/x-pack/plugins/searchprofiler/public/application/boot.tsx @@ -4,14 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ import { render, unmountComponentAtNode } from 'react-dom'; +import { HttpStart as Http, ToastsSetup } from 'kibana/public'; import React from 'react'; -import { HttpStart as Http, ToastsSetup } from 'src/core/public'; +import { LicenseStatus } from '../../common/types'; import { App } from '.'; export interface Dependencies { el: HTMLElement; http: Http; - licenseEnabled: boolean; + getLicenseStatus: () => LicenseStatus; I18nContext: any; notifications: ToastsSetup; formatAngularHttpError: any; diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx rename to x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/highlight_details_flyout.tsx b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/highlight_details_flyout.tsx rename to x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/highlight_details_table.tsx b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_table.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/highlight_details_table.tsx rename to x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_table.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/index.ts b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/highlight_details_flyout/index.ts rename to x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/index.ts b/x-pack/plugins/searchprofiler/public/application/components/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/index.ts rename to x-pack/plugins/searchprofiler/public/application/components/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/license_warning_notice.test.ts b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/license_warning_notice.test.ts rename to x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/license_warning_notice.tsx b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/license_warning_notice.tsx rename to x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/percentage_badge.tsx b/x-pack/plugins/searchprofiler/public/application/components/percentage_badge.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/percentage_badge.tsx rename to x-pack/plugins/searchprofiler/public/application/components/percentage_badge.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/breakdown.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/breakdown.ts similarity index 88% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/breakdown.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/breakdown.ts index a65af9a7a3ff3e..41cad70b6b1dd6 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/breakdown.ts +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/breakdown.ts @@ -1,3 +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 const breakdown = { advance: 0, advance_count: 0, diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/normalize_indices.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/normalize_indices.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/normalize_indices.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/normalize_indices.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/normalize_times.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/normalize_times.ts similarity index 98% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/normalize_times.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/normalize_times.ts index f26de49138f121..3cbacd2d31ac2b 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/normalize_times.ts +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/normalize_times.ts @@ -1,3 +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 const inputTimes = [ { type: 'BooleanQuery', diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/processed_search_response.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/processed_search_response.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/processed_search_response.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/processed_search_response.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/search_response.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/search_response.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/fixtures/search_response.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/fixtures/search_response.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/init_data.test.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/init_data.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/init_data.test.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/init_data.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/profile_tree.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/profile_tree.test.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/profile_tree.test.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/profile_tree.test.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/unsafe_utils.test.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/unsafe_utils.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/unsafe_utils.test.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/unsafe_utils.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/utils.test.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/utils.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/__tests__/utils.test.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/utils.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/constants.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/constants.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/constants.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/constants.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/highlight_context.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/highlight_context.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/highlight_context.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/highlight_context.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/index.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/index.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/index_details.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/index_details.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/index_details.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/index_details.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/init_data.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/init_data.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/init_data.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/init_data.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/profile_tree.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/profile_tree.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/profile_tree.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/profile_tree.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/index.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/index.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/shard_details.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/shard_details.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/shard_details.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/shard_details.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/shard_details_tree.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/shard_details_tree.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/shard_details_tree.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/shard_details_tree.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/shard_details_tree_node.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/shard_details_tree_node.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/shard_details/shard_details_tree_node.tsx rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/shard_details/shard_details_tree_node.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/types.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/types.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/types.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/types.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/unsafe_utils.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/unsafe_utils.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/unsafe_utils.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/unsafe_utils.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/use_highlight_tree_node.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/use_highlight_tree_node.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/use_highlight_tree_node.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/use_highlight_tree_node.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/utils.ts b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/utils.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/profile_tree/utils.ts rename to x-pack/plugins/searchprofiler/public/application/components/profile_tree/utils.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/searchprofiler_tabs.test.ts b/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/searchprofiler_tabs.test.ts rename to x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/searchprofiler_tabs.tsx b/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/components/searchprofiler_tabs.tsx rename to x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/index.ts b/x-pack/plugins/searchprofiler/public/application/containers/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/index.ts rename to x-pack/plugins/searchprofiler/public/application/containers/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/empty_tree_placeholder.test.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.test.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/empty_tree_placeholder.test.tsx rename to x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.test.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/empty_tree_placeholder.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/empty_tree_placeholder.tsx rename to x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/index.ts b/x-pack/plugins/searchprofiler/public/application/containers/main/components/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/index.ts rename to x-pack/plugins/searchprofiler/public/application/containers/main/components/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/profile_loading_placeholder.test.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.test.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/profile_loading_placeholder.test.tsx rename to x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.test.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/profile_loading_placeholder.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/components/profile_loading_placeholder.tsx rename to x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/index.ts b/x-pack/plugins/searchprofiler/public/application/containers/main/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/index.ts rename to x-pack/plugins/searchprofiler/public/application/containers/main/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/main.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/main.tsx similarity index 96% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/main.tsx rename to x-pack/plugins/searchprofiler/public/application/containers/main/main.tsx index 63ae5c7583625a..06bcfb9dcb9c10 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/main/main.tsx +++ b/x-pack/plugins/searchprofiler/public/application/containers/main/main.tsx @@ -42,7 +42,7 @@ function hasAggregations(profileResponse: ShardSerialized[]) { } export const Main = () => { - const { licenseEnabled } = useAppContext(); + const { getLicenseStatus } = useAppContext(); const { activeTab, @@ -63,7 +63,7 @@ export const Main = () => { ]); const renderLicenseWarning = () => { - return !licenseEnabled ? ( + return !getLicenseStatus().valid ? ( <> @@ -84,7 +84,7 @@ export const Main = () => { ); } - if (licenseEnabled && pristine) { + if (getLicenseStatus().valid && pristine) { return ; } diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/profile_query_editor.tsx b/x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx similarity index 97% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/profile_query_editor.tsx rename to x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx index b879f15b729982..1d62c9f59f1ce1 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/containers/profile_query_editor.tsx +++ b/x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx @@ -39,7 +39,7 @@ export const ProfileQueryEditor = memo(() => { const dispatch = useProfilerActionContext(); - const { licenseEnabled, notifications } = useAppContext(); + const { getLicenseStatus, notifications } = useAppContext(); const requestProfile = useRequestProfile(); const handleProfileClick = async () => { @@ -65,6 +65,7 @@ export const ProfileQueryEditor = memo(() => { }; const onEditorReady = useCallback(editorInstance => (editorRef.current = editorInstance), []); + const licenseEnabled = getLicenseStatus().valid; return ( string; + getLicenseStatus: () => LicenseStatus; } const AppContext = createContext(null as any); diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/contexts/profiler_context.tsx b/x-pack/plugins/searchprofiler/public/application/contexts/profiler_context.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/contexts/profiler_context.tsx rename to x-pack/plugins/searchprofiler/public/application/contexts/profiler_context.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/editor.test.tsx b/x-pack/plugins/searchprofiler/public/application/editor/editor.test.tsx similarity index 91% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/editor.test.tsx rename to x-pack/plugins/searchprofiler/public/application/editor/editor.test.tsx index d6702ef080ab73..a70d70f117edb6 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/editor.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/editor/editor.test.tsx @@ -10,7 +10,7 @@ jest.mock('./worker', () => { return { workerModule: { id: 'ace/mode/json_worker', src: '' } }; }); -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../test_utils'; import { Editor, Props } from '.'; describe('Editor Component', () => { diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/editor.tsx b/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/editor.tsx rename to x-pack/plugins/searchprofiler/public/application/editor/editor.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/index.ts b/x-pack/plugins/searchprofiler/public/application/editor/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/index.ts rename to x-pack/plugins/searchprofiler/public/application/editor/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/init_editor.ts b/x-pack/plugins/searchprofiler/public/application/editor/init_editor.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/init_editor.ts rename to x-pack/plugins/searchprofiler/public/application/editor/init_editor.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/use_ui_ace_keyboard_mode.tsx b/x-pack/plugins/searchprofiler/public/application/editor/use_ui_ace_keyboard_mode.tsx similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/use_ui_ace_keyboard_mode.tsx rename to x-pack/plugins/searchprofiler/public/application/editor/use_ui_ace_keyboard_mode.tsx diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/worker/index.ts b/x-pack/plugins/searchprofiler/public/application/editor/worker/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/worker/index.ts rename to x-pack/plugins/searchprofiler/public/application/editor/worker/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/worker/worker.d.ts b/x-pack/plugins/searchprofiler/public/application/editor/worker/worker.d.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/worker/worker.d.ts rename to x-pack/plugins/searchprofiler/public/application/editor/worker/worker.d.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/worker/worker.js b/x-pack/plugins/searchprofiler/public/application/editor/worker/worker.js similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/worker/worker.js rename to x-pack/plugins/searchprofiler/public/application/editor/worker/worker.js diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/x_json_highlight_rules.ts b/x-pack/plugins/searchprofiler/public/application/editor/x_json_highlight_rules.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/x_json_highlight_rules.ts rename to x-pack/plugins/searchprofiler/public/application/editor/x_json_highlight_rules.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/x_json_mode.ts b/x-pack/plugins/searchprofiler/public/application/editor/x_json_mode.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/editor/x_json_mode.ts rename to x-pack/plugins/searchprofiler/public/application/editor/x_json_mode.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/hooks/index.ts b/x-pack/plugins/searchprofiler/public/application/hooks/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/hooks/index.ts rename to x-pack/plugins/searchprofiler/public/application/hooks/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/hooks/use_request_profile.ts b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts similarity index 91% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/hooks/use_request_profile.ts rename to x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts index 34b49be7dc39c6..303fe49908233f 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/hooks/use_request_profile.ts +++ b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts @@ -20,7 +20,8 @@ interface ReturnValue { } export const useRequestProfile = () => { - const { http, notifications, formatAngularHttpError, licenseEnabled } = useAppContext(); + const { http, notifications, getLicenseStatus } = useAppContext(); + const licenseEnabled = getLicenseStatus().valid; return async ({ query, index }: Args): Promise => { if (!licenseEnabled) { return { data: null }; @@ -61,8 +62,7 @@ export const useRequestProfile = () => { } catch (e) { try { // Is this a known error type? - const errorString = formatAngularHttpError(e); - notifications.addError(e, { title: errorString }); + notifications.addError(e, { title: e.message }); } catch (_) { // Otherwise just report the original error notifications.addError(e, { diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/index.tsx b/x-pack/plugins/searchprofiler/public/application/index.tsx similarity index 74% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/index.tsx rename to x-pack/plugins/searchprofiler/public/application/index.tsx index d29f193ce9d90d..0f0d2e7339184b 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/index.tsx +++ b/x-pack/plugins/searchprofiler/public/application/index.tsx @@ -10,16 +10,10 @@ import { ProfileContextProvider } from './contexts/profiler_context'; import { AppDependencies } from './boot'; -export function App({ - I18nContext, - licenseEnabled, - notifications, - http, - formatAngularHttpError, -}: AppDependencies) { +export function App({ I18nContext, getLicenseStatus, notifications, http }: AppDependencies) { return ( - +
diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/index.ts b/x-pack/plugins/searchprofiler/public/application/store/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/index.ts rename to x-pack/plugins/searchprofiler/public/application/store/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/reducer.test.ts b/x-pack/plugins/searchprofiler/public/application/store/reducer.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/reducer.test.ts rename to x-pack/plugins/searchprofiler/public/application/store/reducer.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/reducer.ts b/x-pack/plugins/searchprofiler/public/application/store/reducer.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/reducer.ts rename to x-pack/plugins/searchprofiler/public/application/store/reducer.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/store.ts b/x-pack/plugins/searchprofiler/public/application/store/store.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/store/store.ts rename to x-pack/plugins/searchprofiler/public/application/store/store.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/types.ts b/x-pack/plugins/searchprofiler/public/application/types.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/types.ts rename to x-pack/plugins/searchprofiler/public/application/types.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/check_for_json_errors.test.ts b/x-pack/plugins/searchprofiler/public/application/utils/check_for_json_errors.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/check_for_json_errors.test.ts rename to x-pack/plugins/searchprofiler/public/application/utils/check_for_json_errors.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/check_for_json_errors.ts b/x-pack/plugins/searchprofiler/public/application/utils/check_for_json_errors.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/check_for_json_errors.ts rename to x-pack/plugins/searchprofiler/public/application/utils/check_for_json_errors.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/index.ts b/x-pack/plugins/searchprofiler/public/application/utils/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/index.ts rename to x-pack/plugins/searchprofiler/public/application/utils/index.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/ms_to_pretty.ts b/x-pack/plugins/searchprofiler/public/application/utils/ms_to_pretty.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/ms_to_pretty.ts rename to x-pack/plugins/searchprofiler/public/application/utils/ms_to_pretty.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/ns_to_pretty.test.ts b/x-pack/plugins/searchprofiler/public/application/utils/ns_to_pretty.test.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/ns_to_pretty.test.ts rename to x-pack/plugins/searchprofiler/public/application/utils/ns_to_pretty.test.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/ns_to_pretty.ts b/x-pack/plugins/searchprofiler/public/application/utils/ns_to_pretty.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/application/utils/ns_to_pretty.ts rename to x-pack/plugins/searchprofiler/public/application/utils/ns_to_pretty.ts diff --git a/x-pack/legacy/plugins/searchprofiler/public/np_ready/index.ts b/x-pack/plugins/searchprofiler/public/index.ts similarity index 100% rename from x-pack/legacy/plugins/searchprofiler/public/np_ready/index.ts rename to x-pack/plugins/searchprofiler/public/index.ts diff --git a/x-pack/plugins/searchprofiler/public/plugin.ts b/x-pack/plugins/searchprofiler/public/plugin.ts new file mode 100644 index 00000000000000..6d6d5ad3ea6a6b --- /dev/null +++ b/x-pack/plugins/searchprofiler/public/plugin.ts @@ -0,0 +1,80 @@ +/* + * 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 { Plugin, CoreStart, CoreSetup, PluginInitializerContext } from 'kibana/public'; + +import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; +import { LICENSE_CHECK_STATE } from '../../licensing/public'; + +import { PLUGIN } from '../common/constants'; +import { AppPublicPluginDependencies } from './types'; +import { LicenseStatus } from '../common/types'; + +export class SearchProfilerUIPlugin implements Plugin { + private licenseStatus: LicenseStatus; + + constructor(ctx: PluginInitializerContext) { + this.licenseStatus = { valid: false }; + } + + async setup( + { http, getStartServices }: CoreSetup, + { dev_tools, home, licensing }: AppPublicPluginDependencies + ) { + home.featureCatalogue.register({ + id: PLUGIN.id, + title: i18n.translate('xpack.searchProfiler.registryProviderTitle', { + defaultMessage: 'Search Profiler', + }), + description: i18n.translate('xpack.searchProfiler.registryProviderDescription', { + defaultMessage: 'Quickly check the performance of any Elasticsearch query.', + }), + icon: 'searchProfilerApp', + path: '/app/kibana#/dev_tools/searchprofiler', + showOnHomePage: false, + category: FeatureCatalogueCategory.ADMIN, + }); + + dev_tools.register({ + id: 'searchprofiler', + title: i18n.translate('xpack.searchProfiler.pageDisplayName', { + defaultMessage: 'Search Profiler', + }), + order: 5, + enableRouting: false, + mount: async (ctx, params) => { + const [coreStart] = await getStartServices(); + const { notifications, i18n: i18nDep } = coreStart; + const { boot } = await import('./application/boot'); + return boot({ + http, + getLicenseStatus: () => this.licenseStatus, + el: params.element, + I18nContext: i18nDep.Context, + notifications: notifications.toasts, + formatAngularHttpError, + }); + }, + }); + + licensing.license$.subscribe(license => { + const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType); + const isAvailable = + state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.id).isAvailable; + + if (isAvailable) { + this.licenseStatus = { valid: true }; + } else { + this.licenseStatus = { valid: false, message }; + } + }); + } + + async start(core: CoreStart, plugins: any) {} + + async stop() {} +} diff --git a/x-pack/plugins/searchprofiler/public/types.ts b/x-pack/plugins/searchprofiler/public/types.ts new file mode 100644 index 00000000000000..697761669dd2f4 --- /dev/null +++ b/x-pack/plugins/searchprofiler/public/types.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 { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; +import { DevToolsSetup } from '../../../../src/plugins/dev_tools/public'; +import { LicensingPluginSetup } from '../../licensing/public'; + +export interface AppPublicPluginDependencies { + licensing: LicensingPluginSetup; + home: HomePublicPluginSetup; + dev_tools: DevToolsSetup; +} diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/index.ts b/x-pack/plugins/searchprofiler/server/index.ts similarity index 64% rename from x-pack/legacy/plugins/searchprofiler/server/np_ready/index.ts rename to x-pack/plugins/searchprofiler/server/index.ts index 9253a0d6b15242..459cd6c344d923 100644 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/index.ts +++ b/x-pack/plugins/searchprofiler/server/index.ts @@ -3,8 +3,9 @@ * 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 'kibana/server'; import { SearchProfilerServerPlugin } from './plugin'; -export const plugin = () => { - return new SearchProfilerServerPlugin(); +export const plugin = (ctx: PluginInitializerContext) => { + return new SearchProfilerServerPlugin(ctx); }; diff --git a/x-pack/plugins/searchprofiler/server/plugin.ts b/x-pack/plugins/searchprofiler/server/plugin.ts new file mode 100644 index 00000000000000..d405f700c28234 --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/plugin.ts @@ -0,0 +1,49 @@ +/* + * 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, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; + +import { LICENSE_CHECK_STATE } from '../../licensing/common/types'; + +import { LicenseStatus } from '../common/types'; +import { AppServerPluginDependencies } from './types'; +import * as profileRoute from './routes/profile'; +import { PLUGIN } from '../common/constants'; + +export class SearchProfilerServerPlugin implements Plugin { + licenseStatus: LicenseStatus; + log: Logger; + + constructor({ logger }: PluginInitializerContext) { + this.log = logger.get(); + this.licenseStatus = { valid: false }; + } + + async setup({ http }: CoreSetup, { licensing, elasticsearch }: AppServerPluginDependencies) { + const router = http.createRouter(); + profileRoute.register({ elasticsearch, router, getLicenseStatus: () => this.licenseStatus }); + + licensing.license$.subscribe(license => { + const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType); + const hasRequiredLicense = state === LICENSE_CHECK_STATE.Valid; + if (hasRequiredLicense && license.getFeature(PLUGIN.id).isAvailable) { + this.licenseStatus = { valid: true }; + } else { + this.licenseStatus = { + valid: false, + message, + }; + if (message) { + this.log.info(message); + } + } + }); + } + + start() {} + + stop() {} +} diff --git a/x-pack/plugins/searchprofiler/server/routes/profile.ts b/x-pack/plugins/searchprofiler/server/routes/profile.ts new file mode 100644 index 00000000000000..b452119b490acb --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/routes/profile.ts @@ -0,0 +1,57 @@ +/* + * 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 cloneDeep from 'lodash.clonedeep'; +import { RouteDependencies } from '../types'; + +export const register = ({ router, getLicenseStatus }: RouteDependencies) => { + router.post( + { + path: '/api/searchprofiler/profile', + validate: { + body: schema.object({ + query: schema.object({}, { allowUnknowns: true }), + index: schema.string(), + type: schema.string({ defaultValue: '' }), + }), + }, + }, + async (ctx, request, response) => { + const currentLicenseStatus = getLicenseStatus(); + if (!currentLicenseStatus.valid) { + return response.forbidden({ + body: { + message: currentLicenseStatus.message ?? '', + }, + }); + } + + const { + core: { elasticsearch }, + } = ctx; + + let parsed = cloneDeep(request.body.query); + parsed.profile = true; + parsed = JSON.stringify(parsed, null, 2); + + const body = { + index: request.body.index, + body: parsed, + }; + try { + const resp = await elasticsearch.dataClient.callAsCurrentUser('search', body); + return response.ok({ + body: { + ok: true, + resp, + }, + }); + } catch (err) { + return response.internalError({ body: err }); + } + } + ); +}; diff --git a/x-pack/plugins/searchprofiler/server/types.ts b/x-pack/plugins/searchprofiler/server/types.ts new file mode 100644 index 00000000000000..3242ac6cdb3bb4 --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/types.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. + */ + +import { IRouter } from 'kibana/server'; +import { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { LicenseStatus } from '../common/types'; + +export interface AppServerPluginDependencies { + licensing: LicensingPluginSetup; + elasticsearch: ElasticsearchPlugin; +} + +export interface RouteDependencies { + getLicenseStatus: () => LicenseStatus; + elasticsearch: ElasticsearchPlugin; + router: IRouter; +} From ea827b4eb127961fdaf3088444940491eed420a6 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 13:13:34 +0100 Subject: [PATCH 2/8] Whitespace, clean up types and remove unused files --- .../legacy/plugins/searchprofiler/README.md | 26 ----------------- .../plugins/searchprofiler/public/legacy.ts | 28 ------------------- .../searchprofiler/public/register_feature.js | 28 ------------------- .../public/application/boot.tsx | 1 - .../containers/profile_query_editor.tsx | 1 + .../plugins/searchprofiler/public/plugin.ts | 1 - 6 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 x-pack/legacy/plugins/searchprofiler/README.md delete mode 100644 x-pack/legacy/plugins/searchprofiler/public/legacy.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/public/register_feature.js diff --git a/x-pack/legacy/plugins/searchprofiler/README.md b/x-pack/legacy/plugins/searchprofiler/README.md deleted file mode 100644 index 1dec1bb4e54504..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Profiler - -A UI for the query and aggregation profiler in Elasticsearch - -## Development - -Assuming you've checked out x-plugins next to kibana... - -- Run `yarn kbn bootstrap` -- Run `yarn start` to watch for and sync files on change -- Open a new terminal to run Kibana - use `yarn start` to launch it in dev mode - - Kibana will automatically restart as files are synced - - If you need debugging output, run `DEBUG=reporting yarn start` instead - -If you have installed this somewhere other than via x-plugins, and next to the kibana repo, you'll need to change the `pathToKibana` setting in `gulpfile.js` - -## Testing - -To run the server tests, change into `x-plugins/kibana` and run: - -```bash -mocha --debug --compilers js:@babel/register plugins/profiler/**/__tests__/**/*.js -``` - - ---kbnServer.tests_bundle.pluginId diff --git a/x-pack/legacy/plugins/searchprofiler/public/legacy.ts b/x-pack/legacy/plugins/searchprofiler/public/legacy.ts deleted file mode 100644 index b767705e025a00..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/public/legacy.ts +++ /dev/null @@ -1,28 +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. - */ - -/* eslint-disable @kbn/eslint/no-restricted-paths */ -import { npSetup } from 'ui/new_platform'; -import { I18nContext } from 'ui/i18n'; -// @ts-ignore -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -// @ts-ignore -import { formatAngularHttpError } from 'ui/notify/lib'; -import 'ui/autoload/all'; - -import { plugin } from './np_ready'; - -const pluginInstance = plugin({} as any); - -pluginInstance.setup(npSetup.core, { - ...npSetup.plugins, - __LEGACY: { - I18nContext, - licenseEnabled: xpackInfo.get('features.searchprofiler.enableAppLink'), - notifications: npSetup.core.notifications.toasts, - formatAngularHttpError, - }, -}); diff --git a/x-pack/legacy/plugins/searchprofiler/public/register_feature.js b/x-pack/legacy/plugins/searchprofiler/public/register_feature.js deleted file mode 100644 index 2a4218e2527c7c..00000000000000 --- a/x-pack/legacy/plugins/searchprofiler/public/register_feature.js +++ /dev/null @@ -1,28 +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 { - FeatureCatalogueRegistryProvider, - FeatureCatalogueCategory, -} from 'ui/registry/feature_catalogue'; - -import { i18n } from '@kbn/i18n'; - -FeatureCatalogueRegistryProvider.register(() => { - return { - id: 'searchprofiler', - title: i18n.translate('xpack.searchProfiler.registryProviderTitle', { - defaultMessage: 'Search Profiler', - }), - description: i18n.translate('xpack.searchProfiler.registryProviderDescription', { - defaultMessage: 'Quickly check the performance of any Elasticsearch query.', - }), - icon: 'searchProfilerApp', - path: '/app/kibana#/dev_tools/searchprofiler', - showOnHomePage: false, - category: FeatureCatalogueCategory.ADMIN, - }; -}); diff --git a/x-pack/plugins/searchprofiler/public/application/boot.tsx b/x-pack/plugins/searchprofiler/public/application/boot.tsx index 9c0e63e03542ed..31837cde60798a 100644 --- a/x-pack/plugins/searchprofiler/public/application/boot.tsx +++ b/x-pack/plugins/searchprofiler/public/application/boot.tsx @@ -15,7 +15,6 @@ export interface Dependencies { getLicenseStatus: () => LicenseStatus; I18nContext: any; notifications: ToastsSetup; - formatAngularHttpError: any; } export type AppDependencies = Omit; diff --git a/x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx b/x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx index 1d62c9f59f1ce1..5348c55ad52139 100644 --- a/x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx +++ b/x-pack/plugins/searchprofiler/public/application/containers/profile_query_editor.tsx @@ -3,6 +3,7 @@ * 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, { useRef, memo, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { diff --git a/x-pack/plugins/searchprofiler/public/plugin.ts b/x-pack/plugins/searchprofiler/public/plugin.ts index 6d6d5ad3ea6a6b..92ae42d86ab61b 100644 --- a/x-pack/plugins/searchprofiler/public/plugin.ts +++ b/x-pack/plugins/searchprofiler/public/plugin.ts @@ -56,7 +56,6 @@ export class SearchProfilerUIPlugin implements Plugin Date: Mon, 20 Jan 2020 14:19:22 +0100 Subject: [PATCH 3/8] First iteration of end-to-end plugin working - Updated license check to only check for presence of basic license (not search profiler as a feature - Updated the payload: removed types from validation - Also added README in public regarding the location of styles --- .../plugins/searchprofiler/public/README.md | 3 +++ .../application/hooks/use_request_profile.ts | 2 +- .../plugins/searchprofiler/public/plugin.ts | 4 +-- .../plugins/searchprofiler/server/plugin.ts | 17 ++++++++++--- .../searchprofiler/server/routes/profile.ts | 25 +++++++++++-------- x-pack/plugins/searchprofiler/server/types.ts | 3 ++- 6 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 x-pack/plugins/searchprofiler/public/README.md diff --git a/x-pack/plugins/searchprofiler/public/README.md b/x-pack/plugins/searchprofiler/public/README.md new file mode 100644 index 00000000000000..3cf79162b3965f --- /dev/null +++ b/x-pack/plugins/searchprofiler/public/README.md @@ -0,0 +1,3 @@ +## Please note + +See x-pack/legacy/plugins/searchprofiler/public for styles. diff --git a/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts index 303fe49908233f..028d77766d47b1 100644 --- a/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts +++ b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts @@ -40,7 +40,7 @@ export const useRequestProfile = () => { return { data: parsed.profile.shards }; } - const payload: Record = { query }; + const payload: Record = { query: parsed }; if (index == null || index === '') { payload.index = '_all'; diff --git a/x-pack/plugins/searchprofiler/public/plugin.ts b/x-pack/plugins/searchprofiler/public/plugin.ts index 92ae42d86ab61b..1f460aee31dfd0 100644 --- a/x-pack/plugins/searchprofiler/public/plugin.ts +++ b/x-pack/plugins/searchprofiler/public/plugin.ts @@ -62,9 +62,7 @@ export class SearchProfilerUIPlugin implements Plugin { const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType); - const isAvailable = - state === LICENSE_CHECK_STATE.Valid && license.getFeature(PLUGIN.id).isAvailable; - + const isAvailable = state === LICENSE_CHECK_STATE.Valid; if (isAvailable) { this.licenseStatus = { valid: true }; } else { diff --git a/x-pack/plugins/searchprofiler/server/plugin.ts b/x-pack/plugins/searchprofiler/server/plugin.ts index d405f700c28234..3f9d72ffda78cb 100644 --- a/x-pack/plugins/searchprofiler/server/plugin.ts +++ b/x-pack/plugins/searchprofiler/server/plugin.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; import { LICENSE_CHECK_STATE } from '../../licensing/common/types'; @@ -24,17 +25,27 @@ export class SearchProfilerServerPlugin implements Plugin { async setup({ http }: CoreSetup, { licensing, elasticsearch }: AppServerPluginDependencies) { const router = http.createRouter(); - profileRoute.register({ elasticsearch, router, getLicenseStatus: () => this.licenseStatus }); + profileRoute.register({ + elasticsearch, + router, + getLicenseStatus: () => this.licenseStatus, + log: this.log, + }); licensing.license$.subscribe(license => { const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType); const hasRequiredLicense = state === LICENSE_CHECK_STATE.Valid; - if (hasRequiredLicense && license.getFeature(PLUGIN.id).isAvailable) { + if (hasRequiredLicense) { this.licenseStatus = { valid: true }; } else { this.licenseStatus = { valid: false, - message, + message: + message || + // Ensure that there is a message when license check fails + i18n.translate('xpack.searchprofiler.licenseCheckErrorMessage', { + defaultMessage: 'License check failed', + }), }; if (message) { this.log.info(message); diff --git a/x-pack/plugins/searchprofiler/server/routes/profile.ts b/x-pack/plugins/searchprofiler/server/routes/profile.ts index b452119b490acb..620c4b8e7f9417 100644 --- a/x-pack/plugins/searchprofiler/server/routes/profile.ts +++ b/x-pack/plugins/searchprofiler/server/routes/profile.ts @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ import { schema } from '@kbn/config-schema'; -import cloneDeep from 'lodash.clonedeep'; import { RouteDependencies } from '../types'; -export const register = ({ router, getLicenseStatus }: RouteDependencies) => { +export const register = ({ router, getLicenseStatus, log }: RouteDependencies) => { router.post( { path: '/api/searchprofiler/profile', @@ -15,7 +14,6 @@ export const register = ({ router, getLicenseStatus }: RouteDependencies) => { body: schema.object({ query: schema.object({}, { allowUnknowns: true }), index: schema.string(), - type: schema.string({ defaultValue: '' }), }), }, }, @@ -24,7 +22,7 @@ export const register = ({ router, getLicenseStatus }: RouteDependencies) => { if (!currentLicenseStatus.valid) { return response.forbidden({ body: { - message: currentLicenseStatus.message ?? '', + message: currentLicenseStatus.message!, }, }); } @@ -33,13 +31,19 @@ export const register = ({ router, getLicenseStatus }: RouteDependencies) => { core: { elasticsearch }, } = ctx; - let parsed = cloneDeep(request.body.query); - parsed.profile = true; - parsed = JSON.stringify(parsed, null, 2); + const { + body: { query, index }, + } = request; + + const parsed = { + // Activate profiler mode for this query. + profile: true, + ...query, + }; const body = { - index: request.body.index, - body: parsed, + index, + body: JSON.stringify(parsed, null, 2), }; try { const resp = await elasticsearch.dataClient.callAsCurrentUser('search', body); @@ -50,7 +54,8 @@ export const register = ({ router, getLicenseStatus }: RouteDependencies) => { }, }); } catch (err) { - return response.internalError({ body: err }); + log.error(err); + return response.internalError(err); } } ); diff --git a/x-pack/plugins/searchprofiler/server/types.ts b/x-pack/plugins/searchprofiler/server/types.ts index 3242ac6cdb3bb4..cef9cc6b887684 100644 --- a/x-pack/plugins/searchprofiler/server/types.ts +++ b/x-pack/plugins/searchprofiler/server/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from 'kibana/server'; +import { IRouter, Logger } from 'kibana/server'; import { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch'; import { LicensingPluginSetup } from '../../licensing/server'; import { LicenseStatus } from '../common/types'; @@ -18,4 +18,5 @@ export interface RouteDependencies { getLicenseStatus: () => LicenseStatus; elasticsearch: ElasticsearchPlugin; router: IRouter; + log: Logger; } From 58b618dc4998fba599c0ff2ee1577cfb2043729a Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 15:20:31 +0100 Subject: [PATCH 4/8] Added extractProfilerErrorMessage function to interface with new error reporting from profiler endpoint --- .../public/application/editor/editor.tsx | 7 ++---- .../application/hooks/use_request_profile.ts | 24 +++++++++++++++---- .../searchprofiler/server/routes/profile.ts | 10 +++++++- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx b/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx index 014336f379059a..0477b270724dae 100644 --- a/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx +++ b/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx @@ -10,10 +10,7 @@ import { Editor as AceEditor } from 'brace'; import { initializeEditor } from './init_editor'; import { useUIAceKeyboardMode } from './use_ui_ace_keyboard_mode'; -interface EditorShim { - getValue(): string; - focus(): void; -} +type EditorShim = ReturnType; export type EditorInstance = EditorShim; @@ -23,7 +20,7 @@ export interface Props { onEditorReady: (editor: EditorShim) => void; } -const createEditorShim = (aceEditor: AceEditor): EditorShim => { +const createEditorShim = (aceEditor: AceEditor) => { return { getValue() { return aceEditor.getValue(); diff --git a/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts index 028d77766d47b1..a6ac26df9555d9 100644 --- a/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts +++ b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts @@ -19,6 +19,19 @@ interface ReturnValue { error?: string; } +const extractProfilerErrorMessage = async (e: any): Promise => { + if (e.body?.attributes?.error?.reason) { + const { reason, line, col } = e.body.attributes.error; + return `${reason} at line: ${line - 1} col: ${col}`; + } + + if (e.body?.message) { + return e.body.message; + } + + return; +}; + export const useRequestProfile = () => { const { http, notifications, getLicenseStatus } = useAppContext(); const licenseEnabled = getLicenseStatus().valid; @@ -60,10 +73,13 @@ export const useRequestProfile = () => { return { data: resp.resp.profile.shards }; } catch (e) { - try { - // Is this a known error type? - notifications.addError(e, { title: e.message }); - } catch (_) { + const profilerErrorMessage = await extractProfilerErrorMessage(e); + if (profilerErrorMessage) { + notifications.addError(e, { + title: e.message, + toastMessage: profilerErrorMessage, + }); + } else { // Otherwise just report the original error notifications.addError(e, { title: i18n.translate('xpack.searchProfiler.errorSomethingWentWrongTitle', { diff --git a/x-pack/plugins/searchprofiler/server/routes/profile.ts b/x-pack/plugins/searchprofiler/server/routes/profile.ts index 620c4b8e7f9417..c47ab81b2ab7e6 100644 --- a/x-pack/plugins/searchprofiler/server/routes/profile.ts +++ b/x-pack/plugins/searchprofiler/server/routes/profile.ts @@ -55,7 +55,15 @@ export const register = ({ router, getLicenseStatus, log }: RouteDependencies) = }); } catch (err) { log.error(err); - return response.internalError(err); + return response.customError({ + statusCode: err.status || 500, + body: err.body + ? { + message: err.message, + attributes: err.body, + } + : err, + }); } } ); From 28b4707d0b94211f0d22fd0e02a04ab921c5e779 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 15:25:20 +0100 Subject: [PATCH 5/8] Fix paths to test_utils --- .../highlight_details_flyout/highlight_details_flyout.test.tsx | 2 +- .../application/components/license_warning_notice.test.ts | 2 +- .../components/profile_tree/__tests__/profile_tree.test.tsx | 2 +- .../public/application/components/searchprofiler_tabs.test.ts | 2 +- .../containers/main/components/empty_tree_placeholder.test.tsx | 2 +- .../main/components/profile_loading_placeholder.test.tsx | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx index 30a4c1dce1dff7..f539baadd50525 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../test_utils'; import { HighlightDetailsFlyout, Props } from '.'; describe('Highlight Details Flyout', () => { diff --git a/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.test.ts b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.test.ts index ebe7a00737868f..79a2d6c1426f72 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.test.ts +++ b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../test_utils'; import { LicenseWarningNotice } from './license_warning_notice'; diff --git a/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/profile_tree.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/profile_tree.test.tsx index ca95ac97e260a9..dbd30f584850c3 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/profile_tree.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__tests__/profile_tree.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../../test_utils'; import { searchResponse } from './fixtures/search_response'; import { ProfileTree, Props } from '../profile_tree'; diff --git a/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.test.ts b/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.test.ts index 8ee43e28bcd2c5..28eb56ae051c7d 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.test.ts +++ b/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../test_utils'; import { SearchProfilerTabs, Props } from './searchprofiler_tabs'; diff --git a/x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.test.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.test.tsx index 4f17d0b4304f64..811f83041006bb 100644 --- a/x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/containers/main/components/empty_tree_placeholder.test.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../../test_utils'; import { EmptyTreePlaceHolder } from '.'; describe('EmptyTreePlaceholder', () => { diff --git a/x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.test.tsx b/x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.test.tsx index 9b3348b4cab4b2..1428840a9464fa 100644 --- a/x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/containers/main/components/profile_loading_placeholder.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../../test_utils'; import { ProfileLoadingPlaceholder } from '.'; describe('Profile Loading Placeholder', () => { From 80957cc7158fbe9809eacc9cfcce092c6a9a941e Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 20 Jan 2020 15:36:41 +0100 Subject: [PATCH 6/8] Update I18n for search profiler --- x-pack/.i18nrc.json | 4 ++-- x-pack/plugins/searchprofiler/server/plugin.ts | 2 +- x-pack/plugins/translations/translations/ja-JP.json | 3 --- x-pack/plugins/translations/translations/zh-CN.json | 3 --- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 71e3bdd6c8c846..869a5115a8aee0 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -28,9 +28,9 @@ "xpack.ml": "legacy/plugins/ml", "xpack.monitoring": "legacy/plugins/monitoring", "xpack.remoteClusters": "legacy/plugins/remote_clusters", - "xpack.reporting": [ "plugins/reporting", "legacy/plugins/reporting" ], + "xpack.reporting": ["plugins/reporting", "legacy/plugins/reporting"], "xpack.rollupJobs": "legacy/plugins/rollup", - "xpack.searchProfiler": "legacy/plugins/searchprofiler", + "xpack.searchProfiler": "plugins/searchprofiler", "xpack.security": ["legacy/plugins/security", "plugins/security"], "xpack.server": "legacy/server", "xpack.siem": "legacy/plugins/siem", diff --git a/x-pack/plugins/searchprofiler/server/plugin.ts b/x-pack/plugins/searchprofiler/server/plugin.ts index 3f9d72ffda78cb..2e09a0a8ffd99f 100644 --- a/x-pack/plugins/searchprofiler/server/plugin.ts +++ b/x-pack/plugins/searchprofiler/server/plugin.ts @@ -43,7 +43,7 @@ export class SearchProfilerServerPlugin implements Plugin { message: message || // Ensure that there is a message when license check fails - i18n.translate('xpack.searchprofiler.licenseCheckErrorMessage', { + i18n.translate('xpack.searchProfiler.licenseCheckErrorMessage', { defaultMessage: 'License check failed', }), }; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index c8a58d90595c4e..94c48430e27a88 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -10500,7 +10500,6 @@ "xpack.searchProfiler.highlightDetails.totalTimeTooltip": "子を除き、このクエリコンポーネントだけに使用された合計時間です", "xpack.searchProfiler.highlightDetails.typeTitle": "タイプ", "xpack.searchProfiler.licenseErrorMessageDescription": "さらに可視化するには有効なライセンス ({licenseTypeList} または {platinumLicenseType}), が必要ですが、クラスターに見つかりませんでした。", - "xpack.searchProfiler.licenseHasExpiredMessage": "検索プロフィールを利用できません。ライセンスが期限切れです。", "xpack.searchProfiler.pageDisplayName": "検索プロファイラー", "xpack.searchProfiler.platinumLicenseTitle": "プラチナ", "xpack.searchProfiler.profileTree.cumulativeTimeTitle": "累積時間:", @@ -10515,8 +10514,6 @@ "xpack.searchProfiler.registryProviderDescription": "Elasticsearch クエリのパフォーマンスを素早く確認します.", "xpack.searchProfiler.registryProviderTitle": "検索プロファイラー", "xpack.searchProfiler.trialLicenseTitle": "トライアル", - "xpack.searchProfiler.unavailableLicenseInformationMessage": "検索プロファイラーを利用できません。現在ライセンス情報が利用できません。", - "xpack.searchProfiler.upgradeLicenseMessage": "現在の {licenseInfo} ライセンスでは検索プロファイラーを利用できません。ライセンスをアップグレードしてください。", "xpack.security.account.breadcrumb": "アカウント管理", "xpack.security.account.changePasswordDescription": "アカウントのパスワードを変更します。", "xpack.security.account.changePasswordForm.cancelButtonLabel": "リセット", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 583495972c4c1e..5e23c0d2d4b28c 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -10499,7 +10499,6 @@ "xpack.searchProfiler.highlightDetails.totalTimeTooltip": "此查询组件花费的总时间(包括子项)", "xpack.searchProfiler.highlightDetails.typeTitle": "类型", "xpack.searchProfiler.licenseErrorMessageDescription": "分析器可视化需要有效的许可({licenseTypeList}或{platinumLicenseType},但在您的集群中未找到任何许可。", - "xpack.searchProfiler.licenseHasExpiredMessage": "Search Profiler 不可用 - 许可已过期。", "xpack.searchProfiler.pageDisplayName": "Search Profiler", "xpack.searchProfiler.platinumLicenseTitle": "白金级", "xpack.searchProfiler.profileTree.cumulativeTimeTitle": "累计时间:", @@ -10514,8 +10513,6 @@ "xpack.searchProfiler.registryProviderDescription": "快速检查任何 Elasticsearch 查询的性能。", "xpack.searchProfiler.registryProviderTitle": "Search Profiler", "xpack.searchProfiler.trialLicenseTitle": "试用", - "xpack.searchProfiler.unavailableLicenseInformationMessage": "Search Profiler 不可用 - 许可信息当前不可用。", - "xpack.searchProfiler.upgradeLicenseMessage": "Search Profiler 不可用于当前的{licenseInfo}许可。请升级您的许可。", "xpack.security.account.breadcrumb": "帐户管理", "xpack.security.account.changePasswordDescription": "为您的帐户更改密码。", "xpack.security.account.changePasswordForm.cancelButtonLabel": "重置", From c14047c81374ac30eec705ca5ec2136228afe56c Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 21 Jan 2020 11:41:20 +0100 Subject: [PATCH 7/8] Fix react hooks ordering bug with license status updates and fix test (wait for first license object before rendering) --- .../public/application/boot.tsx | 3 ++- .../components/license_warning_notice.tsx | 2 +- .../application/contexts/app_context.tsx | 27 ++++++++++++++++--- .../public/application/editor/editor.tsx | 6 ++--- .../public/application/index.tsx | 4 +-- .../plugins/searchprofiler/public/plugin.ts | 26 +++++++----------- .../apps/dev_tools/searchprofiler_editor.ts | 2 +- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/x-pack/plugins/searchprofiler/public/application/boot.tsx b/x-pack/plugins/searchprofiler/public/application/boot.tsx index 31837cde60798a..944b9a513e81cf 100644 --- a/x-pack/plugins/searchprofiler/public/application/boot.tsx +++ b/x-pack/plugins/searchprofiler/public/application/boot.tsx @@ -6,15 +6,16 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { HttpStart as Http, ToastsSetup } from 'kibana/public'; import React from 'react'; + import { LicenseStatus } from '../../common/types'; import { App } from '.'; export interface Dependencies { el: HTMLElement; http: Http; - getLicenseStatus: () => LicenseStatus; I18nContext: any; notifications: ToastsSetup; + initialLicenseStatus: LicenseStatus; } export type AppDependencies = Omit; diff --git a/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.tsx b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.tsx index da9991529e7d44..295e15056acc4f 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice.tsx @@ -36,7 +36,7 @@ export const LicenseWarningNotice = () => { title={i18n.translate('xpack.searchProfiler.licenseErrorMessageTitle', { defaultMessage: 'License error', })} - color="warning" + color="danger" iconType="alert" style={{ padding: '16px' }} > diff --git a/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx b/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx index 2862041f2e7edc..14556d51803353 100644 --- a/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx +++ b/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx @@ -4,10 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useContext, createContext } from 'react'; +import React, { useContext, createContext, useCallback } from 'react'; + import { HttpSetup, ToastsSetup } from 'kibana/public'; import { LicenseStatus } from '../../../common/types'; +export interface ContextArgs { + http: HttpSetup; + notifications: ToastsSetup; + initialLicenseStatus: LicenseStatus; +} + export interface ContextValue { http: HttpSetup; notifications: ToastsSetup; @@ -18,12 +25,24 @@ const AppContext = createContext(null as any); export const AppContextProvider = ({ children, - value, + args: { http, notifications, initialLicenseStatus }, }: { children: React.ReactNode; - value: ContextValue; + args: ContextArgs; }) => { - return {children}; + const getLicenseStatus = useCallback(() => initialLicenseStatus, [initialLicenseStatus]); + + return ( + + {children} + + ); }; export const useAppContext = () => { diff --git a/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx b/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx index 0477b270724dae..5f8ab776a7672c 100644 --- a/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx +++ b/x-pack/plugins/searchprofiler/public/application/editor/editor.tsx @@ -37,15 +37,13 @@ export const Editor = memo(({ licenseEnabled, initialValue, onEditorReady }: Pro const [textArea, setTextArea] = useState(null); - if (licenseEnabled) { - useUIAceKeyboardMode(textArea); - } + useUIAceKeyboardMode(textArea); useEffect(() => { const divEl = containerRef.current; editorInstanceRef.current = initializeEditor({ el: divEl, licenseEnabled }); editorInstanceRef.current.setValue(initialValue, 1); - setTextArea(containerRef.current!.querySelector('textarea')); + setTextArea(licenseEnabled ? containerRef.current!.querySelector('textarea') : null); onEditorReady(createEditorShim(editorInstanceRef.current)); }, [initialValue, onEditorReady, licenseEnabled]); diff --git a/x-pack/plugins/searchprofiler/public/application/index.tsx b/x-pack/plugins/searchprofiler/public/application/index.tsx index 0f0d2e7339184b..fd8ab61eb9b089 100644 --- a/x-pack/plugins/searchprofiler/public/application/index.tsx +++ b/x-pack/plugins/searchprofiler/public/application/index.tsx @@ -10,10 +10,10 @@ import { ProfileContextProvider } from './contexts/profiler_context'; import { AppDependencies } from './boot'; -export function App({ I18nContext, getLicenseStatus, notifications, http }: AppDependencies) { +export function App({ I18nContext, initialLicenseStatus, notifications, http }: AppDependencies) { return ( - +
diff --git a/x-pack/plugins/searchprofiler/public/plugin.ts b/x-pack/plugins/searchprofiler/public/plugin.ts index 1f460aee31dfd0..a0f6478daf7735 100644 --- a/x-pack/plugins/searchprofiler/public/plugin.ts +++ b/x-pack/plugins/searchprofiler/public/plugin.ts @@ -6,20 +6,16 @@ import { i18n } from '@kbn/i18n'; import { Plugin, CoreStart, CoreSetup, PluginInitializerContext } from 'kibana/public'; +import { first } from 'rxjs/operators'; import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; import { LICENSE_CHECK_STATE } from '../../licensing/public'; import { PLUGIN } from '../common/constants'; import { AppPublicPluginDependencies } from './types'; -import { LicenseStatus } from '../common/types'; export class SearchProfilerUIPlugin implements Plugin { - private licenseStatus: LicenseStatus; - - constructor(ctx: PluginInitializerContext) { - this.licenseStatus = { valid: false }; - } + constructor(ctx: PluginInitializerContext) {} async setup( { http, getStartServices }: CoreSetup, @@ -50,25 +46,21 @@ export class SearchProfilerUIPlugin implements Plugin this.licenseStatus, + initialLicenseStatus, el: params.element, I18nContext: i18nDep.Context, notifications: notifications.toasts, }); }, }); - - licensing.license$.subscribe(license => { - const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType); - const isAvailable = state === LICENSE_CHECK_STATE.Valid; - if (isAvailable) { - this.licenseStatus = { valid: true }; - } else { - this.licenseStatus = { valid: false, message }; - } - }); } async start(core: CoreStart, plugins: any) {} diff --git a/x-pack/test/functional/apps/dev_tools/searchprofiler_editor.ts b/x-pack/test/functional/apps/dev_tools/searchprofiler_editor.ts index f8eea76026cc2d..56d7a66930ebfb 100644 --- a/x-pack/test/functional/apps/dev_tools/searchprofiler_editor.ts +++ b/x-pack/test/functional/apps/dev_tools/searchprofiler_editor.ts @@ -51,7 +51,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await aceEditor.setValue(editorTestSubjectSelector, input); await retry.waitFor( - `parser errors to match expection: HAS ${expectation ? 'ERRORS' : 'NO ERRORS'}`, + `parser errors to match expectation: HAS ${expectation ? 'ERRORS' : 'NO ERRORS'}`, async () => { const actual = await aceEditor.hasParseErrors(editorTestSubjectSelector); return expectation === actual; From dab013551654afba164030e1bf0b1513d3c4b9d9 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 22 Jan 2020 12:34:18 +0100 Subject: [PATCH 8/8] Added index.ts file to common in searchprofiler route Marked types and values as internal Removed unnecessary "async" from function Update import to not use "src" alias --- x-pack/plugins/searchprofiler/common/constants.ts | 1 + x-pack/plugins/searchprofiler/common/index.ts | 9 +++++++++ x-pack/plugins/searchprofiler/common/types.ts | 1 + .../plugins/searchprofiler/public/application/boot.tsx | 2 +- .../public/application/contexts/app_context.tsx | 2 +- .../public/application/hooks/use_request_profile.ts | 4 ++-- x-pack/plugins/searchprofiler/public/plugin.ts | 2 +- x-pack/plugins/searchprofiler/server/plugin.ts | 3 +-- x-pack/plugins/searchprofiler/server/types.ts | 4 ++-- 9 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 x-pack/plugins/searchprofiler/common/index.ts diff --git a/x-pack/plugins/searchprofiler/common/constants.ts b/x-pack/plugins/searchprofiler/common/constants.ts index 689663988a3084..be653543f21f50 100644 --- a/x-pack/plugins/searchprofiler/common/constants.ts +++ b/x-pack/plugins/searchprofiler/common/constants.ts @@ -7,6 +7,7 @@ import { LicenseType } from '../../licensing/common/types'; const basicLicense: LicenseType = 'basic'; +/** @internal */ export const PLUGIN = Object.freeze({ id: 'searchprofiler', minimumLicenseType: basicLicense, diff --git a/x-pack/plugins/searchprofiler/common/index.ts b/x-pack/plugins/searchprofiler/common/index.ts new file mode 100644 index 00000000000000..e345d99f4bed70 --- /dev/null +++ b/x-pack/plugins/searchprofiler/common/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 { PLUGIN } from './constants'; + +export { LicenseStatus } from './types'; diff --git a/x-pack/plugins/searchprofiler/common/types.ts b/x-pack/plugins/searchprofiler/common/types.ts index 3872559fc00662..fa69f249feb46e 100644 --- a/x-pack/plugins/searchprofiler/common/types.ts +++ b/x-pack/plugins/searchprofiler/common/types.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +/** @internal */ export interface LicenseStatus { valid: boolean; message?: string; diff --git a/x-pack/plugins/searchprofiler/public/application/boot.tsx b/x-pack/plugins/searchprofiler/public/application/boot.tsx index 944b9a513e81cf..d6e865f0eb8865 100644 --- a/x-pack/plugins/searchprofiler/public/application/boot.tsx +++ b/x-pack/plugins/searchprofiler/public/application/boot.tsx @@ -7,7 +7,7 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { HttpStart as Http, ToastsSetup } from 'kibana/public'; import React from 'react'; -import { LicenseStatus } from '../../common/types'; +import { LicenseStatus } from '../../common'; import { App } from '.'; export interface Dependencies { diff --git a/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx b/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx index 14556d51803353..ea7c3c97c39145 100644 --- a/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx +++ b/x-pack/plugins/searchprofiler/public/application/contexts/app_context.tsx @@ -7,7 +7,7 @@ import React, { useContext, createContext, useCallback } from 'react'; import { HttpSetup, ToastsSetup } from 'kibana/public'; -import { LicenseStatus } from '../../../common/types'; +import { LicenseStatus } from '../../../common'; export interface ContextArgs { http: HttpSetup; diff --git a/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts index a6ac26df9555d9..3d8bee1d62b274 100644 --- a/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts +++ b/x-pack/plugins/searchprofiler/public/application/hooks/use_request_profile.ts @@ -19,7 +19,7 @@ interface ReturnValue { error?: string; } -const extractProfilerErrorMessage = async (e: any): Promise => { +const extractProfilerErrorMessage = (e: any): string | undefined => { if (e.body?.attributes?.error?.reason) { const { reason, line, col } = e.body.attributes.error; return `${reason} at line: ${line - 1} col: ${col}`; @@ -73,7 +73,7 @@ export const useRequestProfile = () => { return { data: resp.resp.profile.shards }; } catch (e) { - const profilerErrorMessage = await extractProfilerErrorMessage(e); + const profilerErrorMessage = extractProfilerErrorMessage(e); if (profilerErrorMessage) { notifications.addError(e, { title: e.message, diff --git a/x-pack/plugins/searchprofiler/public/plugin.ts b/x-pack/plugins/searchprofiler/public/plugin.ts index a0f6478daf7735..8f44e65e4546ae 100644 --- a/x-pack/plugins/searchprofiler/public/plugin.ts +++ b/x-pack/plugins/searchprofiler/public/plugin.ts @@ -11,7 +11,7 @@ import { first } from 'rxjs/operators'; import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; import { LICENSE_CHECK_STATE } from '../../licensing/public'; -import { PLUGIN } from '../common/constants'; +import { PLUGIN } from '../common'; import { AppPublicPluginDependencies } from './types'; export class SearchProfilerUIPlugin implements Plugin { diff --git a/x-pack/plugins/searchprofiler/server/plugin.ts b/x-pack/plugins/searchprofiler/server/plugin.ts index 2e09a0a8ffd99f..e446b864287157 100644 --- a/x-pack/plugins/searchprofiler/server/plugin.ts +++ b/x-pack/plugins/searchprofiler/server/plugin.ts @@ -9,10 +9,9 @@ import { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/serv import { LICENSE_CHECK_STATE } from '../../licensing/common/types'; -import { LicenseStatus } from '../common/types'; +import { LicenseStatus, PLUGIN } from '../common'; import { AppServerPluginDependencies } from './types'; import * as profileRoute from './routes/profile'; -import { PLUGIN } from '../common/constants'; export class SearchProfilerServerPlugin implements Plugin { licenseStatus: LicenseStatus; diff --git a/x-pack/plugins/searchprofiler/server/types.ts b/x-pack/plugins/searchprofiler/server/types.ts index cef9cc6b887684..7aa0032afba138 100644 --- a/x-pack/plugins/searchprofiler/server/types.ts +++ b/x-pack/plugins/searchprofiler/server/types.ts @@ -5,9 +5,9 @@ */ import { IRouter, Logger } from 'kibana/server'; -import { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch'; +import { ElasticsearchPlugin } from '../../../../src/legacy/core_plugins/elasticsearch'; import { LicensingPluginSetup } from '../../licensing/server'; -import { LicenseStatus } from '../common/types'; +import { LicenseStatus } from '../common'; export interface AppServerPluginDependencies { licensing: LicensingPluginSetup;