From 3881b10c06395511282ecb1e6c46eb9f51b096dd Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 29 Apr 2020 16:30:47 +0200 Subject: [PATCH] load VizOptions component lazily --- .../public/components/table_vis_options.tsx | 5 ++-- .../components/table_vis_options_lazy.tsx | 30 +++++++++++++++++++ .../vis_type_table/public/table_vis_type.ts | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/plugins/vis_type_table/public/components/table_vis_options_lazy.tsx diff --git a/src/plugins/vis_type_table/public/components/table_vis_options.tsx b/src/plugins/vis_type_table/public/components/table_vis_options.tsx index 68348d5ef1060..837d478535936 100644 --- a/src/plugins/vis_type_table/public/components/table_vis_options.tsx +++ b/src/plugins/vis_type_table/public/components/table_vis_options.tsx @@ -147,5 +147,6 @@ function TableOptions({ ); } - -export { TableOptions }; +// default export required for React.Lazy +// eslint-disable-next-line import/no-default-export +export { TableOptions as default }; diff --git a/src/plugins/vis_type_table/public/components/table_vis_options_lazy.tsx b/src/plugins/vis_type_table/public/components/table_vis_options_lazy.tsx new file mode 100644 index 0000000000000..ca273aa771ef1 --- /dev/null +++ b/src/plugins/vis_type_table/public/components/table_vis_options_lazy.tsx @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React, { lazy, Suspense } from 'react'; +import { EuiLoadingSpinner } from '@elastic/eui'; +import { VisOptionsProps } from 'src/plugins/vis_default_editor/public'; +import { TableVisParams } from '../types'; + +const TableOptionsComponent = lazy(() => import('./table_vis_options')); + +export const TableOptions = (props: VisOptionsProps) => ( + }> + + +); diff --git a/src/plugins/vis_type_table/public/table_vis_type.ts b/src/plugins/vis_type_table/public/table_vis_type.ts index 26e5ac8cfd71a..c3bc72497007e 100644 --- a/src/plugins/vis_type_table/public/table_vis_type.ts +++ b/src/plugins/vis_type_table/public/table_vis_type.ts @@ -24,7 +24,7 @@ import { Vis } from '../../visualizations/public'; import { tableVisResponseHandler } from './table_vis_response_handler'; // @ts-ignore import tableVisTemplate from './table_vis.html'; -import { TableOptions } from './components/table_vis_options'; +import { TableOptions } from './components/table_vis_options_lazy'; import { getTableVisualizationControllerClass } from './vis_controller'; export function getTableVisTypeDefinition(core: CoreSetup, context: PluginInitializerContext) {