Skip to content

Commit bbcccd2

Browse files
authored
Web console: refactor table filters, show inactive MSQ worker count (#18768)
* Make TableFilters class instead of using the interface from react-table * Add refresh button to ShowJson and ShowJsonOrStages * Show inactive workers
1 parent a440a42 commit bbcccd2

File tree

43 files changed

+970
-606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+970
-606
lines changed

web-console/src/bootstrap/react-table-defaults.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ import type { Filter } from 'react-table';
2121
import { ReactTableDefaults } from 'react-table';
2222

2323
import { Loader } from '../components';
24-
import {
25-
booleanCustomTableFilter,
26-
DEFAULT_TABLE_CLASS_NAME,
27-
GenericFilterInput,
28-
ReactTablePagination,
29-
} from '../react-table';
24+
import { DEFAULT_TABLE_CLASS_NAME, GenericFilterInput, ReactTablePagination } from '../react-table';
3025
import { countBy } from '../utils';
26+
import { TableFilter } from '../utils/table-filters';
3127

3228
const NoData = React.memo(function NoData(props: { children?: React.ReactNode }) {
3329
const { children } = props;
@@ -41,10 +37,11 @@ export function bootstrapReactTable() {
4137
defaultFilterMethod: (filter: Filter, row: any) => {
4238
const id = filter.pivotId || filter.id;
4339
const subRows = row._subRows;
40+
const tableFilter = TableFilter.fromFilter(filter);
4441
if (Array.isArray(subRows)) {
45-
return subRows.some(r => booleanCustomTableFilter(filter, r[id]));
42+
return subRows.some(r => tableFilter.matches(r[id]));
4643
} else {
47-
return booleanCustomTableFilter(filter, row[id]);
44+
return tableFilter.matches(row[id]);
4845
}
4946
},
5047
LoadingComponent: Loader,

web-console/src/components/show-json-or-stages/__snapshots__/show-json-or-stages.spec.tsx.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ exports[`ShowJsonOrStages matches snapshot 1`] = `
1010
<div
1111
class="bp5-button-group right-buttons"
1212
>
13+
<button
14+
class="bp5-button bp5-disabled bp5-minimal"
15+
disabled=""
16+
tabindex="-1"
17+
type="button"
18+
>
19+
<span
20+
class="bp5-button-text"
21+
>
22+
Refesh
23+
</span>
24+
</button>
1325
<button
1426
class="bp5-button bp5-disabled bp5-minimal"
1527
disabled=""

web-console/src/components/show-json-or-stages/show-json-or-stages.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface ShowJsonOrStagesProps {
4040
export const ShowJsonOrStages = React.memo(function ShowJsonOrStages(props: ShowJsonOrStagesProps) {
4141
const { endpoint, transform, downloadFilename } = props;
4242

43-
const [jsonState] = useQueryManager<null, [string, Execution | undefined]>({
43+
const [jsonState, queryManager] = useQueryManager<null, [string, Execution | undefined]>({
4444
processQuery: async (_, signal) => {
4545
const resp = await Api.instance.get(endpoint, { signal });
4646
let data = resp.data;
@@ -68,6 +68,12 @@ export const ShowJsonOrStages = React.memo(function ShowJsonOrStages(props: Show
6868
<div className="show-json-or-stages">
6969
<div className="top-actions">
7070
<ButtonGroup className="right-buttons">
71+
<Button
72+
disabled={jsonState.loading}
73+
text="Refesh"
74+
minimal
75+
onClick={() => queryManager.rerunLastQuery()}
76+
/>
7177
{downloadFilename && (
7278
<Button
7379
disabled={jsonState.loading}

web-console/src/components/show-json/__snapshots__/show-json.spec.tsx.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ exports[`ShowJson matches snapshot 1`] = `
1010
<div
1111
class="bp5-button-group right-buttons"
1212
>
13+
<button
14+
class="bp5-button bp5-disabled bp5-minimal"
15+
disabled=""
16+
tabindex="-1"
17+
type="button"
18+
>
19+
<span
20+
class="bp5-button-text"
21+
>
22+
Refesh
23+
</span>
24+
</button>
1325
<button
1426
class="bp5-button bp5-disabled bp5-minimal"
1527
disabled=""

web-console/src/components/show-json/show-json.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface ShowJsonProps {
3838
export const ShowJson = React.memo(function ShowJson(props: ShowJsonProps) {
3939
const { endpoint, transform, downloadFilename } = props;
4040

41-
const [jsonState] = useQueryManager<null, string>({
41+
const [jsonState, queryManager] = useQueryManager<null, string>({
4242
processQuery: async (_, signal) => {
4343
const resp = await Api.instance.get(endpoint, { signal });
4444
let data = resp.data;
@@ -53,6 +53,12 @@ export const ShowJson = React.memo(function ShowJson(props: ShowJsonProps) {
5353
<div className="show-json">
5454
<div className="top-actions">
5555
<ButtonGroup className="right-buttons">
56+
<Button
57+
disabled={jsonState.loading}
58+
text="Refesh"
59+
minimal
60+
onClick={() => queryManager.rerunLastQuery()}
61+
/>
5662
{downloadFilename && (
5763
<Button
5864
disabled={jsonState.loading}

web-console/src/components/table-filterable-cell/table-filterable-cell.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
import { Menu, MenuDivider, MenuItem, Popover } from '@blueprintjs/core';
2020
import type { ReactNode } from 'react';
2121
import React from 'react';
22-
import type { Filter } from 'react-table';
2322

24-
import type { FilterMode } from '../../react-table';
25-
import { addOrUpdateFilter, combineModeAndNeedle, filterModeToIcon } from '../../react-table';
23+
import type { FilterMode, TableFilters } from '../../utils/table-filters';
24+
import { TableFilter } from '../../utils/table-filters';
2625
import { Deferred } from '../deferred/deferred';
2726

2827
import './table-filterable-cell.scss';
@@ -33,8 +32,8 @@ const FILTER_MODES_NO_COMPARISONS: FilterMode[] = ['=', '!='];
3332
export interface TableFilterableCellProps {
3433
field: string;
3534
value: string;
36-
filters: Filter[];
37-
onFiltersChange(filters: Filter[]): void;
35+
filters: TableFilters;
36+
onFiltersChange(filters: TableFilters): void;
3837
enableComparisons?: boolean;
3938
children?: ReactNode;
4039
displayValue?: string;
@@ -57,15 +56,10 @@ export const TableFilterableCell = React.memo(function TableFilterableCell(
5756
{(enableComparisons ? FILTER_MODES : FILTER_MODES_NO_COMPARISONS).map((mode, i) => (
5857
<MenuItem
5958
key={i}
60-
icon={filterModeToIcon(mode)}
59+
icon={TableFilter.modeToIcon(mode)}
6160
text={displayValue ?? value}
6261
onClick={() =>
63-
onFiltersChange(
64-
addOrUpdateFilter(filters, {
65-
id: field,
66-
value: combineModeAndNeedle(mode, value),
67-
}),
68-
)
62+
onFiltersChange(filters.addOrUpdate(new TableFilter(field, mode, value)))
6963
}
7064
/>
7165
))}

0 commit comments

Comments
 (0)