From 249d63462fc2b9199d1ecc5974f69991e845de02 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 9 Dec 2019 14:15:21 +0100 Subject: [PATCH] [ML] Fix table factory usage. (#52486) (#52495) Moves calling the table factory out of components to avoid instantiation on every render call. Note all of this is a workaround for our own typescript version of EuiInMemoryTable. Once the original table has been migrated to TS, we should be able to remove the custom code. --- .../overview/components/anomaly_detection_panel/table.tsx | 4 ++-- .../components/transform_list/expanded_row_preview_pane.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/table.tsx b/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/table.tsx index f6fe1100d1b133..37266017d95391 100644 --- a/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/table.tsx +++ b/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/table.tsx @@ -35,6 +35,8 @@ import { JobSelectorBadge } from '../../../components/job_selector/job_selector_ import { toLocaleString } from '../../../util/string_utils'; import { getSeverityColor } from '../../../../common/util/anomaly_utils'; +const MlInMemoryTable = mlInMemoryTableFactory(); + // Used to pass on attribute names to table columns export enum AnomalyDetectionListColumns { id = 'id', @@ -45,8 +47,6 @@ export enum AnomalyDetectionListColumns { jobsInGroup = 'jobs_in_group', } -const MlInMemoryTable = mlInMemoryTableFactory(); - interface Props { items: GroupsDictionary; statsBarData: JobStatsBarStats; diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx index 5a5e8308b8d571..6ee03ccca16e12 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row_preview_pane.tsx @@ -22,6 +22,8 @@ import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/p import { formatHumanReadableDateTimeSeconds } from '../../../../../../common/utils/date_utils'; import { transformTableFactory } from './transform_table'; +const TransformTable = transformTableFactory(); + interface Props { transformConfig: TransformPivotConfig; } @@ -197,8 +199,6 @@ export const ExpandedRowPreviewPane: FC = ({ transformConfig }) => { const transformTableLoading = previewData.length === 0 && isLoading === true; const dataTestSubj = `transformPreviewTabContent${!transformTableLoading ? ' loaded' : ''}`; - const TransformTable = transformTableFactory(); - return (