Skip to content

Commit

Permalink
[APM] Makes service overview page default (#85786) (#85891)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* fixes linting

Co-authored-by: Cauê Marcondes <[email protected]>

Co-authored-by: Cauê Marcondes <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2020
1 parent 7d7ebb1 commit bcafd22
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/e2e/cypress/integration/apm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Then should redirect to correct path
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Buttons({

const detailsUrl = getAPMHref({
basePath,
path: `/services/${selectedNodeServiceName}/transactions`,
path: `/services/${selectedNodeServiceName}`,
query: urlParams,
});
const focusUrl = getAPMHref({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function TransactionOverviewLink({ serviceName, ...rest }: Props) {

return (
<APMLink
path={`/services/${serviceName}/transactions`}
path={`/services/${serviceName}`}
query={pickKeys(urlParams as APMQueryParams, ...persistedFilters)}
{...rest}
/>
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const uiSettings: Record<string, UiSettingsParams<boolean>> = {
name: i18n.translate('xpack.apm.enableServiceOverviewExperimentName', {
defaultMessage: 'APM Service overview',
}),
value: false,
value: true,
description: i18n.translate(
'xpack.apm.enableServiceOverviewExperimentDescription',
{
Expand Down

0 comments on commit bcafd22

Please sign in to comment.