Skip to content

Commit

Permalink
Check time selection range for undefined value
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
  • Loading branch information
arfio authored and bhufmann committed May 19, 2021
1 parent 3006ce9 commit f41237f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
32 changes: 17 additions & 15 deletions packages/react-components/src/components/table-output-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,23 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
});
}

private async handleTimeSelectionChange(range: TimelineChart.TimeGraphRange) {
const start = Math.trunc(this.props.range.getstart() + range.start);
if (this.lastIndex.timestamp === start) {
return;
}
const index = await this.fetchTableIndex(start);
if (index && this.gridApi) {
this.lastIndex = { timestamp: start, index: index };
this.gridApi.deselectAll();
this.gridApi.ensureIndexVisible(index);
const node = this.gridApi.getDisplayedRowAtIndex(index);
if (node.id) {
node.setSelected(true);
} else {
this.pendingIndex = index;
private async handleTimeSelectionChange(range?: TimelineChart.TimeGraphRange) {
if (range) {
const start = Math.trunc(this.props.range.getstart() + range.start);
if (this.lastIndex.timestamp === start) {
return;
}
const index = await this.fetchTableIndex(start);
if (index && this.gridApi) {
this.lastIndex = { timestamp: start, index: index };
this.gridApi.deselectAll();
this.gridApi.ensureIndexVisible(index);
const node = this.gridApi.getDisplayedRowAtIndex(index);
if (node.id) {
node.setSelected(true);
} else {
this.pendingIndex = index;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,19 @@ export class TraceContextComponent extends React.Component<TraceContextProps, Tr
return Math.floor(totalWidth * this.COMPONENT_WIDTH_PROPORTION);
}

private handleTimeSelectionChange(range: TimelineChart.TimeGraphRange) {
const t1 = Math.trunc(range.start + this.state.timeOffset);
const t2 = Math.trunc(range.end + this.state.timeOffset);
private handleTimeSelectionChange(range?: TimelineChart.TimeGraphRange) {
if (range) {
const t1 = Math.trunc(range.start + this.state.timeOffset);
const t2 = Math.trunc(range.end + this.state.timeOffset);

this.props.messageManager.addStatusMessage(this.TIME_SELECTION_STATUS_BAR_KEY, {
text: `T1: ${t1} T2: ${t2} Delta: ${t2 - t1}`,
category: Messages.MessageCategory.TRACE_CONTEXT
});
this.setState(prevState => ({
currentTimeSelection: new TimeRange(range.start, range.end, prevState.timeOffset)
}));
this.props.messageManager.addStatusMessage(this.TIME_SELECTION_STATUS_BAR_KEY, {
text: `T1: ${t1} T2: ${t2} Delta: ${t2 - t1}`,
category: Messages.MessageCategory.TRACE_CONTEXT
});
this.setState(prevState => ({
currentTimeSelection: new TimeRange(range.start, range.end, prevState.timeOffset)
}));
}
}

private handleViewRangeChange(viewRange: TimelineChart.TimeGraphRange) {
Expand Down

0 comments on commit f41237f

Please sign in to comment.