-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Observability] Lazy load shared components (#88802)
Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
e251ff4
commit 6391ef9
Showing
8 changed files
with
78 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/observability/public/components/shared/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { lazy, Suspense } from 'react'; | ||
import { CoreVitalProps, HeaderMenuPortalProps } from './types'; | ||
|
||
export function getCoreVitalsComponent(props: CoreVitalProps) { | ||
const CoreVitalsLazy = lazy(() => import('./core_web_vitals/index')); | ||
return ( | ||
<Suspense fallback={null}> | ||
<CoreVitalsLazy {...props} /> | ||
</Suspense> | ||
); | ||
} | ||
|
||
export function HeaderMenuPortal(props: HeaderMenuPortalProps) { | ||
const HeaderMenuPortalLazy = lazy(() => import('./header_menu_portal')); | ||
return ( | ||
<Suspense fallback={null}> | ||
<HeaderMenuPortalLazy {...props} /> | ||
</Suspense> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/observability/public/components/shared/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ReactNode } from 'react'; | ||
import { AppMountParameters } from '../../../../../../src/core/public'; | ||
import { UXMetrics } from './core_web_vitals'; | ||
|
||
export interface HeaderMenuPortalProps { | ||
children: ReactNode; | ||
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; | ||
} | ||
|
||
export interface CoreVitalProps { | ||
loading: boolean; | ||
data?: UXMetrics | null; | ||
displayServiceName?: boolean; | ||
serviceName?: string; | ||
totalPageViews?: number; | ||
displayTrafficMetric?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters