From b7abeed4e51090daeb0b309f1bdcce9dd13b3f2b Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Mon, 20 Sep 2021 06:45:15 -0700 Subject: [PATCH] ui: fixed showing empty result pages (#1306) Fixes #1149 This is a more universal fix for #1297 --- htmlui/src/SnapshotsTable.js | 12 +----------- htmlui/src/Table.js | 6 +++--- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/htmlui/src/SnapshotsTable.js b/htmlui/src/SnapshotsTable.js index 4adf0d03e..24eecaf5b 100644 --- a/htmlui/src/SnapshotsTable.js +++ b/htmlui/src/SnapshotsTable.js @@ -35,7 +35,6 @@ export class SnapshotsTable extends Component { snapshots: [], showHidden: false, isLoading: false, - forceFirstPage: false, error: null, }; this.onChange = this.onChange.bind(this); @@ -95,7 +94,6 @@ export class SnapshotsTable extends Component { onChange(x) { this.setState({ showHidden: x.target.checked, - forceFirstPage: true, }); } @@ -109,14 +107,6 @@ export class SnapshotsTable extends Component { return ; } - const willForceFirstPage = this.state.forceFirstPage; - - if (this.state.forceFirstPage) { - this.setState({ - forceFirstPage: false, - }) - } - snapshots.sort((a, b) => -compare(a.startTime, b.startTime)); let { filteredSnapshots, hiddenCount } = this.coalesceSnapshots(snapshots); @@ -171,7 +161,7 @@ export class SnapshotsTable extends Component {
- + ; } diff --git a/htmlui/src/Table.js b/htmlui/src/Table.js index 659578886..20b8365a8 100644 --- a/htmlui/src/Table.js +++ b/htmlui/src/Table.js @@ -44,7 +44,7 @@ function paginationItems(count, active, gotoPage) { return items; } -export default function MyTable({ columns, data, forceFirstPage }) { +export default function MyTable({ columns, data }) { // Use the state and functions returned from useTable to build your UI const { getTableProps, @@ -71,8 +71,8 @@ export default function MyTable({ columns, data, forceFirstPage }) { usePagination, ) - if (forceFirstPage && pageIndex !== 0) { - gotoPage(0); + if (pageIndex >= pageCount && pageIndex !== 0 && pageCount > 0) { + gotoPage(pageCount - 1); } const paginationUI = pageOptions.length > 1 &&