diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.stories.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.stories.tsx index 9c7e6803e4450..991c3764019af 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.stories.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.stories.tsx @@ -13,12 +13,9 @@ import { APMServiceContext } from '../../../../context/apm_service/apm_service_c import { MockUrlParamsContextProvider } from '../../../../context/url_params_context/mock_url_params_context_provider'; import { AnalyzeDataButton } from './analyze_data_button'; -const KibanaContext = createKibanaReactContext(({ - http: { basePath: { get: () => '' } }, -} as unknown) as Partial); - interface Args { agentName: string; + canShowDashboard: boolean; environment?: string; serviceName: string; } @@ -28,7 +25,14 @@ export default { component: AnalyzeDataButton, decorators: [ (StoryComponent: ComponentType, { args }: StoryContext) => { - const { agentName, environment, serviceName } = args; + const { agentName, canShowDashboard, environment, serviceName } = args; + + const KibanaContext = createKibanaReactContext(({ + application: { + capabilities: { dashboard: { show: canShowDashboard } }, + }, + http: { basePath: { get: () => '' } }, + } as unknown) as Partial); return ( = () => { }; Example.args = { agentName: 'iOS/swift', + canShowDashboard: true, environment: 'testEnvironment', serviceName: 'testServiceName', }; diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.test.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.test.tsx index fdd28fdb378b4..b8b0cfa3054db 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.test.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.test.tsx @@ -25,6 +25,14 @@ describe('AnalyzeDataButton', () => { }); }); + describe('with no dashboard show capabilities', () => { + it('renders nothing', () => { + render(); + + expect(screen.queryByRole('link')).not.toBeInTheDocument(); + }); + }); + describe('with a RUM agent', () => { it('uses a ux dataType', () => { render(); diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.tsx index e963349364442..d8ff7fdf47c58 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/analyze_data_button.tsx @@ -47,8 +47,12 @@ export function AnalyzeDataButton() { const { urlParams } = useUrlParams(); const { rangeTo, rangeFrom, environment } = urlParams; const basepath = services.http?.basePath.get(); + const canShowDashboard = services.application?.capabilities.dashboard.show; - if (isRumAgentName(agentName) || isIosAgentName(agentName)) { + if ( + (isRumAgentName(agentName) || isIosAgentName(agentName)) && + canShowDashboard + ) { const href = createExploratoryViewUrl( { 'apm-series': {