Skip to content

Commit

Permalink
Align with design doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrunyon committed May 11, 2024
1 parent fe98def commit 0363408
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions plugins/ui/src/deephaven/ui/components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from ..elements import UITable
from ..types import (
CellPressCallback,
ColumnName,
ColumnPressCallback,
QuickFilterExpression,
RowPressCallback,
)

Expand All @@ -18,6 +20,7 @@ def table(
on_cell_double_press: CellPressCallback | None = None,
on_column_press: ColumnPressCallback | None = None,
on_column_double_press: ColumnPressCallback | None = None,
quick_filters: dict[ColumnName, QuickFilterExpression] | None = None,
show_search: bool = False,
show_quick_filters: bool = False,
) -> UITable:
Expand All @@ -43,6 +46,7 @@ def table(
on_column_double_press: The callback function to run when a column is double clicked.
The first parameter is the column name.
show_search: Whether to show the search bar by default.
quick_filters: The quick filters to apply to the table. Dictionary of column name to filter value.
show_quick_filters: Whether to show the quick filter bar by default.
"""
props = locals()
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/src/deephaven/ui/elements/UITable.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def quick_filter(
Returns:
A new UITable
"""
return self._with_dict_prop("filters", filter)
return self._with_dict_prop("quick_filters", filter)

def selection_mode(self, mode: SelectionMode) -> "UITable":
"""
Expand Down
16 changes: 10 additions & 6 deletions plugins/ui/src/js/src/elements/UITable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ function UITable({
onColumnDoublePress,
onRowPress,
onRowDoublePress,
filters,
quickFilters,
sorts,
alwaysFetchColumns,
table: exportedTable,
showSearchBar,
showSearch: showSearchBar,
showQuickFilters,
}: UITableProps): JSX.Element | null {
const dh = useApi();
Expand All @@ -48,12 +48,16 @@ function UITable({
}, [columns, utils, sorts]);

const hydratedQuickFilters = useMemo(() => {
if (filters !== undefined && model !== undefined && columns !== undefined) {
log.debug('Hydrating filters', filters);
if (
quickFilters !== undefined &&
model !== undefined &&
columns !== undefined
) {
log.debug('Hydrating filters', quickFilters);

const dehydratedQuickFilters: DehydratedQuickFilter[] = [];

Object.entries(filters).forEach(([columnName, filter]) => {
Object.entries(quickFilters).forEach(([columnName, filter]) => {
const columnIndex = model.getColumnIndexByName(columnName);
if (columnIndex !== undefined) {
dehydratedQuickFilters.push([columnIndex, { text: filter }]);
Expand All @@ -63,7 +67,7 @@ function UITable({
return utils.hydrateQuickFilters(columns, dehydratedQuickFilters);
}
return undefined;
}, [filters, model, columns, utils]);
}, [quickFilters, model, columns, utils]);

// Just load the object on mount
useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions plugins/ui/src/js/src/elements/UITableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export interface UITableProps {
onColumnPress?: (columnName: ColumnName) => void;
onColumnDoublePress?: (columnName: ColumnName) => void;
alwaysFetchColumns?: string[];
filters?: Record<string, string>;
quickFilters?: Record<string, string>;
sorts?: DehydratedSort[];
showSearchBar?: boolean;
showSearch?: boolean;
showQuickFilters?: boolean;
[key: string]: unknown;
}
Expand Down

0 comments on commit 0363408

Please sign in to comment.