From bcafd2257467b3824640466f37252fb672ad93ad Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Tue, 15 Dec 2020 13:44:49 -0500 Subject: [PATCH] [APM] Makes service overview page default (#85786) (#85891) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Closes #81948 by setting the default route for services to the service overview page also updates links to the general path which gets redirected according to user settings * fixes incorrect test names * Update x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com> * fixes linting Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com> Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../apm/e2e/cypress/integration/apm.feature | 2 +- .../cypress/support/step_definitions/apm.ts | 5 ++--- .../components/app/Main/route_config/index.tsx | 18 ++++++++++++++---- .../app/ServiceMap/Popover/Buttons.tsx | 2 +- .../Links/apm/TransactionOverviewLink.tsx | 2 +- x-pack/plugins/apm/server/ui_settings.ts | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/apm/e2e/cypress/integration/apm.feature b/x-pack/plugins/apm/e2e/cypress/integration/apm.feature index 494a6b5fadb5b..72c060c48f755 100644 --- a/x-pack/plugins/apm/e2e/cypress/integration/apm.feature +++ b/x-pack/plugins/apm/e2e/cypress/integration/apm.feature @@ -3,4 +3,4 @@ Feature: APM Scenario: Transaction duration charts Given a user browses the APM UI application When the user inspects the opbeans-node service - Then should redirect to correct path with correct params \ No newline at end of file + Then should redirect to correct path diff --git a/x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts b/x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts index 42c2bc7ffd318..b7a405274385d 100644 --- a/x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts +++ b/x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts @@ -25,7 +25,6 @@ When(`the user inspects the opbeans-node service`, () => { .click({ force: true }); }); -Then(`should redirect to correct path with correct params`, () => { - cy.url().should('contain', `/app/apm/services/opbeans-node/transactions`); - cy.url().should('contain', `transactionType=request`); +Then(`should redirect to correct path`, () => { + cy.url().should('contain', `/app/apm/services/opbeans-node/overview`); }); diff --git a/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx b/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx index 839c087305bd8..9e90e6cfbbc2b 100644 --- a/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx @@ -27,6 +27,8 @@ import { CreateAgentConfigurationRouteHandler, EditAgentConfigurationRouteHandler, } from './route_handlers/agent_configuration'; +import { enableServiceOverview } from '../../../../../common/ui_settings_keys'; +import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; /** * Given a path, redirect to that location, preserving the search and maintaining @@ -143,6 +145,17 @@ function SettingsCustomizeUI(props: RouteComponentProps<{}>) { ); } +function DefaultServicePageRouteHandler( + props: RouteComponentProps<{ serviceName: string }> +) { + const { uiSettings } = useApmPluginContext().core; + const { serviceName } = props.match.params; + if (uiSettings.get(enableServiceOverview)) { + return renderAsRedirectTo(`/services/${serviceName}/overview`)(props); + } + return renderAsRedirectTo(`/services/${serviceName}/transactions`)(props); +} + /** * The array of route definitions to be used when the application * creates the routes. @@ -217,10 +230,7 @@ export const routes: APMRouteDefinition[] = [ exact: true, path: '/services/:serviceName', breadcrumb: ({ match }) => match.params.serviceName, - render: (props: RouteComponentProps<{ serviceName: string }>) => - renderAsRedirectTo( - `/services/${props.match.params.serviceName}/transactions` - )(props), + component: DefaultServicePageRouteHandler, } as APMRouteDefinition<{ serviceName: string }>, { exact: true, diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx index 56110a89ed888..995ec5cd74139 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx @@ -29,7 +29,7 @@ export function Buttons({ const detailsUrl = getAPMHref({ basePath, - path: `/services/${selectedNodeServiceName}/transactions`, + path: `/services/${selectedNodeServiceName}`, query: urlParams, }); const focusUrl = getAPMHref({ diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx index 959f60bfa6439..1d99b82a67326 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx @@ -31,7 +31,7 @@ export function TransactionOverviewLink({ serviceName, ...rest }: Props) { return ( diff --git a/x-pack/plugins/apm/server/ui_settings.ts b/x-pack/plugins/apm/server/ui_settings.ts index 4932d9f79a383..2a9c3d6b71ff2 100644 --- a/x-pack/plugins/apm/server/ui_settings.ts +++ b/x-pack/plugins/apm/server/ui_settings.ts @@ -36,7 +36,7 @@ export const uiSettings: Record> = { name: i18n.translate('xpack.apm.enableServiceOverviewExperimentName', { defaultMessage: 'APM Service overview', }), - value: false, + value: true, description: i18n.translate( 'xpack.apm.enableServiceOverviewExperimentDescription', {