Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web console: fix pagination and filtering regression in supervisor view #16571

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading