[APM] Add logic to setup default landing page for serverless (#158916)

Closes https://github.com/elastic/kibana/issues/158457
## Summary

This PR add default landing page for serverless based on comments
provided here -
https://github.com/elastic/kibana/issues/158457#issuecomment-1570760274
This commit is contained in:
Achyut Jhunjhunwala 2023-06-07 17:27:27 +02:00 committed by GitHub
parent 87dc7ae928
commit ec7ba022e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 2 deletions

View file

@ -12,7 +12,7 @@ xpack.serverless.observability.enabled: true
xpack.infra.logs.app_target: discover
## Set the home route
uiSettings.overrides.defaultRoute: /app/observabilityOnboarding
uiSettings.overrides.defaultRoute: /app/observability/landing
## Set the dev project switch current type
xpack.serverless.plugin.developer.projectSwitcher.currentType: 'observability'

View file

@ -0,0 +1,32 @@
/*
* 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 React from 'react';
import { useHasData } from '../../hooks/use_has_data';
import { useKibana } from '../../utils/kibana_react';
export function LandingPage() {
const { hasDataMap, isAllRequestsComplete } = useHasData();
const {
application: { navigateToUrl },
http: { basePath },
} = useKibana().services;
if (isAllRequestsComplete) {
const { apm, infra_logs: logs } = hasDataMap;
const hasApmData = apm?.hasData;
const hasLogsData = logs?.hasData;
if (hasLogsData) {
navigateToUrl(basePath.prepend('/app/discover'));
} else if (hasApmData) {
navigateToUrl(basePath.prepend('/app/apm/services'));
} else {
navigateToUrl(basePath.prepend('/app/observabilityOnboarding'));
}
}
return <></>;
}

View file

@ -21,6 +21,7 @@ import { SlosWelcomePage } from '../pages/slos_welcome/slos_welcome';
import { SloDetailsPage } from '../pages/slo_details/slo_details';
import { SloEditPage } from '../pages/slo_edit/slo_edit';
import { casesPath } from '../../common';
import { LandingPage } from '../pages/landing/landing';
export type RouteParams<T extends keyof typeof routes> = DecodeParams<typeof routes[T]['params']>;
@ -60,7 +61,7 @@ export const routes = {
},
'/landing': {
handler: () => {
return <SimpleRedirect to="/overview" />;
return <LandingPage />;
},
params: {},
exact: true,