Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(plan): drag-to-resize plan list columns (#20373)
zchpeter31765c19c6d8
diff --git a/frontend/src/react/hooks/useColumnWidths.test.tsx b/frontend/src/react/hooks/useColumnWidths.test.tsxnew file mode 100644index 0000000000..7307ea52de--- /dev/null+++ b/frontend/src/react/hooks/useColumnWidths.test.tsx@@ -0,0 +1,367 @@+import { act } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, describe, expect, test, vi } from "vitest";+import { useColumnWidths } from "./useColumnWidths";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++interface Column {+ key: string;+ defaultWidth: number;+ minWidth?: number;+}++type Handle = ReturnType<typeof useColumnWidths<Column>>;++function Harness({+ columns,+ handleRef,+}: {+ columns: Column[];+ handleRef: { current: Handle | null };+}) {+ const result = useColumnWidths(columns);+ handleRef.current = result;+ return null;+}++let container: HTMLDivElement;+let root: Root;+let handle: { current: Handle | null };++function mount(columns: Column[]) {+ container = document.createElement("div");+ document.body.appendChild(container);+ root = createRoot(container);+ handle = { current: null };+ act(() => {+ root.render(<Harness columns={columns} handleRef={handle} />);+ });+}++function unmount() {+ act(() => {+ root.unmount();+ });+ container.remove();+}++function startDrag(colIndex: number, clientX: number) {+ // Build a React.MouseEvent stand-in. The hook only reads+ // `clientX`, `preventDefault`, and `stopPropagation`.+ const event = {+ clientX,+ preventDefault: () => {},+ stopPropagation: () => {},+ } as unknown as React.MouseEvent;+ act(() => {+ handle.current!.onResizeStart(colIndex, event);+ });+}++function moveMouse(clientX: number) {+ act(() => {+ document.dispatchEvent(new MouseEvent("mousemove", { clientX }));+ });+}++function releaseMouse() {+ act(() => {+ document.dispatchEvent(new MouseEvent("mouseup"));+ });+}++describe("useColumnWidths", () => {+ afterEach(() => {+ // Defensive: make sure no test leaks listeners/body styles.+ if (root) {+ try {+ unmount();+ } catch {+ // already unmounted+ }+ }+ document.body.style.cursor = "";+ document.body.style.userSelect = "";+ });++ test("initial widths come from defaultWidth and totalWidth sums them", () => {+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ { key: "c", defaultWidth: 50 },+ ]);+ expect(handle.current!.widths).toEqual([100, 200, 50]);+ expect(handle.current!.totalWidth).toBe(350);+ });++ test("dragging a column updates that column positionally", () => {+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ { key: "c", defaultWidth: 50 },+ ]);+ startDrag(1, 500);+ moveMouse(540);+ expect(handle.current!.widths).toEqual([100, 240, 50]);+ expect(handle.current!.totalWidth).toBe(390);+ releaseMouse();+ });++ test("dragging left shrinks the column", () => {+ mount([+ { key: "a", defaultWidth: 300 },+ { key: "b", defaultWidth: 200 },+ ]);+ startDrag(0, 100);+ moveMouse(30); // delta = -70, new = 230+ expect(handle.current!.widths).toEqual([230, 200]);+ releaseMouse();+ });++ test("minWidth clamps shrinking", () => {+ mount([{ key: "a", defaultWidth: 200, minWidth: 150 }]);+ startDrag(0, 500);+ moveMouse(0); // delta = -500, raw new = -300, clamp to 150+ expect(handle.current!.widths).toEqual([150]);+ releaseMouse();+ });++ test("minWidth defaults to 40 when not provided", () => {+ mount([{ key: "a", defaultWidth: 100 }]);+ startDrag(0, 200);+ moveMouse(0); // delta = -200, raw new = -100, clamp to 40+ expect(handle.current!.widths).toEqual([40]);+ releaseMouse();+ });++ test("mouseup tears down listeners and restores body styles", () => {+ mount([{ key: "a", defaultWidth: 100 }]);+ startDrag(0, 0);+ expect(document.body.style.cursor).toBe("col-resize");+ expect(document.body.style.userSelect).toBe("none");++ moveMouse(50);+ expect(handle.current!.widths).toEqual([150]);++ releaseMouse();+ expect(document.body.style.cursor).toBe("");+ expect(document.body.style.userSelect).toBe("");++ // After release, further mousemove must be ignored.+ moveMouse(1000);+ expect(handle.current!.widths).toEqual([150]);+ });++ test("unmount mid-drag tears down listeners and restores body styles", () => {+ mount([{ key: "a", defaultWidth: 100 }]);+ startDrag(0, 0);+ expect(document.body.style.cursor).toBe("col-resize");+ expect(document.body.style.userSelect).toBe("none");++ unmount();+ expect(document.body.style.cursor).toBe("");+ expect(document.body.style.userSelect).toBe("");++ // After unmount, the document-level listener must not still+ // be alive. Dispatching a mousemove should be a no-op.+ document.dispatchEvent(new MouseEvent("mousemove", { clientX: 1000 }));+ // No assertion on widths (hook is unmounted), but if cleanup+ // is broken vitest would surface "act outside of a test" warnings.+ });++ test("only the dragged column changes; siblings stay put", () => {+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ { key: "c", defaultWidth: 50 },+ ]);+ startDrag(2, 800);+ moveMouse(900); // c grows by 100+ expect(handle.current!.widths).toEqual([100, 200, 150]);+ releaseMouse();+ });++ test("dragging successive columns updates each independently", () => {+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ ]);++ startDrag(0, 50);+ moveMouse(80); // a: 130+ releaseMouse();+ expect(handle.current!.widths).toEqual([130, 200]);++ startDrag(1, 300);+ moveMouse(250); // b: 150+ releaseMouse();+ expect(handle.current!.widths).toEqual([130, 150]);+ });++ test("schedule-then-teardown invariant: setWidths updater must not deref the drag ref", () => {+ // Regression: mousemove + mouseup in one batch used to crash because the+ // updater closure read dragRef.current after teardown nulled it.+ mount([{ key: "a", defaultWidth: 100 }]);+ startDrag(0, 0);+ expect(() => {+ act(() => {+ document.dispatchEvent(new MouseEvent("mousemove", { clientX: 50 }));+ document.dispatchEvent(new MouseEvent("mouseup"));+ });+ }).not.toThrow();+ expect(handle.current!.widths).toEqual([150]);+ });++ test("a second onResizeStart removes the prior drag's document listeners", () => {+ // Regression: if a second drag started without an intervening mouseup+ // (rapid sequential mousedowns, missed mouseup, multi-touch trackpad),+ // the prior drag's document listeners used to leak — only the latest+ // teardown was reachable. The behavioral end state is identical whether+ // or not the leak exists (both leaked + new listeners read from the same+ // dragRef and produce the same widths), so this test counts net+ // mousemove/mouseup registrations via spies to prove the cleanup.+ const addSpy = vi.spyOn(document, "addEventListener");+ const removeSpy = vi.spyOn(document, "removeEventListener");+ const netDragListeners = () => {+ const added = addSpy.mock.calls.filter(+ ([type]) => type === "mousemove" || type === "mouseup"+ ).length;+ const removed = removeSpy.mock.calls.filter(+ ([type]) => type === "mousemove" || type === "mouseup"+ ).length;+ return added - removed;+ };+ try {+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ ]);+ addSpy.mockClear();+ removeSpy.mockClear();++ startDrag(0, 0);+ expect(netDragListeners()).toBe(2); // mousemove + mouseup++ // Second drag without intervening mouseup: defensive teardown must+ // remove drag #1's pair before registering drag #2's pair.+ startDrag(1, 100);+ expect(netDragListeners()).toBe(2);++ moveMouse(120); // should only affect column b+ expect(handle.current!.widths).toEqual([100, 220]);++ releaseMouse();+ expect(netDragListeners()).toBe(0);+ expect(document.body.style.cursor).toBe("");+ expect(document.body.style.userSelect).toBe("");+ } finally {+ addSpy.mockRestore();+ removeSpy.mockRestore();+ }+ });++ test("drag uses snapshotted minWidth, not the live column constraint", () => {+ // Eager-capture contract: a drag's minWidth is fixed at gesture start.+ // If the caller swaps the column at the dragged index for one with a+ // more permissive minWidth, the drag must still clamp at the original.+ // This is the "equal-length column swap" regression.+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200, minWidth: 150 },+ ]);+ startDrag(1, 200); // snapshot minWidth = 150+ expect(handle.current!.widths).toEqual([100, 200]);++ // Caller swaps column at index 1 for one with a far more permissive minWidth.+ act(() => {+ root.render(+ <Harness+ columns={[+ { key: "a", defaultWidth: 100 },+ { key: "c", defaultWidth: 200, minWidth: 50 },+ ]}+ handleRef={handle}+ />+ );+ });++ // Drag the column far to the left. Live minWidth=50 would allow it, but+ // the snapshotted minWidth=150 must clamp.+ moveMouse(0); // delta = -200, raw new = 0, clamp to snapshotted 150+ expect(handle.current!.widths[1]).toBe(150);+ releaseMouse();+ });++ test("setWidths short-circuits when clamped at minWidth (no-op re-renders)", () => {+ // Without the prev[colIndex] === newWidth guard, dragging the cursor+ // past minWidth would fire setWidths with the same clamped value on+ // every pixel of motion, re-rendering every consumer. Verify the+ // widths array reference is preserved (no new allocation) across a+ // clamped tick — that's how React skips the re-render.+ mount([{ key: "a", defaultWidth: 200, minWidth: 150 }]);+ startDrag(0, 200);+ moveMouse(100); // delta=-100, raw=100, clamped to 150 — first allocation+ const widthsAfterClamp = handle.current!.widths;+ expect(widthsAfterClamp).toEqual([150]);++ // Move further past minWidth. newWidth still clamps to 150 — no-op.+ moveMouse(50); // delta=-150, raw=50, clamped to 150+ expect(handle.current!.widths).toBe(widthsAfterClamp); // same ref+ moveMouse(0); // delta=-200, raw=0, clamped to 150+ expect(handle.current!.widths).toBe(widthsAfterClamp); // still same ref++ // Drag back up. At raw=120 the clamp is still engaged (120 < 150).+ moveMouse(120); // delta=-80, raw=120, still clamped to 150 — no-op+ expect(handle.current!.widths).toBe(widthsAfterClamp); // same ref+ // Cross above minWidth — now a real change, fresh allocation.+ moveMouse(180); // delta=-20, raw=180 > 150 — real change to 180+ expect(handle.current!.widths).toEqual([180]);+ expect(handle.current!.widths).not.toBe(widthsAfterClamp);+ releaseMouse();+ });++ test("drag starts with defaultWidth fallback if widths state lags behind a newly added column", () => {+ // The widths state is sized once at mount; if a caller adds a column+ // afterwards, widthsRef.current[newIndex] is undefined. The hook must+ // fall back to the column's defaultWidth so the gesture starts from a+ // sensible value rather than producing NaN.+ mount([{ key: "a", defaultWidth: 100 }]);+ act(() => {+ root.render(+ <Harness+ columns={[+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ ]}+ handleRef={handle}+ />+ );+ });++ // widths state is still [100]; widthsRef.current[1] is undefined.+ startDrag(1, 500);+ moveMouse(560); // delta = 60, startWidth fallback = 200, new = 260+ expect(handle.current!.widths[1]).toBe(260);+ expect(Number.isNaN(handle.current!.widths[1])).toBe(false);+ releaseMouse();+ });++ test("onResizeStart identity is stable across width changes", () => {+ // Regression: putting `widths` in onResizeStart's deps caused it to rebind+ // on every mousemove tick, re-rendering every header / row consumer.+ mount([+ { key: "a", defaultWidth: 100 },+ { key: "b", defaultWidth: 200 },+ ]);+ const originalOnResizeStart = handle.current!.onResizeStart;+ startDrag(0, 50);+ moveMouse(80);+ moveMouse(120);+ releaseMouse();+ expect(handle.current!.widths).toEqual([170, 200]);+ expect(handle.current!.onResizeStart).toBe(originalOnResizeStart);+ });+});diff --git a/frontend/src/react/hooks/useColumnWidths.ts b/frontend/src/react/hooks/useColumnWidths.tsindex 061f66f8b4..08587371d1 100644--- a/frontend/src/react/hooks/useColumnWidths.ts+++ b/frontend/src/react/hooks/useColumnWidths.ts@@ -1,4 +1,10 @@-import { useCallback, useEffect, useRef, useState } from "react";+import {+ useCallback,+ useEffect,+ useLayoutEffect,+ useRef,+ useState,+} from "react";export interface ColumnWithWidth {defaultWidth: number;@@ -11,6 +17,19 @@ export interface ColumnWithWidth {* positional: `widths[i]` corresponds to `columns[i]`.** Widths are not persisted across remounts.+ *+ * Eager-capture contract: at drag start the hook snapshots colIndex,+ * startX, startWidth, and minWidth into a closure-local drag record.+ * Once captured, the in-flight drag is immune to subsequent changes in+ * `widths` or `columns` (reordering, equal-length swaps, minWidth+ * tweaks, even removal). Callers don't need to memoize aggressively —+ * just don't expect a drag to react to column changes mid-gesture.+ *+ * If a caller grows the column array after mount without remounting the+ * hook, `widths` state stays at its initial length until the next user+ * resize on the new column. The drag's `startWidth` falls back to the+ * column's `defaultWidth` so the gesture starts from a sensible value+ * rather than NaN.*/export function useColumnWidths<T extends ColumnWithWidth>(columns: T[]) {const [widths, setWidths] = useState<number[]>(() =>@@ -20,50 +39,85 @@ export function useColumnWidths<T extends ColumnWithWidth>(columns: T[]) {colIndex: number;startX: number;startWidth: number;+ minWidth: number;} | null>(null);// Holds the teardown function for an active drag so an unmount-mid-drag// (route change, modal close, etc.) tears down document-level listeners// and resets the body cursor/userSelect overrides.const dragCleanupRef = useRef<() => void>(() => {});+ // Closures should capture state eagerly via refs, not via React deps.+ // Putting `widths` in onResizeStart's dep array would rebind the callback+ // on every mousemove (since each tick calls setWidths), which would+ // re-render every header consumer mid-drag. Mirror the latest values+ // into refs via useLayoutEffect (runs synchronously after commit, before+ // paint and before any subsequent event handler can fire) so onResizeStart+ // stays referentially stable AND avoids render-phase ref writes that+ // React 19 concurrent mode could expose from a discarded render.+ const widthsRef = useRef(widths);+ const columnsRef = useRef(columns);+ useLayoutEffect(() => {+ widthsRef.current = widths;+ columnsRef.current = columns;+ });- const onResizeStart = useCallback(- (colIndex: number, e: React.MouseEvent) => {- e.preventDefault();- e.stopPropagation();- dragRef.current = {- colIndex,- startX: e.clientX,- startWidth: widths[colIndex],- };+ const onResizeStart = useCallback((colIndex: number, e: React.MouseEvent) => {+ e.preventDefault();+ e.stopPropagation();+ // Defensively tear down any in-flight drag before starting a new one.+ // A second onResizeStart without an intervening mouseup (rapid+ // sequential mousedowns, missed mouseup outside the document,+ // multi-touch trackpad, programmatic dispatch) would otherwise leak+ // the prior drag's document listeners and orphan its cleanup.+ dragCleanupRef.current();+ // Defensive: the user clicked a header that was just rendered, so the+ // column at this index should be defined. Guard against the edge case+ // where columnsRef has been synced to a shorter array via a commit+ // that's interleaved with this click.+ const col = columnsRef.current[colIndex];+ if (!col) return;+ dragRef.current = {+ colIndex,+ startX: e.clientX,+ // Fall back to defaultWidth if widths state hasn't grown to include+ // a column added after mount (widths state is sized at first render+ // and never auto-extends). Without this, startWidth would be+ // undefined and the drag's newWidth math would produce NaN.+ startWidth: widthsRef.current[colIndex] ?? col.defaultWidth,+ minWidth: col.minWidth ?? 40,+ };- const onMouseMove = (ev: MouseEvent) => {- if (!dragRef.current) return;- const delta = ev.clientX - dragRef.current.startX;- const min = columns[dragRef.current.colIndex].minWidth ?? 40;- const newWidth = Math.max(min, dragRef.current.startWidth + delta);- setWidths((prev) => {- const next = [...prev];- next[dragRef.current!.colIndex] = newWidth;- return next;- });- };- const teardown = () => {- dragRef.current = null;- document.removeEventListener("mousemove", onMouseMove);- document.removeEventListener("mouseup", teardown);- document.body.style.cursor = "";- document.body.style.userSelect = "";- // Reset so the unmount-cleanup is a no-op if the drag ended cleanly.- dragCleanupRef.current = () => {};- };- document.addEventListener("mousemove", onMouseMove);- document.addEventListener("mouseup", teardown);- document.body.style.cursor = "col-resize";- document.body.style.userSelect = "none";- dragCleanupRef.current = teardown;- },- [widths, columns]- );+ const onMouseMove = (ev: MouseEvent) => {+ if (!dragRef.current) return;+ // Read only the snapshot — see "Eager-capture contract" in JSDoc.+ const { colIndex, startX, startWidth, minWidth } = dragRef.current;+ const delta = ev.clientX - startX;+ const newWidth = Math.max(minWidth, startWidth + delta);+ setWidths((prev) => {+ // Short-circuit no-op updates. While clamped at minWidth (cursor+ // moving farther past the edge), this fires once per pixel of+ // mouse motion with the same newWidth — without this guard,+ // React would still re-render every consumer per tick.+ if (prev[colIndex] === newWidth) return prev;+ const next = [...prev];+ next[colIndex] = newWidth;+ return next;+ });+ };+ const teardown = () => {+ dragRef.current = null;+ document.removeEventListener("mousemove", onMouseMove);+ document.removeEventListener("mouseup", teardown);+ document.body.style.cursor = "";+ document.body.style.userSelect = "";+ // Reset so the unmount-cleanup is a no-op if the drag ended cleanly.+ dragCleanupRef.current = () => {};+ };+ document.addEventListener("mousemove", onMouseMove);+ document.addEventListener("mouseup", teardown);+ document.body.style.cursor = "col-resize";+ document.body.style.userSelect = "none";+ dragCleanupRef.current = teardown;+ }, []);useEffect(() => {return () => {diff --git a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsxindex eeb216dcf5..e5f8c7a418 100644--- a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx+++ b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx@@ -45,6 +45,7 @@ import {TableRow,} from "@/react/components/ui/table";import { Tooltip } from "@/react/components/ui/tooltip";+import { useColumnWidths } from "@/react/hooks/useColumnWidths";import { useEscapeKey } from "@/react/hooks/useEscapeKey";import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";import { useSessionPageSize } from "@/react/hooks/useSessionPageSize";@@ -107,7 +108,7 @@ import {type SearchParams as VueSearchParams,} from "@/utils";import { extractStageUID } from "@/utils/v1/issue/rollout";-import { getReviewBadge } from "./utils/reviewBadge";+import { getReviewBadge, type ReviewBadge } from "./utils/reviewBadge";// Task status priority order for determining rollout stage statusconst TASK_STATUS_FILTERS: Task_Status[] = [@@ -375,27 +376,230 @@ export function ProjectPlanDashboardPage({ projectId }: { projectId: string }) {// PlanTable// ---------------------------------------------------------------------------+interface PlanColumn {+ key: string;+ title: React.ReactNode;+ defaultWidth: number;+ minWidth?: number;+ resizable?: boolean;+ render: (plan: Plan, ctx: PlanRowContext) => React.ReactNode;+}++interface PlanRowContext {+ creator: { title: string; name: string };+ updateTimeTs: number;+ approvalTag: { label: string; variant: ReviewBadge["variant"] } | undefined;+ checkSummary: {+ running: number;+ success: number;+ warning: number;+ error: number;+ };+ hasAnyCheck: boolean;+ isDeleted: boolean;+ showDraftTag: boolean;+ environmentStore: ReturnType<typeof useEnvironmentV1Store>;+}++function getRolloutStageStatus(summary: Plan_RolloutStageSummary): Task_Status {+ for (const status of TASK_STATUS_FILTERS) {+ if (summary.taskStatusCounts.some((item) => item.status === status)) {+ return status;+ }+ }+ return Task_Status.STATUS_UNSPECIFIED;+}+function PlanTable({ plans, projectId }: { plans: Plan[]; projectId: string }) {const { t } = useTranslation();+ const columns = useMemo<PlanColumn[]>(+ () => [+ {+ key: "name",+ title: t("issue.table.name"),+ defaultWidth: 320,+ minWidth: 200,+ resizable: true,+ render: (plan, ctx) => (+ <div className="flex items-center gap-x-2 overflow-hidden">+ <span className="whitespace-nowrap text-control opacity-60">+ {extractPlanUID(plan.name)}+ </span>+ {plan.title ? (+ <span className="truncate normal-nums min-w-0">{plan.title}</span>+ ) : (+ <span className="opacity-60 italic">{t("common.untitled")}</span>+ )}+ {ctx.isDeleted && (+ <span className="inline-flex items-center rounded-full bg-warning/10 text-warning px-2 py-0.5 text-xs shrink-0">+ {t("common.closed")}+ </span>+ )}+ {ctx.showDraftTag && !ctx.isDeleted && (+ <span className="inline-flex items-center rounded-full bg-control-bg text-control-light px-2 py-0.5 text-xs shrink-0">+ {t("common.draft")}+ </span>+ )}+ </div>+ ),+ },+ {+ key: "checks",+ title: t("plan.checks.self"),+ defaultWidth: 200,+ minWidth: 120,+ resizable: true,+ render: (_plan, ctx) =>+ ctx.hasAnyCheck ? (+ <div className="flex items-center gap-3 flex-wrap">+ {ctx.checkSummary.running > 0 && (+ <div className="flex items-center gap-1 text-control">+ <Loader2 className="size-4 animate-spin" />+ <span>{t("task.status.running")}</span>+ </div>+ )}+ {ctx.checkSummary.error > 0 && (+ <div className="flex items-center gap-1 text-error">+ <XCircle className="size-4" />+ <span>{ctx.checkSummary.error}</span>+ </div>+ )}+ {ctx.checkSummary.warning > 0 && (+ <div className="flex items-center gap-1 text-warning">+ <AlertCircle className="size-4" />+ <span>{ctx.checkSummary.warning}</span>+ </div>+ )}+ {ctx.checkSummary.success > 0 && (+ <div className="flex items-center gap-1 text-success">+ <CheckCircle className="size-4" />+ <span>{ctx.checkSummary.success}</span>+ </div>+ )}+ </div>+ ) : (+ <span className="text-control-light">-</span>+ ),+ },+ {+ key: "review",+ title: t("plan.navigator.review"),+ defaultWidth: 140,+ minWidth: 100,+ resizable: true,+ render: (_plan, ctx) =>+ ctx.approvalTag ? (+ <Badge+ variant={ctx.approvalTag.variant}+ className="whitespace-nowrap"+ >+ {ctx.approvalTag.label}+ </Badge>+ ) : (+ <span className="text-control-light">-</span>+ ),+ },+ {+ key: "stages",+ title: t("rollout.stage.self", { count: 2 }),+ defaultWidth: 260,+ minWidth: 140,+ resizable: true,+ render: (plan, ctx) =>+ plan.rolloutStageSummaries.length === 0 ? (+ <span className="text-control-light">-</span>+ ) : (+ <div className="flex items-center gap-1 flex-wrap">+ {plan.rolloutStageSummaries.map((summary, index) => {+ const envName = formatEnvironmentName(+ extractStageUID(summary.stage)+ );+ const environment =+ ctx.environmentStore.getEnvironmentByName(envName);+ const stageStatus = getRolloutStageStatus(summary);+ return (+ <div key={summary.stage} className="flex items-center gap-1">+ <div className="flex items-center gap-1">+ <TaskStatusIcon status={stageStatus} />+ <span className="text-sm">+ {environment?.title || envName}+ </span>+ </div>+ {index < plan.rolloutStageSummaries.length - 1 && (+ <span className="mx-1 text-control-light">→</span>+ )}+ </div>+ );+ })}+ </div>+ ),+ },+ {+ key: "updated",+ title: t("issue.table.updated"),+ defaultWidth: 152,+ minWidth: 100,+ resizable: true,+ render: (_plan, ctx) => (+ <Tooltip content={formatAbsoluteDateTime(ctx.updateTimeTs * 1000)}>+ <span className="text-control-light whitespace-nowrap">+ {humanizeTs(ctx.updateTimeTs)}+ </span>+ </Tooltip>+ ),+ },+ {+ key: "creator",+ title: t("issue.table.creator"),+ defaultWidth: 152,+ minWidth: 100,+ resizable: true,+ render: (_plan, ctx) => (+ <div className="flex items-center gap-x-1.5">+ <span className="text-sm truncate min-w-0">+ {ctx.creator.title}+ </span>+ </div>+ ),+ },+ ],+ [t]+ );++ const { widths, totalWidth, onResizeStart } = useColumnWidths(columns);+return (<div className="overflow-x-auto">- <Table className="min-w-[1000px]">+ <Table className="table-fixed" style={{ minWidth: `${totalWidth}px` }}>+ <colgroup>+ {widths.map((w, i) => (+ <col key={columns[i].key} style={{ width: `${w}px` }} />+ ))}+ </colgroup><TableHeader><TableRow className="bg-control-bg">- <TableHead className="min-w-80">{t("issue.table.name")}</TableHead>- <TableHead className="w-50">{t("plan.checks.self")}</TableHead>- <TableHead className="w-35">{t("plan.navigator.review")}</TableHead>- <TableHead className="w-65">- {t("rollout.stage.self", { count: 2 })}- </TableHead>- <TableHead className="w-38">{t("issue.table.updated")}</TableHead>- <TableHead className="w-38">{t("issue.table.creator")}</TableHead>+ {columns.map((col, colIdx) => (+ <TableHead+ key={col.key}+ resizable={col.resizable}+ onResizeStart={+ col.resizable ? (e) => onResizeStart(colIdx, e) : undefined+ }+ >+ {col.title}+ </TableHead>+ ))}</TableRow></TableHeader><TableBody>{plans.map((plan) => (- <PlanRow key={plan.name} plan={plan} projectId={projectId} />+ <PlanRow+ key={plan.name}+ plan={plan}+ projectId={projectId}+ columns={columns}+ />))}</TableBody></Table>@@ -407,10 +611,18 @@ function PlanTable({ plans, projectId }: { plans: Plan[]; projectId: string }) {// PlanRow// ----------------------------------------------------------------------------function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {- const { t } = useTranslation();+function PlanRow({+ plan,+ projectId,+ columns,+}: Readonly<{+ plan: Plan;+ projectId: string;+ columns: PlanColumn[];+}>) {const userStore = useUserStore();const environmentStore = useEnvironmentV1Store();+ const { t } = useTranslation();const isDeleted = plan.state === State.DELETED;const showDraftTag = plan.issue === "" && !plan.hasRollout;@@ -464,7 +676,6 @@ function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {return { label: t(badge.labelKey), variant: badge.variant };}, [plan.approvalStatus, plan.hasRollout, plan.issue, t]);- // Plan check status summaryconst checkSummary = useMemo(() => {const statusCount = plan.planCheckRunStatusCount || {};const running = statusCount["RUNNING"] || 0;@@ -481,16 +692,15 @@ function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {checkSummary.error >0;- // Rollout stages- const getRolloutStageStatus = (- summary: Plan_RolloutStageSummary- ): Task_Status => {- for (const status of TASK_STATUS_FILTERS) {- if (summary.taskStatusCounts.some((item) => item.status === status)) {- return status;- }- }- return Task_Status.STATUS_UNSPECIFIED;+ const ctx: PlanRowContext = {+ creator,+ updateTimeTs,+ approvalTag,+ checkSummary,+ hasAnyCheck,+ isDeleted,+ showDraftTag,+ environmentStore,};return (@@ -498,121 +708,11 @@ function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {className={cn("cursor-pointer", isDeleted && "opacity-60")}onClick={onRowClick}>- {/* Title */}- <TableCell>- <div className="flex items-center gap-x-2 overflow-hidden">- <span className="whitespace-nowrap text-control opacity-60">- {extractPlanUID(plan.name)}- </span>- {plan.title ? (- <span className="truncate normal-nums">{plan.title}</span>- ) : (- <span className="opacity-60 italic">{t("common.untitled")}</span>- )}- {isDeleted && (- <span className="inline-flex items-center rounded-full bg-warning/10 text-warning px-2 py-0.5 text-xs shrink-0">- {t("common.closed")}- </span>- )}- {showDraftTag && !isDeleted && (- <span className="inline-flex items-center rounded-full bg-control-bg text-control-light px-2 py-0.5 text-xs shrink-0">- {t("common.draft")}- </span>- )}- </div>- </TableCell>-- {/* Checks */}- <TableCell>- {hasAnyCheck ? (- <div className="flex items-center gap-3 flex-wrap">- {checkSummary.running > 0 && (- <div className="flex items-center gap-1 text-control">- <Loader2 className="size-4 animate-spin" />- <span>{t("task.status.running")}</span>- </div>- )}- {checkSummary.error > 0 && (- <div className="flex items-center gap-1 text-error">- <XCircle className="size-4" />- <span>{checkSummary.error}</span>- </div>- )}- {checkSummary.warning > 0 && (- <div className="flex items-center gap-1 text-warning">- <AlertCircle className="size-4" />- <span>{checkSummary.warning}</span>- </div>- )}- {checkSummary.success > 0 && (- <div className="flex items-center gap-1 text-success">- <CheckCircle className="size-4" />- <span>{checkSummary.success}</span>- </div>- )}- </div>- ) : (- <span className="text-control-light">-</span>- )}- </TableCell>-- {/* Approval */}- <TableCell>- {approvalTag ? (- <Badge variant={approvalTag.variant} className="whitespace-nowrap">- {approvalTag.label}- </Badge>- ) : (- <span className="text-control-light">-</span>- )}- </TableCell>-- {/* Stages */}- <TableCell>- {plan.rolloutStageSummaries.length === 0 ? (- <span className="text-control-light">-</span>- ) : (- <div className="flex items-center gap-1 flex-wrap">- {plan.rolloutStageSummaries.map((summary, index) => {- const envName = formatEnvironmentName(- extractStageUID(summary.stage)- );- const environment =- environmentStore.getEnvironmentByName(envName);- const stageStatus = getRolloutStageStatus(summary);- return (- <div key={summary.stage} className="flex items-center gap-1">- <div className="flex items-center gap-1">- <TaskStatusIcon status={stageStatus} />- <span className="text-sm">- {environment?.title || envName}- </span>- </div>- {index < plan.rolloutStageSummaries.length - 1 && (- <span className="mx-1 text-control-light">→</span>- )}- </div>- );- })}- </div>- )}- </TableCell>-- {/* Updated */}- <TableCell>- <Tooltip content={formatAbsoluteDateTime(updateTimeTs * 1000)}>- <span className="text-control-light whitespace-nowrap">- {humanizeTs(updateTimeTs)}- </span>- </Tooltip>- </TableCell>-- {/* Creator */}- <TableCell>- <div className="flex items-center gap-x-1.5">- <span className="text-sm truncate">{creator.title}</span>- </div>- </TableCell>+ {columns.map((col) => (+ <TableCell key={col.key} className="overflow-hidden">+ {col.render(plan, ctx)}+ </TableCell>+ ))}</TableRow>);}