mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-19 07:42:38 +01:00
fix(ui): clarify dashboard proposal hierarchy (#22180)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - An agent can propose dashboard areas and responsibilities in one card. > - The card put the area name above a separate “New area” row. > - Responsibility rows had no type label and no visible parent structure. > - This pull request puts area changes in the heading and nests responsibility changes below it. > - People can see what each change creates and where it belongs before they apply it. ## Linked Issues or Issue Description **What existing behavior does this improve?** The dashboard proposal card in task conversations and the dashboard edit module. **Subsystem affected** The board UI and its Storybook examples. **Current behavior** “New area” appears in a row below the area title. New responsibilities appear at the same level. Their type is not stated. **Proposed behavior** “New area” appears beside the area title. Each new responsibility has a label and sits below its parent area. Existing areas have a separate label. Area headings follow the heading level in the dashboard module. **Reason and benefit** The person can see the parent area, the change type and the text to review in that order. Long proposals are easier to scan. **Breaking changes** None. Proposal inputs, indexes, dependencies and apply/decline endpoints stay the same. ## What Changed - Put area changes and their controls in the area heading. - Nest responsibility rows under each area. Label additions, rewords, moves and removals. - Keep the drop/keep dependency behavior and the existing apply payload. - Keep area classification and group partitions in one helper. Expose whether each group has an existing parent area. - Add Storybook examples for the new hierarchy, a narrow layout and a mix of new and existing areas. - Add focused component and browser checks for the hierarchy, responsive layout and apply payload. ## Verification - 24 focused unit tests passed across the proposal card, dashboard module and dashboard helpers. - 25 Chromium checks passed against current-source Storybook after the review refactor, with one worker and no retries. They cover six proposal states in light and dark themes at widths of 390 and 960 pixels, plus the existing apply payload. - The UI typecheck passed in low-memory mode after the review refactor. The initial implementation also passed the static Storybook build; current-head CI supplies broad build coverage. - 30 map/catalog tests passed. Catalog checks, token gates and whitespace checks passed. - A hierarchy regression failed before the fix and passed after it. A later hosted-story check found a skipped heading level. The fix passed the expanded browser checks. - Initial concurrent browser, build and typecheck runs hit the workspace memory limit. The final browser pass used one worker and the typecheck used low-memory mode. - The first CI build stopped because its runner received a shutdown signal after the UI build completed. A new CI run checks the review fixes. - The local verification selector returned exit 2 because the new browser spec is a global CI input. [Current-head CI](https://github.com/paperclipai/paperclip/actions/runs/44333497172) passed typecheck, build, all selected test suites, E2E shards and the final verify gate for `e71916cdde90ede313cc167ab8cfb8a5c3bb501a`. No visual baseline comparison was run because the baseline manifest has no published snapshots. - [Greptile reviewed the current head](https://github.com/paperclipai/paperclip/pull/22180#issuecomment-6982500386) at 5/5 with no findings. Both earlier maintainability threads are resolved; two Paperclip reviews remain pending. ## Risks Low risk. This changes UI structure and labels. Long text and drop/keep controls must continue to fit at narrow widths. The focused browser checks cover those states. Storybook uses synthetic API data and does not prove server persistence or permissions. ## Model Used OpenAI GPT-6 through Codex, with reasoning, tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
adb2bcf896
commit
a9dc0df9da
7 files changed
+268
-49
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
for (const theme of ["light", "dark"]) {
|
||||
for (const width of [390, 960]) {
|
||||
for (const story of ["proposal-hierarchy", "proposal-hierarchy-mobile", "proposal-create", "proposal-new-and-existing-areas", "proposal-edit", "proposal-in-conversation"]) {
|
||||
test(`${story} ${theme} ${width}`, async ({ page }, testInfo) => {
|
||||
await page.setViewportSize({ width, height: 1100 });
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
await page.goto(`/iframe.html?id=feature-responsibility-dashboard--${story}&viewMode=story&globals=theme:${theme}`);
|
||||
const finished = () => page.evaluate(() => (window as unknown as {
|
||||
__STORYBOOK_ADDONS_CHANNEL__?: { data: Record<string, Array<{ status?: string }>> };
|
||||
}).__STORYBOOK_ADDONS_CHANNEL__?.data.storyFinished?.[0]?.status);
|
||||
await expect.poll(finished, { timeout: 30_000 }).not.toBeUndefined();
|
||||
expect(await finished()).toBe("success");
|
||||
expect(errors).toEqual([]);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
|
||||
if (story === "proposal-hierarchy") {
|
||||
const area = page.getByRole("region", { name: "Fundraising" });
|
||||
const heading = area.getByRole("heading", { name: "Fundraising" });
|
||||
const responsibilities = area.getByRole("list", { name: "Responsibilities in Fundraising" });
|
||||
await expect(responsibilities.getByText("New responsibility", { exact: true })).toHaveCount(2);
|
||||
expect((await responsibilities.getByRole("listitem").first().boundingBox())!.x).toBeGreaterThan((await heading.boundingBox())!.x);
|
||||
await expect(responsibilities.getByRole("button", { name: "Drop this change" })).toHaveCount(2);
|
||||
await area.getByRole("button", { name: "Drop this change" }).first().click();
|
||||
await expect(area.locator("[data-dropped]")).toHaveCount(3);
|
||||
await expect(area.getByText("Goes with Fundraising")).toHaveCount(2);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
await responsibilities.getByRole("button", { name: "Keep", exact: true }).last().click();
|
||||
await expect(area.locator("[data-dropped]")).toHaveCount(1);
|
||||
await area.getByRole("button", { name: "Keep", exact: true }).click();
|
||||
}
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
await page.getByTestId("dashboard-changes").screenshot({ path: testInfo.outputPath(`${story}-${theme}-${width}.png`) });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test("nested selections retain the existing apply payload", async ({ page }) => {
|
||||
await page.goto("/iframe.html?id=feature-responsibility-dashboard--proposal-hierarchy&viewMode=story");
|
||||
const area = page.getByRole("region", { name: "Portfolio", exact: true });
|
||||
await area.getByRole("button", { name: "Drop this change" }).first().click();
|
||||
await area.getByRole("button", { name: "Keep", exact: true }).last().click();
|
||||
await page.evaluate(() => {
|
||||
const original = window.fetch;
|
||||
(window as unknown as { appliedBody: unknown }).appliedBody = undefined;
|
||||
window.fetch = (input, init) => {
|
||||
if (String(input).endsWith("/accept")) {
|
||||
(window as unknown as { appliedBody: unknown }).appliedBody = JSON.parse(String(init?.body));
|
||||
}
|
||||
return original(input, init);
|
||||
};
|
||||
});
|
||||
await page.getByRole("button", { name: "Apply changes" }).click();
|
||||
await expect.poll(() => page.evaluate(() => (window as unknown as { appliedBody: unknown }).appliedBody))
|
||||
.toEqual({ keep: [0, 1, 2, 3, 5, 6, 7, 8, 9] });
|
||||
});
|
||||
@@ -59,14 +59,27 @@ describe("DashboardChangesCard", () => {
|
||||
return match;
|
||||
};
|
||||
const group = (name: string) => container.querySelector<HTMLElement>(`section[aria-label="${name}"]`)!;
|
||||
const rows = (name: string) => [...group(name).querySelectorAll<HTMLElement>("li")];
|
||||
const rows = (name: string) => [...group(name).querySelectorAll<HTMLElement>("[data-dashboard-change]")];
|
||||
|
||||
it("identifies new areas in their headings and nests explicitly named new responsibilities", async () => {
|
||||
await render(<DashboardChangesCard interaction={dashboardChangesFixture("create")} />);
|
||||
const fundraising = group("Fundraising");
|
||||
const area = fundraising.querySelector('[data-dashboard-change="add_area"]')!;
|
||||
expect(area.querySelector("h3")?.textContent).toBe("Fundraising");
|
||||
expect(area.textContent).toContain("New area");
|
||||
const responsibilities = fundraising.querySelector('ul[aria-label="Responsibilities in Fundraising"]')!;
|
||||
expect(responsibilities).not.toBeNull();
|
||||
expect(responsibilities.contains(area)).toBe(false);
|
||||
expect([...responsibilities.querySelectorAll("li")].map((row) => row.querySelector('[data-change-label]')?.textContent))
|
||||
.toEqual(["New responsibility", "New responsibility"]);
|
||||
});
|
||||
|
||||
it("shows a first dashboard grouped by area, in plain words, with the agent's reasons", async () => {
|
||||
await render(<DashboardChangesCard interaction={dashboardChangesFixture("create")} />);
|
||||
const text = container.textContent ?? "";
|
||||
expect(text).toContain("Chief proposes");
|
||||
expect(text).toContain("A first dashboard from your answers and your calendar.");
|
||||
expect([...container.querySelectorAll("h4")].map((heading) => heading.textContent)).toEqual(["Fundraising", "Portfolio", "Team", "Board"]);
|
||||
expect([...container.querySelectorAll("h3")].map((heading) => heading.textContent)).toEqual(["Fundraising", "Portfolio", "Team", "Board"]);
|
||||
expect(rows("Fundraising").map((row) => row.getAttribute("data-dashboard-change"))).toEqual(["add_area", "add_responsibility", "add_responsibility"]);
|
||||
expect(rows("Fundraising")[1]!.textContent).toContain("You run the weekly fundraising sync");
|
||||
expect(text).not.toMatch(/\b(issue|interaction|op|areaRef)\b/i);
|
||||
@@ -83,8 +96,21 @@ describe("DashboardChangesCard", () => {
|
||||
expect(rows("Portfolio")[0]!.textContent).toContain("Moved from Fundraising");
|
||||
const team = rows("Team");
|
||||
// Area changes first: the rename, seen by others too, then the responsibility let go with its reason.
|
||||
expect(team[0]!.textContent).toContain("TeamPeopleAlso renamed for 2 other people");
|
||||
expect(team[1]!.textContent).toContain("Hire a second designer.Let goThat is a task that finishes");
|
||||
expect(team[0]!.querySelector("h3")?.textContent).toBe("Team People");
|
||||
expect(team[0]!.textContent).toContain("Rename areaAlso renamed for 2 other people");
|
||||
expect(team[1]!.textContent).toContain("Let go of responsibilityHire a second designer.Let goThat is a task that finishes");
|
||||
});
|
||||
|
||||
it("names the existing parent area when only a responsibility is added, and identifies area removal", async () => {
|
||||
const interaction = dashboardChangesFixture("create");
|
||||
await render(<DashboardChangesCard interaction={{ ...interaction, payload: { ...interaction.payload, changes: [
|
||||
{ ...interaction.payload.changes[1]!, index: 0, groupRef: null, groupAreaId: "fundraising", dependsOn: [] },
|
||||
{ ...interaction.payload.changes[3]!, index: 1, op: "remove_area", groupRef: null, groupAreaId: "portfolio", reason: "Someone else owns it now." },
|
||||
] } }} />);
|
||||
expect(group("Fundraising").textContent).toContain("FundraisingExisting areaNew responsibility");
|
||||
expect(group("Portfolio").querySelector("h3")?.textContent?.trim()).toBe("Portfolio");
|
||||
expect(group("Portfolio").textContent).toContain("Remove area");
|
||||
expect(group("Portfolio").querySelector("ul")).toBeNull();
|
||||
});
|
||||
|
||||
it("drops a new area together with what is filed under it, and keeps the area when one of them is kept", async () => {
|
||||
@@ -101,6 +127,16 @@ describe("DashboardChangesCard", () => {
|
||||
expect(acceptMock).toHaveBeenCalledExactlyOnceWith("issue-dashboard-conversation", "dashboard-changes-create", [0, 1, 2, 3, 5, 6, 7, 8, 9]);
|
||||
});
|
||||
|
||||
it("does not label an unfiled responsibility as an existing area", async () => {
|
||||
const interaction = dashboardChangesFixture("edit");
|
||||
await render(<DashboardChangesCard interaction={{ ...interaction, payload: { ...interaction.payload, changes: [
|
||||
{ ...interaction.payload.changes[0]!, groupAreaId: null, groupName: "No area" },
|
||||
] } }} />);
|
||||
expect(group("No area").textContent).not.toContain("Existing area");
|
||||
expect(group("No area").querySelector("h3")?.textContent).toBe("No area");
|
||||
expect(rows("No area")[0]!.textContent).toContain("Every prospective LP hears from us at least every two weeks.");
|
||||
});
|
||||
|
||||
it("applies everything when nothing is dropped, and cannot apply nothing", async () => {
|
||||
await render(<DashboardChangesCard interaction={dashboardChangesFixture("edit")} />);
|
||||
for (const name of ["Fundraising", "Portfolio", "Team"]) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
dashboardChangeGroups,
|
||||
dashboardChangeWords,
|
||||
droppedWithArea,
|
||||
isDashboardAreaChange,
|
||||
keptDashboardChanges,
|
||||
lettingGoWith,
|
||||
toggleDashboardChange,
|
||||
@@ -58,6 +59,16 @@ export function useDashboardChangesActions(interaction: Pick<ProposeDashboardCha
|
||||
return { accept, decline, busy: accept.isPending || decline.isPending, error: accept.error ?? decline.error };
|
||||
}
|
||||
|
||||
const CHANGE_LABELS: Record<ResponsibilityDashboardChange["op"], string> = {
|
||||
add_area: "New area",
|
||||
rename_area: "Rename area",
|
||||
remove_area: "Remove area",
|
||||
add_responsibility: "New responsibility",
|
||||
reword_responsibility: "Reword responsibility",
|
||||
move_responsibility: "Move responsibility",
|
||||
remove_responsibility: "Let go of responsibility",
|
||||
};
|
||||
|
||||
function ChangeRow({
|
||||
change,
|
||||
changes,
|
||||
@@ -73,25 +84,40 @@ function ChangeRow({
|
||||
}) {
|
||||
const isDropped = dropped.has(change.index);
|
||||
const words = dashboardChangeWords(change);
|
||||
const areaChange = isDashboardAreaChange(change);
|
||||
const Row = areaChange ? "div" : "li";
|
||||
const withArea = isDropped ? droppedWithArea(changes, dropped, change) : null;
|
||||
const lettingGo = change.op === "remove_area" && !isDropped ? lettingGoWith(changes, dropped, change) : [];
|
||||
return (
|
||||
<li
|
||||
className="flex min-w-0 items-start gap-2 py-2"
|
||||
<Row
|
||||
className="flex min-w-0 items-start gap-2"
|
||||
data-dashboard-change={change.op}
|
||||
data-dropped={isDropped ? "" : undefined}
|
||||
>
|
||||
<div className={cn("flex min-w-0 flex-1 flex-col gap-0.5", isDropped && "text-muted-foreground line-through")}>
|
||||
{words.before ? <p className="break-words text-sm text-muted-foreground line-through">{words.before}</p> : null}
|
||||
{words.after ? <p className={cn("break-words text-sm", !isDropped && "text-foreground")}>{words.after}</p> : null}
|
||||
<div className={cn("flex min-w-0 flex-1 flex-col gap-1", isDropped && "text-muted-foreground")}>
|
||||
{areaChange ? (
|
||||
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1">
|
||||
<h3 className={cn("min-w-0 break-words text-base font-semibold", isDropped ? "line-through" : "text-foreground")}>
|
||||
{words.before ? <span className="text-muted-foreground line-through">{words.before}{" "}</span> : null}
|
||||
{words.after}
|
||||
</h3>
|
||||
<span data-change-label="" className="text-xs text-muted-foreground">{CHANGE_LABELS[change.op]}</span>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<span data-change-label="" className="text-xs text-muted-foreground">{CHANGE_LABELS[change.op]}</span>
|
||||
{words.before ? <p className="break-words text-sm text-muted-foreground line-through">{words.before}</p> : null}
|
||||
{words.after ? <p className={cn("break-words text-sm", isDropped ? "line-through" : "text-foreground")}>{words.after}</p> : null}
|
||||
</>
|
||||
)}
|
||||
{words.note ? <p className="text-xs text-muted-foreground">{words.note}</p> : null}
|
||||
{lettingGo.length > 0 ? (
|
||||
<p className="text-xs text-muted-foreground">Also lets go of: {lettingGo.join("; ")}</p>
|
||||
) : null}
|
||||
{change.reason ? <p className="text-xs text-muted-foreground">{change.reason}</p> : null}
|
||||
{change.reason ? <p className="break-words text-xs text-muted-foreground">{change.reason}</p> : null}
|
||||
</div>
|
||||
{isDropped ? (
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<div className="flex max-w-1/3 shrink-0 flex-col items-end gap-1">
|
||||
{withArea ? <span className="text-xs text-muted-foreground">Goes with {withArea}</span> : null}
|
||||
<Button type="button" size="xs" variant="ghost" disabled={busy} onClick={onToggle}>Keep</Button>
|
||||
</div>
|
||||
@@ -110,7 +136,7 @@ function ChangeRow({
|
||||
<X aria-hidden="true" />
|
||||
</Button>
|
||||
)}
|
||||
</li>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -179,24 +205,35 @@ export function DashboardChangesCard({
|
||||
<p className="text-xs text-muted-foreground">{agentName} proposes</p>
|
||||
{payload.message ? <p className="text-sm text-foreground">{payload.message}</p> : null}
|
||||
</div>
|
||||
<div className="flex flex-col gap-3">
|
||||
{groups.map((group) => (
|
||||
<section key={group.key} aria-label={group.name} data-dashboard-change-group={group.key}>
|
||||
<h4 className="text-sm font-semibold text-foreground">{group.name}</h4>
|
||||
<ul className="flex flex-col divide-y divide-border">
|
||||
{group.changes.map((change) => (
|
||||
<ChangeRow
|
||||
key={change.index}
|
||||
change={change}
|
||||
changes={changes}
|
||||
dropped={dropped}
|
||||
busy={busy}
|
||||
onToggle={() => setDropped((current) => toggleDashboardChange(changes, current, change.index))}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
))}
|
||||
<div className="flex flex-col gap-6">
|
||||
{groups.map((group) => {
|
||||
const { areaChanges, responsibilityChanges } = group;
|
||||
const row = (change: ResponsibilityDashboardChange) => (
|
||||
<ChangeRow
|
||||
key={change.index}
|
||||
change={change}
|
||||
changes={changes}
|
||||
dropped={dropped}
|
||||
busy={busy}
|
||||
onToggle={() => setDropped((current) => toggleDashboardChange(changes, current, change.index))}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<section key={group.key} aria-label={group.name} data-dashboard-change-group={group.key} className="flex min-w-0 flex-col gap-3">
|
||||
{areaChanges.length > 0 ? areaChanges.map(row) : (
|
||||
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1">
|
||||
<h3 className="min-w-0 break-words text-base font-semibold text-foreground">{group.name}</h3>
|
||||
{group.hasExistingArea ? <span className="text-xs text-muted-foreground">Existing area</span> : null}
|
||||
</div>
|
||||
)}
|
||||
{responsibilityChanges.length > 0 ? (
|
||||
<ul aria-label={`Responsibilities in ${group.name}`} className="flex min-w-0 flex-col gap-3 pl-4 sm:pl-6">
|
||||
{responsibilityChanges.map(row)}
|
||||
</ul>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{error ? <p role="alert" className="text-sm text-destructive">{describeError(error).body}</p> : null}
|
||||
{notRight ? (
|
||||
@@ -209,15 +246,17 @@ export function DashboardChangesCard({
|
||||
placeholder="e.g. Keep Hiring, and fewer responsibilities under Fundraising"
|
||||
/>
|
||||
) : (
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{showConversationLink ? (
|
||||
<Button asChild type="button" variant="ghost" size="sm">
|
||||
<Link to={`/issues/${interaction.issueId}`}>Open the conversation</Link>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{showConversationLink ? (
|
||||
<Button asChild type="button" variant="ghost" size="sm">
|
||||
<Link to={`/issues/${interaction.issueId}`}>Open the conversation</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
<Button type="button" variant="ghost" size="sm" disabled={busy} onClick={() => setNotRight(true)}>
|
||||
Not right
|
||||
</Button>
|
||||
) : null}
|
||||
<Button type="button" variant="ghost" size="sm" disabled={busy} onClick={() => setNotRight(true)}>
|
||||
Not right
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
|
||||
@@ -22,6 +22,25 @@ describe("dashboard change groups", () => {
|
||||
expect(dashboardChangeGroups(smallEditChanges).find((group) => group.name === "Team")!.changes.map((change) => change.op))
|
||||
.toEqual(["rename_area", "remove_responsibility"]);
|
||||
});
|
||||
|
||||
it("separates area edits from responsibility edits and identifies existing parents", () => {
|
||||
const groups = dashboardChangeGroups([
|
||||
...createSizedChanges.slice(0, 3),
|
||||
smallEditChanges[2]!,
|
||||
smallEditChanges[3]!,
|
||||
{ ...smallEditChanges[0]!, index: 10, groupAreaId: null, groupName: "No area" },
|
||||
]);
|
||||
expect(groups.map((group) => ({
|
||||
name: group.name,
|
||||
existing: group.hasExistingArea,
|
||||
areaEdits: group.areaChanges.map((change) => change.op),
|
||||
responsibilityEdits: group.responsibilityChanges.map((change) => change.op),
|
||||
}))).toEqual([
|
||||
{ name: "Fundraising", existing: false, areaEdits: ["add_area"], responsibilityEdits: ["add_responsibility", "add_responsibility"] },
|
||||
{ name: "Team", existing: true, areaEdits: ["rename_area"], responsibilityEdits: ["remove_responsibility"] },
|
||||
{ name: "No area", existing: false, areaEdits: [], responsibilityEdits: ["reword_responsibility"] },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dropping and keeping", () => {
|
||||
|
||||
@@ -16,10 +16,15 @@ export interface DashboardChangeGroup {
|
||||
name: string;
|
||||
/** The group is a new area. */
|
||||
isNew: boolean;
|
||||
hasExistingArea: boolean;
|
||||
areaChanges: ResponsibilityDashboardChange[];
|
||||
responsibilityChanges: ResponsibilityDashboardChange[];
|
||||
changes: ResponsibilityDashboardChange[];
|
||||
}
|
||||
|
||||
const AREA_OPS = new Set<ResponsibilityDashboardChange["op"]>(["add_area", "rename_area", "remove_area"]);
|
||||
export function isDashboardAreaChange(change: ResponsibilityDashboardChange): boolean {
|
||||
return change.op === "add_area" || change.op === "rename_area" || change.op === "remove_area";
|
||||
}
|
||||
|
||||
function groupKey(change: Pick<ResponsibilityDashboardChange, "groupAreaId" | "groupRef">) {
|
||||
if (change.groupRef !== null) return `new:${change.groupRef}`;
|
||||
@@ -28,18 +33,27 @@ function groupKey(change: Pick<ResponsibilityDashboardChange, "groupAreaId" | "g
|
||||
|
||||
/** The changes by area, in the order the agent first named each area; area changes first within a group. */
|
||||
export function dashboardChangeGroups(changes: readonly ResponsibilityDashboardChange[]): DashboardChangeGroup[] {
|
||||
const groups = new Map<string, DashboardChangeGroup>();
|
||||
const groups = new Map<string, Omit<DashboardChangeGroup, "changes">>();
|
||||
for (const change of changes) {
|
||||
const key = groupKey(change);
|
||||
const group = groups.get(key) ?? { key, name: change.groupName, isNew: false, changes: [] };
|
||||
const group = groups.get(key) ?? {
|
||||
key,
|
||||
name: change.groupName,
|
||||
isNew: false,
|
||||
hasExistingArea: change.groupAreaId !== null,
|
||||
areaChanges: [],
|
||||
responsibilityChanges: [],
|
||||
};
|
||||
if (change.op === "add_area") group.isNew = true;
|
||||
group.changes.push(change);
|
||||
if (isDashboardAreaChange(change)) group.areaChanges.push(change);
|
||||
else group.responsibilityChanges.push(change);
|
||||
groups.set(key, group);
|
||||
}
|
||||
return [...groups.values()].map((group) => ({
|
||||
...group,
|
||||
changes: [...group.changes].sort((a, b) => Number(!AREA_OPS.has(a.op)) - Number(!AREA_OPS.has(b.op)) || a.index - b.index),
|
||||
}));
|
||||
return [...groups.values()].map((group) => {
|
||||
group.areaChanges.sort((a, b) => a.index - b.index);
|
||||
group.responsibilityChanges.sort((a, b) => a.index - b.index);
|
||||
return { ...group, changes: [...group.areaChanges, ...group.responsibilityChanges] };
|
||||
});
|
||||
}
|
||||
|
||||
export interface DashboardChangeWords {
|
||||
@@ -55,7 +69,7 @@ export interface DashboardChangeWords {
|
||||
export function dashboardChangeWords(change: ResponsibilityDashboardChange): DashboardChangeWords {
|
||||
switch (change.op) {
|
||||
case "add_area":
|
||||
return { before: null, after: "New area", note: null };
|
||||
return { before: null, after: change.name, note: null };
|
||||
case "rename_area":
|
||||
return {
|
||||
before: change.fromName,
|
||||
@@ -63,7 +77,7 @@ export function dashboardChangeWords(change: ResponsibilityDashboardChange): Das
|
||||
note: change.sharedWith > 0 ? `Also renamed for ${change.sharedWith === 1 ? "1 other person" : `${change.sharedWith} other people`}` : null,
|
||||
};
|
||||
case "remove_area":
|
||||
return { before: null, after: "Remove this area", note: null };
|
||||
return { before: change.groupName, after: null, note: null };
|
||||
case "add_responsibility":
|
||||
return { before: null, after: change.sentence, note: null };
|
||||
case "reword_responsibility":
|
||||
|
||||
@@ -67,6 +67,14 @@ export const smallEditChanges: ResponsibilityDashboardChange[] = [
|
||||
change(3, { op: "rename_area", groupAreaId: "area-team", groupName: "Team", fromName: "Team", name: "People", sharedWith: 2 }),
|
||||
];
|
||||
|
||||
export const mixedAreaChanges: ResponsibilityDashboardChange[] = [
|
||||
change(0, { op: "add_responsibility", groupAreaId: "area-product", groupName: "Product", sentence: "Every launch has a named owner and a clear release date." }),
|
||||
change(1, { op: "add_area", groupRef: "quality", groupName: "Quality & Reliability", name: "Quality & Reliability", reason: "Give the health of the product its own home." }),
|
||||
change(2, { op: "add_responsibility", groupRef: "quality", groupName: "Quality & Reliability", dependsOn: [1], sentence: "The core product journeys pass their daily checks.", reason: "Keep a clear signal for the work customers depend on." }),
|
||||
change(3, { op: "move_responsibility", groupRef: "quality", groupName: "Quality & Reliability", dependsOn: [1], responsibilityId: "resp-speed", fromSentence: "Key pages load quickly and stay fast.", fromAreaId: "area-product", fromAreaName: "Product" }),
|
||||
change(4, { op: "add_area", groupRef: "community", groupName: "Community", name: "Community", reason: "An area can start empty; add responsibilities when you are ready." }),
|
||||
];
|
||||
|
||||
function payload(changes: ResponsibilityDashboardChange[], mode: ProposeDashboardChangesPayload["mode"], message: string | null): ProposeDashboardChangesPayload {
|
||||
return { version: 1, ownerUserId: RESPONSIBILITY_FIXTURE_OWNER_ID, mode, message, changes };
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
dashboardFixtureAgents,
|
||||
dashboardStateFixture,
|
||||
dashboardVersionsFixture,
|
||||
mixedAreaChanges,
|
||||
} from "../../fixtures/responsibility-dashboard";
|
||||
import { prepareFixtureApi } from "../../support/capability-gaps/api";
|
||||
|
||||
@@ -30,7 +31,7 @@ const meta = {
|
||||
implementation: "production",
|
||||
boundary: "fixtures",
|
||||
notes:
|
||||
"Shipped Dashboard edit module of the Outline v2 view, behind the experimental enableResponsibilities flag: creating a dashboard with an agent when it is empty, the quiet Edit your dashboard row below the areas when it is not, a conversation in progress, proposed changes waiting (a first dashboard and a small edit) with each change droppable, the Undo line after applying, and the version list. States, proposals, versions and the agent are synthetic fixtures; starting, applying, declining and restoring are simulated, so these stories do not prove the server's guardrails, writer rule, atomic apply or what a restore puts back.",
|
||||
"Shipped Dashboard edit module and DashboardChangesCard, behind the experimental enableResponsibilities flag. Proposals show area changes in their headings and explicitly labeled responsibility changes nested under their parent area. Covers first creation, existing and new areas together, an empty new area, rewords, moves, removals, drop/keep dependencies, narrow layout and the correction form. Also covers the edit-module entry states, Undo and versions. States, proposals, versions and the agent are synthetic fixtures; starting, applying, declining and restoring are simulated, so these stories do not prove server guardrails, the writer rule, atomic apply or what a restore puts back.",
|
||||
},
|
||||
},
|
||||
beforeEach: () =>
|
||||
@@ -127,6 +128,11 @@ export const ProposalCreate: Story = {
|
||||
render: () => <ModuleIn state={dashboardStateFixture("create_proposal")} />,
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const fundraising = within(canvas.getByRole("region", { name: "Fundraising" }));
|
||||
await expect(fundraising.getByRole("heading", { name: "Fundraising" })).toBeInTheDocument();
|
||||
await expect(fundraising.getByText("New area", { exact: true })).toBeInTheDocument();
|
||||
const responsibilities = within(fundraising.getByRole("list", { name: "Responsibilities in Fundraising" }));
|
||||
await expect(responsibilities.getAllByText("New responsibility", { exact: true })).toHaveLength(2);
|
||||
const team = within(canvas.getByRole("region", { name: "Team" }));
|
||||
await userEvent.click(team.getAllByRole("button", { name: "Drop this change" })[0]!);
|
||||
await expect(team.getByText("Goes with Team")).toBeInTheDocument();
|
||||
@@ -135,6 +141,44 @@ export const ProposalCreate: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const ProposalHierarchy: Story = {
|
||||
name: "Proposal hierarchy: new areas and responsibilities",
|
||||
render: () => <Column><DashboardChangesCard interaction={dashboardChangesFixture("create")} /></Column>,
|
||||
};
|
||||
|
||||
export const ProposalHierarchyMobile: Story = {
|
||||
name: "Proposal hierarchy: mobile",
|
||||
render: () => <div className="max-w-sm"><DashboardChangesCard interaction={dashboardChangesFixture("create")} /></div>,
|
||||
};
|
||||
|
||||
export const ProposalNewAndExistingAreas: Story = {
|
||||
name: "Proposal hierarchy: new and existing areas",
|
||||
render: () => {
|
||||
const interaction = dashboardChangesFixture("edit");
|
||||
return (
|
||||
<Column>
|
||||
<DashboardChangesCard interaction={{ ...interaction, payload: { ...interaction.payload, message: "Keep Product focused, and give quality a home of its own.", changes: mixedAreaChanges } }} />
|
||||
</Column>
|
||||
);
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const product = within(canvas.getByRole("region", { name: "Product" }));
|
||||
await expect(product.getByText("Existing area")).toBeInTheDocument();
|
||||
await expect(product.getByText("New responsibility")).toBeInTheDocument();
|
||||
const quality = within(canvas.getByRole("region", { name: "Quality & Reliability" }));
|
||||
await expect(quality.getByText("New area")).toBeInTheDocument();
|
||||
await expect(quality.getByText("Moved from Product")).toBeInTheDocument();
|
||||
const community = within(canvas.getByRole("region", { name: "Community" }));
|
||||
await expect(community.queryByRole("list")).not.toBeInTheDocument();
|
||||
await userEvent.click(quality.getAllByRole("button", { name: "Drop this change" })[0]!);
|
||||
await expect(quality.getAllByText("Goes with Quality & Reliability")).toHaveLength(2);
|
||||
await userEvent.click(quality.getAllByRole("button", { name: "Keep" })[2]!);
|
||||
await expect(quality.queryByText("Goes with Quality & Reliability")).not.toBeInTheDocument();
|
||||
await userEvent.click(quality.getByRole("button", { name: "Keep" }));
|
||||
},
|
||||
};
|
||||
|
||||
/** A small edit waits: a reword (old sentence struck through), a move, a removal with its reason, a rename others see too. */
|
||||
export const ProposalEdit: Story = {
|
||||
name: "Proposal waiting: a small edit",
|
||||
|
||||
Reference in new issue
Block a user