Skip to content
This repository was archived by the owner on Jul 31, 2026. It is now read-only.

feat(Table): add renderRow prop to wrap data rows - #354

Merged
simplesagar merged 3 commits into
mainfrom
feat/table-render-row
Jul 15, 2026
Merged

feat(Table): add renderRow prop to wrap data rows#354
simplesagar merged 3 commits into
mainfrom
feat/table-render-row

Conversation

@simplesagar

@simplesagar simplesagar commented Jul 14, 2026

Copy link
Copy Markdown
Member

What

Adds a renderRow prop to Table (and Table.Body): (row, rowElement) => ReactNode. The internal RowContainer now forwards refs and extra <tr> props, so the row element can back composition patterns like Radix ContextMenuTrigger asChild.

  • Applies to plain, expandable (wraps the <tr> only, not the expanded panel), and grouped rows.
  • No behavior change when the prop is omitted.

Why

The Gram dashboard is adding right-click context menus to all table rows with per-row actions (companion PR in speakeasy-api/gram). Moonshine's Table owns the <tr>, so consumers had no way to attach a context-menu trigger per row.

Testing

  • New src/components/Table/index.test.tsx: wrapper runs per row, extra props (onContextMenu, data-testid) land on the <tr>, onRowClick still works when wrapped.
  • New WithRenderRow story.
  • pnpm type-check, pnpm lint, pnpm test (50/50), pnpm build all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mpze1EupifNgKSkWRZ8BZc


Summary by cubic

Adds a new renderRow prop to Table so consumers can wrap each <tr> (e.g., per‑row context menus) without changing behavior when unused. Works with sortable headers, expandable rows, and grouped rows.

  • New Features
    • renderRow: (row, rowElement) => ReactNode on Table and Table.Body.
    • Applies to plain rows, expandable rows (wraps only the <tr>), and grouped rows; compatible with sorting.
    • RowContainer forwards refs and additional <tr> props; onRowClick remains supported when wrapped.

Written for commit f740151. Summary will update on new commits.

Review in cubic

simplesagar and others added 3 commits July 14, 2026 15:14
RowContainer now forwards refs and extra tr props so the row element can
back composition patterns like Radix ContextMenuTrigger asChild.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mpze1EupifNgKSkWRZ8BZc
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mpze1EupifNgKSkWRZ8BZc
Re-applied renderRow on top of upstream sorting support and the
prettier-to-oxfmt migration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mpze1EupifNgKSkWRZ8BZc

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 3 files

Confidence score: 4/5

  • In src/components/Table/index.test.tsx, renderRow is missing coverage for expandable and grouped row paths that the PR says are supported, so a regression in row structure/behavior could slip through and only show up at runtime for those table variants — add targeted tests for expandable-row wrapping and grouped-row rendering before (or immediately after) merge to de-risk this.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/components/Table/index.test.tsx">

<violation number="1" location="src/components/Table/index.test.tsx:203">
P2: Consider adding test coverage for `renderRow` with expandable rows and grouped rows. The PR description lists both as supported paths — expandable rows wrap only the `<tr>` (not the expanded panel) and grouped rows apply `renderRow` to each row inside the group — but the current tests only cover plain data rows. Adding a quick test for each would confirm the wrapping boundary and prevent regressions.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

expect(screen.getByText("go")).toBeTruthy();
});

it("wraps every data row and forwards extra props onto the <tr>", () => {

@cubic-dev-ai cubic-dev-ai Bot Jul 15, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Consider adding test coverage for renderRow with expandable rows and grouped rows. The PR description lists both as supported paths — expandable rows wrap only the <tr> (not the expanded panel) and grouped rows apply renderRow to each row inside the group — but the current tests only cover plain data rows. Adding a quick test for each would confirm the wrapping boundary and prevent regressions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/components/Table/index.test.tsx, line 203:

<comment>Consider adding test coverage for `renderRow` with expandable rows and grouped rows. The PR description lists both as supported paths — expandable rows wrap only the `<tr>` (not the expanded panel) and grouped rows apply `renderRow` to each row inside the group — but the current tests only cover plain data rows. Adding a quick test for each would confirm the wrapping boundary and prevent regressions.</comment>

<file context>
@@ -191,3 +192,52 @@ describe("Table sortable headers", () => {
+    expect(screen.getByText("go")).toBeTruthy();
+  });
+
+  it("wraps every data row and forwards extra props onto the <tr>", () => {
+    const onContextMenu = vi.fn((e: React.MouseEvent) => e.preventDefault());
+    render(
</file context>
Fix with cubic

@simplesagar
simplesagar merged commit 4fcbeac into main Jul 15, 2026
6 checks passed
@simplesagar
simplesagar deleted the feat/table-render-row branch July 15, 2026 00:06
Thegreatsura pushed a commit to Thegreatsura/gram that referenced this pull request Jul 17, 2026
… per-entry actions (speakeasy-api#4210)

## What

Every table row, card, and list entry whose "⋯" kebab menu offers
per-entry actions now offers the same actions on right-click, finishing
the initiative started by `CardContextMenu`
(source/environment/prompt/assistant cards) and the hand-wired session
rows.

**New shared component:** `TableRowContextMenu` — the `asChild` sibling
of `CardContextMenu` for `<tr>`/row elements, fed by the same `Action[]`
as the visible kebab, no-op when empty. Both now share
`ActionContextMenuContent`.

**Wired surfaces:**
- DotTable rows: sources table; remote identity provider tabs (MCP
servers, sessions, OAuth clients)
- moonshine tables via the new `renderRow` prop: deployments,
exclusions, policy center, shadow MCP inventory, team members
(hand-wired mirror incl. separator + per-item RBAC gating)
- Other rows: roles (CSS-grid), tool list, source tools, chat logs
- Cards: org home project cards/rows, plugin cards

**Refactors along the way:** raw dropdown kebabs now render from a
single `Action[]` (visuals unchanged);
`useSourceToolActions`/`useProjectActions`/`useDeploymentActions` hooks
extracted so both menus share one source of truth;
`ContextMenuSeparator` added to the primitive.

**Deliberately out of scope:** Triggers (no per-row menu exists),
Sources grid cards (already done), Team invites (visible buttons, not
hidden options).

## Dependency

⚠️ The five moonshine-table pages use the new `Table`/`Table.Body`
`renderRow` prop from speakeasy-api/moonshine#354. CI stays red on this
draft until that PR merges + releases and `@speakeasy-api/moonshine` is
bumped here. Everything was verified locally against the built moonshine
branch.

## Verification

- `pnpm -F dashboard type-check`: clean (against local moonshine build)
- `pnpm -F dashboard test`: 711/711
- `pnpm -F dashboard lint` (oxfmt + no-barrels + oxlint type-aware +
tsc): clean
- `pnpm -F dashboard build`: passes

Design spec and implementation plans are committed under
`docs/superpowers/`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Mpze1EupifNgKSkWRZ8BZc

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds right‑click context menus to all rows, cards, and list items that
already have a kebab (⋯) menu. The same per‑entry actions now show on
right‑click with shared components, consistent RBAC/disabled states, and
better accessibility.

- New Features
- New `TableRowContextMenu` (no‑op when empty) and shared
`ActionContextMenuContent` + `ContextMenuSeparator`; `Action` now
supports `description` and `separatorBefore`.
- Unified action builders power both kebab and context menus across:
sources; MCP servers/sessions/clients; deployments, exclusions, policy
center, shadow MCP inventory, team members; roles, tool list, source
tools, chat logs; org project and plugin cards. Shadow MCP actions moved
to `shadowMCPInventoryActionItems.ts`.
- Moonshine tables use `Table`/`Table.Body` `renderRow` with
`onRowClick`; added tests for menu mapping/selection; docs include a
demo GIF.
  - Bumped `@speakeasy-api/moonshine` to `1.44.0` for `renderRow`.

- Bug Fixes
- Addressed review feedback: Shadow MCP action set is additive again;
deployments prevent redeploy double‑submit via shared mutation key;
roles use one `roleActions()` for both menus; team menu avoids stray
separators; exclusions forward `action.disabled`; plugin card dropdown
and context menu share one action list; sources rows use link
`href`/`ariaLabel`; `AnnotationToggle` exposes its description via
`aria-describedby`; removed dead `SourceToolActions`.
- Restored `pnpm-lock.yaml` overrides/patches to resolve lockfile
mismatch and added a changeset for dashboard.

<sup>Written for commit d710ab4.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/speakeasy-api/gram/pull/4210?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants