Skip to content

feat: DH-22891: Example middleware plugin#1372

Merged
mofojed merged 11 commits into
deephaven:mainfrom
vbabich:vlad-DH-21467-table-options-middleware-example
Jul 8, 2026
Merged

feat: DH-22891: Example middleware plugin#1372
mofojed merged 11 commits into
deephaven:mainfrom
vbabich:vlad-DH-21467-table-options-middleware-example

Conversation

@vbabich

@vbabich vbabich commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Adds table-middleware-example, a minimal WidgetMiddlewarePlugin demonstrating how a middleware plugin is inserted into a widget's render chain and how it can wrap the next component and inject custom props - with no coupling to IrisGrid or any other specific widget.

What it does

  • A single shared body hook (exampleMiddlewareBody) returning { inject, wrap }: injects a custom exampleInjectedProp and wraps the
    wrapped component in an ExampleMiddlewareContext.Provider plus a small
    "Wrapped by example middleware" banner.
  • The one body hook drives both middleware paths via the
    @deephaven/plugin factories: createWidgetMiddleware (non-panel /
    dashboard) and createPanelMiddleware (panel path, which preserves
    golden-layout's panel ref so componentState persistence stays intact).
  • Wired up as a PluginType.MIDDLEWARE_PLUGIN with supportedTypes: ['Table', 'TreeTable', 'HierarchicalTable', 'PartitionedTable'].

The middleware example needs to be registered in plugins/manifest.json to be loaded in dev mode.

## feat: DH-22891: Example middleware plugin

Adds `table-middleware-example`, a minimal `WidgetMiddlewarePlugin`
demonstrating how a middleware plugin is inserted into a widget's render
chain and how it can **wrap** the next component and **inject** custom
props — with no coupling to IrisGrid or any other specific widget.

### What it does

- A single shared body hook (`exampleMiddlewareBody`) returning `{
inject, wrap }`: injects a custom `exampleInjectedProp` and wraps the
wrapped component in an `ExampleMiddlewareContext.Provider` plus a small
"Wrapped by example middleware" banner.
- The one body hook drives both middleware paths via the
`@deephaven/plugin` factories: `createWidgetMiddleware` (non-panel /
dashboard) and `createPanelMiddleware` (panel path, which preserves
golden-layout's panel ref so `componentState` persistence stays intact).
- Wired up as a `PluginType.MIDDLEWARE_PLUGIN` with `supportedTypes:
['Table', 'TreeTable', 'HierarchicalTable', 'PartitionedTable']`,
registered in `plugins/manifest.json`.
@vbabich vbabich self-assigned this Jun 22, 2026
@vbabich vbabich marked this pull request as ready for review July 7, 2026 20:50
@vbabich vbabich requested review from a team, bmingles and Copilot and removed request for a team July 7, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a new example plugin, table-middleware-example, under plugins/table-middleware-example/src/js. It demonstrates the WidgetMiddlewarePlugin mechanism: a middleware component is inserted into a widget's render chain (for Table, TreeTable, HierarchicalTable, and PartitionedTable) and can inject custom props onto the next component and wrap it (here, with a context provider and a small banner). A single shared body hook (exampleMiddlewareBody) drives both the non-panel widget path (createWidgetMiddleware) and the ref-preserving panel path (createPanelMiddleware). The plugin is intentionally minimal and decoupled from IrisGrid, serving as documentation-by-example for the new middleware API in @deephaven/plugin.

Changes:

  • Adds a shared exampleMiddlewareBody returning { inject, wrap }, plus ExampleWidgetMiddleware/ExamplePanelMiddleware built from it via the @deephaven/plugin factories.
  • Registers everything as a PluginType.MIDDLEWARE_PLUGIN (ExampleMiddlewarePlugin) with a small context (ExampleMiddlewareContext) and barrel exports.
  • Adds standard plugin scaffolding (package.json, vite.config.ts, README, LICENSE, .gitignore) and a package-lock.json workspace link entry.

Reviewed changes

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

Show a summary per file
File Description
plugins/table-middleware-example/src/js/src/exampleMiddlewareBody.tsx Shared body hook implementing inject and wrap behavior.
plugins/table-middleware-example/src/js/src/ExampleWidgetMiddleware.tsx Non-panel widget middleware built via createWidgetMiddleware.
plugins/table-middleware-example/src/js/src/ExamplePanelMiddleware.tsx Panel-path middleware built via createPanelMiddleware (ref-forwarding).
plugins/table-middleware-example/src/js/src/ExampleMiddlewarePlugin.ts WidgetMiddlewarePlugin definition wiring both paths and supportedTypes.
plugins/table-middleware-example/src/js/src/ExampleMiddlewareContext.ts Context type/provider read by descendants of the wrapped widget.
plugins/table-middleware-example/src/js/src/index.ts Barrel exports and default export of the plugin.
plugins/table-middleware-example/src/js/package.json Package metadata, deps, and build scripts.
plugins/table-middleware-example/src/js/vite.config.ts Vite library build config (cjs, externalized deps).
plugins/table-middleware-example/src/js/README.md Documentation of the example; overstates manifest registration (flagged).
plugins/table-middleware-example/src/js/LICENSE Apache-2.0 license text.
plugins/table-middleware-example/src/js/.gitignore Ignores node_modules and dist.
package-lock.json Adds workspace link entry for the new plugin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/table-middleware-example/src/js/README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@vbabich vbabich requested a review from mofojed July 8, 2026 19:15
@mofojed mofojed merged commit d7a4972 into deephaven:main Jul 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants