Skip to content

Commit

Permalink
[ML] Fix table factory usage. (#52486) (#52495)
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 398e69b commit 249d634
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Group>();

// Used to pass on attribute names to table columns
export enum AnomalyDetectionListColumns {
id = 'id',
Expand All @@ -45,8 +47,6 @@ export enum AnomalyDetectionListColumns {
jobsInGroup = 'jobs_in_group',
}

const MlInMemoryTable = mlInMemoryTableFactory<Group>();

interface Props {
items: GroupsDictionary;
statsBarData: JobStatsBarStats;
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 249d634

Please sign in to comment.