-
Notifications
You must be signed in to change notification settings - Fork 4k
/
ExperimentRunsTableCompactView.js
720 lines (693 loc) · 25.2 KB
/
ExperimentRunsTableCompactView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import ExperimentViewUtil from './ExperimentViewUtil';
import { RunInfo } from '../sdk/MlflowMessages';
import classNames from 'classnames';
import { Dropdown, Menu } from 'antd';
import BaggedCell from './BaggedCell';
import { CellMeasurer, CellMeasurerCache, AutoSizer, Column, Table } from 'react-virtualized';
import _ from 'lodash';
import { LoadMoreBar } from './LoadMoreBar';
import 'react-virtualized/styles.css';
import { COLUMN_TYPES } from '../constants';
export const NUM_RUN_METADATA_COLS = 10;
const TABLE_HEADER_HEIGHT = 48;
const UNBAGGED_COL_WIDTH = 125;
const BAGGED_COL_WIDTH = 250;
const BORDER_STYLE = '1px solid rgb(240, 240, 240)';
const LOAD_MORE_ROW_HEIGHT = 37;
const styles = {
sortArrow: {
marginLeft: '2px',
},
sortContainer: {
minHeight: '18px',
},
sortToggle: {
cursor: 'pointer',
},
sortKeyName: {
display: 'inline-block',
},
metricParamCellContent: {
display: 'inline-block',
maxWidth: 120,
},
metricParamNameContainer: {
display: 'inline-block',
overflow: 'hidden',
},
unbaggedMetricParamColHeader: {
maxWidth: UNBAGGED_COL_WIDTH,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
padding: '12px 8px',
height: '100%',
},
columnStyle: {
display: 'flex',
alignItems: 'flex-start',
},
baggedCellContainer: {
whiteSpace: 'normal',
},
};
/**
* Compact table view for displaying runs associated with an experiment. Renders metrics/params in
* a single table cell per run (as opposed to one cell per metric/param).
*/
export class ExperimentRunsTableCompactView extends React.Component {
constructor(props) {
super(props);
this.getRow = this.getRow.bind(this);
this.tableRef = React.createRef();
this.state = {
expanding: false,
isAtScrollBottom: false,
};
}
static propTypes = {
runInfos: PropTypes.arrayOf(PropTypes.instanceOf(RunInfo)).isRequired,
modelVersionsByRunUuid: PropTypes.object.isRequired,
// List of list of params in all the visible runs
paramsList: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.object)).isRequired,
// List of list of metrics in all the visible runs
metricsList: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.object)).isRequired,
// List of tags dictionary in all the visible runs.
tagsList: PropTypes.arrayOf(PropTypes.object).isRequired,
// Function which takes one parameter (runId)
onCheckbox: PropTypes.func.isRequired,
onCheckAll: PropTypes.func.isRequired,
onExpand: PropTypes.func.isRequired,
isAllChecked: PropTypes.bool.isRequired,
onSortBy: PropTypes.func.isRequired,
orderByKey: PropTypes.string,
orderByAsc: PropTypes.bool.isRequired,
runsSelected: PropTypes.object.isRequired,
runsExpanded: PropTypes.object.isRequired,
paramKeyList: PropTypes.arrayOf(PropTypes.string).isRequired,
metricKeyList: PropTypes.arrayOf(PropTypes.string).isRequired,
metricRanges: PropTypes.object.isRequired,
// Handler for adding a metric or parameter to the set of bagged columns. All bagged metrics
// are displayed in a single column, while each unbagged metric has its own column. Similar
// logic applies for params.
onAddBagged: PropTypes.func.isRequired,
// Handler for removing a metric or parameter from the set of bagged columns.
onRemoveBagged: PropTypes.func.isRequired,
// Array of keys corresponding to unbagged params
unbaggedParams: PropTypes.arrayOf(PropTypes.string).isRequired,
// Array of keys corresponding to unbagged metrics
unbaggedMetrics: PropTypes.arrayOf(PropTypes.string).isRequired,
nextPageToken: PropTypes.string,
numRunsFromLatestSearch: PropTypes.number,
handleLoadMoreRuns: PropTypes.func.isRequired,
loadingMore: PropTypes.bool.isRequired,
categorizedUncheckedKeys: PropTypes.object.isRequired,
nestChildren: PropTypes.bool,
};
/** Returns a row of table content (i.e. a non-header row) corresponding to a single run. */
getRow({ idx, isParent, hasExpander, expanderOpen, childrenIds }) {
const {
runInfos,
modelVersionsByRunUuid,
paramsList,
metricsList,
onCheckbox,
orderByKey,
orderByAsc,
runsSelected,
tagsList,
onSortBy,
onExpand,
paramKeyList,
metricKeyList,
metricRanges,
unbaggedMetrics,
unbaggedParams,
onRemoveBagged,
categorizedUncheckedKeys,
} = this.props;
const paramsMap = ExperimentViewUtil.toParamsMap(paramsList[idx]);
const metricsMap = ExperimentViewUtil.toMetricsMap(metricsList[idx]);
const runInfo = runInfos[idx];
const modelVersionInfo = modelVersionsByRunUuid[runInfo.run_uuid];
const selected = runsSelected[runInfo.run_uuid] === true;
const rowContents = [
ExperimentViewUtil.getCheckboxForRow(selected, () => onCheckbox(runInfo.run_uuid), 'div'),
ExperimentViewUtil.getExpander(
hasExpander,
expanderOpen,
() => {
onExpand(runInfo.run_uuid, childrenIds);
this.setState({ expanding: true });
},
runInfo.run_uuid,
'div',
),
];
const excludedTagsSet = new Set(categorizedUncheckedKeys[COLUMN_TYPES.TAGS]);
ExperimentViewUtil.getRunInfoCellsForRow(
runInfo,
_.pickBy(tagsList[idx], (t) => !excludedTagsSet.has(t.key)),
isParent,
'div',
this.handleCellToggle,
categorizedUncheckedKeys[COLUMN_TYPES.ATTRIBUTES],
).forEach((col) => rowContents.push(col));
rowContents.push(
ExperimentViewUtil.getLinkedModelCell(modelVersionInfo, this.handleCellToggle),
);
const unbaggedParamSet = new Set(unbaggedParams);
const unbaggedMetricSet = new Set(unbaggedMetrics);
const baggedParams = paramKeyList.filter(
(paramKey) => !unbaggedParamSet.has(paramKey) && paramsMap[paramKey] !== undefined,
);
const baggedMetrics = metricKeyList.filter(
(metricKey) => !unbaggedMetricSet.has(metricKey) && metricsMap[metricKey] !== undefined,
);
// Add params (unbagged, then bagged)
unbaggedParams.forEach((paramKey) => {
rowContents.push(ExperimentViewUtil.getUnbaggedParamCell(paramKey, paramsMap, 'div'));
});
// Add bagged params
const paramsCellContents = baggedParams.map((paramKey) => {
const keyname = 'param-' + paramKey;
const sortIcon = ExperimentViewUtil.getSortIcon(
orderByKey,
orderByAsc,
ExperimentViewUtil.makeCanonicalKey('params', paramKey),
);
return (
<BaggedCell
key={keyname}
sortIcon={sortIcon}
keyName={paramKey}
value={paramsMap[paramKey].getValue()}
onSortBy={onSortBy}
isMetric={false}
isParam
onRemoveBagged={onRemoveBagged}
/>
);
});
if (this.shouldShowBaggedColumn(true)) {
rowContents.push(
<div
key={'params-container-cell-' + runInfo.run_uuid}
className='metric-param-container-cell'
>
{paramsCellContents}
</div>,
);
}
// Add metrics (unbagged, then bagged)
unbaggedMetrics.forEach((metricKey) => {
rowContents.push(
ExperimentViewUtil.getUnbaggedMetricCell(metricKey, metricsMap, metricRanges, 'div'),
);
});
// Add bagged metrics
const metricsCellContents = baggedMetrics.map((metricKey) => {
const keyname = 'metric-' + metricKey;
const sortIcon = ExperimentViewUtil.getSortIcon(
orderByKey,
orderByAsc,
ExperimentViewUtil.makeCanonicalKey('metrics', metricKey),
);
return (
<BaggedCell
key={keyname}
keyName={metricKey}
value={metricsMap[metricKey].getValue().toString()}
sortIcon={sortIcon}
onSortBy={onSortBy}
isMetric
isParam={false}
onRemoveBagged={onRemoveBagged}
/>
);
});
if (this.shouldShowBaggedColumn(false)) {
rowContents.push(
<div
key={'metrics-container-cell-' + runInfo.run_uuid}
className='metric-param-container-cell'
>
{metricsCellContents}
</div>,
);
}
return {
key: runInfo.run_uuid,
contents: rowContents,
isChild: !isParent,
};
}
/**
* Returns true if our table should contain a column for displaying bagged params (if isParam is
* truthy) or bagged metrics.
*/
shouldShowBaggedColumn(isParam) {
const { metricKeyList, paramKeyList, unbaggedMetrics, unbaggedParams } = this.props;
if (isParam) {
return unbaggedParams.length !== paramKeyList.length || paramKeyList.length === 0;
}
return unbaggedMetrics.length !== metricKeyList.length || metricKeyList.length === 0;
}
/**
* Returns an array of header-row cells (DOM elements) corresponding to metric / parameter
* columns.
*/
getMetricParamHeaderCells() {
const {
onSortBy,
orderByKey,
orderByAsc,
paramKeyList,
metricKeyList,
unbaggedMetrics,
unbaggedParams,
onAddBagged,
} = this.props;
const columns = [];
const getHeaderCell = (isParam, key, i) => {
const keyType = isParam ? 'params' : 'metrics';
const canonicalKey = ExperimentViewUtil.makeCanonicalKey(keyType, key);
const sortIcon = ExperimentViewUtil.getSortIcon(orderByKey, orderByAsc, canonicalKey);
const className = 'bottom-row';
const elemKey = (isParam ? 'param-' : 'metric-') + key;
const keyContainerWidth = sortIcon ? 'calc(100% - 20px)' : '100%';
return (
<div key={elemKey} className={className} style={styles.unbaggedMetricParamColHeader}>
<Dropdown
trigger={['click']}
overlay={
<Menu className='mlflow-menu'>
<Menu.Item
className='mlflow-menu-item'
onClick={() => onSortBy(canonicalKey, true)}
>
Sort ascending
</Menu.Item>
<Menu.Item
className='mlflow-menu-item'
onClick={() => onSortBy(canonicalKey, false)}
>
Sort descending
</Menu.Item>
<Menu.Item className='mlflow-menu-item' onClick={() => onAddBagged(isParam, key)}>
Collapse column
</Menu.Item>
</Menu>
}
>
<span className='param-sort-toggle-group'>
<span
className='metric-param-sort-toggle'
style={{
maxWidth: keyContainerWidth,
...styles.metricParamNameContainer,
}}
>
{key}
</span>
<span style={ExperimentViewUtil.styles.sortIconContainer}>{sortIcon}</span>
</span>
</Dropdown>
</div>
);
};
const paramClassName = classNames('bottom-row', { 'left-border': unbaggedParams.length === 0 });
const metricClassName = classNames('bottom-row', {
'left-border': unbaggedMetrics.length === 0,
});
unbaggedParams.forEach((paramKey, i) => {
columns.push(getHeaderCell(true, paramKey, i));
});
if (this.shouldShowBaggedColumn(true)) {
columns.push(
<div key='meta-bagged-params left-border' className={paramClassName}>
{paramKeyList.length !== 0 ? '' : '(n/a)'}
</div>,
);
}
unbaggedMetrics.forEach((metricKey, i) => {
columns.push(getHeaderCell(false, metricKey, i));
});
if (this.shouldShowBaggedColumn(false)) {
columns.push(
<div key='meta-bagged-metrics left-border' className={metricClassName}>
{metricKeyList.length !== 0 ? '' : '(n/a)'}
</div>,
);
}
return columns;
}
handleCellToggle = () => {
this._cache.clearAll();
this.forceUpdate();
};
_cache = new CellMeasurerCache({
fixedWidth: true,
minHeight: 32,
});
_lastRenderedWidth = -1;
_lastOrderByKey = this.props.orderByKey;
_lastOrderByAsc = this.props.orderByAsc;
_lastRunsExpanded = this.props.runsExpanded;
_lastUnbaggedMetrics = this.props.unbaggedMetrics;
_lastUnbaggedParams = this.props.unbaggedParams;
render() {
const {
runInfos,
onCheckAll,
isAllChecked,
onSortBy,
orderByKey,
orderByAsc,
tagsList,
runsExpanded,
unbaggedMetrics,
unbaggedParams,
nextPageToken,
numRunsFromLatestSearch,
loadingMore,
handleLoadMoreRuns,
categorizedUncheckedKeys,
nestChildren,
} = this.props;
const rows = ExperimentViewUtil.getRowRenderMetadata({
runInfos,
tagsList,
runsExpanded,
nestChildren,
});
const headerCells = [
ExperimentViewUtil.getSelectAllCheckbox(onCheckAll, isAllChecked, 'div'),
// placeholder for expander header cell,
ExperimentViewUtil.getExpanderHeader('div'),
];
ExperimentViewUtil.getRunMetadataHeaderCells(
onSortBy,
orderByKey,
orderByAsc,
'div',
categorizedUncheckedKeys[COLUMN_TYPES.ATTRIBUTES],
).forEach((headerCell) => headerCells.push(headerCell));
this.getMetricParamHeaderCells().forEach((cell) => headerCells.push(cell));
const showLoadMore = this.state.isAtScrollBottom || this.props.loadingMore;
return (
<div
id='autosizer-container'
className='runs-table-flex-container compact-view-table-container'
data-test-id='compact-runs-table-view'
>
<AutoSizer>
{({ width, height }) => {
if (this._lastRenderedWidth !== width) {
this._lastRenderedWidth = width;
this._cache.clearAll();
}
if (this._lastOrderByKey !== orderByKey) {
this._lastOrderByKey = orderByKey;
this._cache.clearAll();
}
if (this._lastOrderByAsc !== orderByAsc) {
this._lastOrderByAsc = orderByAsc;
this._cache.clearAll();
}
if (this._lastUnbaggedMetrics !== unbaggedMetrics) {
this._lastUnbaggedMetrics = unbaggedMetrics;
this._cache.clearAll();
}
if (this._lastUnbaggedParams !== unbaggedParams) {
this._lastUnbaggedParams = unbaggedParams;
this._cache.clearAll();
}
const runMetadataColWidths = [
30, // checkbox column width
20, // expander column width
35, // 'Status' column width
180, // 'Date' column width
120, // 'user' column width
120, // 'Run Name' column width
100, // 'Source' column width
80, // 'Version' column width
250, // 'Tags' column width,
190, // 'Linked Models' column width
];
const showBaggedParams = this.shouldShowBaggedColumn(true);
const showBaggedMetrics = this.shouldShowBaggedColumn(false);
const runMetadataWidth = runMetadataColWidths.reduce((a, b) => a + b);
const tableMinWidth =
BAGGED_COL_WIDTH * (showBaggedParams + showBaggedMetrics) +
runMetadataWidth +
UNBAGGED_COL_WIDTH * (unbaggedMetrics.length + unbaggedParams.length);
const tableWidth = Math.max(width, tableMinWidth);
// If we aren't showing bagged metrics or params (bagged metrics & params are the
// only cols that use the CellMeasurer component), set the row height statically
const cellMeasurerProps = {};
if (showBaggedMetrics || showBaggedParams) {
cellMeasurerProps.rowHeight = this._cache.rowHeight;
cellMeasurerProps.deferredMeasurementCache = this._cache;
} else {
cellMeasurerProps.rowHeight = 32;
}
const numVisibleMetaColumns =
NUM_RUN_METADATA_COLS - categorizedUncheckedKeys[COLUMN_TYPES.ATTRIBUTES].length;
return [
<Table
key='table'
ref={this.tableRef}
onScroll={this.handleScroll}
{...cellMeasurerProps}
width={tableWidth}
height={Math.max(height - TABLE_HEADER_HEIGHT, 200) + 20}
headerHeight={TABLE_HEADER_HEIGHT}
overscanRowCount={2}
rowCount={rows.length}
gridStyle={{
borderLeft: BORDER_STYLE,
borderBottom: BORDER_STYLE,
borderRight: BORDER_STYLE,
}}
rowGetter={({ index }) => this.getRow(rows[index])}
rowStyle={({ index }) => {
const base = {
alignItems: 'stretch',
borderBottom: BORDER_STYLE,
overflow: 'visible',
};
if (index === -1) {
return {
...base,
backgroundColor: '#fafafa',
borderTop: BORDER_STYLE,
borderLeft: BORDER_STYLE,
borderRight: BORDER_STYLE,
};
}
return base;
}}
>
{[...Array(numVisibleMetaColumns).keys()].map((colIdx) => {
return (
<Column
dataKey={'column-' + colIdx}
key={'column-' + colIdx}
width={runMetadataColWidths[colIdx]}
headerRenderer={() => headerCells[colIdx]}
style={{
...styles.columnStyle,
// show left boarder for run tags column
...(colIdx === numVisibleMetaColumns - 1
? { borderLeft: BORDER_STYLE }
: undefined),
}}
cellRenderer={({ rowIndex, rowData, parent, dataKey }) => (
<CellMeasurer
cache={this._cache}
columnIndex={colIdx}
key={dataKey}
parent={parent}
rowIndex={rowIndex}
>
{rowData.contents[colIdx]}
</CellMeasurer>
)}
/>
);
})}
{unbaggedParams.map((unbaggedParam, idx) => {
return (
<Column
key={'param-' + unbaggedParam}
dataKey={'param-' + unbaggedParam}
width={UNBAGGED_COL_WIDTH}
headerRenderer={() => headerCells[numVisibleMetaColumns + idx]}
style={styles.columnStyle}
cellRenderer={({ rowData }) => rowData.contents[numVisibleMetaColumns + idx]}
/>
);
})}
{showBaggedParams && (
<Column
width={BAGGED_COL_WIDTH}
flexShrink={0}
label='Parameters'
dataKey='params'
headerRenderer={() => {
return (
<div
style={{
...styles.unbaggedMetricParamColHeader,
leftBorder: BORDER_STYLE,
}}
>
Parameters
</div>
);
}}
style={{ ...styles.columnStyle, borderLeft: BORDER_STYLE }}
cellRenderer={({ rowIndex, rowData, parent, dataKey }) => {
const colIdx = numVisibleMetaColumns + unbaggedParams.length;
// Add extra padding for load more
const paddingOpt =
rowIndex === rows.length - 1
? { paddingBottom: LOAD_MORE_ROW_HEIGHT * 2 }
: {};
return (
<CellMeasurer
cache={this._cache}
columnIndex={colIdx}
key={dataKey}
parent={parent}
rowIndex={rowIndex}
>
<div style={{ ...styles.baggedCellContainer, ...paddingOpt }}>
{rowData.contents[colIdx]}
</div>
</CellMeasurer>
);
}}
/>
)}
{unbaggedMetrics.map((unbaggedMetric, idx) => {
const colIdx =
numVisibleMetaColumns + showBaggedParams + unbaggedParams.length + idx;
return (
<Column
key={'metric-' + unbaggedMetric}
label='Version'
dataKey={'metric-' + unbaggedMetric}
width={UNBAGGED_COL_WIDTH}
headerRenderer={() => headerCells[colIdx]}
style={styles.columnStyle}
cellRenderer={({ rowData }) => rowData.contents[colIdx]}
/>
);
})}
{showBaggedMetrics && (
<Column
width={BAGGED_COL_WIDTH}
flexShrink={0}
label='Metrics'
dataKey='metrics'
headerRenderer={() => {
return (
<div
style={{
...styles.unbaggedMetricParamColHeader,
leftBorder: BORDER_STYLE,
}}
>
Metrics
</div>
);
}}
style={{ ...styles.columnStyle, borderLeft: BORDER_STYLE }}
cellRenderer={({ rowIndex, rowData, parent, dataKey }) => {
const colIdx =
numVisibleMetaColumns +
showBaggedParams +
unbaggedParams.length +
unbaggedMetrics.length;
return (
<CellMeasurer
cache={this._cache}
columnIndex={colIdx}
key={dataKey}
parent={parent}
rowIndex={rowIndex}
>
<div style={{ ...styles.baggedCellContainer }}>
{rowData.contents[colIdx]}
</div>
</CellMeasurer>
);
}}
/>
)}
</Table>,
showLoadMore ? (
<LoadMoreBar
key='load-more-row'
loadingMore={loadingMore}
onLoadMore={handleLoadMoreRuns}
disableButton={ExperimentViewUtil.disableLoadMoreButton({
numRunsFromLatestSearch: numRunsFromLatestSearch,
nextPageToken,
})}
nestChildren={nestChildren}
style={{
position: 'absolute',
bottom: 20,
border: BORDER_STYLE,
width: tableWidth,
height: LOAD_MORE_ROW_HEIGHT,
}}
/>
) : null,
];
}}
</AutoSizer>
</div>
);
}
componentDidUpdate(prevProps) {
this.maybeHandleScroll();
this.maybeHandleLoadMoreFinish(prevProps);
}
maybeHandleLoadMoreFinish(prevProps) {
const loadMoreJustFinished = prevProps.loadingMore === false && this.props.loadingMore === true;
if (loadMoreJustFinished) {
this.setState({ isAtScrollBottom: false });
}
}
maybeHandleScroll() {
if (this.state.expanding) {
this.handleScroll();
this.setState({ expanding: false });
}
}
handleScroll = _.debounce(() => {
// Getting clientHeight, scrollHeight and scrollTop from the Grid instance directly here because
// corresponding inputs provided by onScroll are wrong at mounting phase and upon toggling
if (!this.tableRef.current) return;
const grid = this.tableRef.current.Grid;
const { clientHeight, scrollHeight, scrollTop } = {
clientHeight: grid.props.height,
scrollHeight: grid.getTotalRowsHeight(),
scrollTop: grid.state.scrollTop,
};
const isRunsListShort = scrollHeight < clientHeight;
const isAtScrollBottom = isRunsListShort || clientHeight + scrollTop >= scrollHeight;
this.setState({ isAtScrollBottom });
}, 100);
}
const mapStateToProps = (state, ownProps) => {
const { metricsList } = ownProps;
return { metricRanges: ExperimentViewUtil.computeMetricRanges(metricsList) };
};
export default connect(mapStateToProps)(ExperimentRunsTableCompactView);