From c3a045e9c2b0f984dfde4eebc3605bf172944d32 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 29 Sep 2021 11:44:04 +0200 Subject: [PATCH] [UX Dashboard] Enabled inspector panel for ux dashboard (#113118) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../plugins/apm/public/application/uxApp.tsx | 11 +++-- .../app/RumDashboard/ActionMenu/index.tsx | 2 + .../RumDashboard/ActionMenu/inpector_link.tsx | 40 +++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/inpector_link.tsx diff --git a/x-pack/plugins/apm/public/application/uxApp.tsx b/x-pack/plugins/apm/public/application/uxApp.tsx index e889b0a1e7d68..16f05cbd51a2c 100644 --- a/x-pack/plugins/apm/public/application/uxApp.tsx +++ b/x-pack/plugins/apm/public/application/uxApp.tsx @@ -37,6 +37,7 @@ import { redirectTo } from '../components/routing/redirect_to'; import { useBreadcrumbs } from '../../../observability/public'; import { useApmPluginContext } from '../context/apm_plugin/use_apm_plugin_context'; import { APP_WRAPPER_CLASS } from '../../../../../src/core/public'; +import { InspectorContextProvider } from '../context/inspector/inspector_context'; export const uxRoutes: APMRouteDefinition[] = [ { @@ -128,10 +129,12 @@ export function UXAppRoot({ > - - - - + + + + + + diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/index.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/index.tsx index a3c85b866ed60..170e3a2fdad1e 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/index.tsx +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/index.tsx @@ -16,6 +16,7 @@ import { import { useUrlParams } from '../../../../context/url_params_context/use_url_params'; import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; import { AppMountParameters } from '../../../../../../../../src/core/public'; +import { InspectorHeaderLink } from '../../../shared/apm_header_action_menu/inspector_header_link'; const ANALYZE_DATA = i18n.translate('xpack.apm.analyzeDataButtonLabel', { defaultMessage: 'Analyze data', @@ -79,6 +80,7 @@ export function UXActionMenu({ defaultMessage: 'Add data', })} + ); diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/inpector_link.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/inpector_link.tsx new file mode 100644 index 0000000000000..fe686d5571eb8 --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/ActionMenu/inpector_link.tsx @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiHeaderLink } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React from 'react'; +import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; +import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; +import { useInspectorContext } from '../../../../context/inspector/use_inspector_context'; +import { enableInspectEsQueries } from '../../../../../../observability/common/ui_settings_keys'; + +export function UxInspectorHeaderLink() { + const { inspector } = useApmPluginContext(); + const { inspectorAdapters } = useInspectorContext(); + const { + services: { uiSettings }, + } = useKibana(); + + const isInspectorEnabled = uiSettings?.get(enableInspectEsQueries); + + const inspect = () => { + inspector.open(inspectorAdapters); + }; + + if (!isInspectorEnabled) { + return null; + } + + return ( + + {i18n.translate('xpack.apm.inspectButtonText', { + defaultMessage: 'Inspect', + })} + + ); +}