Skip to content

Commit

Permalink
add lazy loading to enable all the services for canvas
Browse files Browse the repository at this point in the history
Signed-off-by: ananzh <[email protected]>
  • Loading branch information
ananzh committed Jun 28, 2023
1 parent 3da84d6 commit b3cbfde
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/plugins/data_explorer/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const DataExplorerApp = ({ basename, history }: DataExplorerAppDeps) => {
restrictWidth={false}
paddingSize="none"
>
{view.ui.canvas}
<React.Suspense fallback={<div>Loading...</div>}>{view.ui.canvas}</React.Suspense>
</EuiPageTemplate>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@
*/

import React from 'react';
import { getServices } from '../../../opensearch_dashboards_services';

export const createCanvas = () => {
return <div>Test Canvas</div>;
const CanvasComponent = React.lazy(async () => {
const services = await getServices();

if (!services) {
return { default: () => <div>Test Canvas</div> };
}
return { default: () => <div>Test Canvas has services</div> };
});

return (
<React.Suspense fallback={<div>Loading...</div>}>
<CanvasComponent />
</React.Suspense>
);
};

0 comments on commit b3cbfde

Please sign in to comment.