Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(members): keep the member drawer's binding tables inside their cards (#21806)
zchpeterb2a070061f44
diff --git a/docs/design/member-drawer-binding-tables.md b/docs/design/member-drawer-binding-tables.mdnew file mode 100644index 0000000000..d6311e7211--- /dev/null+++ b/docs/design/member-drawer-binding-tables.md@@ -0,0 +1,109 @@+# Member drawer binding tables++Status: implemented in this PR · 2026-11-01 · [BYT-10364](https://linear.app/bytebase/issue/BYT-10364)++On a project's Members page, Edit on a member opens a drawer with one card per role binding, and+each card lists the binding's databases, schemas and tables in a table. A long name widens its+column until the table runs out of the card, and every card lines its columns up differently.+**Each card's table keeps a fixed column layout fitted to the card, so every card opens with the+same columns; a name too long for its column ends in an ellipsis and shows in full on hover, and+the user can widen a column, in that card only.** Expiration moves from a column to the card's+header, because it belongs to the binding, not to a row.++## Problem++Verified on `main` at `cbaf903ae6`, in `EditMemberRoleDrawer` (`frontend/src/routes/workspace/MembersPage.tsx`):++- **Columns size to their content.** The table has no fixed layout, so the browser sizes each+ column from its longest value. A long schema or table name pushes Table and Expiration past the+ card's edge, and the whole drawer body scrolls sideways.+- **Every card has its own geometry.** Each card sizes its columns from its own rows, so the+ Database, Schema, Table and Expiration headers sit at a different x in every card.+- **Truncation does nothing.** `MemberDatabaseResourceName` truncates the instance and database+ names, but an auto-layout cell grows to fit them, so nothing is ever cut.+- **Expiration repeats on every row.** `getSingleBindingRows` copies the binding's one+ `expiredTime` onto each resource row, so a binding with ten tables shows the same expiration ten+ times, in the column that overflows first.+- **The drawer is narrower than the contract's tier.** It uses sheet width `medium` (640px); the UX+ contract gives `wide` (832px) to a sheet with nested tables.++## Principle++> A role card reads like the other tables in Bytebase, the plan list and Access grants: fixed+> columns that fit the space, long identifiers cut with the full value on hover, and columns the+> reader can widen. Nothing a card shows changes another card.++## Decisions++**D1 · Fixed columns, fitted to the card.** Each card's table uses `table-fixed` with Database,+Schema and Table columns. On open, the columns are spread across the card's width with+`distributeColumnWidths` and `fillableWidth` from `useColumnWidths`, as Access grants does, so+every card opens with the same columns and no card scrolls. The table sits in an `overflow-x-auto`+box inside the card, so a width the user drags past the card scrolls that card only. Rejected:+wrapping long names in fixed columns (#21699); it shows every name in full but gives rows uneven+heights and is not how Bytebase's other identifier tables read.++**D2 · Columns resize per card, and the widths are not kept.** Every column has the shared resize+handle. Dragging it changes that card only; widths reset when the drawer opens again. Rejected: one+set of widths shared by every card; a reader reviews one binding at a time, and sharing would tie+every card to state held by the drawer for no task the drawer serves.++**D3 · A cut name shows in full on hover.** Schema and Table cells use `EllipsisText`, which adds+the tooltip only when the value is cut. The Database cell keeps its engine icon, instance title and+database name, each an `EllipsisText` of its own, as `DatabaseTargetDisplay` does, so the database+name stays partly visible beside a long instance title and hovering either shows it in full. `*`+(every database, schema or table) never needs a tooltip.++**D4 · Expiration goes to the card header.** The header row reads: role title, the Expired badge+when expired (as today), then on the right "Expiration" and the value the column showed, the+`operational` timestamp or "Never", before the delete button. The table loses its Expiration+column. The strings already exist (`common.expiration`, `project.members.never-expires`).++**D5 · The drawer moves to sheet width `wide`.** The edit-member sheet goes from `medium` (640px) to+`wide` (832px), the contract's tier for a sheet with nested tables. The grant sheet the drawer+opens on top, and the workspace member sheet, keep their widths.++## States++| Binding scope | Name length | Card shows |+|---|---|---|+| Every database | — | One row: `*`, `*`, `*`. |+| A database | Fits | Engine icon, instance › database; Schema and Table `*`. |+| A database, schema and tables | Fits | One row per table, database and schema repeated, nothing cut. |+| Any | A name longer than its column | The name ends in `…`; hovering it shows the full value. |+| Any | A column dragged wider than the card | That card's table scrolls sideways; other cards unchanged. |++| Expiration | Header right side |+|---|---|+| None | "Expiration Never" |+| A future time | "Expiration" and the time, `operational` form |+| A past time | Expired badge after the role title, struck-through title, dimmed card (as today), and the time |++At phone width the sheet is the screen's width; columns shrink to fit, no column below its minimum+width, and a card whose minimum widths don't fit scrolls sideways.++## Scope++| File | Change |+|---|---|+| `frontend/src/routes/workspace/MemberBindingResourceTable.tsx` | New: one card's table (D1–D3). |+| `frontend/src/routes/workspace/MemberDatabaseResourceName.tsx` | A tooltip on the instance title or database name when it is cut (D3). |+| `frontend/src/routes/workspace/MembersPage.tsx` | Uses the new table, moves expiration to the header (D4), sheet `wide` (D5). |++Tests:++- `MemberBindingResourceTable.test.tsx`: Database, Schema and Table headers and no Expiration; a+ row per resource and `*` for an unscoped binding; dragging a column in one table leaves another+ table's widths unchanged.+- `MemberDatabaseResourceName.test.tsx`: the full instance title or database name on hover when it+ is cut, no tooltip when it fits.+- `MembersPage.test.tsx`: each card's header shows its expiration once, "Never" or the time.+- `tests/e2e/project-members/project-members.spec.ts`: with a long schema and table name, every+ card's columns line up and stay inside the card on open, hovering a cut table name shows it in+ full, and dragging a column in one card leaves the other cards' columns where they were.++## Not in this PR++- Grouping a binding's tables under one database and schema row (the issue's second open point).+- Reading a cut name on a touch screen, where there is no hover.+- The workspace member sheet and the grant sheet.diff --git a/frontend/src/routes/workspace/MemberBindingResourceTable.test.tsx b/frontend/src/routes/workspace/MemberBindingResourceTable.test.tsxnew file mode 100644index 0000000000..2548b6a01e--- /dev/null+++ b/frontend/src/routes/workspace/MemberBindingResourceTable.test.tsx@@ -0,0 +1,85 @@+import { fireEvent, render, screen, within } from "@testing-library/react";+import { describe, expect, test, vi } from "vitest";+import type { DatabaseResource } from "@/types";+import { MemberBindingResourceTable } from "./MemberBindingResourceTable";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock("./MemberDatabaseResourceName", () => ({+ MemberDatabaseResourceName: ({+ resource,+ }: {+ resource?: DatabaseResource;+ }) => <span>{resource?.databaseFullName ?? "*"}</span>,+}));++const columnHeaders = () =>+ screen.getAllByRole("columnheader").map((th) => th.textContent);++describe("MemberBindingResourceTable", () => {+ test("lists database, schema and table, one row per resource, without an expiration column", () => {+ render(+ <MemberBindingResourceTable+ resources={[+ {+ databaseFullName: "instances/prod/databases/hr",+ schema: "public",+ table: "employee",+ },+ { databaseFullName: "instances/prod/databases/hr", schema: "audit" },+ ]}+ />+ );++ expect(columnHeaders()).toEqual([+ "common.database",+ "common.schema",+ "common.table",+ ]);+ const rows = screen.getAllByRole("row").slice(1);+ expect(rows.map((row) => within(row).getAllByRole("cell").map((c) => c.textContent))).toEqual([+ ["instances/prod/databases/hr", "public", "employee"],+ ["instances/prod/databases/hr", "audit", "*"],+ ]);+ });++ test("dragging a column edge widens that column in its own table only", () => {+ const { container } = render(+ <>+ <MemberBindingResourceTable resources={[]} />+ <MemberBindingResourceTable resources={[]} />+ </>+ );+ const [first, second] = Array.from(container.querySelectorAll("table"));+ const colWidths = (table: HTMLTableElement) =>+ Array.from(table.querySelectorAll("col")).map((col) => col.style.width);+ const before = colWidths(first);+ expect(colWidths(second)).toEqual(before);++ const schemaHeader = within(first).getByRole("columnheader", {+ name: "common.schema",+ });+ const handle = schemaHeader.lastElementChild as HTMLElement;+ fireEvent.mouseDown(handle, { clientX: 100 });+ fireEvent.mouseMove(document, { clientX: 180 });+ fireEvent.mouseUp(document);++ expect(colWidths(first)).toEqual([+ before[0],+ `${Number.parseInt(before[1]) + 80}px`,+ before[2],+ ]);+ expect(colWidths(second)).toEqual(before);+ });++ test("an unscoped binding is one row of *", () => {+ render(<MemberBindingResourceTable resources={[]} />);++ const rows = screen.getAllByRole("row").slice(1);+ expect(rows.map((row) => within(row).getAllByRole("cell").map((c) => c.textContent))).toEqual([+ ["*", "*", "*"],+ ]);+ });+});diff --git a/frontend/src/routes/workspace/MemberBindingResourceTable.tsx b/frontend/src/routes/workspace/MemberBindingResourceTable.tsxnew file mode 100644index 0000000000..068d302512--- /dev/null+++ b/frontend/src/routes/workspace/MemberBindingResourceTable.tsx@@ -0,0 +1,101 @@+import { useCallback, useMemo, useRef } from "react";+import { useTranslation } from "react-i18next";+import { EllipsisText } from "@/components/ui/ellipsis-text";+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from "@/components/ui/table";+import { TableCellContent } from "@/components/ui/table-cell-content";+import {+ distributeColumnWidths,+ fillableWidth,+ useColumnWidths,+} from "@/hooks/useColumnWidths";+import type { DatabaseResource } from "@/types";+import { MemberDatabaseResourceName } from "./MemberDatabaseResourceName";++const COLUMNS = [+ { key: "database", defaultWidth: 280, minWidth: 160 },+ { key: "schema", defaultWidth: 200, minWidth: 120 },+ { key: "table", defaultWidth: 240, minWidth: 120 },+] as const;++// One role binding's databases, schemas and tables. An empty list is a binding+// with no resource condition, which reaches every database.+export function MemberBindingResourceTable({+ resources,+}: {+ resources: DatabaseResource[];+}) {+ const { t } = useTranslation();+ const titles = [t("common.database"), t("common.schema"), t("common.table")];+ const columns = useMemo(() => [...COLUMNS], []);+ const { widths, totalWidth, onResizeStart, setWidths } =+ useColumnWidths(columns);++ // Fitted once, to this card's scroller, so every card opens with the same+ // columns; a later drag can widen this card past its edge.+ const didFitRef = useRef(false);+ const fitToCard = useCallback(+ (node: HTMLDivElement | null) => {+ if (!node || didFitRef.current) return;+ const width = fillableWidth(node);+ if (width <= 0) return;+ didFitRef.current = true;+ setWidths(distributeColumnWidths(columns, width));+ },+ [columns, setWidths]+ );++ const rows: (DatabaseResource | undefined)[] =+ resources.length > 0 ? resources : [undefined];++ return (+ <div ref={fitToCard} className="overflow-x-auto">+ <Table+ className="w-auto table-fixed"+ style={{ width: `${totalWidth}px` }}+ >+ <colgroup>+ {widths.map((w, i) => (+ <col key={columns[i].key} style={{ width: `${w}px` }} />+ ))}+ </colgroup>+ <TableHeader>+ <TableRow>+ {columns.map((col, i) => (+ <TableHead+ key={col.key}+ resizable+ onResizeStart={(e) => onResizeStart(i, e)}+ >+ {titles[i]}+ </TableHead>+ ))}+ </TableRow>+ </TableHeader>+ <TableBody>+ {rows.map((resource, i) => (+ <TableRow key={i}>+ <TableCell>+ <TableCellContent>+ <MemberDatabaseResourceName resource={resource} />+ </TableCellContent>+ </TableCell>+ <TableCell>+ <EllipsisText text={resource?.schema ?? "*"} />+ </TableCell>+ <TableCell>+ <EllipsisText text={resource?.table ?? "*"} />+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </div>+ );+}diff --git a/frontend/src/routes/workspace/MemberDatabaseResourceName.test.tsx b/frontend/src/routes/workspace/MemberDatabaseResourceName.test.tsxindex e2d63bd677..0d3fe381a5 100644--- a/frontend/src/routes/workspace/MemberDatabaseResourceName.test.tsx+++ b/frontend/src/routes/workspace/MemberDatabaseResourceName.test.tsx@@ -1,5 +1,5 @@-import { render, screen } from "@testing-library/react";-import { beforeEach, describe, expect, test, vi } from "vitest";+import { act, render, screen } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import type { DatabaseResource } from "@/types";import { MemberDatabaseResourceName } from "./MemberDatabaseResourceName";@@ -102,6 +102,58 @@ describe("MemberDatabaseResourceName", () => {expect(screen.getByText("hr")).toBeInTheDocument();});+ describe("a name cut by its column", () => {+ // jsdom lays nothing out, so each test says which names overflow.+ let cut: string[] = [];+ beforeEach(() => {+ cut = [];+ vi.spyOn(HTMLElement.prototype, "scrollWidth", "get").mockImplementation(+ function (this: HTMLElement) {+ return cut.includes(this.textContent ?? "") ? 200 : 100;+ }+ );+ vi.spyOn(HTMLElement.prototype, "clientWidth", "get").mockReturnValue(+ 100+ );+ });+ afterEach(() => {+ vi.restoreAllMocks();+ });++ const focusName = async (name: string) => {+ await act(async () => {+ screen+ .getByText(name)+ .dispatchEvent(new FocusEvent("focusin", { bubbles: true }));+ });+ };+ const overlayText = () =>+ document.getElementById("bb-react-layer-overlay")?.textContent ?? "";++ test("shows the full instance title on hover", async () => {+ cut = ["Production"];+ render(<MemberDatabaseResourceName resource={resource} />);++ await focusName("Production");+ expect(overlayText()).toBe("Production");+ });++ test("shows the full database name on hover", async () => {+ cut = ["hr"];+ render(<MemberDatabaseResourceName resource={resource} />);++ await focusName("hr");+ expect(overlayText()).toBe("hr");+ });++ test("shows no tooltip for a name that fits", async () => {+ render(<MemberDatabaseResourceName resource={resource} />);++ await focusName("hr");+ expect(overlayText()).toBe("");+ });+ });+test("renders wildcard for unscoped resources", () => {render(<MemberDatabaseResourceName />);diff --git a/frontend/src/routes/workspace/MemberDatabaseResourceName.tsx b/frontend/src/routes/workspace/MemberDatabaseResourceName.tsxindex ff4b3bdc38..08f5f2c3f7 100644--- a/frontend/src/routes/workspace/MemberDatabaseResourceName.tsx+++ b/frontend/src/routes/workspace/MemberDatabaseResourceName.tsx@@ -1,6 +1,7 @@import { ChevronRight } from "lucide-react";import { useMemo } from "react";import { EngineIcon } from "@/components/EngineIcon";+import { EllipsisText } from "@/components/ui/ellipsis-text";import { useAppStore } from "@/stores/app";import type { DatabaseResource } from "@/types";import {@@ -57,9 +58,12 @@ export function MemberDatabaseResourceName({{display.engine !== undefined && (<EngineIcon engine={display.engine} className="mr-1 h-4 w-4" />)}- <span className="truncate text-control">{display.instanceTitle}</span>+ <EllipsisText+ text={display.instanceTitle}+ className="min-w-0 text-control"+ /><ChevronRight className="h-4 w-4 shrink-0 text-control-light opacity-60" />- <span className="truncate text-main">{display.databaseName}</span>+ <EllipsisText text={display.databaseName} className="min-w-0 text-main" /></div>);}diff --git a/frontend/src/routes/workspace/MembersPage.test.tsx b/frontend/src/routes/workspace/MembersPage.test.tsxindex 0bde0e39ef..a6fd0e0149 100644--- a/frontend/src/routes/workspace/MembersPage.test.tsx+++ b/frontend/src/routes/workspace/MembersPage.test.tsx@@ -19,6 +19,8 @@ const {maximumRequestExpirationSeconds,accountSelectProps,roleList,+ memberBindingList,+ conditionByExpression,} = vi.hoisted(() => ({mockUseProductIntro: vi.fn(),mockPushNotification: vi.fn(),@@ -32,6 +34,10 @@ const {permissions: string[];}>,},+ memberBindingList: { value: [] as unknown[] },+ // What convertFromExpr reads from a binding's parsed condition, keyed by+ // the condition's expression.+ conditionByExpression: { value: {} as Record<string, unknown> },}));vi.mock("@/components/AccountMultiSelect", () => ({@@ -218,6 +224,8 @@ vi.mock("@/components/ui/tabs", () => ({vi.mock("@/components/ui/tooltip", () => ({Tooltip: ({ children }: { children: ReactNode }) =>createElement("span", {}, children),+ BlockTooltip: ({ children }: { children: ReactNode }) =>+ createElement("span", {}, children),}));vi.mock("@/hooks/useEscapeKey", () => ({@@ -295,13 +303,14 @@ vi.mock("@/utils/cel-attributes", () => ({vi.mock("@/utils/issue/cel", () => ({buildConditionExpr: (args: Record<string, unknown>) => ({ ...args }),- convertFromExpr: () => ({}),+ convertFromExpr: (expr?: { expression?: string }) =>+ conditionByExpression.value[expr?.expression ?? ""] ?? {},readableCondition: () => ({}),stringifyConditionExpression: () => "",}));vi.mock("@/lib/memberBindings", () => ({- getMemberBindings: () => [],+ getMemberBindings: () => memberBindingList.value,groupProjectRoleBindings: () => [],}));@@ -314,7 +323,7 @@ vi.mock("react-i18next", () => ({useTranslation: () => ({ t: (key: string) => key }),}));-const projectIamPolicy = { bindings: [] };+const projectIamPolicy = { bindings: [] as unknown[] };vi.mock("@/stores", () => ({pushNotification: mockPushNotification,@@ -380,6 +389,11 @@ vi.mock("./MemberDatabaseResourceName", () => ({MemberDatabaseResourceName: () => null,}));+vi.mock("@/components/HumanizeTs", () => ({+ HumanizeTs: ({ tsMs }: { tsMs: number }) =>+ createElement("time", {}, new Date(tsMs).toISOString()),+}));+vi.mock("@/modules/access-control/RequestRoleSheet", () => ({RequestRoleSheet: () => null,}));@@ -402,6 +416,8 @@ beforeEach(() => {maximumRequestExpirationSeconds.value = undefined;accountSelectProps.value = undefined;roleList.value = [{ name: "roles/sqlEditorUser", permissions: [] }];+ memberBindingList.value = [];+ conditionByExpression.value = {};projectIamPolicy.bindings = [];container = document.createElement("div");document.body.appendChild(container);@@ -796,3 +812,76 @@ describe("MembersPage workspace role grant drawer", () => {expect(container.textContent).toContain("bb.instances.list");});});++describe("MembersPage member drawer", () => {+ const member = "user:[email protected]";++ async function openMemberDrawer(): Promise<void> {+ memberBindingList.value = [+ {+ type: "users",+ title: "Dev One",+ binding: member,+ user: { email: "[email protected]", name: "users/[email protected]" },+ workspaceLevelRoles: new Set(),+ projectRoleBindings: projectIamPolicy.bindings,+ },+ ];+ await renderPage();+ const editButton = container.querySelector(+ "button[aria-label='common.edit']"+ ) as HTMLButtonElement;+ await act(async () => {+ editButton.click();+ });+ await flush();+ }++ it("shows each binding's expiration once, in its card header, not as a column", async () => {+ projectIamPolicy.bindings = [+ { role: "roles/projectDeveloper", members: [member] },+ {+ role: "roles/sqlEditorUser",+ members: [member],+ parsedExpr: { expression: "scoped" },+ },+ ];+ conditionByExpression.value = {+ scoped: {+ expiredTime: "2099-01-01T00:00:00.000Z",+ databaseResources: [+ { databaseFullName: "instances/prod/databases/hr", table: "a" },+ { databaseFullName: "instances/prod/databases/hr", table: "b" },+ ],+ },+ };+ await openMemberDrawer();++ const headers = [...container.querySelectorAll("th")].map(+ (th) => th.textContent+ );+ expect(headers).not.toContain("common.expiration");+ expect(container.textContent).toContain(+ "common.expirationproject.members.never-expires"+ );+ expect(+ container.textContent?.split("2099-01-01T00:00:00.000Z").length+ ).toBe(2);+ });++ it("drops every card of a revoked role, even when the policy holds the same binding twice", async () => {+ const duplicate = { role: "roles/sqlEditorUser", members: [member] };+ const kept = { role: "roles/projectDeveloper", members: [member] };+ projectIamPolicy.bindings = [duplicate, { ...duplicate }, kept];+ await openMemberDrawer();+ const cardDeleteButtons = () =>+ container.querySelectorAll("button[title='common.delete']");+ expect(cardDeleteButtons()).toHaveLength(3);++ projectIamPolicy.bindings = [kept];+ await renderPage();+ await flush();++ expect(cardDeleteButtons()).toHaveLength(1);+ });+});diff --git a/frontend/src/routes/workspace/MembersPage.tsx b/frontend/src/routes/workspace/MembersPage.tsxindex b04e085b81..ca319e8de2 100644--- a/frontend/src/routes/workspace/MembersPage.tsx+++ b/frontend/src/routes/workspace/MembersPage.tsx@@ -152,7 +152,7 @@ import {readableCondition,stringifyConditionExpression,} from "@/utils/issue/cel";-import { MemberDatabaseResourceName } from "./MemberDatabaseResourceName";+import { MemberBindingResourceTable } from "./MemberBindingResourceTable";import { getSetIamPolicyPermissionGuardConfig } from "./membersPageActions";const EMPTY_ROLE_SET = new Set<string>();@@ -1450,28 +1450,21 @@ function EditMemberRoleDrawer({}, [workspaceProfile, form.role]);// Helpers for project edit mode- const getSingleBindingRows = useCallback(+ const getBindingScope = useCallback((binding: Binding): {- databaseResource?: DatabaseResource;+ databaseResources: DatabaseResource[];expiration?: Date;- }[] => {- if (!binding.parsedExpr) return [{}];+ } => {+ if (!binding.parsedExpr) return { databaseResources: [] };const conditionExpr = convertFromExpr(binding.parsedExpr) ?? {};- const base: { expiration?: Date } = {};- if (conditionExpr.expiredTime)- base.expiration = new Date(conditionExpr.expiredTime);- if (- conditionExpr.databaseResources &&- conditionExpr.databaseResources.length > 0- ) {- return conditionExpr.databaseResources.map((r) => ({- ...base,- databaseResource: r,- }));- }- return [base];+ return {+ databaseResources: conditionExpr.databaseResources ?? [],+ expiration: conditionExpr.expiredTime+ ? new Date(conditionExpr.expiredTime)+ : undefined,+ };},[]);@@ -1779,7 +1772,7 @@ function EditMemberRoleDrawer({return (<><Sheet open onOpenChange={(nextOpen) => !nextOpen && onClose()}>- <SheetContent width="medium">+ <SheetContent width="wide"><SheetHeader><div className="flex min-w-0 items-center justify-between gap-x-2"><SheetTitle className="truncate">@@ -1805,8 +1798,20 @@ function EditMemberRoleDrawer({{t("common.no-data")}</div>)}- {liveProjectRoleBindings.map((binding, idx) => {- const rows = getSingleBindingRows(binding);+ {liveProjectRoleBindings.map((binding, index) => {+ // Keyed by role and condition so each card keeps its column+ // widths when another card goes; the API can store the same+ // pair twice, so repeats are numbered.+ const identity = `${binding.role}-${binding.condition?.expression ?? ""}`;+ const repeat = liveProjectRoleBindings+ .slice(0, index)+ .filter(+ (b) =>+ `${b.role}-${b.condition?.expression ?? ""}` ===+ identity+ ).length;+ const { databaseResources, expiration } =+ getBindingScope(binding);const directExecution = directExecutionOf(binding.role,readableCondition(binding.parsedExpr)@@ -1814,18 +1819,18 @@ function EditMemberRoleDrawer({const isExpired = isBindingPolicyExpired(binding);return (<div- key={`${binding.role}-${idx}`}+ key={`${identity}-${repeat}`}className={cn("border rounded-sm",isExpired && "opacity-60")}>{/* Role header */}- <div className="flex items-center justify-between px-4 py-3 bg-control-bg border-b">- <div className="flex items-center gap-x-2">+ <div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-4 py-3 bg-control-bg border-b">+ <div className="flex min-w-0 items-center gap-x-2"><spanclassName={cn(- "font-medium text-sm",+ "truncate font-medium text-sm",isExpired && "line-through")}>@@ -1837,17 +1842,34 @@ function EditMemberRoleDrawer({</Badge>)}</div>- {/* Delete only: the grant form adds a role, so a- pencil here would read as editing this one. */}- <Button- appearance="secondary"- size="sm"- title={t("common.delete")}- disabled={isRequesting}- onClick={() => handleDeleteRole(binding)}- >- <Trash2 className="h-4 w-4" />- </Button>+ <div className="flex items-center gap-x-4 text-sm">+ <div className="flex items-center gap-x-2">+ <span className="text-control-light">+ {t("common.expiration")}+ </span>+ <span className="text-main">+ {expiration ? (+ <HumanizeTs+ mode="operational"+ tsMs={expiration.getTime()}+ />+ ) : (+ t("project.members.never-expires")+ )}+ </span>+ </div>+ {/* Delete only: the grant form adds a role, so a+ pencil here would read as editing this one. */}+ <Button+ appearance="secondary"+ size="sm"+ title={t("common.delete")}+ disabled={isRequesting}+ onClick={() => handleDeleteRole(binding)}+ >+ <Trash2 className="h-4 w-4" />+ </Button>+ </div></div>{directExecution && (@@ -1864,43 +1886,9 @@ function EditMemberRoleDrawer({{/* Database resources table */}<div className="p-4">- <Table>- <TableHeader>- <TableRow>- <TableHead>{t("common.database")}</TableHead>- <TableHead>{t("common.schema")}</TableHead>- <TableHead>{t("common.table")}</TableHead>- <TableHead>{t("common.expiration")}</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {rows.map((row, rowIdx) => (- <TableRow key={rowIdx}>- <TableCell>- <MemberDatabaseResourceName- resource={row.databaseResource}- />- </TableCell>- <TableCell>- {row.databaseResource?.schema ?? "*"}- </TableCell>- <TableCell>- {row.databaseResource?.table ?? "*"}- </TableCell>- <TableCell>- {row.expiration ? (- <HumanizeTs- mode="operational"- tsMs={row.expiration.getTime()}- />- ) : (- t("project.members.never-expires")- )}- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>+ <MemberBindingResourceTable+ resources={databaseResources}+ /></div></div>);diff --git a/frontend/tests/e2e/project-members/project-members.spec.ts b/frontend/tests/e2e/project-members/project-members.spec.tsindex b17837b83d..d093292b73 100644--- a/frontend/tests/e2e/project-members/project-members.spec.ts+++ b/frontend/tests/e2e/project-members/project-members.spec.ts@@ -9,6 +9,7 @@import {type BrowserContext,expect,+ type Locator,type Page,test,} from "@playwright/test";@@ -226,6 +227,76 @@ test.describe("member list", () => {});});+test.describe("edit member drawer", () => {+ const LONG_SCHEMA = "a_really_long_schema_name_for_reporting_and_settlement";+ const TABLE_V2 = "monthly_settlement_reconciliation_report_for_finance_v2";+ const TABLE_V3 = "monthly_settlement_reconciliation_report_for_finance_v3";++ test("long names stay inside each card, are shown on hover, and a drag moves one card only", async ({ page }) => {+ // The grantee keeps Project Developer (no condition) from beforeAll, so+ // the drawer shows a short card beside the long one.+ await setGranteeSqlEditorUser(+ `(resource.database == "${env.database}" && resource.schema_name == "${LONG_SCHEMA}" && resource.table_name in ["${TABLE_V2}", "${TABLE_V3}"]) && request.time < timestamp("2099-01-01T00:00:00.000Z")`,+ );+ const members = new ProjectMembersPage(page, env.baseURL);+ await members.goto(projectId);+ await members.openMember(GRANTEE.email);++ const tables = members.sheet.getByRole("table");+ await expect(tables).toHaveCount(2);+ const longTable = tables.filter({ hasText: TABLE_V2 });+ const shortTable = tables.filter({ hasNotText: TABLE_V2 });+ await expect(members.sheet.getByRole("columnheader", { name: "Expiration" })).toHaveCount(0);++ const box = async (locator: Locator) => {+ const b = await locator.boundingBox();+ if (!b) throw new Error("element has no box");+ return b;+ };+ // Soft, so one run reports every broken decision: the wide sheet tier,+ // columns fitted to each card, and the hover on each cut column.+ expect.soft((await box(members.sheet)).width).toBe(832);+ for (const table of [longTable, shortTable]) {+ const fit = await table.evaluate((el) => {+ const scroller = el.parentElement as HTMLElement;+ return {+ table: el.getBoundingClientRect().width,+ visible: scroller.clientWidth,+ content: scroller.scrollWidth,+ };+ });+ expect.soft(Math.abs(fit.table - fit.visible)).toBeLessThanOrEqual(1);+ expect.soft(fit.content).toBeLessThanOrEqual(fit.visible);+ }+ const tableHeaderX = async (table: Locator) =>+ (await box(table.getByRole("columnheader", { name: "Table", exact: true }))).x;+ const shortTableX = await tableHeaderX(shortTable);+ expect(await tableHeaderX(longTable)).toBe(shortTableX);++ // The cell holds the cut name; hovering adds the tooltip's copy.+ const v2Row = longTable.getByRole("row").filter({ hasText: TABLE_V2 });+ const fullTable = page.getByText(TABLE_V2, { exact: true });+ await expect(fullTable).toHaveCount(1);+ await v2Row.getByText(TABLE_V2, { exact: true }).hover();+ await expect.soft(fullTable).toHaveCount(2);+ // The schema shows on both rows, so its tooltip makes a third copy.+ const fullSchema = page.getByText(LONG_SCHEMA, { exact: true });+ await expect(fullSchema).toHaveCount(2);+ await v2Row.getByText(LONG_SCHEMA, { exact: true }).hover();+ await expect.soft(fullSchema).toHaveCount(3);++ const schemaHeader = await box(longTable.getByRole("columnheader", { name: "Schema", exact: true }));+ const handleX = schemaHeader.x + schemaHeader.width - 3;+ const handleY = schemaHeader.y + schemaHeader.height / 2;+ await page.mouse.move(handleX, handleY);+ await page.mouse.down();+ await page.mouse.move(handleX + 80, handleY, { steps: 8 });+ await page.mouse.up();+ expect(await tableHeaderX(longTable)).toBeGreaterThan(shortTableX + 60);+ expect(await tableHeaderX(shortTable)).toBe(shortTableX);+ });+});+// The approver's card reads the request's condition through the same parser// and reader. The API creates the requests on the grantee's behalf, so the// card also names the requester. Role requests need the approval-workflow