mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
ensure results are always indexed by counter when loading new rows
This commit is contained in:
committed by
Marliana Lara
parent
161c7706bc
commit
0a3633113e
@@ -46,7 +46,7 @@ class JobOutput extends Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
contentError: null,
|
contentError: null,
|
||||||
hasContentLoading: true,
|
hasContentLoading: true,
|
||||||
results: [],
|
results: {},
|
||||||
scrollToIndex: -1,
|
scrollToIndex: -1,
|
||||||
loadedRowCount: 0,
|
loadedRowCount: 0,
|
||||||
loadedRowsMap: {},
|
loadedRowsMap: {},
|
||||||
@@ -80,12 +80,18 @@ class JobOutput extends Component {
|
|||||||
this.setState({ hasContentLoading: true });
|
this.setState({ hasContentLoading: true });
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { results = [], count },
|
data: { results: newResults = [], count },
|
||||||
} = await JobsAPI.readEvents(job.id, job.type, {
|
} = await JobsAPI.readEvents(job.id, job.type, {
|
||||||
page_size: 50,
|
page_size: 50,
|
||||||
order_by: 'start_line',
|
order_by: 'start_line',
|
||||||
});
|
});
|
||||||
this.setState({ results, remoteRowCount: count + 1 });
|
|
||||||
|
this.setState(({ results }) => {
|
||||||
|
newResults.forEach(jobEvent => {
|
||||||
|
results[jobEvent.counter] = jobEvent;
|
||||||
|
});
|
||||||
|
return { results, remoteRowCount: count + 1 };
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setState({ contentError: err });
|
this.setState({ contentError: err });
|
||||||
} finally {
|
} finally {
|
||||||
@@ -126,7 +132,6 @@ class JobOutput extends Component {
|
|||||||
|
|
||||||
async loadMoreRows({ startIndex, stopIndex }) {
|
async loadMoreRows({ startIndex, stopIndex }) {
|
||||||
const { job } = this.props;
|
const { job } = this.props;
|
||||||
const { results } = this.state;
|
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
counter__gte: startIndex,
|
counter__gte: startIndex,
|
||||||
@@ -135,7 +140,12 @@ class JobOutput extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return await JobsAPI.readEvents(job.id, job.type, params).then(response => {
|
return await JobsAPI.readEvents(job.id, job.type, params).then(response => {
|
||||||
this.setState({ results: [...results, ...response.data.results] });
|
this.setState(({ results }) => {
|
||||||
|
response.data.results.forEach(jobEvent => {
|
||||||
|
results[jobEvent.counter] = jobEvent;
|
||||||
|
});
|
||||||
|
return { results };
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +168,7 @@ class JobOutput extends Component {
|
|||||||
handleScrollBottom() {
|
handleScrollBottom() {
|
||||||
const { remoteRowCount } = this.state;
|
const { remoteRowCount } = this.state;
|
||||||
this.listRef.scrollToRow(remoteRowCount - 1);
|
this.listRef.scrollToRow(remoteRowCount - 1);
|
||||||
|
this.setState({ scrollToIndex: remoteRowCount - 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResize({ width }) {
|
handleResize({ width }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user