forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[file upload] lazy load to reduce page load size (elastic#74967)
* [file upload] lazy load to reduce page load size * tslint
- Loading branch information
Showing
6 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
x-pack/plugins/file_upload/public/get_file_upload_component.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,38 @@ | ||
/* | ||
* 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 from 'react'; | ||
import { FeatureCollection } from 'geojson'; | ||
|
||
export interface FileUploadComponentProps { | ||
appName: string; | ||
isIndexingTriggered: boolean; | ||
onFileUpload: (geojsonFile: FeatureCollection, name: string) => void; | ||
onFileRemove: () => void; | ||
onIndexReady: (indexReady: boolean) => void; | ||
transformDetails: string; | ||
onIndexingComplete: (indexResponses: { | ||
indexDataResp: unknown; | ||
indexPatternResp: unknown; | ||
}) => void; | ||
} | ||
|
||
let lazyLoadPromise: Promise<React.ComponentType<FileUploadComponentProps>>; | ||
|
||
export async function getFileUploadComponent(): Promise< | ||
React.ComponentType<FileUploadComponentProps> | ||
> { | ||
if (typeof lazyLoadPromise !== 'undefined') { | ||
return lazyLoadPromise; | ||
} | ||
|
||
lazyLoadPromise = new Promise(async (resolve) => { | ||
// @ts-expect-error | ||
const { JsonUploadAndParse } = await import('./components/json_upload_and_parse'); | ||
resolve(JsonUploadAndParse); | ||
}); | ||
return lazyLoadPromise; | ||
} |
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