Skip to content

feat: Add input filter support to GridWidgetPlugin#2438

Merged
mattrunyon merged 18 commits intodeephaven:mainfrom
mattrunyon:mattrunyon_dh-18354
Jun 9, 2025
Merged

feat: Add input filter support to GridWidgetPlugin#2438
mattrunyon merged 18 commits intodeephaven:mainfrom
mattrunyon:mattrunyon_dh-18354

Conversation

@mattrunyon
Copy link
Copy Markdown
Collaborator

@mattrunyon mattrunyon commented May 8, 2025

This adds a few new hooks

  • useDhId which will be used to route to a specific component in dh.ui (via prop), or the panel ID (via context) as a fallback. This uses useFiber which is not exported because it's an escape hatch that should be used very rarely. useDhId takes no props and can read the __dhId prop of the component via the useFiber hook.
  • useDashboardId gives the ID of the current dashboard
  • useDashboardColumnFilters is used to subscribe to column filter changes and also advertise the columns and table (if provided) available for filtering. This should allow us to hook up the existing filtering/linking to dh.ui and probably also ChartBuilder in dh.ui tables.

The contexts for useDhId and useDashboardId are added to Dashboard so there shouldn't be any changes for enterprise since it uses the Dashboard component.

Also reworked the events around this to have stronger types using the helper methods we added.

Test with dh.ui single normal table in a panel (ui.table support PR will follow in plugins repo)

Run this. Then add an input filter via the UI and the columns from the table should be filterable in the table

from deephaven import ui
from deephaven.plot import express as dx

_stocks = dx.data.stocks()

t = ui.panel(_stocks, title="UI Panel")

@mattrunyon mattrunyon self-assigned this May 8, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 66.30435% with 62 lines in your changes missing coverage. Please review.

Project coverage is 47.31%. Comparing base (431c057) to head (93a0bb0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ckages/dashboard-core-plugins/src/FilterPlugin.tsx 25.00% 21 Missing ⚠️
...rd-core-plugins/src/panels/DropdownFilterPanel.tsx 0.00% 8 Missing ⚠️
...board-core-plugins/src/panels/InputFilterPanel.tsx 0.00% 8 Missing ⚠️
packages/dashboard/src/useDashboardId.ts 16.66% 5 Missing ⚠️
packages/dashboard/src/useFiber.tsx 87.80% 5 Missing ⚠️
packages/dashboard/src/DashboardLayout.tsx 0.00% 4 Missing ⚠️
...es/dashboard-core-plugins/src/GridWidgetPlugin.tsx 76.92% 3 Missing ⚠️
...kages/dashboard-core-plugins/src/linker/Linker.tsx 57.14% 3 Missing ⚠️
...ashboard-core-plugins/src/panels/IrisGridPanel.tsx 66.66% 3 Missing ⚠️
...oard-core-plugins/src/useDashboardColumnFilters.ts 93.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2438      +/-   ##
==========================================
+ Coverage   47.21%   47.31%   +0.10%     
==========================================
  Files         718      723       +5     
  Lines       39620    39772     +152     
  Branches     9914    10144     +230     
==========================================
+ Hits        18706    18819     +113     
- Misses      20903    20942      +39     
  Partials       11       11              
Flag Coverage Δ
unit 47.31% <66.30%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mattrunyon mattrunyon marked this pull request as ready for review May 19, 2025 22:33
@mattrunyon mattrunyon requested review from Copilot and mofojed May 19, 2025 22:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for input filters within the grid widget plugin and enhances related dashboards and filter event handling. Key changes include adding new hooks (e.g. useDashboardColumnFilters), updating event handling in panels and plugins, and modifying associated tests and type definitions to support the new filter functionality.

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/dashboard/src/useDhId.test.tsx New tests for the useDhId hook behavior
packages/dashboard/src/useDashboardId.ts Added hook for retrieving dashboard IDs via context
packages/dashboard/src/layout/LayoutUtils.ts Updated the PanelId type to remove array support
packages/dashboard/src/DashboardLayout.tsx Wrapped panel components with DhIdContext provider
packages/dashboard/src/Dashboard.tsx Integrated DashboardIdContext and FiberProvider changes
packages/dashboard/package.json Added new type dependency for react-reconciler
packages/dashboard-core-plugins/src/useDashboardColumnFilters.ts New hook to subscribe and filter dashboard column filters
packages/dashboard-core-plugins/src/useDashboardColumnFilters.test.tsx Introduced tests validating new filter hook behavior
packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx Enhanced grid widget to support input filters and process clear filters events
packages/dashboard-core-plugins/src/FilterPlugin.tsx Updated filter event handling with standardized event listener hooks
Others Various panel and linker components updated to wire filter events correctly
Comments suppressed due to low confidence (2)

packages/dashboard-core-plugins/src/useDashboardColumnFilters.test.tsx:124

  • Duplicate test names found in the test suite, which could lead to confusion in test results. Consider renaming one of the tests to clearly distinguish between different test scenarios.
test('Ignores filters with different name or type', () => {

packages/dashboard/src/layout/LayoutUtils.ts:32

  • The updated PanelId type now only supports a single string value instead of an array. Verify that all downstream consumers are compatible with this change to avoid potential type mismatches.
export type PanelId = Brand<'PanelId', string | undefined>;

Comment thread packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx Outdated
Comment thread packages/golden-layout/src/utils/EventUtils.ts Outdated
Comment thread packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx Outdated
Comment thread packages/golden-layout/src/utils/EventUtils.ts Outdated
Comment thread packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx
Comment thread packages/dashboard-core-plugins/src/FilterEvents.ts
Comment thread packages/dashboard-core-plugins/src/FilterEvents.ts
Comment thread packages/dashboard-core-plugins/src/FilterEvents.ts Outdated
Comment thread packages/dashboard-core-plugins/src/GridWidgetPlugin.test.tsx
Comment thread packages/dashboard-core-plugins/src/linker/LinkerUtils.ts

static getInputFiltersForColumns(
columns: readonly DhType.Column[],
columns: readonly { name: string; type: string }[],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Another one of these types, though we don't want iris-grid depending on dashboard-core-plugins.
We've got out @deephaven/filters package - maybe makes sense to pull the input filter type definitions down and use them in both iris-grid/dashboard-core-plugins?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This util doesn't even need to be in IrisGridUtils. It's only used by the panel and the new hook which are both in dashboard-core-plugins. I don't see it used anywhere in enterprise

For relatively simple types like this, I'm not opposed to just having it as an inline literal. The util doesn't actually care that it's an input filter column or a table column or a dropdown filter column. It cares that it has those 2 props and all those other types satisfy that constraint

Originally I had all of these as just dh.Column[], but that is not the case when using it within charts. Chart has a FilterColumnMap type that has values { name: string; type: string }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea it probably doesn't really make sense in IrisGridUtils. But no need to make that a breaking change here.

@mattrunyon mattrunyon requested a review from mofojed May 21, 2025 22:03
Comment thread packages/dashboard/src/useDhId.ts Outdated
log.warn(
`useDhId must be used within a DhIdContext provider if there is no ${DH_ID_PROP} prop. Defaulting to empty string.`
);
return '';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ehhh I don't like returning an empty string either - should return a string | null, or even two signatures with a param e.g. useDhId(throwOnNull: false): string | null and useDhId(throwOnNull: true): string

In useDashboardColumnFilters we shouldn't be emitting events with a blank or null panelId I don't think.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original intent was to throw always on no ID, but that breaks dh.ui without the update to dh.ui to pass through the panel ID

I've just switched to string | null return for now. Although it's annoying using the branded type for FilterColumnSourceId because I have to cast when calling useDhId and changing the return type to string | null didn't cause the original cast to fail.

I am in favor of removing the branded type for FilterColumnSourceId. I don't think it's somewhere we will commonly mix up ID types and they're both strings at the end of the day. The filter doesn't care if it's a panel or widget ID, it just needs a unique identifier

@mattrunyon mattrunyon requested a review from mofojed May 27, 2025 16:53
Comment thread packages/dashboard-core-plugins/src/useDashboardColumnFilters.ts Outdated
@mattrunyon mattrunyon requested a review from mofojed June 2, 2025 21:33
mofojed
mofojed previously approved these changes Jun 5, 2025
@mattrunyon mattrunyon merged commit 9de971f into deephaven:main Jun 9, 2025
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants