-
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.
* perf: ⚡️ load dynamically reporting management section * refactor: 💡 remove JSX from main plugin entry file * perf: ⚡️ lazy-load CSV sharing panel React component * perf: ⚡️ lazy-load screen capture sharing panel React components * feat: 🎸 show spinner while shring panels are loading
- Loading branch information
Showing
9 changed files
with
152 additions
and
42 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/reporting/public/components/panel_spinner.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,22 @@ | ||
/* | ||
* 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 * as React from 'react'; | ||
import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui'; | ||
|
||
export const PanelSpinner: React.FC = (props) => { | ||
return ( | ||
<> | ||
<EuiSpacer /> | ||
<EuiFlexGroup justifyContent="spaceAround"> | ||
<EuiFlexItem grow={false}> | ||
<EuiLoadingSpinner size="l" /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer /> | ||
</> | ||
); | ||
}; |
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
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/reporting/public/components/reporting_panel_content_lazy.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,24 @@ | ||
/* | ||
* 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 * as React from 'react'; | ||
import { lazy, Suspense, FC } from 'react'; | ||
import { PanelSpinner } from './panel_spinner'; | ||
import type { Props } from './reporting_panel_content'; | ||
|
||
const LazyComponent = lazy(() => | ||
import('./reporting_panel_content').then(({ ReportingPanelContent }) => ({ | ||
default: ReportingPanelContent, | ||
})) | ||
); | ||
|
||
export const ReportingPanelContent: FC<Omit<Props, 'intl'>> = (props) => { | ||
return ( | ||
<Suspense fallback={<PanelSpinner />}> | ||
<LazyComponent {...props} /> | ||
</Suspense> | ||
); | ||
}; |
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
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/reporting/public/components/screen_capture_panel_content_lazy.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,24 @@ | ||
/* | ||
* 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 * as React from 'react'; | ||
import { lazy, Suspense, FC } from 'react'; | ||
import { PanelSpinner } from './panel_spinner'; | ||
import type { Props } from './screen_capture_panel_content'; | ||
|
||
const LazyComponent = lazy(() => | ||
import('./screen_capture_panel_content').then(({ ScreenCapturePanelContent }) => ({ | ||
default: ScreenCapturePanelContent, | ||
})) | ||
); | ||
|
||
export const ScreenCapturePanelContent: FC<Props> = (props) => { | ||
return ( | ||
<Suspense fallback={<PanelSpinner />}> | ||
<LazyComponent {...props} /> | ||
</Suspense> | ||
); | ||
}; |
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/reporting/public/mount_management_section.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,42 @@ | ||
/* | ||
* 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 * as React from 'react'; | ||
import { render, unmountComponentAtNode } from 'react-dom'; | ||
import { I18nProvider } from '@kbn/i18n/react'; | ||
import { CoreSetup, CoreStart } from 'src/core/public'; | ||
import { Observable } from 'rxjs'; | ||
import { ReportListing } from './components/report_listing'; | ||
import { ManagementAppMountParams } from '../../../../src/plugins/management/public'; | ||
import { ILicense } from '../../licensing/public'; | ||
import { ClientConfigType } from './plugin'; | ||
import { ReportingAPIClient } from './lib/reporting_api_client'; | ||
|
||
export async function mountManagementSection( | ||
coreSetup: CoreSetup, | ||
coreStart: CoreStart, | ||
license$: Observable<ILicense>, | ||
pollConfig: ClientConfigType['poll'], | ||
apiClient: ReportingAPIClient, | ||
params: ManagementAppMountParams | ||
) { | ||
render( | ||
<I18nProvider> | ||
<ReportListing | ||
toasts={coreSetup.notifications.toasts} | ||
license$={license$} | ||
pollConfig={pollConfig} | ||
redirect={coreStart.application.navigateToApp} | ||
apiClient={apiClient} | ||
/> | ||
</I18nProvider>, | ||
params.element | ||
); | ||
|
||
return () => { | ||
unmountComponentAtNode(params.element); | ||
}; | ||
} |
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