Skip to content

Commit

Permalink
[ML] Fix table factory usage. (#52486)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
walterra authored Dec 9, 2019
1 parent e929909 commit cffb4dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
import { AnalyticsViewAction } from '../../../data_frame_analytics/pages/analytics_management/components/analytics_list/actions';
import { formatHumanReadableDateTimeSeconds } from '../../../util/date_utils';

const MlInMemoryTable = mlInMemoryTableFactory<DataFrameAnalyticsListRow>();

interface Props {
items: DataFrameAnalyticsListRow[];
}
Expand Down Expand Up @@ -113,8 +115,6 @@ export const AnalyticsTable: FC<Props> = ({ items }) => {
},
};

const MlInMemoryTable = mlInMemoryTableFactory<DataFrameAnalyticsListRow>();

return (
<MlInMemoryTable
allowNeutralSort={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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<Group>();

// Used to pass on attribute names to table columns
export enum AnomalyDetectionListColumns {
id = 'id',
Expand Down Expand Up @@ -195,8 +197,6 @@ export const AnomalyDetectionTable: FC<Props> = ({ items, jobsList, statsBarData
},
};

const MlInMemoryTable = mlInMemoryTableFactory<Group>();

return (
<Fragment>
<EuiFlexGroup alignItems="center" justifyContent="spaceBetween">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EsDoc>();

interface Props {
transformConfig: TransformPivotConfig;
}
Expand Down Expand Up @@ -197,8 +199,6 @@ export const ExpandedRowPreviewPane: FC<Props> = ({ transformConfig }) => {
const transformTableLoading = previewData.length === 0 && isLoading === true;
const dataTestSubj = `transformPreviewTabContent${!transformTableLoading ? ' loaded' : ''}`;

const TransformTable = transformTableFactory<EsDoc>();

return (
<div data-test-subj={dataTestSubj}>
<TransformTable
Expand Down

0 comments on commit cffb4dc

Please sign in to comment.