Skip to content

Commit

Permalink
Web console: fix pagination and filtering regression in supervisor vi…
Browse files Browse the repository at this point in the history
…ew (#16571) (#16575)

* fix pagination and filtering in supervisor view

* update snapshot

(cherry picked from commit efe9079)

Co-authored-by: Vadim Ogievetsky <[email protected]>
  • Loading branch information
cryptoe and vogievetsky authored Jun 7, 2024
1 parent fb86ada commit 925bbc2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ exports[`SupervisorsView matches snapshot 1`] = `
"accessor": "detailed_state",
"id": "detailed_state",
"show": true,
"width": 130,
"width": 150,
},
{
"Cell": [Function],
Expand Down Expand Up @@ -374,11 +374,12 @@ exports[`SupervisorsView matches snapshot 1`] = `
indexKey="_index"
loading={false}
loadingText="Loading..."
manual={true}
multiSort={true}
nestingLevelKey="_nestingLevel"
nextText="Next"
noDataText=""
ofText="of"
ofText=""
onFetchData={[Function]}
onFilteredChange={[Function]}
originalKey="_original"
Expand All @@ -391,6 +392,7 @@ exports[`SupervisorsView matches snapshot 1`] = `
]
}
pageText="Page"
pages={10000000}
pivotDefaults={{}}
pivotIDKey="_pivotID"
pivotValKey="_pivotVal"
Expand All @@ -399,9 +401,9 @@ exports[`SupervisorsView matches snapshot 1`] = `
resolveData={[Function]}
rowsSelectorText="rows per page"
rowsText="rows"
showPageJump={true}
showPageJump={false}
showPageSizeOptions={true}
showPagination={false}
showPagination={true}
showPaginationBottom={true}
showPaginationTop={false}
sortable={true}
Expand Down
24 changes: 17 additions & 7 deletions web-console/src/views/supervisors-view/supervisors-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { Icon, Intent, Menu, MenuItem, Position, Tag } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { Popover2 } from '@blueprintjs/popover2';
import { SqlExpression } from '@druid-toolkit/query';
import * as JSONBig from 'json-bigint-native';
import type { JSX } from 'react';
import React from 'react';
Expand Down Expand Up @@ -65,6 +66,7 @@ import {
assemble,
checkedCircleIcon,
deepGet,
filterMap,
formatByteRate,
formatBytes,
formatInteger,
Expand Down Expand Up @@ -227,6 +229,12 @@ export class SupervisorsView extends React.PureComponent<
) => {
let supervisors: SupervisorQueryResultRow[];
if (capabilities.hasSql()) {
let filterClause = '';
const whereParts = filterMap(filtered, sqlQueryCustomTableFilter);
if (whereParts.length) {
filterClause = SqlExpression.and(...whereParts).toString();
}

const sqlQuery = assemble(
'WITH s AS (SELECT',
' "supervisor_id",',
Expand All @@ -238,9 +246,7 @@ export class SupervisorsView extends React.PureComponent<
'FROM "sys"."supervisors")',
'SELECT *',
'FROM s',
filtered.length
? `WHERE ${filtered.map(sqlQueryCustomTableFilter).join(' AND ')}`
: undefined,
filterClause ? `WHERE ${filterClause}` : undefined,
sortedToOrderByClause(sorted),
`LIMIT ${pageSize}`,
page ? `OFFSET ${page * pageSize}` : undefined,
Expand Down Expand Up @@ -638,19 +644,23 @@ export class SupervisorsView extends React.PureComponent<
return (
<ReactTable
data={supervisors}
pages={10000000} // Dummy, we are hiding the page selector
loading={supervisorsState.loading}
noDataText={
supervisorsState.isEmpty() ? 'No supervisors' : supervisorsState.getErrorMessage() || ''
}
manual
filterable
filtered={filters}
onFilteredChange={onFiltersChange}
filterable
onFetchData={tableState => {
this.fetchData(tableState);
}}
showPageJump={false}
ofText=""
defaultPageSize={SMALL_TABLE_PAGE_SIZE}
pageSizeOptions={SMALL_TABLE_PAGE_SIZE_OPTIONS}
showPagination={supervisors.length > SMALL_TABLE_PAGE_SIZE}
showPagination
columns={[
{
Header: twoLines('Supervisor ID', <i>(datasource)</i>),
Expand Down Expand Up @@ -684,11 +694,11 @@ export class SupervisorsView extends React.PureComponent<
{
Header: 'Status',
id: 'detailed_state',
width: 130,
width: 150,
accessor: 'detailed_state',
Cell: ({ value }) => (
<TableFilterableCell
field="status"
field="detailed_state"
value={value}
filters={filters}
onFiltersChange={onFiltersChange}
Expand Down

0 comments on commit 925bbc2

Please sign in to comment.