From 390ddf472bff84abf80deac85d044fc6315d51d5 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 22 Jan 2020 13:58:18 +0100 Subject: [PATCH] [SearchProfiler] Move out of legacy (#55331) * Initial move of searchprofiler into new platform directory, lots of things need testing * Whitespace, clean up types and remove unused files * 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 * Added extractProfilerErrorMessage function to interface with new error reporting from profiler endpoint * Fix paths to test_utils * Update I18n for search profiler * Fix react hooks ordering bug with license status updates and fix test (wait for first license object before rendering) * 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 Co-authored-by: Elastic Machine --- .github/CODEOWNERS | 156 ++++++++++++++++++ x-pack/.i18nrc.json | 4 +- .../legacy/plugins/searchprofiler/README.md | 26 --- x-pack/legacy/plugins/searchprofiler/index.ts | 47 +----- .../{np_ready/application => }/index.scss | 0 .../plugins/searchprofiler/public/legacy.ts | 28 ---- .../searchprofiler/public/np_ready/plugin.ts | 62 ------- .../searchprofiler/public/register_feature.js | 28 ---- .../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 | 14 ++ .../searchprofiler/common}/index.ts | 4 +- .../searchprofiler/common/types.ts} | 9 +- x-pack/plugins/searchprofiler/kibana.json | 8 + .../plugins/searchprofiler/public/README.md | 3 + .../public}/application/boot.tsx | 7 +- .../highlight_details_flyout.test.tsx | 2 +- .../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 | 2 +- .../components/license_warning_notice.tsx | 2 +- .../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 | 2 +- .../__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 | 2 +- .../components/searchprofiler_tabs.tsx | 0 .../public}/application/containers/index.ts | 0 .../empty_tree_placeholder.test.tsx | 2 +- .../components/empty_tree_placeholder.tsx | 0 .../containers/main/components/index.ts | 0 .../profile_loading_placeholder.test.tsx | 2 +- .../profile_loading_placeholder.tsx | 0 .../application/containers/main/index.ts | 0 .../application/containers/main/main.tsx | 6 +- .../containers/profile_query_editor.tsx | 4 +- .../application/contexts/app_context.tsx | 31 +++- .../application/contexts/profiler_context.tsx | 0 .../application/editor/editor.test.tsx | 2 +- .../public}/application/editor/editor.tsx | 13 +- .../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 | 30 +++- .../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 | 69 ++++++++ x-pack/plugins/searchprofiler/public/types.ts | 15 ++ x-pack/plugins/searchprofiler/server/index.ts | 11 ++ .../plugins/searchprofiler/server/plugin.ts | 59 +++++++ .../searchprofiler/server/routes/profile.ts | 70 ++++++++ x-pack/plugins/searchprofiler/server/types.ts | 22 +++ .../translations/translations/ja-JP.json | 3 - .../translations/translations/zh-CN.json | 3 - .../apps/dev_tools/searchprofiler_editor.ts | 2 +- 104 files changed, 527 insertions(+), 509 deletions(-) create mode 100644 .github/CODEOWNERS delete mode 100644 x-pack/legacy/plugins/searchprofiler/README.md rename x-pack/legacy/plugins/searchprofiler/public/{np_ready/application => }/index.scss (100%) delete mode 100644 x-pack/legacy/plugins/searchprofiler/public/legacy.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/public/np_ready/plugin.ts delete mode 100644 x-pack/legacy/plugins/searchprofiler/public/register_feature.js 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 => plugins/searchprofiler/common}/index.ts (75%) rename x-pack/{legacy/plugins/searchprofiler/server/np_ready/index.ts => plugins/searchprofiler/common/types.ts} (64%) create mode 100644 x-pack/plugins/searchprofiler/kibana.json create mode 100644 x-pack/plugins/searchprofiler/public/README.md 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 (94%) 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 (87%) rename x-pack/{legacy/plugins/searchprofiler/public/np_ready => plugins/searchprofiler/public}/application/components/license_warning_notice.tsx (99%) 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 (89%) 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 (90%) 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 (85%) 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 (86%) 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 (53%) 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 (84%) 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 (73%) 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 create mode 100644 x-pack/plugins/searchprofiler/server/index.ts 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 new file mode 100644 index 00000000000000..547776c4cfe661 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,156 @@ +# GitHub CODEOWNERS definition +# Identify which groups will be pinged by changes to different parts of the codebase. +# For more info, see https://help.github.com/articles/about-codeowners/ + +# App +/x-pack/legacy/plugins/lens/ @elastic/kibana-app +/x-pack/legacy/plugins/graph/ @elastic/kibana-app +/src/plugins/share/ @elastic/kibana-app +/src/legacy/server/url_shortening/ @elastic/kibana-app +/src/legacy/server/sample_data/ @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/dashboard/ @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/discover/ @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/visualize/ @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/local_application_service/ @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/home/ @elastic/kibana-app +/src/legacy/core_plugins/kibana/public/dev_tools/ @elastic/kibana-app +/src/legacy/core_plugins/metrics/ @elastic/kibana-app +/src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app +/src/plugins/home/ @elastic/kibana-app +/src/plugins/kibana_legacy/ @elastic/kibana-app +/src/plugins/timelion/ @elastic/kibana-app +/src/plugins/dev_tools/ @elastic/kibana-app + +# App Architecture +/src/plugins/data/ @elastic/kibana-app-arch +/src/plugins/embeddable/ @elastic/kibana-app-arch +/src/plugins/expressions/ @elastic/kibana-app-arch +/src/plugins/kibana_react/ @elastic/kibana-app-arch +/src/plugins/kibana_utils/ @elastic/kibana-app-arch +/src/plugins/navigation/ @elastic/kibana-app-arch +/src/plugins/ui_actions/ @elastic/kibana-app-arch +/src/plugins/visualizations/ @elastic/kibana-app-arch +/x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch +/src/legacy/core_plugins/data/ @elastic/kibana-app-arch +/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js @elastic/kibana-app-arch +/src/legacy/core_plugins/embeddable_api/ @elastic/kibana-app-arch +/src/legacy/core_plugins/interpreter/ @elastic/kibana-app-arch +/src/legacy/core_plugins/kibana_react/ @elastic/kibana-app-arch +/src/legacy/core_plugins/kibana/public/management/ @elastic/kibana-app-arch +/src/legacy/core_plugins/kibana/server/field_formats/ @elastic/kibana-app-arch +/src/legacy/core_plugins/kibana/server/routes/api/management/ @elastic/kibana-app-arch +/src/legacy/core_plugins/kibana/server/routes/api/suggestions/ @elastic/kibana-app-arch +/src/legacy/core_plugins/visualizations/ @elastic/kibana-app-arch +/src/legacy/server/index_patterns/ @elastic/kibana-app-arch + +# APM +/x-pack/legacy/plugins/apm/ @elastic/apm-ui +/x-pack/test/functional/apps/apm/ @elastic/apm-ui +/src/legacy/core_plugins/apm_oss/ @elastic/apm-ui + +# Beats +/x-pack/legacy/plugins/beats_management/ @elastic/beats + +# Canvas +/x-pack/legacy/plugins/canvas/ @elastic/kibana-canvas + +# Logs & Metrics UI +/x-pack/legacy/plugins/infra/ @elastic/logs-metrics-ui +/x-pack/legacy/plugins/integrations_manager/ @elastic/epm + +# Machine Learning +/x-pack/legacy/plugins/ml/ @elastic/ml-ui +/x-pack/test/functional/apps/machine_learning/ @elastic/ml-ui +/x-pack/test/functional/services/machine_learning/ @elastic/ml-ui +/x-pack/test/functional/services/ml.ts @elastic/ml-ui +# ML team owns the transform plugin, ES team added here for visibility +# because the plugin lives in Kibana's Elasticsearch management section. +/x-pack/legacy/plugins/transform/ @elastic/ml-ui @elastic/es-ui +/x-pack/test/functional/apps/transform/ @elastic/ml-ui +/x-pack/test/functional/services/transform_ui/ @elastic/ml-ui +/x-pack/test/functional/services/transform.ts @elastic/ml-ui + +# Maps +/x-pack/legacy/plugins/maps/ @elastic/kibana-gis +/x-pack/test/api_integration/apis/maps/ @elastic/kibana-gis +/x-pack/test/functional/apps/maps/ @elastic/kibana-gis +/x-pack/test/functional/es_archives/maps/ @elastic/kibana-gis +/x-pack/test/visual_regression/tests/maps/index.js @elastic/kibana-gis + +# Operations +/src/dev/ @elastic/kibana-operations +/src/setup_node_env/ @elastic/kibana-operations +/src/optimize/ @elastic/kibana-operations +/packages/*eslint*/ @elastic/kibana-operations +/packages/*babel*/ @elastic/kibana-operations +/packages/kbn-dev-utils*/ @elastic/kibana-operations +/packages/kbn-es/ @elastic/kibana-operations +/packages/kbn-pm/ @elastic/kibana-operations +/packages/kbn-test/ @elastic/kibana-operations +/packages/kbn-ui-shared-deps/ @elastic/kibana-operations +/src/legacy/server/keystore/ @elastic/kibana-operations +/src/legacy/server/pid/ @elastic/kibana-operations +/src/legacy/server/sass/ @elastic/kibana-operations +/src/legacy/server/utils/ @elastic/kibana-operations +/src/legacy/server/warnings/ @elastic/kibana-operations + +# Platform +/src/core/ @elastic/kibana-platform +/config/kibana.yml @elastic/kibana-platform +/x-pack/plugins/features/ @elastic/kibana-platform +/x-pack/plugins/licensing/ @elastic/kibana-platform +/packages/kbn-config-schema/ @elastic/kibana-platform +/src/legacy/server/config/ @elastic/kibana-platform +/src/legacy/server/http/ @elastic/kibana-platform +/src/legacy/server/i18n/ @elastic/kibana-platform +/src/legacy/server/logging/ @elastic/kibana-platform +/src/legacy/server/saved_objects/ @elastic/kibana-platform +/src/legacy/server/status/ @elastic/kibana-platform + +# Security +/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-platform +/x-pack/legacy/plugins/security/ @elastic/kibana-security +/x-pack/legacy/plugins/spaces/ @elastic/kibana-security +/x-pack/plugins/spaces/ @elastic/kibana-security +/x-pack/legacy/plugins/encrypted_saved_objects/ @elastic/kibana-security +/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security +/x-pack/plugins/security/ @elastic/kibana-security +/x-pack/test/api_integration/apis/security/ @elastic/kibana-security + +# Kibana Localization +/src/dev/i18n/ @elastic/kibana-localization + +# Pulse +/packages/kbn-analytics/ @elastic/pulse +/src/legacy/core_plugins/ui_metric/ @elastic/pulse +/src/plugins/usage_collection/ @elastic/pulse +/x-pack/legacy/plugins/telemetry/ @elastic/pulse + +# Kibana Alerting Services +/x-pack/legacy/plugins/alerting/ @elastic/kibana-alerting-services +/x-pack/legacy/plugins/actions/ @elastic/kibana-alerting-services +/x-pack/plugins/event_log/ @elastic/kibana-alerting-services +/x-pack/plugins/task_manager/ @elastic/kibana-alerting-services +/x-pack/test/alerting_api_integration/ @elastic/kibana-alerting-services +/x-pack/test/plugin_api_integration/plugins/task_manager/ @elastic/kibana-alerting-services +/x-pack/test/plugin_api_integration/test_suites/task_manager/ @elastic/kibana-alerting-services +/x-pack/legacy/plugins/triggers_actions_ui/ @elastic/kibana-alerting-services +/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/ @elastic/kibana-alerting-services +/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/ @elastic/kibana-alerting-services + +# Design +**/*.scss @elastic/kibana-design + +# Elasticsearch UI +/src/legacy/core_plugins/console/ @elastic/es-ui +/src/plugins/es_ui_shared/ @elastic/es-ui +/x-pack/legacy/plugins/console_extensions/ @elastic/es-ui +/x-pack/legacy/plugins/cross_cluster_replication/ @elastic/es-ui +/x-pack/legacy/plugins/index_lifecycle_management/ @elastic/es-ui +/x-pack/legacy/plugins/index_management/ @elastic/es-ui +/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/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/.i18nrc.json b/x-pack/.i18nrc.json index a4a50072b41f0b..022cc4a94cb6fc 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -27,9 +27,9 @@ "xpack.main": "legacy/plugins/xpack_main", "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.siem": "legacy/plugins/siem", "xpack.security": ["legacy/plugins/security", "plugins/security"], "xpack.server": "legacy/server", 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/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/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/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/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/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..be653543f21f50 --- /dev/null +++ b/x-pack/plugins/searchprofiler/common/constants.ts @@ -0,0 +1,14 @@ +/* + * 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'; + +/** @internal */ +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/index.ts similarity index 75% rename from x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/index.ts rename to x-pack/plugins/searchprofiler/common/index.ts index f2c070fd44b6e6..e345d99f4bed70 100644 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/index.ts +++ b/x-pack/plugins/searchprofiler/common/index.ts @@ -4,4 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -export { checkLicense } from './check_license'; +export { PLUGIN } from './constants'; + +export { LicenseStatus } from './types'; diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/index.ts b/x-pack/plugins/searchprofiler/common/types.ts similarity index 64% rename from x-pack/legacy/plugins/searchprofiler/server/np_ready/index.ts rename to x-pack/plugins/searchprofiler/common/types.ts index 9253a0d6b15242..fa69f249feb46e 100644 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/index.ts +++ b/x-pack/plugins/searchprofiler/common/types.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 { SearchProfilerServerPlugin } from './plugin'; -export const plugin = () => { - return new SearchProfilerServerPlugin(); -}; +/** @internal */ +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/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/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..d6e865f0eb8865 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/application/boot.tsx +++ b/x-pack/plugins/searchprofiler/public/application/boot.tsx @@ -4,17 +4,18 @@ * 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'; import { App } from '.'; export interface Dependencies { el: HTMLElement; http: Http; - licenseEnabled: boolean; I18nContext: any; notifications: ToastsSetup; - formatAngularHttpError: any; + initialLicenseStatus: LicenseStatus; } export type AppDependencies = Omit; 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 94% 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 index 30a4c1dce1dff7..f539baadd50525 100644 --- 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 @@ -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/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 87% 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 index ebe7a00737868f..79a2d6c1426f72 100644 --- 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 @@ -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/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 99% 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 index da9991529e7d44..295e15056acc4f 100644 --- 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 @@ -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/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 89% 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 index ca95ac97e260a9..dbd30f584850c3 100644 --- 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 @@ -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/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 90% 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 index 8ee43e28bcd2c5..28eb56ae051c7d 100644 --- 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 @@ -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/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 85% 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 index 4f17d0b4304f64..811f83041006bb 100644 --- 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 @@ -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/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 86% 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 index 9b3348b4cab4b2..1428840a9464fa 100644 --- 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 @@ -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', () => { 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..5348c55ad52139 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 @@ -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 { @@ -39,7 +40,7 @@ export const ProfileQueryEditor = memo(() => { const dispatch = useProfilerActionContext(); - const { licenseEnabled, notifications } = useAppContext(); + const { getLicenseStatus, notifications } = useAppContext(); const requestProfile = useRequestProfile(); const handleProfileClick = async () => { @@ -65,6 +66,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); 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/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 84% 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 index 014336f379059a..5f8ab776a7672c 100644 --- a/x-pack/legacy/plugins/searchprofiler/public/np_ready/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(); @@ -40,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/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 73% 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..3d8bee1d62b274 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 @@ -19,8 +19,22 @@ interface ReturnValue { error?: string; } +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}`; + } + + if (e.body?.message) { + return e.body.message; + } + + return; +}; + 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 }; @@ -39,7 +53,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'; @@ -59,11 +73,13 @@ export const useRequestProfile = () => { return { data: resp.resp.profile.shards }; } catch (e) { - try { - // Is this a known error type? - const errorString = formatAngularHttpError(e); - notifications.addError(e, { title: errorString }); - } catch (_) { + const profilerErrorMessage = 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/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..fd8ab61eb9b089 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, initialLicenseStatus, 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..8f44e65e4546ae --- /dev/null +++ b/x-pack/plugins/searchprofiler/public/plugin.ts @@ -0,0 +1,69 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { 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'; +import { AppPublicPluginDependencies } from './types'; + +export class SearchProfilerUIPlugin implements Plugin { + constructor(ctx: PluginInitializerContext) {} + + 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'); + + const license = await licensing.license$.pipe(first()).toPromise(); + const { state, message } = license.check(PLUGIN.id, PLUGIN.minimumLicenseType); + const initialLicenseStatus = + state === LICENSE_CHECK_STATE.Valid ? { valid: true } : { valid: false, message }; + + return boot({ + http, + initialLicenseStatus, + el: params.element, + I18nContext: i18nDep.Context, + notifications: notifications.toasts, + }); + }, + }); + } + + 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/plugins/searchprofiler/server/index.ts b/x-pack/plugins/searchprofiler/server/index.ts new file mode 100644 index 00000000000000..459cd6c344d923 --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * 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 = (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..e446b864287157 --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/plugin.ts @@ -0,0 +1,59 @@ +/* + * 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 { CoreSetup, Logger, Plugin, PluginInitializerContext } from 'kibana/server'; + +import { LICENSE_CHECK_STATE } from '../../licensing/common/types'; + +import { LicenseStatus, PLUGIN } from '../common'; +import { AppServerPluginDependencies } from './types'; +import * as profileRoute from './routes/profile'; + +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, + 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) { + this.licenseStatus = { valid: true }; + } else { + this.licenseStatus = { + valid: false, + 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); + } + } + }); + } + + 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..c47ab81b2ab7e6 --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/routes/profile.ts @@ -0,0 +1,70 @@ +/* + * 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 { RouteDependencies } from '../types'; + +export const register = ({ router, getLicenseStatus, log }: RouteDependencies) => { + router.post( + { + path: '/api/searchprofiler/profile', + validate: { + body: schema.object({ + query: schema.object({}, { allowUnknowns: true }), + index: schema.string(), + }), + }, + }, + async (ctx, request, response) => { + const currentLicenseStatus = getLicenseStatus(); + if (!currentLicenseStatus.valid) { + return response.forbidden({ + body: { + message: currentLicenseStatus.message!, + }, + }); + } + + const { + core: { elasticsearch }, + } = ctx; + + const { + body: { query, index }, + } = request; + + const parsed = { + // Activate profiler mode for this query. + profile: true, + ...query, + }; + + const body = { + index, + body: JSON.stringify(parsed, null, 2), + }; + try { + const resp = await elasticsearch.dataClient.callAsCurrentUser('search', body); + return response.ok({ + body: { + ok: true, + resp, + }, + }); + } catch (err) { + log.error(err); + return response.customError({ + statusCode: err.status || 500, + body: err.body + ? { + message: err.message, + attributes: err.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..7aa0032afba138 --- /dev/null +++ b/x-pack/plugins/searchprofiler/server/types.ts @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { IRouter, Logger } from 'kibana/server'; +import { ElasticsearchPlugin } from '../../../../src/legacy/core_plugins/elasticsearch'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { LicenseStatus } from '../common'; + +export interface AppServerPluginDependencies { + licensing: LicensingPluginSetup; + elasticsearch: ElasticsearchPlugin; +} + +export interface RouteDependencies { + getLicenseStatus: () => LicenseStatus; + elasticsearch: ElasticsearchPlugin; + router: IRouter; + log: Logger; +} diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index dc8a12c83c4ef4..f9149ba373e44e 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -10525,7 +10525,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": "累積時間:", @@ -10540,8 +10539,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 1f3517cf5514ea..68b05bc020df4d 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -10524,7 +10524,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": "累计时间:", @@ -10539,8 +10538,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": "重置", 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;